public void CanExamineInputTypesOnMp3Decoder()
 {
     var decoder = new WindowsMediaMp3Decoder();
     Assert.AreEqual(decoder.MediaObject.InputStreamCount, 1);
     foreach (DmoMediaType mediaType in decoder.MediaObject.GetInputTypes(0))
     {
         Debug.WriteLine(String.Format("{0}:{1}:{2}",
             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(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;
			}
		}
        /// <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);
 }