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


C# IPin.Disconnect方法代码示例

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


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

示例1: DisconnectPin

        public static bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
        {
            IPin other;
            int hr = pin.ConnectedTo(out other);
            bool allDisconnected = true;
            PinInfo info;
            pin.QueryPinInfo(out info);
            DsUtils.FreePinInfo(info);

            if (hr == 0 && other != null)
            {
                other.QueryPinInfo(out info);
                if (!DisconnectAllPins(graphBuilder, info.filter))
                {
                    allDisconnected = false;
                }
                hr = pin.Disconnect();
                if (hr != 0)
                {
                    allDisconnected = false;

                }
                hr = other.Disconnect();
                if (hr != 0)
                {
                    allDisconnected = false;

                }
                DsUtils.FreePinInfo(info);
                Marshal.ReleaseComObject(other);
            }
            else
            {

            }
            return allDisconnected;
        }
开发者ID:jiailiuyan,项目名称:WPF-MediaKit,代码行数:37,代码来源:DirectShowUtil.cs

示例2: DisconnectPin

 public static bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
 {
   IPin other;
   int hr = pin.ConnectedTo(out other);
   bool allDisconnected = true;
   PinInfo info;
   pin.QueryPinInfo(out info);
   DsUtils.FreePinInfo(info);
   Log.Info("Disconnecting pin {0}", info.name);
   if (hr == 0 && other != null)
   {
     other.QueryPinInfo(out info);
     if (!DisconnectAllPins(graphBuilder, info.filter))
     {
       allDisconnected = false;
     }
     hr = pin.Disconnect();
     if (hr != 0)
     {
       allDisconnected = false;
       Log.Error("Error disconnecting: {0:x}", hr);
     }
     hr = other.Disconnect();
     if (hr != 0)
     {
       allDisconnected = false;
       Log.Error("Error disconnecting other: {0:x}", hr);
     }
     DsUtils.FreePinInfo(info);
     ReleaseComObject(other);
   }
   else
   {
     Log.Info("  Not connected");
   }
   return allDisconnected;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:37,代码来源:DirectShowUtil.cs

示例3: TryConnect

    private static bool TryConnect(IGraphBuilder graphBuilder, string filtername, IPin outputPin, IBaseFilter to)
    {
      bool ret = false;
      int hr;
      FilterInfo info;
      PinInfo outputInfo;

      to.QueryFilterInfo(out info);
      ReleaseComObject(info.pGraph);

      outputPin.QueryPinInfo(out outputInfo);
      DsUtils.FreePinInfo(outputInfo);

      if (info.achName.Equals(filtername))
      {
        return false; //do not connect to self
      }
      Log.Debug("Testing filter: {0}", info.achName);

      IEnumPins enumPins;
      IPin[] pins = new IPin[1];
      to.EnumPins(out enumPins);
      do
      {
        int pinsFetched;
        hr = enumPins.Next(1, pins, out pinsFetched);
        if (hr != 0 || pinsFetched == 0)
        {
          break;
        }
        PinDirection direction;
        pins[0].QueryDirection(out direction);
        if (direction == PinDirection.Input && !HasConnection(pins[0])) // && TestMediaTypes(outputPin, pins[0]))
        {
          PinInfo pinInfo;
          pins[0].QueryPinInfo(out pinInfo);
          DsUtils.FreePinInfo(pinInfo);
          Log.Debug("Testing compatibility to {0}",
                    pinInfo.name);
          //ListMediaTypes(pins[0]);
          //hr =  outputPin.Connect(pins[0], null);
          hr = graphBuilder.ConnectDirect(outputPin, pins[0], null);
          if (hr == 0)
          {
            Log.Debug("Connection succeeded");
            if (RenderOutputPins(graphBuilder, to))
            {
              Log.Info("Successfully rendered pin {0}:{1} to {2}:{3}.",
                       filtername, outputInfo.name, info.achName, pinInfo.name);
              ret = true;
              ReleaseComObject(pins[0]);
              break;
            }
            else
            {
              Log.Debug("Rendering got stuck. Trying next filter, and disconnecting {0}!", outputInfo.name);
              outputPin.Disconnect();
              pins[0].Disconnect();
            }
          }
          else
          {
            Log.Debug("Could not connect, filters are not compatible: {0:x}", hr);
          }
        }
        ReleaseComObject(pins[0]);
      } while (true);
      ReleaseComObject(enumPins);
      if (!ret)
      {
        Log.Debug("Dead end. Could not successfully connect pin {0} to filter {1}!", outputInfo.name, info.achName);
      }
      return ret;
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:74,代码来源:DirectShowUtil.cs

示例4: DisconnectPin

    /// <summary>
    /// Disconnects a single Pin.
    /// </summary>
    /// <param name="graphBuilder">IGraphBuilder</param>
    /// <param name="pin">Pin to disconnect</param>
    /// <returns>True if successful</returns>
    bool DisconnectPin(IGraphBuilder graphBuilder, IPin pin)
    {
      IntPtr other_ptr;
      int hr = pin.ConnectedTo(out other_ptr);
      bool allDisconnected = true;
      if (hr == 0 && other_ptr != IntPtr.Zero)
      {
        IPin other = Marshal.GetObjectForIUnknown(other_ptr) as IPin;
        PinInfo info;
        pin.QueryPinInfo(out info);
        ServiceRegistration.Get<ILogger>().Info("Disconnecting pin {0}", info.name);
        FilterGraphTools.FreePinInfo(info);

        other.QueryPinInfo(out info);
        if (!DisconnectAllPins(graphBuilder, info.filter))
          allDisconnected = false;

        FilterGraphTools.FreePinInfo(info);

        hr = pin.Disconnect();
        if (hr != 0)
        {
          allDisconnected = false;
          ServiceRegistration.Get<ILogger>().Error("Error disconnecting: {0:x}", hr);
        }
        hr = other.Disconnect();
        if (hr != 0)
        {
          allDisconnected = false;
          ServiceRegistration.Get<ILogger>().Error("Error disconnecting other: {0:x}", hr);
        }
        Marshal.ReleaseComObject(other);
      }
      else
      {
        ServiceRegistration.Get<ILogger>().Info("  Not connected");
      }
      return allDisconnected;
    }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:45,代码来源:GraphRebuilder.cs


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