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


C# IGraphBuilder.Reconnect方法代码示例

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


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

示例1: ReConnectAll

 public static bool ReConnectAll(IGraphBuilder graphBuilder, IBaseFilter filter)
 {
   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 other;
             hr = pins[0].ConnectedTo(out other);
             if (hr == 0 && other != null)
             {
               Log.Info("Reconnecting {0}:{1}", info.achName, pinInfo.name);
               hr = graphBuilder.Reconnect(pins[0]);
               if (hr != 0)
               {
                 Log.Warn("Reconnect failed: {0}:{1}, code: 0x{2:x}", info.achName, pinInfo.name, hr);
               }
             }
           }
           ReleaseComObject(pins[0]);
         }
         else
         {
           iFetched = 0;
           Log.Info("no pins?");
           break;
         }
       }
       else
       {
         iFetched = 0;
       }
     } while (iFetched == 1);
     ReleaseComObject(pinEnum);
   }
   return bAllConnected;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:70,代码来源:DirectShowUtil.cs

示例2: ReConnectAll

    /// <summary>
    /// Reconnects all filters in graph.
    /// </summary>
    /// <param name="graphBuilder">IGraphBuilder</param>
    /// <param name="filter">Current IBaseFilter in graph</param>
    static void ReConnectAll(IGraphBuilder graphBuilder, IBaseFilter filter)
    {
      IEnumPins pinEnum;
      FilterInfo info = FilterGraphTools.QueryFilterInfoAndFree(filter);
      IntPtr ptrFetched = Marshal.AllocCoTaskMem(4);
      int hr = filter.EnumPins(out pinEnum);
      if ((hr == 0) && (pinEnum != null))
      {
        ServiceRegistration.Get<ILogger>().Info("got pins");
        IPin[] pins = new IPin[1];
        int iFetched;
        int iPinNo = 0;
        do
        {
          // Get the next pin
          iPinNo++;
          hr = pinEnum.Next(1, pins, ptrFetched);

          // In case of error stop the pin enumeration
          if (hr != 0)
            break;

          iFetched = Marshal.ReadInt32(ptrFetched);
          if (iFetched == 1 && pins[0] != null)
          {
            PinInfo pinInfo;
            hr = pins[0].QueryPinInfo(out pinInfo);
            if (hr == 0)
            {
              ServiceRegistration.Get<ILogger>().Info("  got pin#{0}:{1}", iPinNo - 1, pinInfo.name);
              FilterGraphTools.FreePinInfo(pinInfo);
            }
            else
            {
              ServiceRegistration.Get<ILogger>().Info("  got pin:?");
            }
            PinDirection pinDir;
            pins[0].QueryDirection(out pinDir);
            if (pinDir == PinDirection.Output)
            {
              IntPtr other_ptr;
              hr = pins[0].ConnectedTo(out other_ptr);
              if (hr == 0 && other_ptr != IntPtr.Zero)
              {
                ServiceRegistration.Get<ILogger>().Info("Reconnecting {0}:{1}", info.achName, pinInfo.name);
                hr = graphBuilder.Reconnect(pins[0]);
                if (hr != 0)
                  ServiceRegistration.Get<ILogger>().Warn("Reconnect failed: {0}:{1}, code: 0x{2:x}", info.achName, pinInfo.name, hr);
                IPin other = Marshal.GetObjectForIUnknown(other_ptr) as IPin;
                PinInfo otherPinInfo;
                other.QueryPinInfo(out otherPinInfo);
                ReConnectAll(graphBuilder, otherPinInfo.filter);
                FilterGraphTools.FreePinInfo(otherPinInfo);
                Marshal.ReleaseComObject(other);
              }
            }
            Marshal.ReleaseComObject(pins[0]);
          }
          else
          {
            ServiceRegistration.Get<ILogger>().Info("no pins?");
            break;
          }
        }
        while (iFetched == 1);
        FilterGraphTools.TryRelease(ref pinEnum);
        Marshal.FreeCoTaskMem(ptrFetched);
      }
    }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:74,代码来源:GraphRebuilder.cs


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