/// <summary> /// Returns a new instance of the <see cref="MediaFoundationEncoder"/> class, configured as wma encoder. /// </summary> /// <param name="sourceFormat">The input format, of the data to encode.</param> /// <param name="bitRate">The bitrate to use. The final bitrate can differ from the specified value.</param> /// <param name="targetStream">The stream to write to.</param> /// <remarks>For more information about supported input and output formats, see <see href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff819498(v=vs.85).aspx"/>.</remarks> /// <returns>A new instance of the <see cref="MediaFoundationEncoder"/> class, configured as wma encoder.</returns> // ReSharper disable once InconsistentNaming public static MediaFoundationEncoder CreateWMAEncoder(WaveFormat sourceFormat, Stream targetStream, int bitRate = 192000) { if (sourceFormat == null) { throw new ArgumentNullException("sourceFormat"); } if (targetStream == null) { throw new ArgumentNullException("targetStream"); } if (targetStream.CanWrite != true) { throw new ArgumentException("Stream not writeable.", "targetStream"); } MediaType targetMediaType = FindBestMediaType(AudioSubTypes.WindowsMediaAudio, sourceFormat.SampleRate, sourceFormat.Channels, bitRate); MediaType sourceMediaType = MediaFoundationCore.MediaTypeFromWaveFormat(sourceFormat); if (targetMediaType == null) { throw new PlatformNotSupportedException("No WMA-Encoder was found."); } return(new MediaFoundationEncoder(targetStream, sourceMediaType, targetMediaType, TranscodeContainerTypes.MFTranscodeContainerType_ASF)); }
static MediaFoundationDecoder() { MediaFoundationCore.Startup(); //make sure that the MediaFoundation is started up. }
static MediaFoundationEncoder() { MediaFoundationCore.Startup(); }
private SourceReader Initialize(ByteStream byteStream) { return(Initialize(MediaFoundationCore.CreateSourceReaderFromByteStream(byteStream, null))); }