Table of Contents

Class StreamMediaFoundationReader

Namespace
NAudio.Wave
Assembly
NAudio.Wasapi.dll

MediaFoundationReader supporting reading from a stream
Automatically converts to PCM.
If it is a video file with multiple audio streams, it will pick out the first audio stream.

public class StreamMediaFoundationReader : MediaFoundationReader, IAsyncDisposable, IDisposable, IWaveProvider
Inheritance
StreamMediaFoundationReader
Implements
Inherited Members
Extension Methods

Constructors

StreamMediaFoundationReader(Stream, MediaFoundationReaderSettings, string, string)

Constructs a new media foundation reader from a stream

public StreamMediaFoundationReader(Stream stream, MediaFoundationReader.MediaFoundationReaderSettings settings = null, string contentType = null, string originName = null)

Parameters

stream Stream

The data stream to initialize the reader from.

settings MediaFoundationReader.MediaFoundationReaderSettings

Optional. Additional options that affect how the reader reads data.

contentType string

Optional. A MIME type hint (e.g. "audio/ogg") for the byte stream, passed to Media Foundation as MF_BYTESTREAM_CONTENT_TYPE to help its source resolver select a byte-stream handler. Because a stream carries no file name, the resolver otherwise has only the content sniffer's guess to go on; supplying a hint here is the reliable way to decode formats the sniffer does not recognise. When supplied, automatic content sniffing is skipped.

originName string

Optional. A file name or URL whose extension identifies the format (e.g. "track.ogg"), passed to Media Foundation as MF_BYTESTREAM_ORIGIN_NAME. This gives the byte-stream path the same extension-based resolution the file-based MediaFoundationReader gets via MFCreateSourceReaderFromURL, and is generally the most reliable hint. When supplied, automatic content sniffing is skipped.

Remarks

A supplied hint only helps Media Foundation locate a decoder that is already installed on the machine; it does not add codec support. If both hints are supplied they are both applied.

Exceptions

ArgumentNullException

stream is null.

ArgumentException

stream is unreadable, or unseekable.

Methods

Dispose(bool)

Cleanup the wrapper implementation

protected override void Dispose(bool disposing)

Parameters

disposing bool