private void GetControlInterface() { this.tuner = null; this.crossbar = null; object o; int hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMTVTuner).GUID, out o); if (hr >= 0) { this.tuner = o as IAMTVTuner; o = null; hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMCrossbar).GUID, out o); if (hr >= 0) { this.crossbar = o as IBaseFilter; o = null; } // Use the crossbar class to help us sort out all the possible video inputs // The class needs to be given the capture filters ANALOGVIDEO input pin IPin pinVideo = DsFindPin.ByCategory(this.videoCaptureFilter, PinCategory.AnalogVideoIn, 0); if (pinVideo != null) { try { this.crossbarHelper = new CrossbarHelper(pinVideo); } catch {} Marshal.ReleaseComObject(pinVideo); } hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMTVAudio).GUID, out o); if (hr >= 0) { this.amTVAudio = o as IAMTVAudio; o = null; } } }
protected override void Decompose() { if (this.graphBuilder != null) { int hr = 0; OnGraphEnded(); // Decompose the graph try { hr = (this.graphBuilder as IMediaControl).StopWhenReady(); } catch { } try { hr = (this.graphBuilder as IMediaControl).Stop(); } catch { } RemoveHandlers(); FilterGraphTools.RemoveAllFilters(this.graphBuilder); if (this.crossbarHelper != null) { this.crossbarHelper.Dispose(); } this.crossbarHelper = null; if (this.tuner != null) { Marshal.ReleaseComObject(this.tuner); } this.tuner = null; if (this.amTVAudio != null) { Marshal.ReleaseComObject(this.amTVAudio); } this.amTVAudio = null; if (this.crossbar != null) { Marshal.ReleaseComObject(this.crossbar); } this.crossbar = null; if (this.videoCaptureFilter != null) { Marshal.ReleaseComObject(this.videoCaptureFilter); } this.videoCaptureFilter = null; if (this.audioCaptureFilter != null) { Marshal.ReleaseComObject(this.audioCaptureFilter); } this.audioCaptureFilter = null; if (this.audioRenderer != null) { Marshal.ReleaseComObject(this.audioRenderer); } this.audioRenderer = null; if (this.videoRenderer != null) { Marshal.ReleaseComObject(this.videoRenderer); } this.videoRenderer = null; if (this.captureGraphBuilder != null) { Marshal.ReleaseComObject(this.captureGraphBuilder); } this.captureGraphBuilder = null; if (useWPF) { WPFStop(); } try { rot.Dispose(); } catch { } try { Marshal.ReleaseComObject(this.graphBuilder); this.graphBuilder = null; } catch { } } }
private void GetControlInterface() { this.tuner = null; this.crossbar = null; object o; int hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMTVTuner).GUID, out o); if (hr >= 0) { this.tuner = o as IAMTVTuner; o = null; hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMCrossbar).GUID, out o); if (hr >= 0) { this.crossbar = o as IBaseFilter; o = null; } // Use the crossbar class to help us sort out all the possible video inputs // The class needs to be given the capture filters ANALOGVIDEO input pin IPin pinVideo = DsFindPin.ByCategory(this.videoCaptureFilter, PinCategory.AnalogVideoIn, 0); if (pinVideo != null) { try { this.crossbarHelper = new CrossbarHelper(pinVideo); } catch{} Marshal.ReleaseComObject(pinVideo); } hr = this.captureGraphBuilder.FindInterface(null, null, this.videoCaptureFilter, typeof(IAMTVAudio).GUID, out o); if (hr >= 0) { this.amTVAudio = o as IAMTVAudio; o = null; } } }
protected override void Decompose() { if (this.graphBuilder != null) { int hr = 0; OnGraphEnded(); // Decompose the graph try { hr = (this.graphBuilder as IMediaControl).StopWhenReady(); } catch { } try { hr = (this.graphBuilder as IMediaControl).Stop(); } catch { } RemoveHandlers(); FilterGraphTools.RemoveAllFilters(this.graphBuilder); if (this.crossbarHelper != null) this.crossbarHelper.Dispose(); this.crossbarHelper = null; if (this.tuner != null) Marshal.ReleaseComObject(this.tuner); this.tuner = null; if (this.amTVAudio != null) Marshal.ReleaseComObject(this.amTVAudio); this.amTVAudio = null; if (this.crossbar != null) Marshal.ReleaseComObject(this.crossbar); this.crossbar = null; if (this.videoCaptureFilter != null) Marshal.ReleaseComObject(this.videoCaptureFilter); this.videoCaptureFilter = null; if (this.audioCaptureFilter != null) Marshal.ReleaseComObject(this.audioCaptureFilter); this.audioCaptureFilter = null; if (this.audioRenderer != null) Marshal.ReleaseComObject(this.audioRenderer); this.audioRenderer = null; if (this.videoRenderer != null) Marshal.ReleaseComObject(this.videoRenderer); this.videoRenderer = null; if (this.captureGraphBuilder != null) Marshal.ReleaseComObject(this.captureGraphBuilder); this.captureGraphBuilder = null; if (useWPF) WPFStop(); try { rot.Dispose(); } catch { } try { Marshal.ReleaseComObject(this.graphBuilder); this.graphBuilder = null; } catch { } } }