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


C# IGraphBuilder.EnumFilters方法代码示例

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


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

示例1: DumpGraphInfo

        public void DumpGraphInfo(string fileName, IGraphBuilder graph)
        {
            if (string.IsNullOrEmpty(fileName) || graph == null) return;

            string filterOutputString = string.Empty;

            IEnumFilters enumFilters;
            int hr = graph.EnumFilters(out enumFilters);
            DsError.ThrowExceptionForHR(hr);

            IntPtr fetched = IntPtr.Zero;

            IBaseFilter[] filters = { null };

            int r = 0;
            while (r == 0)
            {
                try
                {
                    r = enumFilters.Next(filters.Length, filters, fetched);
                    DsError.ThrowExceptionForHR(r);

                    if (filters == null || filters.Length == 0 || filters[0] == null) continue;

                    FilterInfo filterInfo;
                    filters[0].QueryFilterInfo(out filterInfo);

                    filterOutputString += string.Format("{0:X8}", Marshal.GetIUnknownForObjectInContext(filters[0]).ToInt32()) + " ";

                    filterOutputString += filterInfo.achName + Environment.NewLine;

                    /* We will want to enum all the pins on the source filter */
                    IEnumPins pinEnum;

                    hr = filters[0].EnumPins(out pinEnum);
                    DsError.ThrowExceptionForHR(hr);

                    IntPtr fetched2 = IntPtr.Zero;
                    IPin[] pins = { null };

                    while (pinEnum.Next(pins.Length, pins, fetched2) == 0)
                    {
                        PinInfo pinInfo;
                        pins[0].QueryPinInfo(out pinInfo);

                        var prefix = "[In ] ";
                        if (pinInfo.dir == PinDirection.Output)
                            prefix = "[Out] ";

                        filterOutputString += string.Format("{0:X8}", Marshal.GetIUnknownForObjectInContext(pins[0]).ToInt32()) + " ";
                        filterOutputString += prefix + pinInfo.name + Environment.NewLine;

                        Marshal.ReleaseComObject(pins[0]);
                    }

                    Marshal.ReleaseComObject(pinEnum);
                }
                catch
                {
                    r = 0;
                    continue;
                }

            }

            Marshal.ReleaseComObject(enumFilters);

            var file2 = System.IO.File.CreateText(fileName);
            file2.AutoFlush = true;
            file2.Write(filterOutputString);
            file2.Close();
        }
开发者ID:mojoe-playground,项目名称:WPF-MediaKit,代码行数:72,代码来源:MediaUriPlayer.cs

示例2: RemoveFilters

        public static void RemoveFilters(IGraphBuilder graphBuilder, string filterName)
        {
            if (graphBuilder == null)
            {
                return;
            }

            int hr = 0;
            IEnumFilters enumFilters = null;
            ArrayList filtersArray = new ArrayList();

            try
            {
                hr = graphBuilder.EnumFilters(out enumFilters);
                DsError.ThrowExceptionForHR(hr);

                IBaseFilter[] filters = new IBaseFilter[1];
                IntPtr fetched = IntPtr.Zero;

                while (enumFilters.Next(filters.Length, filters, fetched) == 0)
                {
                    filtersArray.Add(filters[0]);
                }

                foreach (IBaseFilter filter in filtersArray)
                {
                    FilterInfo info;
                    filter.QueryFilterInfo(out info);
                    Marshal.ReleaseComObject(info.pGraph);

                    try
                    {
                        if (!String.IsNullOrEmpty(filterName))
                        {
                            if (String.Equals(info.achName, filterName))
                            {
                                DisconnectAllPins(graphBuilder, filter);
                                hr = graphBuilder.RemoveFilter(filter);
                                DsError.ThrowExceptionForHR(hr);
                                Marshal.ReleaseComObject(filter);
                                System.Diagnostics.Trace.WriteLine("Remove filter from graph: {0}", info.achName);
                            }
                        }
                        else
                        {
                            DisconnectAllPins(graphBuilder, filter);
                            hr = graphBuilder.RemoveFilter(filter);
                            DsError.ThrowExceptionForHR(hr);
                            int i = Marshal.ReleaseComObject(filter);
                            System.Diagnostics.Trace.WriteLine(string.Format("Remove filter from graph: {0} {1}", info.achName, i));
                        }
                    }
                    catch (Exception error)
                    {
                        System.Diagnostics.Trace.TraceError("Remove of filter: {0}, failed with code (HR): {1}, explanation: {2}", info.achName, hr.ToString(),
                                   error.Message);
                    }
                }
            }
            catch (Exception)
            {
                return;
            }
            finally
            {
                if (enumFilters != null)
                {
                    Marshal.ReleaseComObject(enumFilters);
                }
            }
        }
开发者ID:jiailiuyan,项目名称:WPF-MediaKit,代码行数:71,代码来源:DirectShowUtil.cs

示例3: RemoveAllFilters

        public static void RemoveAllFilters(IGraphBuilder graphBuilder)
        {
            int hr = 0;
            IEnumFilters enumFilters;
            var filtersArray = new ArrayList();

            if (graphBuilder == null)
                throw new ArgumentNullException("graphBuilder");

            hr = graphBuilder.EnumFilters(out enumFilters);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                var filters = new IBaseFilter[1];
                IntPtr fetched = IntPtr.Zero;

                while (enumFilters.Next(filters.Length, filters, fetched) == 0)
                {
                    filtersArray.Add(filters[0]);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(enumFilters);
            }

            foreach (IBaseFilter filter in filtersArray)
            {
                hr = graphBuilder.RemoveFilter(filter);
                Marshal.ReleaseComObject(filter);
            }
        }
开发者ID:naik899,项目名称:VideoMaker,代码行数:33,代码来源:FilterGraphTools.cs

示例4: FindFilterByName

    public static IBaseFilter FindFilterByName(IGraphBuilder graphBuilder, string filterName)
    {
      IBaseFilter filter = null;
      IEnumFilters enumFilters;

      if (graphBuilder == null)
        throw new ArgumentNullException("graphBuilder");

      int hr = graphBuilder.EnumFilters(out enumFilters);
      if (hr == 0)
      {
        IBaseFilter[] filters = new IBaseFilter[1];
        int fetched;

        while (enumFilters.Next(filters.Length, filters, out fetched) == 0)
        {
          if (GetFilterName(filters[0]).Equals(filterName))
          {
            filter = filters[0];
            break;
          }
        }
        Release.ComObject(enumFilters);
      }

      return filter;
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:27,代码来源:FilterGraphTools.cs

示例5: RemoveAllFilters

        /// <summary>
        /// Removes all filters from a DirectShow graph
        /// </summary>
        /// <param name="graphBuilder">The DirectShow graph to remove all the filters from</param>
        protected static void RemoveAllFilters(IGraphBuilder graphBuilder)
        {
            if (graphBuilder == null)
                return;

            IEnumFilters enumFilters;

            /* The list of filters from the DirectShow graph */
            var filtersArray = new List<IBaseFilter>();

            if (graphBuilder == null)
                throw new ArgumentNullException("graphBuilder");

            /* Gets the filter enumerator from the graph */
            int hr = graphBuilder.EnumFilters(out enumFilters);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                /* This array is filled with reference to a filter */
                var filters = new IBaseFilter[1];
                IntPtr fetched = IntPtr.Zero;

                /* Get reference to all the filters */
                while (enumFilters.Next(filters.Length, filters, fetched) == 0)
                {
                    /* Add the filter to our array */
                    filtersArray.Add(filters[0]);
                }
            }
            finally
            {
                /* Enum filters is a COM, so release that */
                Marshal.ReleaseComObject(enumFilters);
            }

            /* Loop over and release each COM */
            for (int i = 0; i < filtersArray.Count; i++)
            {
                graphBuilder.RemoveFilter(filtersArray[i]);
                while (Marshal.ReleaseComObject(filtersArray[i]) > 0)
                {}
            }
        }
开发者ID:fivesixty,项目名称:StandaloneMB,代码行数:48,代码来源:BaseClasses.cs

示例6: FindFilterByClsid

        public static IBaseFilter FindFilterByClsid(IGraphBuilder graphBuilder, Guid filterClsid)
        {
            int hr = 0;
            IBaseFilter filter = null;
            IEnumFilters enumFilters = null;

            if (graphBuilder == null)
                throw new ArgumentNullException("graphBuilder");

            hr = graphBuilder.EnumFilters(out enumFilters);
            if (hr == 0)
            {
                var filters = new IBaseFilter[1];
                IntPtr fetched = IntPtr.Zero;

                while (enumFilters.Next(filters.Length, filters, fetched) == 0)
                {
                    Guid clsid;

                    hr = filters[0].GetClassID(out clsid);

                    if ((hr == 0) && (clsid == filterClsid))
                    {
                        filter = filters[0];
                        break;
                    }

                    Marshal.ReleaseComObject(filters[0]);
                }
                Marshal.ReleaseComObject(enumFilters);
            }

            return filter;
        }
开发者ID:naik899,项目名称:VideoMaker,代码行数:34,代码来源:FilterGraphTools.cs

示例7: GetFilterByName

 public static IBaseFilter GetFilterByName(IGraphBuilder graphBuilder, string name)
 {
   int hr = 0;
   IEnumFilters ienumFilt = null;
   IBaseFilter[] foundfilter = new IBaseFilter[2];
   int iFetched = 0;
   try
   {
     hr = graphBuilder.EnumFilters(out ienumFilt);
     if (hr == 0 && ienumFilt != null)
     {
       ienumFilt.Reset();
       do
       {
         hr = ienumFilt.Next(1, foundfilter, out iFetched);
         if (hr == 0 && iFetched == 1)
         {
           FilterInfo filter_infos = new FilterInfo();
           foundfilter[0].QueryFilterInfo(out filter_infos);
           ReleaseComObject(filter_infos.pGraph);
           Log.Debug("GetFilterByName: {0}, {1}", name, filter_infos.achName);
           if (filter_infos.achName.LastIndexOf(name) != -1)
           {
             ReleaseComObject(ienumFilt);
             ienumFilt = null;
             return foundfilter[0];
           }
           ReleaseComObject(foundfilter[0]);
         }
       } while (iFetched == 1 && hr == 0);
       if (ienumFilt != null)
       {
         ReleaseComObject(ienumFilt);
       }
       ienumFilt = null;
     }
   }
   catch (Exception) {}
   finally
   {
     if (ienumFilt != null)
     {
       ReleaseComObject(ienumFilt);
     }
   }
   return null;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:47,代码来源:DirectShowUtil.cs

示例8: SetGraphOutputFile

        public static void SetGraphOutputFile(IGraphBuilder graphBuilder, string OutputFile)
        {
            int hr = 0;
            IEnumFilters enumFilters = null;

            if (graphBuilder == null)
                throw new ArgumentNullException("graphBuilder");

            hr = graphBuilder.EnumFilters(out enumFilters);
            if (hr == 0)
            {
                IBaseFilter[] filters = new IBaseFilter[1];

                while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
                {
                    Guid clsid;

                    IFileSinkFilter fsf = filters[0] as IFileSinkFilter;

                    if (fsf != null)
                    {
                        hr = fsf.SetFileName(OutputFile, null);
                        Marshal.ReleaseComObject(filters[0]);
                        break;
                    }

                    Marshal.ReleaseComObject(filters[0]);
                }
                Marshal.ReleaseComObject(enumFilters);
            }
        }
开发者ID:Rainking720,项目名称:MediaBrowser.Theater,代码行数:31,代码来源:FilterGraphTools.cs

示例9: RemoveUnusedFiltersFromGraph

    public static void RemoveUnusedFiltersFromGraph(IGraphBuilder graphBuilder)
    {
      if (graphBuilder == null)
        return;

      int hr = 0;
      IEnumFilters enumFilters = null;
      ArrayList filtersArray = new ArrayList();

      try
      {
        hr = graphBuilder.EnumFilters(out enumFilters);
        DsError.ThrowExceptionForHR(hr);

        IBaseFilter[] filters = new IBaseFilter[1];
        int fetched;

        while (enumFilters.Next(filters.Length, filters, out fetched) == 0)
        {
          filtersArray.Add(filters[0]);
        }

        foreach (IBaseFilter filter in filtersArray)
        {
          FilterInfo info;
          filter.QueryFilterInfo(out info);
          Log.Debug("Check graph connections for: {0}", info.achName);

          IEnumPins pinEnum;
          hr = filter.EnumPins(out pinEnum);
          DsError.ThrowExceptionForHR(hr);

          if (hr == 0 && pinEnum != null)
          {
            bool filterUsed = false;
            bool hasOut = false;
            bool hasIn = false;
            pinEnum.Reset();
            IPin[] pins = new IPin[1];
            while (pinEnum.Next(1, pins, out fetched) == 0)
            {
              if (fetched > 0)
              {
                PinDirection pinDir;
                hr = pins[0].QueryDirection(out pinDir);
                DsError.ThrowExceptionForHR(hr);
                if (pinDir == PinDirection.Output)
                  hasOut = true;
                else
                  hasIn = true;
                if (HasConnection(pins[0]))
                {
                  filterUsed = true;
                  break;
                }
              }
            }
            ReleaseComObject(pinEnum);
            if (!filterUsed && hasOut && hasIn)
            {
              hr = graphBuilder.RemoveFilter(filter);
              DsError.ThrowExceptionForHR(hr);
              if (hr == 0)
                Log.Debug(" - remove done");
            }
          }
          ReleaseComObject(info.pGraph);
          ReleaseComObject(filter);
        }
      }
      catch (Exception error)
      {
        Log.Error("DirectShowUtil: Remove unused filters failed - {0}", error.Message);
      }
      ReleaseComObject(enumFilters);
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:76,代码来源:DirectShowUtil.cs

示例10: SetARMode

    /// <summary>
    /// Find the overlay mixer and/or the VMR9 windowless filters
    /// and tell them we dont want a fixed Aspect Ratio
    /// Mediaportal handles AR itself
    /// </summary>
    /// <param name="graphBuilder"></param>
    public static void SetARMode(IGraphBuilder graphBuilder, AspectRatioMode ARRatioMode)
    {
      int hr;
      IBaseFilter overlay;
      graphBuilder.FindFilterByName("Overlay Mixer2", out overlay);

      if (overlay != null)
      {
        IPin iPin;
        overlay.FindPin("Input0", out iPin);
        if (iPin != null)
        {
          IMixerPinConfig pMC = iPin as IMixerPinConfig;
          if (pMC != null)
          {
            AspectRatioMode mode;
            hr = pMC.SetAspectRatioMode(ARRatioMode);
            hr = pMC.GetAspectRatioMode(out mode);
            //ReleaseComObject(pMC);
          }
          ReleaseComObject(iPin);
        }
        ReleaseComObject(overlay);
      }


      IEnumFilters enumFilters;
      hr = graphBuilder.EnumFilters(out enumFilters);
      if (hr >= 0 && enumFilters != null)
      {
        int iFetched;
        enumFilters.Reset();
        IBaseFilter[] pBasefilter = new IBaseFilter[2];
        do
        {
          pBasefilter = null;
          hr = enumFilters.Next(1, pBasefilter, out iFetched);
          if (hr == 0 && iFetched == 1 && pBasefilter[0] != null)
          {
            IVMRAspectRatioControl pARC = pBasefilter[0] as IVMRAspectRatioControl;
            if (pARC != null)
            {
              pARC.SetAspectRatioMode(VMRAspectRatioMode.None);
            }
            IVMRAspectRatioControl9 pARC9 = pBasefilter[0] as IVMRAspectRatioControl9;
            if (pARC9 != null)
            {
              pARC9.SetAspectRatioMode(VMRAspectRatioMode.None);
            }

            IEnumPins pinEnum;
            hr = pBasefilter[0].EnumPins(out pinEnum);
            if ((hr == 0) && (pinEnum != null))
            {
              pinEnum.Reset();
              IPin[] pins = new IPin[1];
              int f;
              do
              {
                // Get the next pin
                hr = pinEnum.Next(1, pins, out f);
                if (f == 1 && hr == 0 && pins[0] != null)
                {
                  IMixerPinConfig pMC = pins[0] as IMixerPinConfig;
                  if (null != pMC)
                  {
                    pMC.SetAspectRatioMode(ARRatioMode);
                  }
                  ReleaseComObject(pins[0]);
                }
              } while (f == 1);
              ReleaseComObject(pinEnum);
            }
            ReleaseComObject(pBasefilter[0]);
          }
        } while (iFetched == 1 && pBasefilter[0] != null);
        ReleaseComObject(enumFilters);
      }
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:85,代码来源:DirectShowUtil.cs

示例11: GetFilter

        private static IBaseFilter GetFilter(IGraphBuilder graph,string mask) {
            IBaseFilter filter = null;
            IEnumFilters filters;
            FilterInfo info;
            int hr = 0;
            System.IntPtr count = (System.IntPtr) 0;
            hr = graph.EnumFilters(out filters);
            DsError.ThrowExceptionForHR(hr);

            IBaseFilter[] f = new IBaseFilter[1];
            while (filters.Next(1, f,count) == 0)
            {
                hr = f[0].QueryFilterInfo(out info);
                DsError.ThrowExceptionForHR(hr);

                if (info.achName.ToLower().EndsWith(mask))
                {
                    filter = f[0];
                    break;
                }
            }
            return filter;
        }
开发者ID:vlkam,项目名称:OpenLearningPlayer,代码行数:23,代码来源:DirectShowPlayer.cs

示例12: RemoveAllFilters

    public static void RemoveAllFilters(IGraphBuilder graphBuilder)
    {
      if (graphBuilder == null)
        throw new ArgumentNullException("graphBuilder");

      IEnumFilters enumFilters = null;
      System.Collections.ArrayList filtersArray = new System.Collections.ArrayList();

      try
      {
        int hr = graphBuilder.EnumFilters(out enumFilters);
        DsError.ThrowExceptionForHR(hr);

        IBaseFilter[] filters = new IBaseFilter[1];
        int fetched;

        while (enumFilters.Next(filters.Length, filters, out fetched) == 0)
        {
          filtersArray.Add(filters[0]);
        }
        foreach (IBaseFilter filter in filtersArray)
        {
          FilterInfo info;
          filter.QueryFilterInfo(out info);
          Log.Log.Write("Remove filter from graph: {0}", info.achName);
          graphBuilder.RemoveFilter(filter);
          while (Release.ComObject(filter) > 0) ;
        }
      }
      catch (Exception)
      {
        Log.Log.Write("Remove filter error!");
        return;
      }
      finally
      {
        if (enumFilters != null)
        {
          Release.ComObject(enumFilters);
        }
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:42,代码来源:FilterGraphTools.cs

示例13: DisconnectAllPins

    public static void DisconnectAllPins(IGraphBuilder graphBuilder)
    {
      IEnumFilters enumFilters;

      if (graphBuilder == null)
        throw new ArgumentNullException("graphBuilder");

      int hr = graphBuilder.EnumFilters(out enumFilters);
      DsError.ThrowExceptionForHR(hr);

      try
      {
        IBaseFilter[] filters = new IBaseFilter[1];
        int fetched;

        while (enumFilters.Next(filters.Length, filters, out fetched) == 0)
        {
          try
          {
            DisconnectPins(filters[0]);
          }
          catch (Exception ex)
          {
            Log.Log.WriteFile("Error while disconnecting all pins: ", ex);
          }
          Release.ComObject(filters[0]);
        }
      }
      finally
      {
        Release.ComObject(enumFilters);
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:33,代码来源:FilterGraphTools.cs

示例14: SetSyncSource

        public static void SetSyncSource(IGraphBuilder graphBuilder, IReferenceClock clock)
        {
            int hr = 0;
            IEnumFilters enumFilters = null;

            if (graphBuilder == null)
                throw new ArgumentNullException("graphBuilder");

            hr = graphBuilder.EnumFilters(out enumFilters);
            if (hr == 0)
            {
                IBaseFilter[] filters = new IBaseFilter[1];

                while (enumFilters.Next(filters.Length, filters, IntPtr.Zero) == 0)
                {
                    hr = filters[0].SetSyncSource(clock);
                    DsError.ThrowExceptionForHR(hr);

                    Marshal.ReleaseComObject(filters[0]);
                }
                Marshal.ReleaseComObject(enumFilters);
            }
        }
开发者ID:Rainking720,项目名称:MediaBrowser.Theater,代码行数:23,代码来源:FilterGraphTools.cs

示例15: FindFilterByClassID

    public static void FindFilterByClassID(IGraphBuilder m_graphBuilder, Guid classID, out IBaseFilter filterFound)
    {
      filterFound = null;

      if (m_graphBuilder == null)
      {
        return;
      }
      IEnumFilters ienumFilt = null;
      try
      {
        int hr = m_graphBuilder.EnumFilters(out ienumFilt);
        if (hr == 0 && ienumFilt != null)
        {
          int iFetched;
          IBaseFilter[] filter = new IBaseFilter[2];
          ienumFilt.Reset();
          do
          {
            hr = ienumFilt.Next(1, filter, out iFetched);
            if (hr == 0 && iFetched == 1)
            {
              Guid filterGuid;
              filter[0].GetClassID(out filterGuid);
              if (filterGuid == classID)
              {
                filterFound = filter[0];
                return;
              }
              ReleaseComObject(filter[0]);
              filter[0] = null;
            }
          } while (iFetched == 1 && hr == 0);
          if (ienumFilt != null)
          {
            ReleaseComObject(ienumFilt);
          }
          ienumFilt = null;
        }
      }
      catch (Exception) {}
      finally
      {
        if (ienumFilt != null)
        {
          ReleaseComObject(ienumFilt);
        }
      }
      return;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:50,代码来源:DirectShowUtil.cs


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