예제 #1
0
    public static IPin FindPin(IBaseFilter filter, int index, PIN_DIRECTION direction)
    {
        int curr_index = 0;
        var result     = EnumPins(filter, (info) =>
        {
            if (info.dir != direction)
            {
                return(false);
            }
            return(index == curr_index++);
        });

        if (result == null)
        {
            throw new ArgumentException("Can't find pin.");
        }
        return(result);
    }
예제 #2
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="name">名称</param>
 /// <param name="dir">方向</param>
 public CxPinInfo(string name, PIN_DIRECTION dir)
 {
     Name      = name;
     Direction = dir;
 }
 public int FindPin([NativeTypeName("IUnknown *")] IUnknown *pSource, PIN_DIRECTION pindir, [NativeTypeName("const GUID *")] Guid *pCategory, [NativeTypeName("const GUID *")] Guid *pType, [NativeTypeName("BOOL")] int fUnconnected, int num, [NativeTypeName("IPin **")] IPin **ppPin)
 {
     return(((delegate * unmanaged <ICaptureGraphBuilder2 *, IUnknown *, PIN_DIRECTION, Guid *, Guid *, int, int, IPin **, int>)(lpVtbl[11]))((ICaptureGraphBuilder2 *)Unsafe.AsPointer(ref this), pSource, pindir, pCategory, pType, fUnconnected, num, ppPin));
 }
예제 #4
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="name">ピン名称</param>
 /// <param name="direction">ピンの向き</param>
 public CxDSPinInfo(string name, PIN_DIRECTION direction)
 {
     Name = name;
     Direction = direction;
 }
예제 #5
0
        /// <summary>
        /// ピンの検索
        /// </summary>
        /// <param name="filter">フィルタ</param>
        /// <param name="index">番号 [0~]</param>
        /// <param name="direction">方向 (Unknown を指定した場合、方向に関係なく列挙されます)</param>
        /// <returns>
        ///		見つかった場合は、ピンの IPin インターフェースを返します。
        ///		見つからなかった場合は、 null を返します。
        ///	</returns>
        public static IPin FindPin(IBaseFilter filter, int index, PIN_DIRECTION direction)
        {
            IEnumPins enumpins = null;
            IPin      pin      = null;

            try
            {
                filter.EnumPins(ref enumpins);

                int fetched = 0;
                while (enumpins.Next(1, ref pin, ref fetched) == 0)
                {
                    if (fetched == 0)
                    {
                        break;
                    }

                    var info = new PIN_INFO();

                    try
                    {
                        pin.QueryPinInfo(info);
                        if (info.dir == direction)
                        {
                            if (index <= 0)
                            {
                                return(pin);
                            }
                            index--;
                        }

                        if (pin != null)
                        {
                            Marshal.ReleaseComObject(pin);
                        }
                        pin = null;
                    }
                    finally
                    {
                        if (info.pFilter != null)
                        {
                            Marshal.ReleaseComObject(info.pFilter);
                        }
                    }
                }
            }
            catch
            {
                if (pin != null)
                {
                    Marshal.ReleaseComObject(pin);
                }
                throw;
            }
            finally
            {
                if (enumpins != null)
                {
                    Marshal.ReleaseComObject(enumpins);
                }
            }

            return(null);
        }