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


C# IBaseFilter.EnumPins方法代码示例

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


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

示例1: GetPin

        /// <summary>
        /// Get filter's pin.
        /// </summary>
        /// 
        /// <param name="filter">Filter to get pin of.</param>
        /// <param name="dir">Pin's direction.</param>
        /// <param name="num">Pin's number.</param>
        /// 
        /// <returns>Returns filter's pin.</returns>
        /// 
        public static IPin GetPin( IBaseFilter filter, PinDirection dir, int num )
        {
            IPin[] pin = new IPin[1];
            IEnumPins pinsEnum = null;

            // enum filter pins
            if ( filter.EnumPins( out pinsEnum ) == 0 )
            {
                PinDirection pinDir;
                int n;

                // get next pin
                while ( pinsEnum.Next( 1, pin, out n ) == 0 )
                {
                    // query pin`s direction
                    pin[0].QueryDirection( out pinDir );

                    if ( pinDir == dir )
                    {
                        if ( num == 0 )
                            return pin[0];
                        num--;
                    }

                    Marshal.ReleaseComObject( pin[0] );
                    pin[0] = null;
                }
            }
            return null;
        }
开发者ID:Tob1112,项目名称:405sentry,代码行数:40,代码来源:Tools.cs

示例2: FindPin

        public static IPin FindPin(IBaseFilter filter, PinDirection direction, Guid mediaType, Guid pinCategory, string preferredName)
        {
            if (Guid.Empty != pinCategory)
            {
                int idx = 0;

                do
                {
                    IPin pinByCategory = DsFindPin.ByCategory(filter, pinCategory, idx);

                    if (pinByCategory != null)
                    {
                        if (IsMatchingPin(pinByCategory, direction, mediaType))
                            return PrintInfoAndReturnPin(filter, pinByCategory, direction, mediaType, pinCategory, "found by category");

                        Marshal.ReleaseComObject(pinByCategory);
                    }
                    else
                        break;

                    idx++;
                }
                while (true);
            }

            if (!string.IsNullOrEmpty(preferredName))
            {
                IPin pinByName = DsFindPin.ByName(filter, preferredName);
                if (pinByName != null && IsMatchingPin(pinByName, direction, mediaType))
                    return PrintInfoAndReturnPin(filter, pinByName, direction, mediaType, pinCategory, "found by name");

                Marshal.ReleaseComObject(pinByName);
            }

            IEnumPins pinsEnum;
            IPin[] pins = new IPin[1];

            int hr = filter.EnumPins(out pinsEnum);
            DsError.ThrowExceptionForHR(hr);

            while (pinsEnum.Next(1, pins, IntPtr.Zero) == 0)
            {
                IPin pin = pins[0];
                if (pin != null)
                {
                    if (IsMatchingPin(pin, direction, mediaType))
                        return PrintInfoAndReturnPin(filter, pin, direction, mediaType, pinCategory, "found by direction and media type");

                    Marshal.ReleaseComObject(pin);
                }
            }

            return null;
        }
开发者ID:hpavlov,项目名称:occurec,代码行数:54,代码来源:DsHelper.cs

示例3: DisconnectAllPins

        public static bool DisconnectAllPins(IGraphBuilder graphBuilder, IBaseFilter filter)
        {
            IEnumPins pinEnum;
            int hr = filter.EnumPins(out pinEnum);
            if (hr != 0 || pinEnum == null)
            {
                return false;
            }
            FilterInfo info;
            filter.QueryFilterInfo(out info);

            Marshal.ReleaseComObject(info.pGraph);
            bool allDisconnected = true;
            for (; ; )
            {
                IPin[] pins = new IPin[1];
                IntPtr fetched = IntPtr.Zero;
                hr = pinEnum.Next(1, pins, fetched);
                if (hr != 0 || fetched == IntPtr.Zero)
                {
                    break;
                }
                PinInfo pinInfo;
                pins[0].QueryPinInfo(out pinInfo);
                DsUtils.FreePinInfo(pinInfo);
                if (pinInfo.dir == PinDirection.Output)
                {
                    if (!DisconnectPin(graphBuilder, pins[0]))
                    {
                        allDisconnected = false;
                    }
                }
                Marshal.ReleaseComObject(pins[0]);
            }
            Marshal.ReleaseComObject(pinEnum);
            return allDisconnected;
        }
开发者ID:jiailiuyan,项目名称:WPF-MediaKit,代码行数:37,代码来源:DirectShowUtil.cs

示例4: GetUnconnectedPin

        protected IPin GetUnconnectedPin(IBaseFilter filter, PinDirection direction)
        {
            IPin destPin = null;
            IEnumPins iEnum;
            var pins = new IPin[1];

            var hr = filter.EnumPins(out iEnum);
            Marshal.ThrowExceptionForHR(hr);

            var fetched = Marshal.AllocCoTaskMem(4);
            hr = iEnum.Next(1, pins, fetched);
            Marshal.ThrowExceptionForHR(hr);

            while (Marshal.ReadInt32(fetched) == 1)
            {
                PinDirection pinDir;
                IPin pPin;
                destPin = pins[0];

                hr = destPin.QueryDirection(out pinDir);
                Marshal.ThrowExceptionForHR(hr);

                PinInfo info;
                destPin.QueryPinInfo(out info);
                //var name = info.name;
                destPin.ConnectedTo(out pPin);

                if (pPin == null && pinDir == direction)
                    break;

                hr = iEnum.Next(1, pins, fetched);
                Marshal.ThrowExceptionForHR(hr);
            }
            Marshal.FreeCoTaskMem(fetched);
            return destPin;
        }
开发者ID:alnicol,项目名称:Realtek-2832U,代码行数:36,代码来源:RadioBase.cs

示例5: RenderUnconnectedOutputPins

    public static void RenderUnconnectedOutputPins(IGraphBuilder graphBuilder, IBaseFilter baseFilter)
    {
      if (baseFilter == null)
        return;

      int fetched;
      IEnumPins pinEnum;
      int hr = baseFilter.EnumPins(out pinEnum);
      DsError.ThrowExceptionForHR(hr);
      if (hr == 0 && pinEnum != null)
      {
        pinEnum.Reset();
        IPin[] pins = new IPin[1];
        while (pinEnum.Next(1, pins, out fetched) == 0 && fetched > 0)
        {
          PinDirection pinDir;
          pins[0].QueryDirection(out pinDir);
          if (pinDir == PinDirection.Output && !HasConnection(pins[0]))
          {
            FilterInfo i;
            PinInfo pinInfo;
            string pinName = string.Empty;
            if (baseFilter.QueryFilterInfo(out i) == 0)
            {
              if (pins[0].QueryPinInfo(out pinInfo) == 0)
              {
                Log.Debug("Filter: {0} - try to connect: {1}", i.achName, pinInfo.name);
                pinName = pinInfo.name;
                DsUtils.FreePinInfo(pinInfo);
              }
            }

            ReleaseComObject(i.pGraph);
            hr = graphBuilder.Render(pins[0]);
            if (hr != 0)
              Log.Debug(" - failed");
          }
          ReleaseComObject(pins[0]);
        }
        ReleaseComObject(pinEnum);
      }
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:42,代码来源:DirectShowUtil.cs

示例6: RenderOutputPins

        public static void RenderOutputPins(IGraphBuilder graphBuilder, IBaseFilter filter)
        {
            if (graphBuilder == null) throw new ArgumentNullException("graphBuilder");
            if (filter == null) throw new ArgumentNullException("filter");

            int hr = 0;

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

            IEnumPins enumPins;
            var pins = new IPin[1];
            IntPtr fetched = IntPtr.Zero;

            hr = filter.EnumPins(out enumPins);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                while (enumPins.Next(pins.Length, pins, fetched) == 0)
                {
                    try
                    {
                        PinDirection direction;

                        pins[0].QueryDirection(out direction);

                        if (direction == PinDirection.Output)
                        {
                            hr = graphBuilder.Render(pins[0]);
                            DsError.ThrowExceptionForHR(hr);
                        }
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(pins[0]);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(enumPins);
            }
        }
开发者ID:naik899,项目名称:VideoMaker,代码行数:44,代码来源:FilterGraphTools.cs

示例7: EnumeratePins

        public static IList<PinQueryInfo> EnumeratePins(IBaseFilter filter)
        {
            if (filter == null) throw new ArgumentNullException("filter");
            int hr = 0;

            var pinsInfo = new List<PinQueryInfo>();

            IEnumPins pinsEnum = null;
            try
            {
                hr = filter.EnumPins(out pinsEnum);
                DsError.ThrowExceptionForHR(hr);

                if (pinsEnum == null) throw new InvalidOperationException("pinsEnum is null");

                var pins = new IPin[1];

                while (true)
                {
                    try
                    {
                        int fetched = 0;

                        IntPtr pcFetched = Marshal.AllocCoTaskMem(4);

                        try
                        {
                            hr = pinsEnum.Next(pins.Length, pins, pcFetched);
                            DsError.ThrowExceptionForHR(hr);
                            fetched = Marshal.ReadInt32(pcFetched);
                        }
                        finally
                        {
                            Marshal.FreeCoTaskMem(pcFetched);
                        }

                        if (fetched == 1)
                        {
                            // we have something
                            IPin pin = pins[0];

                            string queryId;
                            hr = pin.QueryId(out queryId);
                            DsError.ThrowExceptionForHR(hr);

                            PinInfo pinInfo;
                            hr = pin.QueryPinInfo(out pinInfo);
                            DsError.ThrowExceptionForHR(hr);

                            pinsInfo.Add(new PinQueryInfo(pinInfo.dir, pinInfo.name, queryId));
                        }
                        else
                        {
                            break;
                        }
                    }
                    finally
                    {
                        if (pins[0] != null) Marshal.ReleaseComObject(pins[0]);
                        pins[0] = null;
                    }
                }
            }
            finally
            {
                if (pinsEnum != null) Marshal.ReleaseComObject(pinsEnum);
            }

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

示例8: SetFilterFormat

        public static void SetFilterFormat(AMMediaType streamFormat, IBaseFilter filter)
        {
            if (filter == null) throw new ArgumentNullException("filter");

            int hr;

            IEnumPins pinsEnum = null;
            try
            {
                hr = filter.EnumPins(out pinsEnum);
                DsError.ThrowExceptionForHR(hr);

                if (pinsEnum == null) throw new SplicerException(Resources.ErrorPinsEnumeratorIsNull);

                var pins = new IPin[1];

                while (true)
                {
                    try
                    {
                        int fetched = 0;
                        IntPtr pcFetched = Marshal.AllocCoTaskMem(4);
                        try
                        {
                            hr = pinsEnum.Next(pins.Length, pins, pcFetched);
                            DsError.ThrowExceptionForHR(hr);
                            fetched = Marshal.ReadInt32(pcFetched);
                        }
                        finally
                        {
                            Marshal.FreeCoTaskMem(pcFetched);
                        }

                        if (fetched == 1)
                        {
                            // we have something
                            IPin pin = pins[0];

                            string queryId;
                            hr = pin.QueryId(out queryId);
                            DsError.ThrowExceptionForHR(hr);

                            PinInfo pinInfo;
                            hr = pin.QueryPinInfo(out pinInfo);
                            DsError.ThrowExceptionForHR(hr);

                            if (pinInfo.dir != PinDirection.Output) continue;
                            var streamConfig = (IAMStreamConfig) pin;

                            hr = streamConfig.SetFormat(streamFormat);
                            DsError.ThrowExceptionForHR(hr);
                        }
                        else
                        {
                            break;
                        }
                    }
                    finally
                    {
                        if (pins[0] != null) Marshal.ReleaseComObject(pins[0]);
                        pins[0] = null;
                    }
                }
            }
            finally
            {
                if (pinsEnum != null) Marshal.ReleaseComObject(pinsEnum);
            }
        }
开发者ID:naik899,项目名称:VideoMaker,代码行数:69,代码来源:FilterGraphTools.cs

示例9: LogOutputPinsConnectionRecursive

        public static void LogOutputPinsConnectionRecursive(IBaseFilter filter, string previous = "")
        {
            bool log = true;
            IEnumPins pinEnum = null;
            if (filter.EnumPins(out pinEnum) == 0)
            {
                FilterInfo sourceFilterInfo;
                filter.QueryFilterInfo(out sourceFilterInfo);
                int fetched = 0;
                IPin[] pins = new IPin[1];
                while (pinEnum.Next(1, pins, out fetched) == 0 && fetched > 0)
                {
                    IPin pin = pins[0];
                    PinDirection pinDirection;
                    if (pin.QueryDirection(out pinDirection) == 0 && pinDirection == PinDirection.Output)
                    {
                        log = false;
                        IPin connectedPin;
                        if (pin.ConnectedTo(out connectedPin) == 0 && connectedPin != null)
                        {
                            PinInfo connectedPinInfo;
                            connectedPin.QueryPinInfo(out connectedPinInfo);
                            FilterInfo connectedFilterInfo;
                            connectedPinInfo.filter.QueryFilterInfo(out connectedFilterInfo);
                            if (previous == "") previous = sourceFilterInfo.achName;
                            DirectShowUtil.ReleaseComObject(connectedPin, 2000);
                            IBaseFilter connectedFilter;
                            if (connectedFilterInfo.pGraph.FindFilterByName(connectedFilterInfo.achName, out connectedFilter) == 0 && connectedFilter != null)
                            {
                                LogOutputPinsConnectionRecursive(connectedFilter, previous + string.Format(" --> {0}", connectedFilterInfo.achName));
                                DirectShowUtil.ReleaseComObject(connectedFilter);
                            }
                        }
                        DirectShowUtil.ReleaseComObject(pin, 2000);
                    }
                }
            }
            DirectShowUtil.ReleaseComObject(pinEnum, 2000);

            if (log) Log.Instance.Debug(previous);
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:41,代码来源:OnlineVideosPlayer.cs

示例10: FilterHasInputPin

        /// <summary>
        /// This filter has an input pin matching one of the pins in the list.
        /// </summary>
        /// <param name="thisFilter"></param>
        /// <param name="inputPins"></param>
        /// <returns></returns>
        private bool FilterHasInputPin(IBaseFilter thisFilter, List<IPin> inputPins)
        {
            if (inputPins.Count == 0) return false;

            IEnumPins enumPins;
            thisFilter.EnumPins(out enumPins);

            IPin p;
            uint fetched;
            enumPins.Next(1, out p, out fetched);
            while (fetched == 1) {
                _PinDirection pinDir;
                p.QueryDirection(out pinDir);
                if (pinDir == _PinDirection.PINDIR_INPUT) {
                    if (inputPins.Contains(p)) {
                        return true;
                    }
                }
                enumPins.Next(1, out p, out fetched);
            }
            return false;
        }
开发者ID:joke1410,项目名称:conferencexp,代码行数:28,代码来源:Graphs.cs

示例11: FindPin

		private IPin FindPin(IBaseFilter filter, PinDirection direction, Guid mediaType, string preferredName)
		{
			if (!string.IsNullOrEmpty(preferredName))
			{
				IPin pinByName = DsFindPin.ByName(filter, preferredName);

				if (IsMatchingPin(pinByName, direction, mediaType))
					return pinByName;

				Marshal.ReleaseComObject(pinByName);
			}

			IEnumPins pinsEnum;
			IPin[] pins = new IPin[1];

			int hr = filter.EnumPins(out pinsEnum);
			DsError.ThrowExceptionForHR(hr);

			while (pinsEnum.Next(1, pins, IntPtr.Zero) == 0)
			{
				IPin pin = pins[0];
				if (pin != null)
				{
					if (IsMatchingPin(pin, direction, mediaType))
						return pin;

					Marshal.ReleaseComObject(pin);
				}
			}

			return null;
		}
开发者ID:hpavlov,项目名称:video.directshowvideocapture,代码行数:32,代码来源:DirectShowCapture.cs

示例12: ConnectAllOutputFiltersFrom

        protected virtual void ConnectAllOutputFiltersFrom(IBaseFilter fromFilter, IFilterGraph2 graph)
        {
            // Get the pin enumerator
            IEnumPins ppEnum;
            int hr = fromFilter.EnumPins(out ppEnum);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                // Walk the pins looking for a match
                IPin[] pPins = new IPin[1];
                //22 int lFetched;
                //22 while ((ppEnum.Next(1, pPins, out lFetched) >= 0) && (lFetched == 1))
                while (ppEnum.Next(1, pPins, IntPtr.Zero) >= 0)
                {
                    // Read the direction
                    PinDirection ppindir;
                    hr = pPins[0].QueryDirection(out ppindir);
                    DsError.ThrowExceptionForHR(hr);

                    // Is it the right direction?
                    if (ppindir == PinDirection.Output)
                    {
                        if (pPins[0] != null)
                        {
                            hr = graph.Render(pPins[0]);
                            //DsError.ThrowExceptionForHR(hr);
                        }
                    }
                    Marshal.ReleaseComObject(pPins[0]);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(ppEnum);
            }
        }
开发者ID:dgis,项目名称:CodeTV,代码行数:37,代码来源:GraphBuilderBase.cs

示例13: ByName

        /// <summary>
        /// Scans a filter's pins looking for a pin with the specified name
        /// </summary>
        /// <param name="vSource">The filter to scan</param>
        /// <param name="vPinName">The pin name to find</param>
        /// <returns>The matching pin, or null if not found</returns>
        public static IPin ByName(IBaseFilter vSource, string vPinName)
        {
            int hr;
            IEnumPins ppEnum;
            PinInfo ppinfo;
            IPin pRet = null;
            IPin[] pPins = new IPin[1];

            if (vSource == null)
            {
                return null;
            }

            // Get the pin enumerator
            hr = vSource.EnumPins(out ppEnum);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                // Walk the pins looking for a match
                while (ppEnum.Next(1, pPins, IntPtr.Zero) == 0)
                {
                    // Read the info
                    hr = pPins[0].QueryPinInfo(out ppinfo);
                    DsError.ThrowExceptionForHR(hr);

                    // Is it the right name?
                    if (ppinfo.name == vPinName)
                    {
                        DsUtils.FreePinInfo(ppinfo);
                        pRet = pPins[0];
                        break;
                    }
                    Marshal.ReleaseComObject(pPins[0]);
                    DsUtils.FreePinInfo(ppinfo);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(ppEnum);
            }

            return pRet;
        }
开发者ID:esurharun,项目名称:TSDumper,代码行数:50,代码来源:Utils.cs

示例14: ByDirection

        /// <summary>
        /// Scans a filter's pins looking for a pin in the specified direction
        /// </summary>
        /// <param name="vSource">The filter to scan</param>
        /// <param name="vDir">The direction to find</param>
        /// <param name="iIndex">Zero based index (ie 2 will return the third pin in the specified direction)</param>
        /// <returns>The matching pin, or null if not found</returns>
        public static IPin ByDirection(IBaseFilter vSource, PinDirection vDir, int iIndex)
        {
            int hr;
            IEnumPins ppEnum;
            PinDirection ppindir;
            IPin pRet = null;
            IPin[] pPins = new IPin[1];

            if (vSource == null)
            {
                return null;
            }

            // Get the pin enumerator
            hr = vSource.EnumPins(out ppEnum);
            DsError.ThrowExceptionForHR(hr);

            try
            {
                // Walk the pins looking for a match
                while (ppEnum.Next(1, pPins, IntPtr.Zero) == 0)
                {
                    // Read the direction
                    hr = pPins[0].QueryDirection(out ppindir);
                    DsError.ThrowExceptionForHR(hr);

                    // Is it the right direction?
                    if (ppindir == vDir)
                    {
                        // Is is the right index?
                        if (iIndex == 0)
                        {
                            pRet = pPins[0];
                            break;
                        }
                        iIndex--;
                    }
                    Marshal.ReleaseComObject(pPins[0]);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(ppEnum);
            }

            return pRet;
        }
开发者ID:esurharun,项目名称:TSDumper,代码行数:54,代码来源:Utils.cs

示例15: RenderOutputPins

    public static bool RenderOutputPins(IGraphBuilder graphBuilder, IBaseFilter filter, int maxPinsToRender,
                                        bool tryAllFilters)
    {
      int pinsRendered = 0;
      bool bAllConnected = true;
      IEnumPins pinEnum;
      FilterInfo info;
      filter.QueryFilterInfo(out info);
      ReleaseComObject(info.pGraph);

      int hr = filter.EnumPins(out pinEnum);
      if ((hr == 0) && (pinEnum != null))
      {
        Log.Info("got pins");
        pinEnum.Reset();
        IPin[] pins = new IPin[1];
        int iFetched;
        int iPinNo = 0;
        do
        {
          // Get the next pin
          //Log.Info("  get pin:{0}",iPinNo);
          iPinNo++;
          hr = pinEnum.Next(1, pins, out iFetched);
          if (hr == 0)
          {
            if (iFetched == 1 && pins[0] != null)
            {
              PinInfo pinInfo = new PinInfo();
              hr = pins[0].QueryPinInfo(out pinInfo);
              DsUtils.FreePinInfo(pinInfo);
              if (hr == 0)
              {
                Log.Info("  got pin#{0}:{1}", iPinNo - 1, pinInfo.name);
              }
              else
              {
                Log.Info("  got pin:?");
              }
              PinDirection pinDir;
              pins[0].QueryDirection(out pinDir);
              if (pinDir == PinDirection.Output)
              {
                IPin pConnectPin = null;
                hr = pins[0].ConnectedTo(out pConnectPin);
                if (hr != 0 || pConnectPin == null)
                {
                  hr = 0;
                  if (TryConnect(graphBuilder, info.achName, pins[0], tryAllFilters))
                    //if ((hr=graphBuilder.Render(pins[0])) == 0)
                  {
                    Log.Info("  render ok");
                  }
                  else
                  {
                    Log.Error(" render {0} failed:{1:x}, trying alternative graph builder", pinInfo.name, hr);

                    if ((hr = graphBuilder.Render(pins[0])) == 0)
                    {
                      Log.Info(" render ok");
                    }
                    else
                    {
                      Log.Error(" render failed:{0:x}", hr);
                      bAllConnected = false;
                    }
                  }
                  pinsRendered++;
                }
                if (pConnectPin != null)
                {
                  ReleaseComObject(pConnectPin);
                }
                pConnectPin = null;
                //else Log.Info("pin is already connected");
              }
              ReleaseComObject(pins[0]);
            }
            else
            {
              iFetched = 0;
              Log.Info("no pins?");
              break;
            }
          }
          else
          {
            iFetched = 0;
          }
        } while (iFetched == 1 && pinsRendered < maxPinsToRender && bAllConnected);
        ReleaseComObject(pinEnum);
      }
      return bAllConnected;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:94,代码来源:DirectShowUtil.cs


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