当前位置: 首页>>代码示例>>C#>>正文


C# IFilterGraph2.RemoveFilter方法代码示例

本文整理汇总了C#中IFilterGraph2.RemoveFilter方法的典型用法代码示例。如果您正苦于以下问题:C# IFilterGraph2.RemoveFilter方法的具体用法?C# IFilterGraph2.RemoveFilter怎么用?C# IFilterGraph2.RemoveFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFilterGraph2的用法示例。


在下文中一共展示了IFilterGraph2.RemoveFilter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddRenderers

        protected virtual void AddRenderers(IFilterGraph2 graphBuilder)
        {
            int hr = 0;
            Guid iid = typeof(IBaseFilter).GUID;

            if (this.AudioRendererDevice != null)
            {
                try
                {
                    this.audioRenderer = null;

                    IBaseFilter tmp;

                    object o;
                    this.AudioRendererDevice.Mon.BindToObject(null, null, ref iid, out o);
                    tmp = o as IBaseFilter;

                    //Add the Video input device to the graph
                    hr = graphBuilder.AddFilter(tmp, this.AudioRendererDevice.Name);
                    if (hr >= 0)
                    {
                        // Got it !
                        this.audioRenderer = tmp;
                    }
                    else
                    {
                        // Try another...
                        int hr1 = graphBuilder.RemoveFilter(tmp);
                        Marshal.ReleaseComObject(tmp);
                        //DsError.ThrowExceptionForHR(hr);
                    }
                }
                catch { }
            }

            if (this.audioRenderer == null)
            {
                // Add default audio renderer
                this.audioRenderer = (IBaseFilter)new DSoundRender();
                hr = graphBuilder.AddFilter(this.audioRenderer, "DirectSound Renderer");
                ThrowExceptionForHR("Adding the DirectSound Renderer: ", hr);
            }

            // To see something

            if (useWPF)
            {
                // Get the SampleGrabber interface
                ISampleGrabber sampleGrabber = new SampleGrabber() as ISampleGrabber;
                this.videoRenderer = sampleGrabber as IBaseFilter;

                // Set the media type to Video
                AMMediaType media = new AMMediaType();
                media.majorType = MediaType.Video;
                //media.subType = MediaSubType.YUY2; // RGB24;
                //media.formatType = FormatType.Null;
                //media.sampleSize = 1;
                //media.temporalCompression = false;
                //media.fixedSizeSamples = false;
                //media.unkPtr = IntPtr.Zero;
                //media.formatType = FormatType.None;
                //media.formatSize = 0;
                //media.formatPtr = IntPtr.Zero;
                media.subType = MediaSubType.RGB32; // RGB24;
                media.formatType = FormatType.VideoInfo;
                hr = sampleGrabber.SetMediaType(media);
                ThrowExceptionForHR("Setting the MediaType on the SampleGrabber: ", hr);
                DsUtils.FreeAMMediaType(media);

                // Configure the samplegrabber
                hr = sampleGrabber.SetCallback(this, 1);
                DsError.ThrowExceptionForHR(hr);

                // Add the frame grabber to the graph
                hr = graphBuilder.AddFilter(this.videoRenderer, "SampleGrabber");
                ThrowExceptionForHR("Adding the SampleGrabber: ", hr);

                //hr = ConnectFilters(this.videoRenderer, nullRenderer);
            }
            else
            {
                try
                {
                    this.videoRenderer = (IBaseFilter)new EnhancedVideoRenderer();
                    hr = graphBuilder.AddFilter(this.videoRenderer, "Enhanced Video Renderer");
                    ThrowExceptionForHR("Adding the EVR: ", hr);
                    useEVR = true;
                }
                catch (Exception) { }
                if (!useEVR)
                {
                    this.videoRenderer = (IBaseFilter)new VideoMixingRenderer9();
                    hr = graphBuilder.AddFilter(this.videoRenderer, "Video Mixing Renderer 9");
                    ThrowExceptionForHR("Adding the VMR9: ", hr);
                }
            }
            //IReferenceClock clock = this.audioRenderer as IReferenceClock;
            //if(clock != null)
            //{
            //    // Set the graph clock.
//.........这里部分代码省略.........
开发者ID:dgis,项目名称:CodeTV,代码行数:101,代码来源:GraphBuilderBase.cs

示例2: CreateAutomaticFilterInstance

 /// <summary>
 /// Creates the filter by trying to detect it
 /// </summary>
 /// <param name="crossbar">The crossbar componen</param>
 /// <param name="tuner">The tuner component</param>
 /// <param name="graph">The stored graph</param>
 /// <param name="graphBuilder">The graphBuilder</param>
 /// <returns>true, if the graph building was successful</returns>
 private bool CreateAutomaticFilterInstance(Graph graph, Tuner tuner, Crossbar crossbar, IFilterGraph2 graphBuilder)
 {
   //get all tv audio tuner devices on this system
   DsDevice[] devices = null;
   try
   {
     devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSTVAudio);
     devices = DeviceSorter.Sort(devices, tuner.TunerName, crossbar.CrossBarName);
   }
   catch (Exception)
   {
     Log.Log.WriteFile("analog: AddTvAudioFilter no tv audio devices found - Trying TvTuner filter");
   }
   if (devices != null && devices.Length > 0)
   {
     // try each tv audio tuner
     for (int i = 0; i < devices.Length; i++)
     {
       IBaseFilter tmp;
       Log.Log.WriteFile("analog: AddTvAudioFilter try:{0} {1}", devices[i].Name, i);
       //if tv audio tuner is currently in use we can skip it
       if (DevicesInUse.Instance.IsUsed(devices[i]))
         continue;
       int hr;
       try
       {
         //add tv audio tuner to graph
         hr = graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
       }
       catch (Exception)
       {
         Log.Log.WriteFile("analog: cannot add filter to graph");
         continue;
       }
       if (hr != 0)
       {
         //failed to add tv audio tuner to graph, continue with the next one
         if (tmp != null)
         {
           graphBuilder.RemoveFilter(tmp);
           Release.ComObject("tvAudioFilter filter", tmp);
         }
         continue;
       }
       // try connecting the tv tuner-> tv audio tuner
       if (FilterGraphTools.ConnectPin(graphBuilder, tuner.AudioPin, tmp, 0))
       {
         // Got it !
         // Connect tv audio tuner to the crossbar
         IPin pin = DsFindPin.ByDirection(tmp, PinDirection.Output, 0);
         hr = graphBuilder.Connect(pin, crossbar.AudioTunerIn);
         if (hr < 0)
         {
           //failed
           graphBuilder.RemoveFilter(tmp);
           Release.ComObject("audiotuner pinin", pin);
           Release.ComObject("audiotuner filter", tmp);
         }
         else
         {
           //succeeded. we're done
           Log.Log.WriteFile("analog: AddTvAudioFilter succeeded:{0}", devices[i].Name);
           Release.ComObject("audiotuner pinin", pin);
           _filterTvAudioTuner = tmp;
           _audioDevice = devices[i];
           DevicesInUse.Instance.Add(_audioDevice);
           _tvAudioTunerInterface = tuner.Filter as IAMTVAudio;
           break;
         }
       }
       else
       {
         // cannot connect tv tuner-> tv audio tuner, try next one...
         graphBuilder.RemoveFilter(tmp);
         Release.ComObject("audiotuner filter", tmp);
       }
     }
   }
   if (_filterTvAudioTuner == null)
   {
     Log.Log.WriteFile("analog: AddTvAudioFilter no tv audio devices found - Trying TvTuner filter");
     int hr = graphBuilder.Connect(tuner.AudioPin, crossbar.AudioTunerIn);
     if (hr != 0)
     {
       Log.Log.Error("analog: unable to add TvAudioTuner to graph - even TvTuner as TvAudio fails");
       mode = TvAudioVariant.Unavailable;
     }
     else
     {
       Log.Log.WriteFile("analog: AddTvAudioFilter connected TvTuner with Crossbar directly succeeded!");
       mode = TvAudioVariant.TvTunerConnection;
       _tvAudioTunerInterface = tuner.Filter as IAMTVAudio;
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:TvAudio.cs

示例3: CreateConfigurationBasedFilterInstance

 /// <summary>
 /// Creates the filter based on the configuration file
 /// </summary>
 /// <param name="tuner">The tuner component</param>
 /// <param name="graph">The stored graph</param>
 /// <param name="graphBuilder">The graphBuilder</param>
 /// <returns>true, if the graph building was successful</returns>
 private bool CreateConfigurationBasedFilterInstance(Graph graph, IFilterGraph2 graphBuilder, Tuner tuner)
 {
   string deviceName = graph.Crossbar.Name;
   _audioTunerIn = null;
   DsDevice[] devices;
   //get list of all crossbar devices installed on this system
   try
   {
     devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSCrossbar);
     devices = DeviceSorter.Sort(devices, graph.Tuner.Name);
   }
   catch (Exception)
   {
     Log.Log.WriteFile("analog: AddCrossBarFilter no crossbar devices found");
     return false;
   }
   if (devices == null || devices.Length == 0)
   {
     Log.Log.WriteFile("analog: AddCrossBarFilter no crossbar devices found");
     return false;
   }
   //try each crossbar
   for (int i = 0; i < devices.Length; i++)
   {
     IBaseFilter tmp;
     //if crossbar is already in use then we can skip it
     if (DevicesInUse.Instance.IsUsed(devices[i]))
       continue;
     if (!deviceName.Equals(devices[i].Name))
       continue;
     Log.Log.WriteFile("analog: AddCrossBarFilter use:{0} {1}", devices[i].Name, i);
     int hr;
     try
     {
       //add the crossbar to the graph
       hr = graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
     }
     catch (Exception)
     {
       Log.Log.WriteFile("analog: cannot add filter to graph");
       continue;
     }
     if (hr != 0)
     {
       //failed. try next crossbar
       if (tmp != null)
       {
         graphBuilder.RemoveFilter(tmp);
         Release.ComObject("CrossBarFilter", tmp);
       }
       continue;
     }
     _crossBarFilter = (IAMCrossbar)tmp;
     _videoPinMap = graph.Crossbar.VideoPinMap;
     _audioPinMap = graph.Crossbar.AudioPinMap;
     _videoPinRelatedAudioMap = graph.Crossbar.VideoPinRelatedAudioMap;
     _videoOutPinIndex = graph.Crossbar.VideoOut;
     _audioOutPinIndex = graph.Crossbar.AudioOut;
     if (_videoOutPinIndex == -1)
     {
       Log.Log.WriteFile("analog: AddCrossbarFilter no video output found");
       graphBuilder.RemoveFilter(tmp);
       _crossBarFilter = null;
       Release.ComObject("CrossBarFilter", tmp);
       continue;
     }
     //connect tv tuner->crossbar
     IPin tunerOut = DsFindPin.ByDirection(tuner.Filter, PinDirection.Output,
                                           graph.Tuner.VideoPin);
     if (tunerOut != null && _videoPinMap.ContainsKey(AnalogChannel.VideoInputType.Tuner) &&
         FilterGraphTools.ConnectPin(graphBuilder, tunerOut, tmp, _videoPinMap[AnalogChannel.VideoInputType.Tuner]))
     {
       // Got it, we're done
       _filterCrossBar = tmp;
       _crossBarDevice = devices[i];
       DevicesInUse.Instance.Add(_crossBarDevice);
       if (_audioTunerIn == null)
       {
         _audioTunerIn = DsFindPin.ByDirection(_filterCrossBar, PinDirection.Input,
                                               _audioPinMap[AnalogChannel.AudioInputType.Tuner]);
       }
       Release.ComObject("tuner video out", tunerOut);
       _videoOut = DsFindPin.ByDirection(_filterCrossBar, PinDirection.Output, _videoOutPinIndex);
       if (_audioOutPinIndex != -1)
       {
         _audioOut = DsFindPin.ByDirection(_filterCrossBar, PinDirection.Output, _audioOutPinIndex);
       }
       Log.Log.WriteFile("analog: AddCrossBarFilter succeeded");
       break;
     }
     // cannot connect tv tuner to crossbar, try next crossbar device
     if (tmp != null)
     {
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:Crossbar.cs

示例4: CreateAutomaticFilterInstance

    /// <summary>
    /// Creates the filter by trying to detect it
    /// </summary>
    /// <param name="tuner">The tuner component</param>
    /// <param name="graph">The stored graph</param>
    /// <param name="graphBuilder">The graphBuilder</param>
    /// <returns>true, if the graph building was successful</returns>
    private bool CreateAutomaticFilterInstance(Graph graph, IFilterGraph2 graphBuilder, Tuner tuner)
    {
      _audioTunerIn = null;
      DsDevice[] devices;
      //get list of all crossbar devices installed on this system
      try
      {
        devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSCrossbar);
        devices = DeviceSorter.Sort(devices, graph.Tuner.Name);
      }
      catch (Exception)
      {
        Log.Log.WriteFile("analog: AddCrossBarFilter no crossbar devices found");
        return false;
      }
      if (devices == null || devices.Length == 0)
      {
        Log.Log.WriteFile("analog: AddCrossBarFilter no crossbar devices found");
        return false;
      }
      //try each crossbar
      for (int i = 0; i < devices.Length; i++)
      {
        IBaseFilter tmp;
        Log.Log.WriteFile("analog: AddCrossBarFilter try:{0} {1}", devices[i].Name, i);
        //if crossbar is already in use then we can skip it
        if (DevicesInUse.Instance.IsUsed(devices[i]))
          continue;
        int hr;
        try
        {
          //add the crossbar to the graph
          hr = graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
        }
        catch (Exception)
        {
          Log.Log.WriteFile("analog: cannot add filter to graph");
          continue;
        }
        if (hr != 0)
        {
          //failed. try next crossbar
          if (tmp != null)
          {
            graphBuilder.RemoveFilter(tmp);
            Release.ComObject("CrossBarFilter", tmp);
          }
          continue;
        }
        _crossBarFilter = (IAMCrossbar)tmp;
        CheckCapabilities();
        if (_videoOutPinIndex == -1)
        {
          Log.Log.WriteFile("analog: AddCrossbarFilter no video output found");
          graphBuilder.RemoveFilter(tmp);
          _crossBarFilter = null;
          Release.ComObject("CrossBarFilter", tmp);
          continue;
        }

        // Check that the crossbar has a tuner video input pin.
        IPin pinIn = null;
        if (_videoPinMap.ContainsKey(AnalogChannel.VideoInputType.Tuner))
        {
          pinIn = DsFindPin.ByDirection(tmp, PinDirection.Input, _videoPinMap[AnalogChannel.VideoInputType.Tuner]);
        }
        if (pinIn == null)
        {
          // no pin found, continue with next crossbar
          Log.Log.WriteFile("analog: AddCrossBarFilter no video tuner input pin detected");
          if (tmp != null)
          {
            graphBuilder.RemoveFilter(tmp);
            _crossBarFilter = null;
            Release.ComObject("CrossBarFilter", tmp);
          }
          continue;
        }
        //connect tv tuner->crossbar
        int tempVideoPinIndex;
        if (FilterGraphTools.ConnectFilter(graphBuilder, tuner.Filter, pinIn, out tempVideoPinIndex))
        {
          // Got it, we're done
          _filterCrossBar = tmp;
          _crossBarDevice = devices[i];
          DevicesInUse.Instance.Add(_crossBarDevice);
          if (_audioTunerIn == null)
          {
            _audioTunerIn = DsFindPin.ByDirection(_filterCrossBar, PinDirection.Input,
                                                  _audioPinMap[AnalogChannel.AudioInputType.Tuner]);
          }
          Release.ComObject("crossbar videotuner pin", pinIn);
          _videoOut = DsFindPin.ByDirection(_filterCrossBar, PinDirection.Output, _videoOutPinIndex);
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:Crossbar.cs

示例5: AddVideoCompressor

    /// <summary>
    /// Adds the video compressor.
    /// </summary>
    /// <param name="_graphBuilder">GraphBuilder</param>
    /// <returns></returns>
    private bool AddVideoCompressor(IFilterGraph2 _graphBuilder)
    {
      Log.Log.WriteFile("analog: AddVideoCompressor");
      DsDevice[] devices1 = DsDevice.GetDevicesOfCat(FilterCategory.VideoCompressorCategory);
      DsDevice[] devices2 = DsDevice.GetDevicesOfCat(FilterCategory.LegacyAmFilterCategory);
      IList<SoftwareEncoder> videoEncoders = _layer.GetSofwareEncodersVideo();
      DsDevice[] videoDevices = new DsDevice[videoEncoders.Count];
      for (int x = 0; x < videoEncoders.Count; ++x)
      {
        videoDevices[x] = null;
      }
      for (int i = 0; i < devices1.Length; i++)
      {
        for (int x = 0; x < videoEncoders.Count; ++x)
        {
          if (videoEncoders[x].Name == devices1[i].Name)
          {
            videoDevices[x] = devices1[i];
            break;
          }
        }
      }
      for (int i = 0; i < devices2.Length; i++)
      {
        for (int x = 0; x < videoEncoders.Count; ++x)
        {
          if (videoEncoders[x].Name == devices2[i].Name)
          {
            videoDevices[x] = devices2[i];
            break;
          }
        }
      }
      //for each compressor
      Log.Log.WriteFile("analog: AddVideoCompressor found:{0} compressor", videoDevices.Length);
      for (int i = 0; i < videoDevices.Length; i++)
      {
        IBaseFilter tmp;
        if (videoDevices[i] == null || !EncodersInUse.Instance.Add(videoDevices[i], videoEncoders[i]))
        {
          continue;
        }

        Log.Log.WriteFile("analog:  try compressor:{0}", videoDevices[i].Name);
        int hr;
        try
        {
          //add compressor filter to graph
          hr = _graphBuilder.AddSourceFilterForMoniker(videoDevices[i].Mon, null, videoDevices[i].Name, out tmp);
        }
        catch (Exception)
        {
          Log.Log.WriteFile("analog: cannot add compressor to graph");
          EncodersInUse.Instance.Remove(videoDevices[i]);
          continue;
        }
        if (hr != 0)
        {
          //failed to add filter to graph, continue with the next one
          if (tmp != null)
          {
            _graphBuilder.RemoveFilter(tmp);
            Release.ComObject("videocompressor", tmp);
          }
          EncodersInUse.Instance.Remove(videoDevices[i]);
          continue;
        }
        if (tmp == null)
        {
          EncodersInUse.Instance.Remove(videoDevices[i]);
          continue;
        }

        // check if this compressor filter has an mpeg audio output pin
        Log.Log.WriteFile("analog:  connect video pin->video compressor");
        IPin pinVideo = DsFindPin.ByDirection(tmp, PinDirection.Input, 0);
        // we found a nice compressor, lets try to connect the analog video pin to the compressor
        hr = _graphBuilder.Connect(_pinAnalogVideo, pinVideo);
        if (hr != 0)
        {
          Log.Log.WriteFile("analog: failed to connect video pin->video compressor");
          //unable to connec the pin, remove it and continue with next compressor
          _graphBuilder.RemoveFilter(tmp);
          Release.ComObject("videocompressor", tmp);
          EncodersInUse.Instance.Remove(videoDevices[i]);
          continue;
        }

        //succeeded.
        _videoCompressorDevice = videoDevices[i];
        _filterVideoCompressor = tmp;
        return true;
      }
      return false;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:100,代码来源:Encoder.cs

示例6: AddTvEncoderFilter

    /// <summary>
    /// Adds one or 2 encoder filters to the graph
    ///  several posibilities
    ///  1. no encoder filter needed
    ///  2. single encoder filter with seperate audio/video inputs and 1 (mpeg-2) output
    ///  3. single encoder filter with a mpeg2 program stream input (I2S)
    ///  4. two encoder filters. one for audio and one for video
    ///
    ///  At the end of this method the graph looks like:
    ///
    ///  option 2: one encoder filter, with 2 inputs
    ///    [                ]----->[                ]
    ///    [ capture filter ]      [ encoder filter ]
    ///    [                ]----->[                ]
    ///
    ///
    ///  option 3: one encoder filter, with 1 input
    ///    [                ]      [                ]
    ///    [ capture filter ]----->[ encoder filter ]
    ///    [                ]      [                ]
    ///
    ///
    ///  option 4: 2 encoder filters one for audio and one for video
    ///    [                ]----->[   video        ]
    ///    [ capture filter ]      [ encoder filter ]
    ///    [                ]      [                ]
    ///    [                ]   
    ///    [                ]----->[   audio        ]
    ///                            [ encoder filter ]
    ///                            [                ]
    ///
    /// </summary>
    /// <param name="matchPinNames">if set to <c>true</c> the pin names of the encoder filter should match the pin names of the capture filter.</param>
    /// <param name="mpeg2ProgramFilter">if set to <c>true</c> than only encoders with an mpeg2 program output pins are accepted</param>
    /// <param name="_graphBuilder">GraphBuilder</param>
    /// <param name="_tuner">Tuner</param>
    /// <param name="_tvAudio">TvAudio</param>
    /// <param name="_crossbar">Crossbar</param>
    /// <param name="_capture">Capture</param>
    /// <returns>true if encoder filters are added, otherwise false</returns>
    private bool AddTvEncoderFilter(bool matchPinNames, bool mpeg2ProgramFilter, IFilterGraph2 _graphBuilder,
                                    Tuner _tuner, TvAudio _tvAudio, Crossbar _crossbar, Capture _capture)
    {
      Log.Log.WriteFile("analog: AddTvEncoderFilter - MatchPinNames: {0} - MPEG2ProgramFilter: {1}", matchPinNames,
                        mpeg2ProgramFilter);
      bool finished = false;
      DsDevice[] devices;
      // first get all encoder filters available on this system
      try
      {
        devices = DsDevice.GetDevicesOfCat(FilterCategory.WDMStreamingEncoderDevices);
        devices = DeviceSorter.Sort(devices, _tuner.TunerName, _tvAudio.TvAudioName, _crossbar.CrossBarName,
                                    _capture.VideoCaptureName, _capture.AudioCaptureName, _videoEncoderDevice,
                                    _audioEncoderDevice, _multiplexerDevice);
      }
      catch (Exception)
      {
        Log.Log.WriteFile("analog: AddTvEncoderFilter no encoder devices found (Exception)");
        return false;
      }
      if (devices == null)
      {
        Log.Log.WriteFile("analog: AddTvEncoderFilter no encoder devices found (devices == null)");
        return false;
      }
      if (devices.Length == 0)
      {
        Log.Log.WriteFile("analog: AddTvEncoderFilter no encoder devices found");
        return false;
      }
      //for each encoder
      Log.Log.WriteFile("analog: AddTvEncoderFilter found:{0} encoders", devices.Length);
      for (int i = 0; i < devices.Length; i++)
      {
        IBaseFilter tmp;
        //if encoder is in use, we can skip it
        if (DevicesInUse.Instance.IsUsed(devices[i]))
        {
          Log.Log.WriteFile("analog:  skip :{0} (inuse)", devices[i].Name);
          continue;
        }
        Log.Log.WriteFile("analog:  try encoder:{0} {1}", devices[i].Name, i);
        int hr;
        try
        {
          //add encoder filter to graph
          hr = _graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
        }
        catch (Exception)
        {
          Log.Log.WriteFile("analog: cannot add filter {0} to graph", devices[i].Name);
          continue;
        }
        if (hr != 0)
        {
          //failed to add filter to graph, continue with the next one
          if (tmp != null)
          {
            _graphBuilder.RemoveFilter(tmp);
            Release.ComObject("TvEncoderFilter", tmp);
//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:Encoder.cs

示例7: AddTvMultiPlexer

    /// <summary>
    /// Adds the multiplexer filter to the graph.
    /// several posibilities
    ///  1. no tv multiplexer needed
    ///  2. tv multiplexer filter which is connected to a single encoder filter
    ///  3. tv multiplexer filter which is connected to two encoder filter (audio/video)
    ///  4. tv multiplexer filter which is connected to the capture filter
    /// at the end this method the graph looks like this:
    /// 
    ///  option 2: single encoder filter
    ///    [                ]----->[                ]      [             ]
    ///    [ capture filter ]      [ encoder filter ]----->[ multiplexer ]
    ///    [                ]----->[                ]      [             ]
    ///
    ///
    ///  option 3: dual encoder filters
    ///    [                ]----->[   video        ]    
    ///    [ capture filter ]      [ encoder filter ]------>[             ]
    ///    [                ]      [                ]       [             ]
    ///    [                ]                               [ multiplexer ]
    ///    [                ]----->[   audio        ]------>[             ]
    ///                            [ encoder filter ]      
    ///                            [                ]
    ///
    ///  option 4: no encoder filter
    ///    [                ]----->[             ]
    ///    [ capture filter ]      [ multiplexer ]
    ///    [                ]----->[             ]
    /// </summary>
    /// <param name="matchPinNames">if set to <c>true</c> the pin names of the multiplexer filter should match the pin names of the encoder filter.</param>
    /// <param name="_graphBuilder">GraphBuilder</param>
    /// <param name="_tuner">Tuner</param>
    /// <param name="_tvAudio">TvAudio</param>
    /// <param name="_crossbar">Crossbar</param>
    /// <param name="_capture">Capture</param>
    /// <returns>true if encoder filters are added, otherwise false</returns>
    private bool AddTvMultiPlexer(bool matchPinNames, IFilterGraph2 _graphBuilder, Tuner _tuner, TvAudio _tvAudio,
                                  Crossbar _crossbar, Capture _capture)
    {
      //Log.Log.WriteFile("analog: AddTvMultiPlexer");
      DsDevice[] devicesHW;
      DsDevice[] devicesSW;
      DsDevice[] devices;
      //get a list of all multiplexers available on this system
      try
      {
        devicesHW = DsDevice.GetDevicesOfCat(FilterCategory.WDMStreamingMultiplexerDevices);
        devicesHW = DeviceSorter.Sort(devicesHW, _tuner.TunerName, _tvAudio.TvAudioName, _crossbar.CrossBarName,
                                      _capture.VideoCaptureName, _capture.AudioCaptureName, _videoEncoderDevice,
                                      _audioEncoderDevice, _multiplexerDevice);
        // also add the SoftWare Multiplexers in case no compatible HardWare multiplexer is found (NVTV cards)
        devicesSW = _tuner.IsNvidiaCard()
                      ? DsDevice.GetDevicesOfCat(FilterCategory.MediaMultiplexerCategory)
                      : new DsDevice[0];

        devices = new DsDevice[devicesHW.Length + devicesSW.Length];
        int nr = 0;
        for (int i = 0; i < devicesHW.Length; ++i)
          devices[nr++] = devicesHW[i];
        for (int i = 0; i < devicesSW.Length; ++i)
          devices[nr++] = devicesSW[i];
      }
      catch (Exception ex)
      {
        Log.Log.WriteFile("analog: AddTvMultiPlexer no multiplexer devices found (Exception) " + ex.Message);
        return false;
      }
      if (devices.Length == 0)
      {
        Log.Log.WriteFile("analog: AddTvMultiPlexer no multiplexer devices found");
        return false;
      }
      //for each multiplexer
      for (int i = 0; i < devices.Length; i++)
      {
        IBaseFilter tmp;
        Log.Log.WriteFile("analog: AddTvMultiPlexer try:{0} {1}", devices[i].Name, i);
        // if multiplexer is in use, we can skip it
        if (DevicesInUse.Instance.IsUsed(devices[i]))
          continue;
        int hr;
        try
        {
          //add multiplexer to graph
          hr = _graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, devices[i].Name, out tmp);
        }
        catch (Exception)
        {
          Log.Log.WriteFile("analog: cannot add filter to graph");
          continue;
        }
        if (hr != 0)
        {
          //failed to add it to graph, continue with the next multiplexer
          if (tmp != null)
          {
            _graphBuilder.RemoveFilter(tmp);
            Release.ComObject("multiplexer filter", tmp);
          }
          continue;
//.........这里部分代码省略.........
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:101,代码来源:Encoder.cs

示例8: handleInternalNetworkProviderFilter

 private void handleInternalNetworkProviderFilter(DsDevice[] devices, IFilterGraph2 graphBuilder,
                                                  Guid networkProviderClsId, DsROTEntry rotEntry)
 {
   IDvbNetworkProvider interfaceNetworkProvider;
   TuningType tuningTypes;
   for (int i = 0; i < devices.Length; i++)
   {
     bool isCablePreferred = false;
     string name = devices[i].Name ?? "unknown";
     name = name.ToLowerInvariant();
     Log.Log.WriteFile("Found card:{0}", name);
     //silicondust work-around for dvb type detection issue. generic provider would always use dvb-t
     if (name.Contains("silicondust hdhomerun tuner"))
     {
       isCablePreferred = CheckHDHomerunCablePrefered(name);
       Log.Log.WriteFile("silicondust hdhomerun detected - prefer cable mode: {0}", isCablePreferred);
     }
     IBaseFilter tmp;
     graphBuilder.AddSourceFilterForMoniker(devices[i].Mon, null, name, out tmp);
     //Use the Microsoft Network Provider method first but only if available
     IBaseFilter networkDVB = FilterGraphTools.AddFilterFromClsid(graphBuilder, networkProviderClsId,
                                                                  "MediaPortal Network Provider");
     interfaceNetworkProvider = (IDvbNetworkProvider)networkDVB;
     string hash = GetHash(devices[i].DevicePath);
     interfaceNetworkProvider.ConfigureLogging(GetFileName(devices[i].DevicePath), hash, LogLevelOption.Debug);
     if (ConnectFilter(graphBuilder, networkDVB, tmp))
     {
       Log.Log.WriteFile("Detected DVB card:{0}- Hash: {1}", name, hash);
       interfaceNetworkProvider.GetAvailableTuningTypes(out tuningTypes);
       Log.Log.WriteFile("TuningTypes: " + tuningTypes);
       // determine the DVB card supported GUIDs here!
       if ((tuningTypes & TuningType.DvbT) != 0 && !isCablePreferred)
       {
         Log.Log.WriteFile("Detected DVB-T* card:{0}", name);
         TvCardDVBT dvbtCard = new TvCardDVBT(_epgEvents, devices[i]);
         _cards.Add(dvbtCard);
       }
       if ((tuningTypes & TuningType.DvbS) != 0 && !isCablePreferred)
       {
         Log.Log.WriteFile("Detected DVB-S* card:{0}", name);
         TvCardDVBS dvbsCard = new TvCardDVBS(_epgEvents, devices[i]);
         _cards.Add(dvbsCard);
       }
       if ((tuningTypes & TuningType.DvbC) != 0)
       {
         Log.Log.WriteFile("Detected DVB-C* card:{0}", name);
         TvCardDVBC dvbcCard = new TvCardDVBC(_epgEvents, devices[i]);
         _cards.Add(dvbcCard);
       }
       if ((tuningTypes & TuningType.Atsc) != 0 && !isCablePreferred)
       {
         Log.Log.WriteFile("Detected ATSC* card:{0}", name);
         TvCardATSC dvbsCard = new TvCardATSC(_epgEvents, devices[i]);
         _cards.Add(dvbsCard);
       }
     }
     graphBuilder.RemoveFilter(tmp);
     Release.ComObject("tmp filter", tmp);
     graphBuilder.RemoveFilter(networkDVB);
     Release.ComObject("ms provider", networkDVB);
   }
   FilterGraphTools.RemoveAllFilters(graphBuilder);
   rotEntry.Dispose();
   Release.ComObject("graph builder", graphBuilder);
 }
开发者ID:Yura80,项目名称:MediaPortal-1,代码行数:65,代码来源:TvCardCollection.cs

示例9: CreateFilterInstance

    /// <summary>
    /// Creates the teletext component in the graph. First we try to use the stored informations in the graph
    /// </summary>
    /// <param name="graph">The stored graph</param>
    /// <param name="graphBuilder">The graphbuilder</param>
    /// <param name="capture">The capture component</param>
    /// <returns>true, if the building was successful; false otherwise</returns>
    public bool CreateFilterInstance(Graph graph, IFilterGraph2 graphBuilder, Capture capture)
    {
      Log.Log.WriteFile("analog: SetupTeletext()");
      Guid guidBaseFilter = typeof (IBaseFilter).GUID;
      object obj;
      //find and add tee/sink to sink filter
      DsDevice[] devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSSplitter);
      devices[0].Mon.BindToObject(null, null, ref guidBaseFilter, out obj);
      _teeSink = (IBaseFilter)obj;
      int hr = graphBuilder.AddFilter(_teeSink, devices[0].Name);
      if (hr != 0)
      {
        Log.Log.Error("analog:SinkGraphEx.SetupTeletext(): Unable to add tee/sink filter");
        return false;
      }
      //connect capture filter -> tee sink filter
      IPin pin = DsFindPin.ByDirection(_teeSink, PinDirection.Input, 0);
      hr = graphBuilder.Connect(capture.VBIPin, pin);
      Release.ComObject(pin);
      if (hr != 0)
      {
        //failed...
        Log.Log.Error("analog: unable  to connect capture->tee/sink");
        graphBuilder.RemoveFilter(_teeSink);
        Release.ComObject(_teeSink);
        _teeSink = _filterWstDecoder = null;
        return false;
      }
      if (!string.IsNullOrEmpty(graph.Teletext.Name))
      {
        Log.Log.WriteFile("analog: Using Teletext-Component configuration from stored graph");
        devices = DsDevice.GetDevicesOfCat(graph.Teletext.Category);
        foreach (DsDevice device in devices)
        {
          if (device.Name != null && device.Name.Equals(graph.Teletext.Name))
          {
            //found it, add it to the graph
            Log.Log.Info("analog:Using teletext component - {0}", graph.Teletext.Name);
            device.Mon.BindToObject(null, null, ref guidBaseFilter, out obj);
            _filterWstDecoder = (IBaseFilter)obj;
            hr = graphBuilder.AddFilter(_filterWstDecoder, device.Name);
            if (hr != 0)
            {
              //failed...
              Log.Log.Error("analog:SinkGraphEx.SetupTeletext(): Unable to add WST Codec filter");
              graphBuilder.RemoveFilter(_filterWstDecoder);
              _filterWstDecoder = null;
            }
            break;
          }
        }
      }
      if (_filterWstDecoder == null)
      {
        Log.Log.WriteFile("analog: No stored or invalid graph for Teletext component - Trying to detect");

        //find the WST codec filter
        devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSVBICodec);
        foreach (DsDevice device in devices)
        {
          if (device.Name != null && device.Name.IndexOf("WST") >= 0)
          {
            //found it, add it to the graph
            Log.Log.Info("analog:Found WST Codec filter");
            device.Mon.BindToObject(null, null, ref guidBaseFilter, out obj);
            _filterWstDecoder = (IBaseFilter)obj;
            hr = graphBuilder.AddFilter(_filterWstDecoder, device.Name);
            if (hr != 0)
            {
              //failed...
              Log.Log.Error("analog:Unable to add WST Codec filter");
              graphBuilder.RemoveFilter(_teeSink);
              Release.ComObject(_teeSink);
              _teeSink = _filterWstDecoder = null;
              return false;
            }
            graph.Teletext.Name = device.Name;
            graph.Teletext.Category = FilterCategory.AMKSVBICodec;
            break;
          }
        }
        //Look for VBI Codec for Vista users as Vista doesn't use WST Codec anymore
        if (_filterWstDecoder == null)
        {
          devices = DsDevice.GetDevicesOfCat(FilterCategory.AMKSMULTIVBICodec);
          foreach (DsDevice device in devices)
            if (device.Name != null && device.Name.IndexOf("VBI") >= 0)
            {
              //found it, add it to the graph
              Log.Log.Info("analog:Found VBI Codec filter");
              device.Mon.BindToObject(null, null, ref guidBaseFilter, out obj);
              _filterWstDecoder = (IBaseFilter)obj;
              hr = graphBuilder.AddFilter(_filterWstDecoder, device.Name);
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:101,代码来源:TeletextComponent.cs


注:本文中的IFilterGraph2.RemoveFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。