public void OpenOverlay(Guid gPresenter) { object o; if (m_ImageHandlers != null) { foreach (ImageHandler ih in m_ImageHandlers) { ih.Dispose(); } m_ImageHandlers = null; } m_ImageHandlers = new ImageHandler[2]; m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("YUY2"), 320, 240, 16); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC(3), 320, 240, 32, 255); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("AYUV"), 320, 240, 32, 255); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("NV12"), 320, 240, 12, 255); //m_ImageHandlers[1] = new ImageFromText(30, new FourCC(3), 320, 240, 32); m_ImageHandlers[1] = new ImageFromText(30, new FourCC("AYUV"), 320, 240, 32); InitializeGraph(); SetupGraph(gPresenter); IMFGetService pGetService = (IMFGetService)m_pEVR; pGetService.GetService(MFServices.MR_VIDEO_MIXER_SERVICE, typeof(IMFVideoMixerControl).GUID, out o); m_pMixer = (IMFVideoMixerControl)o; pGetService.GetService(MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFVideoPositionMapper).GUID, out o); m_pMapper = (IMFVideoPositionMapper)o; }
private void TearDownGraph() { #if DEBUG if (m_rot != null) { m_rot.Dispose(); m_rot = null; } #endif // Stop sending event messages if (m_pEvent != null) { m_pEvent.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); m_pEvent = null; } if (m_pControl != null) { m_pControl.Stop(); m_pControl = null; } if (m_pDisplay != null) { //Marshal.ReleaseComObject(m_pDisplay); m_pDisplay = null; } if (m_pMapper != null) { Marshal.ReleaseComObject(m_pMapper); m_pMapper = null; } if (m_pMixer != null) { Marshal.ReleaseComObject(m_pMixer); m_pMixer = null; } if (m_pEVR != null) { Marshal.ReleaseComObject(m_pEVR); m_pEVR = null; } if (m_pGraph != null) { Marshal.ReleaseComObject(m_pGraph); m_pGraph = null; } m_state = PlaybackState.Closed; m_seekCaps = 0; m_pSeek = null; }
private void TearDownGraph() { #if DEBUG if (m_rot != null) { m_rot.Dispose(); m_rot = null; } #endif // Stop sending event messages if (m_pEvent != null) { m_pEvent.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); m_pEvent = null; } if (m_pControl != null) { m_pControl.Stop(); m_pControl = null; } if (m_pDisplay != null) { //Marshal.ReleaseComObject(m_pDisplay); m_pDisplay = null; } if (m_pMapper != null) { Marshal.ReleaseComObject(m_pMapper); m_pMapper = null; } if (m_pMixer != null) { Marshal.ReleaseComObject(m_pMixer); m_pMixer = null; } if (m_pEVR != null) { Marshal.ReleaseComObject(m_pEVR); m_pEVR = null; } if (m_pGraph != null) { Marshal.ReleaseComObject(m_pGraph); m_pGraph = null; } m_state = PlaybackState.Closed; m_seekCaps = 0; m_pSeek = null; }
private void InitializeEVR(IBaseFilter pEVR, int dwStreams, out IMFVideoDisplayControl ppDisplay) { IMFVideoRenderer pRenderer; IMFVideoDisplayControl pDisplay; IEVRFilterConfig pConfig; IMFVideoPresenter pPresenter; // Before doing anything else, set any custom presenter or mixer. // Presenter? if (m_clsidPresenter != Guid.Empty) { Type type = Type.GetTypeFromCLSID(m_clsidPresenter); // An error here means that the custom presenter sample from // http://mfnet.sourceforge.net hasn't been installed or // registered. pPresenter = (IMFVideoPresenter)Activator.CreateInstance(type); try { pRenderer = (IMFVideoRenderer)pEVR; pRenderer.InitializeRenderer(null, pPresenter); } finally { //Marshal.ReleaseComObject(pPresenter); } } // Continue with the rest of the set-up. // Set the video window. object o; IMFGetService pGetService = null; pGetService = (IMFGetService)pEVR; pGetService.GetService(MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFVideoDisplayControl).GUID, out o); try { pDisplay = (IMFVideoDisplayControl)o; } catch { Marshal.ReleaseComObject(o); throw; } try { // Set the number of streams. pDisplay.SetVideoWindow(m_hwndVideo.Handle); if (dwStreams > 1) { pConfig = (IEVRFilterConfig)pEVR; pConfig.SetNumberOfStreams(dwStreams); } // Set the display position to the entire window. Rectangle r = m_hwndVideo.ClientRectangle; MFRect rc = new MFRect(r.Left, r.Top, r.Right, r.Bottom); pDisplay.SetVideoPosition(null, rc); // Return the IMFVideoDisplayControl pointer to the caller. ppDisplay = pDisplay; } finally { //Marshal.ReleaseComObject(pDisplay); } m_pMixer = null; }
public void OpenOverlay(Guid gPresenter) { object o; if (m_ImageHandlers != null) { foreach (ImageHandler ih in m_ImageHandlers) { ih.Dispose(); } m_ImageHandlers = null; } m_ImageHandlers = new ImageHandler[2]; m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("YUY2"), 320, 240, 16); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC(3), 320, 240, 32, 255); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("AYUV"), 320, 240, 32, 255); //m_ImageHandlers[0] = new ImageFromPixels(30, new FourCC("NV12"), 320, 240, 12, 255); //m_ImageHandlers[1] = new ImageFromText(30, new FourCC(3), 320, 240, 32); m_ImageHandlers[1] = new ImageFromText(30, new FourCC("AYUV"), 320, 240, 32); InitializeGraph(); SetupGraph(gPresenter); IMFGetService pGetService = (IMFGetService)m_pEVR; pGetService.GetService(MFServices.MR_VIDEO_MIXER_SERVICE, typeof(IMFVideoMixerControl).GUID, out o); m_pMixer = (IMFVideoMixerControl)o; pGetService.GetService(MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFVideoPositionMapper).GUID, out o); m_pMapper = (IMFVideoPositionMapper)o; }
private void InitializeEVR(IBaseFilter pEVR, int dwStreams, out IMFVideoDisplayControl ppDisplay) { IMFVideoRenderer pRenderer; IMFVideoDisplayControl pDisplay; IEVRFilterConfig pConfig; IMFVideoPresenter pPresenter; // Before doing anything else, set any custom presenter or mixer. // Presenter? if (m_clsidPresenter != Guid.Empty) { Type type = Type.GetTypeFromCLSID(m_clsidPresenter); // An error here means that the custom presenter sample from // http://mfnet.sourceforge.net hasn't been installed or // registered. pPresenter = (IMFVideoPresenter)Activator.CreateInstance(type); try { pRenderer = (IMFVideoRenderer)pEVR; pRenderer.InitializeRenderer(null, pPresenter); } finally { //Marshal.ReleaseComObject(pPresenter); } } // Continue with the rest of the set-up. // Set the video window. object o; IMFGetService pGetService = null; pGetService = (IMFGetService)pEVR; pGetService.GetService(MFServices.MR_VIDEO_RENDER_SERVICE, typeof(IMFVideoDisplayControl).GUID, out o); try { pDisplay = (IMFVideoDisplayControl)o; } catch { Marshal.ReleaseComObject(o); throw; } try { // Set the number of streams. pDisplay.SetVideoWindow(m_hwndVideo.Handle); if (dwStreams > 1) { pConfig = (IEVRFilterConfig)pEVR; pConfig.SetNumberOfStreams(dwStreams); } // Set the display position to the entire window. Rectangle r = m_hwndVideo.ClientRectangle; MFRect rc = new MFRect(r.Left, r.Top, r.Right, r.Bottom); pDisplay.SetVideoPosition(null, rc); // Return the IMFVideoDisplayControl pointer to the caller. ppDisplay = pDisplay; } finally { //Marshal.ReleaseComObject(pDisplay); } m_pMixer = null; }