/// <summary> /// Get a read-only list of all renderers that are supported on the current system. /// </summary> public ReadOnlyCollection <Renderer> GetPresentVideoRenderers() { IList <Renderer> renderers = new List <Renderer>(); if (_pMapper != null) { IEnumMoniker pEnum; IMoniker[] pMonikers = new IMoniker[1]; Guid IID_IBaseFilter = typeof(IBaseFilter).GUID; Guid[] inTypes = new Guid[] { DirectShow.MediaType.Video, Guid.Empty }; int hr = _pMapper.EnumMatchingFilters(out pEnum, 0, // Reserved true, // Use exact match? (int)MERIT.MERIT_DO_NOT_USE, true, // At least one input pin? inTypes.Length / 2, // Number of major type/subtype pairs for input inTypes, // Array of major type/subtype pairs for input IntPtr.Zero, // Input medium IntPtr.Zero, // Input pin category true, // Must be a renderer? false, // At least one output pin? 0, // Number of major type/subtype pairs for output null, // Array of major type/subtype pairs for output IntPtr.Zero, // Output medium IntPtr.Zero); // Output pin category if (DsHlp.SUCCEEDED(hr)) { try { object o; IntPtr cFetched = IntPtr.Zero; while (pEnum.Next(1, pMonikers, cFetched) == DsHlp.S_OK) { o = null; Guid clsId = Guid.Empty; try { pMonikers[0].BindToObject(null, null, ref IID_IBaseFilter, out o); if (o != null && o is IBaseFilter) { IBaseFilter pBaseFilter = (IBaseFilter)o; o = null; pBaseFilter.GetClassID(out clsId); Marshal.FinalReleaseComObject(pBaseFilter); } } finally { Marshal.ReleaseComObject(pMonikers[0]); } IRenderer renderer = RendererBase.GetRenderer(clsId); if (renderer != null) { renderers.Add(renderer.Renderer); } } } finally { Marshal.ReleaseComObject(pEnum); } } } return(new ReadOnlyCollection <Renderer>(renderers)); }