CatenaLogic.Windows.Presentation.WebcamPlayer.CapHelper.GetPin C# (CSharp) Method

GetPin() public static method

Gets a specific pin of a specific filter
public static GetPin ( this filter, PinDirection dir, int num ) : IPin
filter this Filter to retrieve the pin for (defines which object should make this method available)
dir PinDirection Direction
num int Number
return IPin
        public static IPin GetPin(this IBaseFilter filter, PinDirection dir, int num)
        {
            // Declare variables
            IPin[] pin = new IPin[1];
            IEnumPins pinsEnum = null;

            // Enumerator the pins
            if (filter.EnumPins(out pinsEnum) == 0)
            {
                // Get the pin direction
                PinDirection pinDir;
                int n = 0;
                ;

                // Loop the pins
                while (pinsEnum.Next(1, pin, out n) == 0)
                {
                    // Query the direction
                    pin[0].QueryDirection(out pinDir);

                    // Is the pin direction correct?
                    if (pinDir == dir)
                    {
                        // Yes, check the pins
                        if (num == 0)
                        {
                            return pin[0];
                        }
                        num--;
                    }

                    // Release the pin, this is not the one we are looking for
                    Marshal.ReleaseComObject(pin[0]);
                    pin[0] = null;
                }
            }

            // Not found
            return null;
        }
CapHelper