public virtual void AddCompressor(FilterInfo fiCompressor) { RemoveCompressor(); compressor = (Compressor)Filter.CreateFilter(fiCompressor); iGB.AddFilter(compressor.BaseFilter, compressor.FriendlyName); compressor.AddedToGraph(fgm); // Chooses input pin try { iGB.Connect(source.OutputPin, compressor.InputPin); } catch(COMException) { RemoveCompressor(); throw; } }
/// <summary> /// The compressor could be audio or video. If there is already an existing compressor of the /// given type, remove it and any downstream filters before adding the given compressor. /// The graph my not yet contain a DV Splitter, in which case, add the splitter first. /// </summary> /// <param name="fiCompressor"></param> public override void AddCompressor(FilterInfo fiCompressor) { Stop(); if (!AddDVSplitter()) { throw new ApplicationException("Failed to add DV Splitter Filter"); } if (fiCompressor.Category.Equals(Filter.CLSID_AudioCompressorCategory)) { if (audioCompressor != null) { RemoveFiltersDownstreamFromPin(splitterAudioOut); RemoveAndDispose(audioCompressor); audioCompressor = null; } audioCompressor = (Compressor)Filter.CreateFilter(fiCompressor); iGB.AddFilter(audioCompressor.BaseFilter, audioCompressor.FriendlyName); audioCompressor.AddedToGraph(fgm); compressor = audioCompressor; _AMMediaType[] mts = Pin.GetMediaTypes(splitterAudioOut); //Returns one DVInfo mt. foreach (_AMMediaType mt in mts) { Debug.WriteLine(MediaType.Dump(mt)); } try { iGB.Connect(this.splitterAudioOut, audioCompressor.InputPin); } catch (COMException) { RemoveAndDispose(audioCompressor); audioCompressor = null; throw; } } else if (fiCompressor.Category.Equals(Filter.CLSID_VideoCompressorCategory)) { if (videoCompressor != null) { RemoveFiltersDownstreamFromPin(splitterVideoOut); RemoveAndDispose(videoCompressor); videoCompressor = null; } videoCompressor = (Compressor)Filter.CreateFilter(fiCompressor); iGB.AddFilter(videoCompressor.BaseFilter, videoCompressor.FriendlyName); videoCompressor.AddedToGraph(fgm); compressor = videoCompressor; try { iGB.Connect(this.splitterVideoOut, videoCompressor.InputPin); } catch (COMException) { RemoveAndDispose(videoCompressor); videoCompressor = null; throw; } } }
public virtual void AddCompressor(FilterInfo fiCompressor) { RemoveCompressor(); compressor = (Compressor)Filter.CreateFilter(fiCompressor); iGB.AddFilter(compressor.BaseFilter, compressor.FriendlyName); compressor.AddedToGraph(fgm); // Chooses input pin Dictionary<string, Object> args = new Dictionary<string, object>(); args.Add("SourceFilter", source); compressor.PreConnectConfig(args); try { iGB.Connect(source.OutputPin, compressor.InputPin); } catch(COMException) { RemoveCompressor(); throw; } }