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)) { ArgumentException exc = new ArgumentException("Unsupported chroma type " + chromaStr); if (m_excHandler != null) { m_excHandler(exc); return(0); } else { throw exc; } } 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]; } if (m_pixelData != null) { m_pixelData.Dispose(); m_pixelData = null; } m_pixelData = new PlanarPixelData(m_format.PlaneSizes); for (int i = 0; i < m_pixelData.Sizes.Length; i++) { m_planes[i] = new IntPtr(m_pixelData.Data[i]); } return(m_format.Planes); }
protected override void Dispose(bool disposing) { IntPtr zero = IntPtr.Zero; LibVlcMethods.libvlc_video_set_callbacks(m_hMediaPlayer, zero, zero, zero, zero); if (m_pixelData != default(PlanarPixelData)) { m_pixelData.Dispose(); } if (disposing) { m_timer.Dispose(); m_callback = null; m_callbacks.Clear(); } }