protected CaptureGraph(FilterInfo fiSource) { try { // Fgm initialization fgm = new FilgraphManagerClass(); iFG = (IFilterGraph)fgm; iGB = (IGraphBuilder)fgm; rotID = FilterGraph.AddToRot(iGB); // Create source filter and initialize it source = (SourceFilter)Filter.CreateFilter(fiSource); iGB.AddFilter(source.BaseFilter, source.FriendlyName); source.AddedToGraph(fgm); // Pass flags to the RtpRenderer filter from the config file. this.rtpRendererFlags = 0; string setting = ConfigurationManager.AppSettings[AppConfig.MDS_RtpRendererFlags]; if (!String.IsNullOrEmpty(setting)) { if (!byte.TryParse(setting, out rtpRendererFlags)) { rtpRendererFlags = 0; } } } catch (Exception) { Cleanup(); throw; } }
private void Cleanup() { if (fgm != null) { fgm.Stop(); FilterGraph.RemoveAllFilters(fgm); FilterGraph.RemoveFromRot(rotID); iGB = null; iFG = null; fgm = null; } DisposeSource(); DisposeCompressor(); DisposeRenderer(); }
protected CaptureGraph(FilterInfo fiSource) { try { // Fgm initialization fgm = new FilgraphManagerClass(); iFG = (IFilterGraph)fgm; iGB = (IGraphBuilder)fgm; rotID = FilterGraph.AddToRot(iGB); // Create source filter and initialize it source = (SourceFilter)Filter.CreateFilter(fiSource); iGB.AddFilter(source.BaseFilter, source.FriendlyName); source.AddedToGraph(fgm); } catch (Exception) { Cleanup(); throw; } }
/// <summary> /// Removes all filters from the graph, starting at the end and working /// back to but not including "start" /// </summary> public void RemoveFiltersDownstreamFrom(Filter start) { if (start == null) { string msg = "Null is not a valid value for parameter 'start'"; Debug.Fail(msg); throw new ArgumentNullException("start", msg); } if (start != source && start != compressor) { string msg = "The 'start' parameter must be either the 'source' or 'compressor' filter"; Debug.Fail(msg); throw new ArgumentOutOfRangeException("start", msg); } Stop(); foreach (IBaseFilter iBF in FilterGraph.FiltersInGraph(iFG)) { if (iBF == start.BaseFilter) { // We're done if we are back to the start filter break; } iFG.RemoveFilter(iBF); } DisposeRenderer(); if (start == source) { DisposeCompressor(); } }