CodeTV.DeviceEnumerator.GetH264Devices C# (CSharp) Method

GetH264Devices() public static method

public static GetH264Devices ( ) : DsDevice[]
return DsDevice[]
        public static DsDevice[] GetH264Devices()
        {
            DsDevice[] devret;
            ArrayList devs = new ArrayList();

            IFilterMapper2 pMapper = (IFilterMapper2)new FilterMapper2();

            Guid[] arrayInTypes = new Guid[2]
                {
                    MediaType.Video,
                    //new Guid(0x8d2d71cb, 0x243f, 0x45e3, 0xb2, 0xd8, 0x5f, 0xd7, 0x96, 0x7e, 0xc0, 0x9b)
                    new Guid(0x34363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71) // FOURCC H264
                };
            IEnumMoniker pEnum = null;
            int hr = pMapper.EnumMatchingFilters(out pEnum,
                    0,                  // Reserved.
                    true,               // Use exact match?
                    (Merit)((int)Merit.DoNotUse + 1), // Minimum merit.
                    true,               // At least one input pin?
                    1,                  // Number of major type/subtype pairs for input.
                    arrayInTypes,       // Array of major type/subtype pairs for input.
                    null,               // Input medium.
                    null,               // Input pin category.
                    false,              // Must be a renderer?
                    true,               // At least one output pin?
                    0,                  // Number of major type/subtype pairs for output.
                    null,               // Array of major type/subtype pairs for output.
                    null,               // Output medium.
                    null);              // Output pin category.

            DsError.ThrowExceptionForHR(hr);

            if (hr >= 0 && pEnum != null)
            {
                try
                {
                    try
                    {
                        // Enumerate the monikers.
                        IMoniker[] pMoniker = new IMoniker[1];
                        while (pEnum.Next(1, pMoniker, IntPtr.Zero) == 0)
                        {
                            try
                            {
                                // The devs array now owns this object.  Don't
                                // release it if we are going to be successfully
                                // returning the devret array
                                devs.Add(new DsDevice(pMoniker[0]));
                            }
                            catch
                            {
                                Marshal.ReleaseComObject(pMoniker[0]);
                                throw;
                            }
                        }
                    }
                    finally
                    {
                        // Clean up.
                        Marshal.ReleaseComObject(pEnum);
                    }

                    // Copy the ArrayList to the DsDevice[]
                    devret = new DsDevice[devs.Count];
                    devs.CopyTo(devret);
                }
                catch
                {
                    foreach (DsDevice d in devs)
                    {
                        d.Dispose();
                    }
                    throw;
                }
            }
            else
            {
                devret = new DsDevice[0];
            }

            Marshal.ReleaseComObject(pMapper);

            return devret;
        }