Introducing the Source Reader

One of the new features in Media Foundation is the Source Reader.

Media Foundation, like DirectShow before it, has focused on the end-to-end pipeline. The application passes in a URL and streaming happens on another thread. The application gives commands (play, pause) and gets events (end of stream).

While this approach is convenient for playback, it makes it relatively hard for the application to get access to the bits as they travel from the source to the renderer.

The Source Reader uses a different model. The application passes in a URL and then requests samples by calling IMFSourceReader::ReadSample in a loop. You can use the Source Reader to get compressed or uncompressed data from the source. For uncompressed data, the Source Reader hosts any decoders that are needed.

I see two very broad categories of application for the Source Reader:

  1. Applications that implement their own playback pipeline -- say, by using Direct3D to draw the video frames directly.
  2. Applications that need to perform non-real-time processing on media data, such as encoding, signal processing, video thumbnails, etc. For this type of application, all you want are the uncompressed samples; you don't need the API to manage streaming threads or a presentation clock.

Format SDK programmers will find the Source Reader looks similar to the FSDK reader object. (The Source Reader can operate in either synchronous or asynchronous mode). 

For DirectShow programmers, the Source Reader fills approximately the same niche as the Sample Grabber filter, except it is (IMO) easier to use.

More information here:

Please remember that everything new in the SDK is beta. There have been minor changes to the Source Reader API for the upcoming RC.

 - Mike