/// <summary> /// retrieves the media type that was set for an output stream, if any /// </summary> /// <param name="outputStreamIndex">Output stream index</param> /// <returns>DMO Media Type or null if no more available</returns> public DmoMediaType GetOutputCurrentType(int outputStreamIndex) { DmoMediaType mediaType; int hresult = mediaObject.GetOutputCurrentType(outputStreamIndex, out mediaType); if (hresult == HResult.S_OK) { // this frees the format (if present) // we should therefore come up with a way of marshaling the format // into a completely managed structure DmoInterop.MoFreeMediaType(ref mediaType); return(mediaType); } else { if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_SET) { throw new InvalidOperationException("Media type was not set."); } else { throw Marshal.GetExceptionForHR(hresult); } } }
/// <summary> /// Tests if the specified Wave Format is supported for output /// n.b. may need to set the input type first /// </summary> /// <param name="outputStreamIndex">Output stream index</param> /// <param name="waveFormat">Wave format</param> /// <returns>True if supported</returns> public bool SupportsOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat) { DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat); bool supported = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY); DmoInterop.MoFreeMediaType(ref mediaType); return(supported); }
/// <summary> /// Requests whether the specified Wave format is supported as an input /// </summary> /// <param name="inputStreamIndex">Input stream index</param> /// <param name="waveFormat">Wave format</param> /// <returns>true if supported</returns> // Token: 0x0600031F RID: 799 RVA: 0x0000A7A8 File Offset: 0x000089A8 public bool SupportsInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat) { DmoMediaType mediaType = this.CreateDmoMediaTypeForWaveFormat(waveFormat); bool result = this.SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY); DmoInterop.MoFreeMediaType(ref mediaType); return(result); }
/// <summary> /// Helper function to make a DMO Media Type to represent a particular WaveFormat /// </summary> private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat) { DmoMediaType mediaType = new DmoMediaType(); int waveFormatExSize = Marshal.SizeOf(waveFormat); // 18 + waveFormat.ExtraSize; DmoInterop.MoInitMediaType(ref mediaType, waveFormatExSize); mediaType.SetWaveFormat(waveFormat); return(mediaType); }
/// <summary> /// Helper function to make a DMO Media Type to represent a particular WaveFormat /// </summary> // Token: 0x06000320 RID: 800 RVA: 0x0000A7D0 File Offset: 0x000089D0 private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat) { DmoMediaType result = default(DmoMediaType); int formatBlockBytes = Marshal.SizeOf(waveFormat); DmoInterop.MoInitMediaType(ref result, formatBlockBytes); result.SetWaveFormat(waveFormat); return(result); }
/// <summary> /// Set output type to the specified wave format /// n.b. may need to set input type first /// </summary> /// <param name="outputStreamIndex">Output stream index</param> /// <param name="waveFormat">Wave format</param> public void SetOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat) { DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat); bool succeeded = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.None); DmoInterop.MoFreeMediaType(ref mediaType); if (!succeeded) { throw new ArgumentException("Media Type not supported"); } }
/// <summary> /// Sets the input type to the specified Wave format /// </summary> /// <param name="inputStreamIndex">Input stream index</param> /// <param name="waveFormat">Wave format</param> // Token: 0x0600031E RID: 798 RVA: 0x0000A770 File Offset: 0x00008970 public void SetInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat) { DmoMediaType mediaType = this.CreateDmoMediaTypeForWaveFormat(waveFormat); bool flag = this.SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.None); DmoInterop.MoFreeMediaType(ref mediaType); if (!flag) { throw new ArgumentException("Media Type not supported"); } }
/// <summary> /// retrieves the media type that was set for an output stream, if any /// </summary> /// <param name="outputStreamIndex">Output stream index</param> /// <returns>DMO Media Type or null if no more available</returns> // Token: 0x06000318 RID: 792 RVA: 0x0000A430 File Offset: 0x00008630 public DmoMediaType GetOutputCurrentType(int outputStreamIndex) { DmoMediaType result; int outputCurrentType = this.mediaObject.GetOutputCurrentType(outputStreamIndex, out result); if (outputCurrentType == 0) { DmoInterop.MoFreeMediaType(ref result); return(result); } if (outputCurrentType == -2147220989) { throw new InvalidOperationException("Media type was not set."); } throw Marshal.GetExceptionForHR(outputCurrentType); }
/// <summary> /// Gets the DMO Media Output type /// </summary> /// <param name="outputStream">The output stream</param> /// <param name="outputTypeIndex">Output type index</param> /// <returns>DMO Media Type or null if no more available</returns> // Token: 0x06000317 RID: 791 RVA: 0x0000A3CC File Offset: 0x000085CC public DmoMediaType?GetOutputType(int outputStream, int outputTypeIndex) { try { DmoMediaType value; if (this.mediaObject.GetOutputType(outputStream, outputTypeIndex, out value) == 0) { DmoInterop.MoFreeMediaType(ref value); return(new DmoMediaType?(value)); } } catch (COMException exception) { if (exception.GetHResult() != -2147220986) { throw; } } return(null); }
private static IEnumerable <DmoDescriptor> GetDmos(Guid category) { IEnumDmo enumDmo; int hresult = DmoInterop.DMOEnum(ref category, DmoEnumFlags.None, 0, null, 0, null, out enumDmo); Marshal.ThrowExceptionForHR(hresult); int itemsFetched; do { Guid guid; IntPtr namePointer; enumDmo.Next(1, out guid, out namePointer, out itemsFetched); if (itemsFetched == 1) { string name = Marshal.PtrToStringUni(namePointer); Marshal.FreeCoTaskMem(namePointer); yield return(new DmoDescriptor(name, guid)); } }while (itemsFetched > 0); yield break; }
/// <summary> /// Gets the DMO Media Output type /// </summary> /// <param name="outputStream">The output stream</param> /// <param name="outputTypeIndex">Output type index</param> /// <returns>DMO Media Type or null if no more available</returns> public DmoMediaType?GetOutputType(int outputStream, int outputTypeIndex) { try { DmoMediaType mediaType; int hresult = mediaObject.GetOutputType(outputStream, outputTypeIndex, out mediaType); if (hresult == HResult.S_OK) { // this frees the format (if present) // we should therefore come up with a way of marshaling the format // into a completely managed structure DmoInterop.MoFreeMediaType(ref mediaType); return(mediaType); } } catch (COMException e) { if (e.ErrorCode != (int)DmoHResults.DMO_E_NO_MORE_ITEMS) { throw; } } return(null); }