public void CanExamineInputTypesOnMp3Decoder() { var decoder = new WindowsMediaMp3Decoder(); Assert.AreEqual(decoder.MediaObject.InputStreamCount, 1); foreach (DmoMediaType mediaType in decoder.MediaObject.GetInputTypes(0)) { Debug.WriteLine($"{mediaType.MajorTypeName}:{mediaType.SubTypeName}:{mediaType.FormatTypeName}"); } }
public void CanExamineOutputTypesOnDecoder() { var decoder = new WindowsMediaMp3Decoder(); decoder.MediaObject.SetInputWaveFormat(0, new Mp3WaveFormat(44100, 2, 200, 32000)); Assert.AreEqual(decoder.MediaObject.OutputStreamCount, 1); foreach (DmoMediaType mediaType in decoder.MediaObject.GetOutputTypes(0)) { Debug.WriteLine($"{mediaType.MajorTypeName}:{mediaType.SubTypeName}:{mediaType.FormatTypeName}"); } }
public void CanExamineInputTypesOnMp3Decoder() { WindowsMediaMp3Decoder decoder = new WindowsMediaMp3Decoder(); Assert.AreEqual(decoder.MediaObject.InputStreamCount, 1); foreach (DmoMediaType mediaType in decoder.MediaObject.GetInputTypes(0)) { Console.WriteLine(String.Format("{0}:{1}:{2}", mediaType.MajorTypeName, mediaType.SubTypeName, mediaType.FormatTypeName)); } }
/// <summary> /// Dispose of this obejct and clean up resources /// </summary> public void Dispose() { if (inputMediaBuffer != null) { inputMediaBuffer.Dispose(); inputMediaBuffer = null; } outputBuffer.Dispose(); if (mp3Decoder != null) { mp3Decoder.Dispose(); mp3Decoder = null; } }
public void Dispose() { if (this.inputMediaBuffer != null) { this.inputMediaBuffer.Dispose(); this.inputMediaBuffer = null; } this.outputBuffer.Dispose(); if (this.mp3Decoder != null) { this.mp3Decoder.Dispose(); this.mp3Decoder = null; } }
public DmoMp3FrameDecompressor(WaveFormat sourceFormat) { this.mp3Decoder = new WindowsMediaMp3Decoder(); if (!this.mp3Decoder.MediaObject.SupportsInputWaveFormat(0, sourceFormat)) { throw new ArgumentException("Unsupported input format"); } this.mp3Decoder.MediaObject.SetInputWaveFormat(0, sourceFormat); this.pcmFormat = new WaveFormat(sourceFormat.SampleRate, sourceFormat.Channels); if (!this.mp3Decoder.MediaObject.SupportsOutputWaveFormat(0, this.pcmFormat)) { throw new ArgumentException(string.Format("Unsupported output format {0}", this.pcmFormat)); } this.mp3Decoder.MediaObject.SetOutputWaveFormat(0, this.pcmFormat); this.inputMediaBuffer = new MediaBuffer(sourceFormat.AverageBytesPerSecond); this.outputBuffer = new DmoOutputDataBuffer(this.pcmFormat.AverageBytesPerSecond); }
/// <summary> /// Initializes a new instance of the DMO MP3 Frame decompressor /// </summary> /// <param name="sourceFormat"></param> public DmoMp3FrameDecompressor(WaveFormat sourceFormat) { this.mp3Decoder = new WindowsMediaMp3Decoder(); if (!mp3Decoder.MediaObject.SupportsInputWaveFormat(0, sourceFormat)) { throw new ArgumentException("Unsupported input format"); } mp3Decoder.MediaObject.SetInputWaveFormat(0, sourceFormat); pcmFormat = new WaveFormat(sourceFormat.SampleRate, sourceFormat.Channels); // 16 bit if (!mp3Decoder.MediaObject.SupportsOutputWaveFormat(0, pcmFormat)) { throw new ArgumentException(String.Format("Unsupported output format {0}", pcmFormat)); } mp3Decoder.MediaObject.SetOutputWaveFormat(0, pcmFormat); // a second is more than enough to decompress a frame at a time inputMediaBuffer = new MediaBuffer(sourceFormat.AverageBytesPerSecond); outputBuffer = new DmoOutputDataBuffer(pcmFormat.AverageBytesPerSecond); }
private bool IsOutputFormatSupported(WaveFormat waveFormat) { var decoder = new WindowsMediaMp3Decoder(); return(decoder.MediaObject.SupportsOutputWaveFormat(0, waveFormat)); }