Beispiel #1
0
        private unsafe int OnFormatCallback(void **opaque, char *chroma, int *width, int *height, int *pitches, int *lines)
        {
            IntPtr pChroma   = new IntPtr(chroma);
            string chromaStr = Marshal.PtrToStringAnsi(pChroma);

            ChromaType type;

            if (!Enum.TryParse <ChromaType>(chromaStr, out type))
            {
                throw new ArgumentException("Unsupported chroma type " + chromaStr);
            }

            m_format = new BitmapFormat(*width, *height, type);
            if (m_formatSetupCB != null)
            {
                m_format = m_formatSetupCB(m_format);
            }

            Marshal.Copy(m_format.Chroma.ToUtf8(), 0, pChroma, 4);
            *width  = m_format.Width;
            *height = m_format.Height;

            for (int i = 0; i < m_format.Planes; i++)
            {
                pitches[i] = m_format.Pitches[i];
                lines[i]   = m_format.Lines[i];
            }

            m_pixelData = new PlanarPixelData(m_format.PlaneSizes);

            return(m_format.Planes);
        }
        public override bool Equals(object obj)
        {
            PlanarPixelData pd = (PlanarPixelData)obj;

            if (pd == null)
            {
                return(false);
            }

            return(this == pd);
        }
Beispiel #3
0
        protected override void Dispose(bool disposing)
        {
            IntPtr zero = IntPtr.Zero;

            LibVlcMethods.libvlc_video_set_callbacks(m_hMediaPlayer, zero, zero, zero, zero);

            if (m_pixelData != null)
            {
                m_pixelData.Dispose();
                m_pixelData = null;
            }

            if (disposing)
            {
                m_timer.Dispose();
                m_formatSetupCB = null;
                m_excHandler    = null;
                m_callback      = null;
                m_callbacks.Clear();
            }
        }
Beispiel #4
0
        private unsafe int OnFormatCallback(void** opaque, char* chroma, int* width, int* height, int* pitches, int* lines)
        {
            IntPtr pChroma = new IntPtr(chroma);
            string chromaStr = Marshal.PtrToStringAnsi(pChroma);

            ChromaType type;
            if (!Enum.TryParse<ChromaType>(chromaStr, out type))
            {
                throw new ArgumentException("Unsupported chroma type " + chromaStr);
            }

            m_format = new BitmapFormat(*width, *height, type);
            if (m_formatSetupCB != null)
            {
                m_format = m_formatSetupCB(m_format);
            }

            Marshal.Copy(m_format.Chroma.ToUtf8(), 0, pChroma, 4);
            *width = m_format.Width;
            *height = m_format.Height;

            for (int i = 0; i < m_format.Planes; i++)
            {
                pitches[i] = m_format.Pitches[i];
                lines[i] = m_format.Lines[i];
            }

            m_pixelData = new PlanarPixelData(m_format.PlaneSizes);

            return m_format.Planes;
        }
        private unsafe int OnFormatCallback(void** opaque, char* chroma, int* width, int* height, int* pitches, int* lines)
        {
            var pChroma = new IntPtr(chroma);
            var chromaStr = Marshal.PtrToStringAnsi(pChroma);

            ChromaType type;
            if (!Enum.TryParse<ChromaType>(chromaStr, out type))
            {
                var exc = new ArgumentException("Unsupported chroma type " + chromaStr);
                if (_mExcHandler != null)
                {
                    _mExcHandler(exc);
                    return 0;
                }
                else
                {
                    throw exc;
                }
            }

            _mFormat = new BitmapFormat(*width, *height, type);
            if (_mFormatSetupCb != null)
            {
                _mFormat = _mFormatSetupCb(_mFormat);
            }

            Marshal.Copy(_mFormat.Chroma.ToUtf8(), 0, pChroma, 4);
            *width = _mFormat.Width;
            *height = _mFormat.Height;

            for (var i = 0; i < _mFormat.Planes; i++)
            {
                pitches[i] = _mFormat.Pitches[i];
                lines[i] = _mFormat.Lines[i];
            }

            _mPixelData = new PlanarPixelData(_mFormat.PlaneSizes);

            return _mFormat.Planes;
        }