/////////////////////////////////////////////////////////////////////////////// // Small helping Methods // /////////////////////////////////////////////////////////////////////////////// #region HELPER /// <summary> /// Returns the <see cref="Guid"/> for the given filter of /// given category. /// </summary> /// <param name="filterName">Name of the filter to search.</param> /// <param name="category">Category of filter to search.</param> /// <returns>The <see cref="Guid"/> for the given filter of /// given category.</returns> private Guid FindGuid(string filterName, Guid category) { int hr; IEnumDMO enumDMO; Guid[] g2 = new Guid[1]; string[] sn = new string[1]; hr = DMOUtils.DMOEnum(category, 0, 0, null, 0, null, out enumDMO); DMOError.ThrowExceptionForHR(hr); try { do { hr = enumDMO.Next(1, g2, sn, IntPtr.Zero); }while (hr == 0 && sn[0] != filterName); // Handle any serious errors DMOError.ThrowExceptionForHR(hr); if (hr != 0) { throw new Exception("Cannot find " + filterName); } } finally { Marshal.ReleaseComObject(enumDMO); } return(g2[0]); }
/// <summary> /// Finds the <see cref="Guid"/> for the given /// category and object /// </summary> /// <param name="gn"> /// A string containing the name of the DMO. /// </param> /// <param name="cat"> /// A <see cref="Guid"/> with the dmo category. /// </param> /// <returns> /// The <see cref="Guid"/> of the found DMO. /// </returns> private Guid FindGuid(string gn, Guid cat) { int hr; IEnumDMO dmoEnum; var g2 = new Guid[1]; var sn = new string[1]; hr = DMOUtils.DMOEnum(cat, 0, 0, null, 0, null, out dmoEnum); DMOError.ThrowExceptionForHR(hr); try { do { hr = dmoEnum.Next(1, g2, sn, IntPtr.Zero); }while (hr == 0 && sn[0] != gn); // Handle any serious errors DMOError.ThrowExceptionForHR(hr); if (hr != 0) { throw new Exception("Cannot find " + gn); } } finally { Marshal.ReleaseComObject(dmoEnum); } return(g2[0]); }
private void Configure() { int hr; hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.None, 0, null, 0, null, out m_idmo); DsError.ThrowExceptionForHR(hr); }
static private void DoRegister(Type t) { // Tell what media types you are able to support. This allows // the smart connect capability of DS to avoid loading your DMO // if it can't handle the stream type. // Note that you don't have to register any (but I recommend // you do). Also, you don't have to provide a subtype (use // Guid.Empty). You can negotiate this at run time in // InternalCheckInputType. DMOPartialMediatype [] pIn = new DMOPartialMediatype[1]; pIn[0] = new DMOPartialMediatype(); pIn[0].type = MediaType.Audio; pIn[0].subtype = MediaSubType.PCM; DMOPartialMediatype [] pOut = new DMOPartialMediatype[1]; pOut[0] = new DMOPartialMediatype(); pOut[0].type = MediaType.Audio; pOut[0].subtype = MediaSubType.PCM; int hr = DMOUtils.DMORegister( DMOName, typeof(DmoSplit).GUID, DMOCat, DMORegisterFlags.None, pIn.Length, pIn, pOut.Length, pOut ); }
private void TestInit() { int hr; AMMediaType pmt = new AMMediaType(); hr = DMOUtils.MoInitMediaType(pmt, 30); Debug.Assert(hr == 0 && pmt.formatPtr != IntPtr.Zero && pmt.formatSize == 30, "MoInitMediaType"); DsUtils.FreeAMMediaType(pmt); }
private void TestName() { int hr; StringBuilder sb = new StringBuilder(80); hr = DMOUtils.DMOGetName(new Guid("{efe6629c-81f7-4281-bd91-c9d604a95af6}"), sb); DMOError.ThrowExceptionForHR(hr); Debug.Assert(sb.ToString() == "Chorus", "DMOGetName"); }
private void TestRegister() { int hr; IEnumDMO idmo; Guid g = Guid.NewGuid(); Guid g2 = Guid.NewGuid(); Debug.WriteLine(g); Debug.WriteLine(g2); DMOPartialMediatype [] pIn = new DMOPartialMediatype[2]; pIn[0] = new DMOPartialMediatype(); pIn[0].type = g2; pIn[0].subtype = MediaSubType.RGB24; pIn[1] = new DMOPartialMediatype(); pIn[1].type = g2; pIn[1].subtype = MediaSubType.RGB32; DMOPartialMediatype [] pOut = new DMOPartialMediatype[2]; pOut[0] = new DMOPartialMediatype(); pOut[0].type = g2; pOut[0].subtype = MediaSubType.RGB24; pOut[1] = new DMOPartialMediatype(); pOut[1].type = g2; pOut[1].subtype = MediaSubType.RGB32; hr = DMOUtils.DMORegister("asdffdsa", g, DMOCategory.VideoEffect, DMORegisterFlags.None, pIn.Length, pIn, pOut.Length, pOut ); Debug.Assert(hr == 0, "DMORegister"); DMOPartialMediatype [] tIn = new DMOPartialMediatype[1]; tIn[0].type = g2; tIn[0].subtype = MediaSubType.RGB32; hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.IncludeKeyed, tIn.Length, tIn, 0, null, out idmo); DMOError.ThrowExceptionForHR(hr); int iCnt1 = CountEm(idmo); Debug.Assert(iCnt1 == 1, "DMORegister"); hr = DMOUtils.DMOUnregister(g, DMOCategory.VideoEffect); DMOError.ThrowExceptionForHR(hr); int iCnt2 = CountEm(idmo); Debug.Assert(iCnt2 == 0, "DMOUnregister"); }
private void junk() { int hr; IEnumDMO idmo; Guid [] g = new Guid[1]; string [] sn = new string[1]; int iCount = 0; hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.None, 0, null, 0, null, out idmo); DMOError.ThrowExceptionForHR(hr); do { DMOWrapperFilter dmoFilter = new DMOWrapperFilter(); IDMOWrapperFilter dmoWrapperFilter = (IDMOWrapperFilter)dmoFilter; hr = idmo.Next(1, g, sn, IntPtr.Zero); DMOError.ThrowExceptionForHR(hr); if (hr > 0) { break; } hr = dmoWrapperFilter.Init(g[0], Guid.Empty); if (hr >= 0) { m_impi = dmoWrapperFilter as IMediaParamInfo; if (m_impi != null) { hr = m_impi.GetParamCount(out iCount); } else { iCount = 0; } if (iCount > 0) { Debug.WriteLine(string.Format("{0} {1} {2}", sn[0], iCount, g[0])); } } } while (iCount >= 0); }
private static void DoRegister(Type t) { // Tell what media types you are able to support. This allows // the smart connect capability of DS to avoid loading your DMO // if it can't handle the stream type. // Note that you don't have to register any (but I recommend // you do). Also, you don't have to provide a subtype (use // Guid.Empty). You can negotiate this at run time in // InternalCheckInputType. DMOPartialMediatype[] inPin = new DMOPartialMediatype[2]; inPin[0] = new DMOPartialMediatype(); inPin[0].type = MediaType.Video; inPin[0].subtype = MediaSubType.RGB24; inPin[1] = new DMOPartialMediatype(); inPin[1].type = MediaType.Video; inPin[1].subtype = MediaSubType.RGB32; DMOPartialMediatype[] outPin = new DMOPartialMediatype[2]; outPin[0] = new DMOPartialMediatype(); outPin[0].type = MediaType.Video; outPin[0].subtype = MediaSubType.RGB24; outPin[1] = new DMOPartialMediatype(); outPin[1].type = MediaType.Video; outPin[1].subtype = MediaSubType.RGB32; int hr = DMOUtils.DMORegister( DMOName, typeof(DmoOverlay).GUID, DMOCat, DMORegisterFlags.None, inPin.Length, inPin, outPin.Length, outPin); }
private Guid FindDMOGuid(string gn, Guid cat) { int hr; IEnumDMO pEnum; Guid[] g2 = new Guid[1]; string[] sn = new String[1]; hr = DMOUtils.DMOEnum(cat, 0, 0, null, 0, null, out pEnum); DMOError.ThrowExceptionForHR(hr); IntPtr fetched = Marshal.AllocCoTaskMem(4); try { do { hr = pEnum.Next(1, g2, sn, fetched); } while (hr == 0 && sn[0] != gn); // Handle any serious errors DMOError.ThrowExceptionForHR(hr); if (hr != 0) { Console.WriteLine("Cannot find " + gn); return(Guid.Empty); } } finally { Marshal.ReleaseComObject(pEnum); Marshal.FreeCoTaskMem(fetched); } return(g2[0]); }
private void TestCopy() { int hr; AMMediaType pmt1 = new AMMediaType(); AMMediaType pmt2 = new AMMediaType(); FilterGraph f = new FilterGraph(); IntPtr ip = Marshal.GetIUnknownForObject(f); pmt1.fixedSizeSamples = true; pmt1.formatPtr = Marshal.AllocCoTaskMem(8); Marshal.WriteInt64(pmt1.formatPtr, long.MaxValue); pmt1.formatSize = 8; pmt1.formatType = FormatType.DvInfo; pmt1.majorType = MediaType.AuxLine21Data; pmt1.sampleSize = 65432; pmt1.subType = MediaSubType.AIFF; pmt1.temporalCompression = true; pmt1.unkPtr = ip; hr = DMOUtils.MoCopyMediaType(pmt2, pmt1); Debug.Assert(hr == 0 && pmt2.fixedSizeSamples == true && pmt2.formatPtr != pmt1.formatPtr && Marshal.ReadInt64(pmt2.formatPtr) == long.MaxValue && pmt2.formatSize == 8 && pmt2.formatType == FormatType.DvInfo && pmt2.majorType == MediaType.AuxLine21Data && pmt2.sampleSize == 65432 && pmt2.subType == MediaSubType.AIFF && pmt2.temporalCompression == true && pmt2.unkPtr == ip, "MoCopyMediaType"); DsUtils.FreeAMMediaType(pmt1); DsUtils.FreeAMMediaType(pmt2); }
private void TestDmoEnum() { int hr; IEnumDMO idmo; DMOPartialMediatype [] tIn = new DMOPartialMediatype[2]; tIn[0].type = MediaType.Audio; tIn[0].subtype = Guid.Empty; tIn[1].type = MediaType.Video; tIn[1].subtype = Guid.Empty; hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.IncludeKeyed, 2, tIn, 0, tIn, out idmo); DMOError.ThrowExceptionForHR(hr); int iCnt1 = CountEm(idmo); hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.IncludeKeyed, 0, null, 0, null, out idmo); DMOError.ThrowExceptionForHR(hr); int iCnt2 = CountEm(idmo); Debug.Assert(iCnt1 == iCnt2, "Hopefully all DMOs are Video or Audio"); // Looking for the MS Screen Encoder MSS1 tIn[0].type = MediaType.Video; tIn[0].subtype = new Guid(0x3153534D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71); tIn[0].subtype = new Guid("D990EE14-776C-4723-BE46-3DA2F56F10B9"); hr = DMOUtils.DMOEnum(DMOCategory.VideoEncoder, DMOEnumerator.IncludeKeyed, 0, null, 1, tIn, out idmo); DMOError.ThrowExceptionForHR(hr); int iCnt3 = CountEm(idmo); Debug.Assert(iCnt3 == 1, "Test Category, and output partial media types"); }
private void TestTypes() { int hr; int i, o; DMOPartialMediatype [] pInTypes = new DMOPartialMediatype[2]; DMOPartialMediatype [] pOutTypes = new DMOPartialMediatype[2]; hr = DMOUtils.DMOGetTypes( new Guid("{efe6629c-81f7-4281-bd91-c9d604a95af6}"), 2, out i, pInTypes, 2, out o, pOutTypes ); DMOError.ThrowExceptionForHR(hr); Debug.Assert(i == o && i == 1, "DMOGetTypes"); Debug.Assert(pInTypes[0].type == MediaType.Audio && pInTypes[0].subtype == MediaSubType.PCM, "DMOGetTypes2"); Debug.Assert(pOutTypes[0].type == MediaType.Audio && pOutTypes[0].subtype == MediaSubType.PCM, "DMOGetTypes3"); }
static private void UnregisterFunction(Type t) { int hr = DMOUtils.DMOUnregister(typeof(DmoSplit).GUID, DMOCat); }
private static void UnregisterFunction(Type t) { int hr = DMOUtils.DMOUnregister(typeof(DmoOverlay).GUID, DMOCat); DMOError.ThrowExceptionForHR(hr); }