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


C# IPin.QueryAccept方法代码示例

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


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

示例1: TestMediaTypes

 private static bool TestMediaTypes(IPin pin, IPin receiver)
 {
   bool ret = false;
   IEnumMediaTypes types;
   pin.EnumMediaTypes(out types);
   types.Reset();
   while (true)
   {
     AMMediaType[] mediaTypes = new AMMediaType[1];
     int typesFetched;
     int hr = types.Next(1, mediaTypes, out typesFetched);
     if (hr != 0 || typesFetched == 0)
     {
       break;
     }
     //Log.Info("Check output type: {0}, {1}", mediaTypes[0].majorType,
     //  mediaTypes[0].subType);
     if (receiver.QueryAccept(mediaTypes[0]) == 0)
     {
       //Log.Info("Accepted!");
       ret = true;
       break;
     }
   }
   ReleaseComObject(types);
   //Log.Info("-----EndofTypes");
   return ret;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:28,代码来源:DirectShowUtil.cs

示例2: QueryConnect

    /// <summary>
    /// QueryConnect checks if two Pins can be connected.
    /// </summary>
    /// <param name="pin">Pin 1</param>
    /// <param name="other">Pin 2</param>
    /// <returns>True if they accept connection</returns>
    static bool QueryConnect(IPin pin, IPin other)
    {
      IEnumMediaTypes enumTypes;
      int hr = pin.EnumMediaTypes(out enumTypes);
      if (hr != 0 || enumTypes == null)
        return false;

      int count = 0;
      IntPtr ptrFetched = Marshal.AllocCoTaskMem(4);
      try
      {
        for (; ; )
        {
          AMMediaType[] types = new AMMediaType[1];
          hr = enumTypes.Next(1, types, ptrFetched);
          if (hr != 0 || Marshal.ReadInt32(ptrFetched) == 0)
            break;

          count++;
          try
          {
            if (other.QueryAccept(types[0]) == 0)
              return true;
          }
          finally
          {
            FilterGraphTools.FreeAMMediaType(types[0]);
          }
        }
        PinInfo info;
        PinInfo infoOther;
        pin.QueryPinInfo(out info);
        other.QueryPinInfo(out infoOther);
        ServiceRegistration.Get<ILogger>().Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, count);
        FilterGraphTools.FreePinInfo(info);
        FilterGraphTools.FreePinInfo(infoOther);
        return false;
      }
      finally
      {
        Marshal.FreeCoTaskMem(ptrFetched);
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:49,代码来源:GraphRebuilder.cs

示例3: QueryConnect

 public static bool QueryConnect(IPin pin, IPin other)
 {
   IEnumMediaTypes enumTypes;
   int hr = pin.EnumMediaTypes(out enumTypes);
   if (hr != 0 || enumTypes == null)
   {
     return false;
   }
   int count = 0;
   for (;;)
   {
     AMMediaType[] types = new AMMediaType[1];
     int fetched;
     hr = enumTypes.Next(1, types, out fetched);
     if (hr != 0 || fetched == 0)
     {
       break;
     }
     count++;
     if (other.QueryAccept(types[0]) == 0)
     {
       return true;
     }
   }
   PinInfo info;
   PinInfo infoOther;
   pin.QueryPinInfo(out info);
   DsUtils.FreePinInfo(info);
   other.QueryPinInfo(out infoOther);
   DsUtils.FreePinInfo(infoOther);
   Log.Info("Pins {0} and {1} do not accept each other. Tested {2} media types", info.name, infoOther.name, count);
   return false;
 }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:33,代码来源:DirectShowUtil.cs

示例4: Connect

        public int Connect(IPin pReceivePin, AMMediaType pmt)
        {
            Monitor.Enter(this);
            int hr = S_OK;
            pin = null;
            pintype = null;
            allocator = null;
            string id = "Unnamed pin";
            pReceivePin.QueryId(out id);
            PinInfo pi = new PinInfo();
            hr = pReceivePin.QueryPinInfo(out pi);
            if (hr == S_OK)
            {
                FilterInfo fi = new FilterInfo();
                hr = pi.filter.QueryFilterInfo(out fi);
                if (hr == S_OK)
                {
                    id += (" (" + fi.achName);
                }
                Guid guid;
                hr = pi.filter.GetClassID(out guid);
                if (hr == S_OK)
                {
                    id += (", " + guid.ToString());
                }
                id += ")";
            }
            try
            {
                AMMediaType amt = null;
                if (pmt != null)
                {
                    amt = pmt;
                }
                else
            #if false
                {
                    IEnumMediaTypes ie;
                    hr = pReceivePin.EnumMediaTypes(out ie);
                    int fetched;
                    int alloc = Marshal.SizeOf(typeof(AMMediaType));
                    IntPtr mtypePtr = Marshal.AllocCoTaskMem(alloc);
                    while (ie.Next(1, mtypePtr, out fetched) == S_OK)
                    {
                        amt = new AMMediaType();
                        Marshal.PtrToStructure(mtypePtr, amt);
                        hr = pReceivePin.QueryAccept(amt);
                        if (hr == S_OK)
                        {
                            break;
                        }
                        DsUtils.FreeAMMediaType(amt);
                        amt = null;
                    }
                    if (fetched == 0)
                    {
                        amt = null;
                    }
                    Marshal.FreeCoTaskMem(mtypePtr);
                }
                if (amt == null)
            #endif
                {
                    amt = mediatype;
                }
                hr = pReceivePin.QueryAccept(amt);
                if (hr == S_FALSE)
                {
                    log.InfoFormat("No media type for pin '{0}'", id);
                    Monitor.Exit(this);
                    return VFW_E_NO_ACCEPTABLE_TYPES;
                }

                hr = pReceivePin.ReceiveConnection(this, amt);
                if (hr == VFW_E_TYPE_NOT_ACCEPTED)
                {
                    log.InfoFormat("No connection to pin '{0}'", id);
                    Monitor.Exit(this);
                    return VFW_E_NO_ACCEPTABLE_TYPES;
                }
                DsError.ThrowExceptionForHR(hr);

                pin = pReceivePin;
                pintype = amt;
            }
            catch (Exception e)
            {
                LogUtil.ExceptionLog.ErrorFormat("Caught exception in connect ({0}): {1}{2}", id, e.Message, e.StackTrace);
                pin = null;
                pintype = null;
                allocator = null;
                Monitor.Exit(this);
                return VFW_E_NO_TRANSPORT;
            }
            Monitor.Exit(this);
            log.InfoFormat("Connected to pin '{0}'", id);
            return S_OK;
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:98,代码来源:DirectShowCodec.cs


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