public AudioVideoBase(String path, Boolean isDemo) : base(isDemo, path) { m_GraphBuilder = (DirectShowLib.IGraphBuilder) new FilterGraph(); m_hr = m_GraphBuilder.RenderFile(path, null); DsError.ThrowExceptionForHR(m_hr); m_MediaControl = (DirectShowLib.IMediaControl)m_GraphBuilder; m_MediaPosition = (DirectShowLib.IMediaPosition)m_GraphBuilder; m_BasicAudio = (DirectShowLib.IBasicAudio)m_GraphBuilder; }
private void InitializeGraph() { m_graph = (DirectShowLib.IGraphBuilder) new FilterGraphNoThread(); // QueryInterface for DirectShow interfaces _mediaControl = (DirectShowLib.IMediaControl)m_graph; _mediaEventEx = (DirectShowLib.IMediaEventEx)m_graph; _mediaSeeking = (DirectShowLib.IMediaSeeking)m_graph; _mediaPosition = (DirectShowLib.IMediaPosition)m_graph; // Query for video interfaces, which may not be relevant for audio files _videoWindow = m_graph as DirectShowLib.IVideoWindow; _basicVideo = m_graph as DirectShowLib.IBasicVideo; // Query for audio interfaces, which may not be relevant for video-only files _basicAudio = m_graph as DirectShowLib.IBasicAudio; // Set up event notification. var hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); }
private void InitializeGraph(bool isDvd) { int hr = 0; _isDvd = isDvd; m_filterGraph = new FilterGraphNoThread(); m_graph = (m_filterGraph as DirectShowLib.IGraphBuilder); // QueryInterface for DirectShow interfaces _mediaControl = (DirectShowLib.IMediaControl)m_graph; _mediaEventEx = (DirectShowLib.IMediaEventEx)m_graph; _mediaSeeking = (DirectShowLib.IMediaSeeking)m_graph; _mediaPosition = (DirectShowLib.IMediaPosition)m_graph; // Query for video interfaces, which may not be relevant for audio files _videoWindow = m_graph as DirectShowLib.IVideoWindow; _basicVideo = m_graph as DirectShowLib.IBasicVideo; // Query for audio interfaces, which may not be relevant for video-only files _basicAudio = m_graph as DirectShowLib.IBasicAudio; // Set up event notification. if (isDvd) hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, DirectShowPlayerConfiguration.WM_DVD_EVENT, IntPtr.Zero); else hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, DirectShowPlayerConfiguration.WM_GRAPH_NOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); if (_config.PublishGraph) m_dsRot = new DsROTEntry(m_graph as IFilterGraph); }
private void CloseInterfaces() { int hr; if (m_adecOut != null) { CleanUpInterface(m_adecOut); m_adecOut = null; } if (_defaultAudioRenderer != null) { m_graph.RemoveFilter(_defaultAudioRenderer as DirectShowLib.IBaseFilter); CleanUpInterface(_defaultAudioRenderer); _defaultAudioRenderer = null; } if (_reclockAudioRenderer != null) { m_graph.RemoveFilter(_reclockAudioRenderer as DirectShowLib.IBaseFilter); CleanUpInterface(_reclockAudioRenderer); _reclockAudioRenderer = null; } if (_wasapiAR != null) { m_graph.RemoveFilter(_wasapiAR as DirectShowLib.IBaseFilter); CleanUpInterface(_wasapiAR); _wasapiAR = null; } if (_lavaudio != null) { m_graph.RemoveFilter(_lavaudio as DirectShowLib.IBaseFilter); CleanUpInterface(_lavaudio); _lavaudio = null; } if (_xyVsFilter != null) { m_graph.RemoveFilter(_xyVsFilter as DirectShowLib.IBaseFilter); CleanUpInterface(_xyVsFilter); _xyVsFilter = null; } if (_xySubFilter != null) { m_graph.RemoveFilter(_xySubFilter as DirectShowLib.IBaseFilter); CleanUpInterface(_xySubFilter); _xySubFilter = null; } if (_lavvideo != null) { m_graph.RemoveFilter(_lavvideo as DirectShowLib.IBaseFilter); CleanUpInterface(_lavvideo); _lavvideo = null; } if (_madvr != null) { m_graph.RemoveFilter(_madvr as DirectShowLib.IBaseFilter); CleanUpInterface(_madvr); _madvr = null; } if (_videoWindow != null) { // Relinquish ownership (IMPORTANT!) after hiding video window hr = _videoWindow.put_Visible(OABool.False); hr = _videoWindow.put_Owner(IntPtr.Zero); } if (_mediaEventEx != null) { hr = _mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); //Marshal.ReleaseComObject(_mediaEventEx); //_mediaEventEx = null; } //if (_dvdNav != null) //{ // Marshal.ReleaseComObject(_dvdNav); // _dvdNav = null; //} /* //this will double release the source filter if (dvdInfo != null) { Marshal.ReleaseComObject(dvdInfo); dvdInfo = null; } if (_mDvdControl != null) { Marshal.ReleaseComObject(_mDvdControl); } */ _mDvdControl = null; CleanUpInterface(_mPDisplay); _mPDisplay = null; CleanUpInterface(_sourceFilter); _sourceFilter = null; CleanUpInterface(_mPEvr); _mPEvr = null; CleanUpInterface(m_filterGraph); m_filterGraph = null; m_filterGraph = null; _mediaEventEx = null; _mediaSeeking = null; _mediaPosition = null; _mediaControl = null; _basicAudio = null; _basicVideo = null; m_graph = null; _videoWindow = null; _filterGraph = null; if (m_dsRot != null) m_dsRot.Dispose(); m_dsRot = null; _mSeekCaps = 0; _streams = null; GC.Collect(); }
private void CloseInterfaces() { _hiddenWindow.SizeChanged -= _hiddenWindow_SizeChanged; int hr; if (_defaultAudioRenderer != null) { m_graph.RemoveFilter(_defaultAudioRenderer as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_defaultAudioRenderer); _defaultAudioRenderer = null; } if (_reclockAudioRenderer != null) { m_graph.RemoveFilter(_reclockAudioRenderer as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_reclockAudioRenderer); _reclockAudioRenderer = null; } if (_lavaudio != null) { m_graph.RemoveFilter(_lavaudio as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_lavaudio); _lavaudio = null; } if (_xyVsFilter != null) { m_graph.RemoveFilter(_xyVsFilter as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_xyVsFilter); _xyVsFilter = null; } if (_xySubFilter != null) { m_graph.RemoveFilter(_xySubFilter as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_xySubFilter); _xySubFilter = null; } if (_lavvideo != null) { m_graph.RemoveFilter(_lavvideo as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_lavvideo); _lavvideo = null; } if (_madvr != null) { m_graph.RemoveFilter(_madvr as DirectShowLib.IBaseFilter); Marshal.ReleaseComObject(_madvr); _madvr = null; } if (_videoWindow != null) { // Relinquish ownership (IMPORTANT!) after hiding video window hr = _videoWindow.put_Visible(OABool.False); hr = _videoWindow.put_Owner(IntPtr.Zero); } if (_mediaEventEx != null) { hr = _mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); Marshal.ReleaseComObject(_mediaEventEx); _mediaEventEx = null; } if (_dvdNav != null) { Marshal.ReleaseComObject(_dvdNav); _dvdNav = null; } if (_mDvdInfo != null) { Marshal.ReleaseComObject(_mDvdInfo); _mDvdInfo = null; } if (_mDvdControl != null) { Marshal.ReleaseComObject(_mDvdControl); _mDvdControl = null; } if (_mPDisplay != null) { Marshal.ReleaseComObject(_mPDisplay); _mPDisplay = null; } if (_filterGraph != null) { Marshal.ReleaseComObject(_filterGraph); _filterGraph = null; } if (_mPEvr != null) { Marshal.ReleaseComObject(_mPEvr); _mPEvr = null; } if (_mediaEventEx != null) { Marshal.ReleaseComObject(_mediaEventEx); _mediaEventEx = null; } if (_mediaSeeking != null) { Marshal.ReleaseComObject(_mediaSeeking); _mediaSeeking = null; } if (_mediaPosition != null) { Marshal.ReleaseComObject(_mediaPosition); _mediaPosition = null; } if (_mediaControl != null) { Marshal.ReleaseComObject(_mediaControl); _mediaControl = null; } if (_basicAudio != null) { Marshal.ReleaseComObject(_basicAudio); _basicAudio = null; } if (_basicVideo != null) { Marshal.ReleaseComObject(_basicVideo); _basicVideo = null; } if (_sourceFilter != null) { Marshal.ReleaseComObject(_sourceFilter); _sourceFilter = null; } if (m_graph != null) { Marshal.ReleaseComObject(m_graph); m_graph = null; } if (_videoWindow != null) { Marshal.ReleaseComObject(_videoWindow); _videoWindow = null; } _mSeekCaps = 0; _streams = null; GC.Collect(); }
private void InitializeGraph() { m_graph = (DirectShowLib.IGraphBuilder)new FilterGraphNoThread(); // QueryInterface for DirectShow interfaces _mediaControl = (DirectShowLib.IMediaControl)m_graph; _mediaEventEx = (DirectShowLib.IMediaEventEx)m_graph; _mediaSeeking = (DirectShowLib.IMediaSeeking)m_graph; _mediaPosition = (DirectShowLib.IMediaPosition)m_graph; // Query for video interfaces, which may not be relevant for audio files _videoWindow = m_graph as DirectShowLib.IVideoWindow; _basicVideo = m_graph as DirectShowLib.IBasicVideo; // Query for audio interfaces, which may not be relevant for video-only files _basicAudio = m_graph as DirectShowLib.IBasicAudio; // Set up event notification. var hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); }
private void InitializeGraph(bool isDvd) { int hr = 0; _isDvd = isDvd; if (isDvd) { _dvdGraphBuilder = new DvdGraphBuilder() as IDvdGraphBuilder; hr = _dvdGraphBuilder.GetFiltergraph(out _graph); DsError.ThrowExceptionForHR(hr); _filterGraph = _graph as IFilterGraph2; } else { _filterGraphNT = new FilterGraphNoThread(); _graph = (_filterGraphNT as DirectShowLib.IGraphBuilder); } // QueryInterface for DirectShow interfaces _mediaControl = (DirectShowLib.IMediaControl)_graph; _mediaEventEx = (DirectShowLib.IMediaEventEx)_graph; _mediaSeeking = (DirectShowLib.IMediaSeeking)_graph; _mediaPosition = (DirectShowLib.IMediaPosition)_graph; // Query for video interfaces, which may not be relevant for audio files _videoWindow = _graph as DirectShowLib.IVideoWindow; _basicVideo = _graph as DirectShowLib.IBasicVideo; // Query for audio interfaces, which may not be relevant for video-only files _basicAudio = _graph as DirectShowLib.IBasicAudio; // Set up event notification. if (isDvd) hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, WM_DVD_EVENT, IntPtr.Zero); else hr = _mediaEventEx.SetNotifyWindow(VideoWindowHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); if (_mbtConfig.Configuration.InternalPlayerConfiguration.PublishGraph) m_dsRot = new DsROTEntry(_graph as IFilterGraph); }