Media Foundation Architecture
Media Foundation is divided into several layers:
- Media Foundation Primitives: Basic object types that are used throughout Media Foundation.
- Media Foundation Platform: Provides work queues, asynchronous callbacks, a mechanism for sending events, and various helper objects.
- Pipeline: Contains the components that create, manipulate, and consume media data. Includes media sources, encoders and decoders, color converters, and so forth.
- Control Layer: Manages the flow of media data from end to end.
- Protected Media Path (PMP): Provides a protected environment for playing premium video content. It is not necessary to use the PMP when writing a Media Foundation application.
Most applications will use APIs from all three layers, but will not use everything in every layer.
.gif)
Platform Layer
In addition to various helper objects, the platform layer defines the following.
- Asynchronous callbacks. The operations performed on digital media can be relatively lengthy—opening network resources, parsing files, decoding video frames, and so forth. Therefore many APIs use asynchronous methods. Media Foundation provides a consistent API for implementing asynchronous callbacks.
- Event model. Media Foundation provides a consistent way for objects to send events. An object can use events to signal the completion of an asynchronous method, or to notify the application about a change in the object's state
- Work queues. A work queue is an efficient way to perform asynchronous operations on another thread.
For more information, see Media Foundation Platform APIs.
Pipeline Layer
The pipeline layer defines the objects that process media data inside the Media Foundation data pipeline. Three types of pipeline object are defined: media sources, Media Foundation transforms (MFTs), and media sinks.
-
Media sources generate media data. Except in trivial cases, a media source gets its raw data from some external location, such as a local file or a network stream.
-
MFTs manipulate media data. An MFT has zero or more inputs and zero or more outputs. Most MFTs have both inputs and outputs, with the inputs providing the data used to generate the output. Typical examples include decoders (compressed input becomes uncompressed output), encoders (uncompressed input becomes compressed output), and digital signal processors (DSPs).
-
Media sinks consume data. For playback, Media Foundation provides an audio renderer sink and a video renderer sink. Media sinks can also be used to write files or send data over the network.
Applications can use the pipeline components as standalone objects, without using the control layer, but cannot access protected media in this way. To get the full benefits of the protected media path, you must use the media session.
To perform an end-to-end task, such as playing a video file, the application must assemble the appropriate set of media sources, MFTs, and media sinks. For playback, the topology loader, which is part of the control layer, automates some of this process. Media data is then passed from one pipeline component to the next. If you are using the media session, the flow of data between pipeline components is completely automated by the control layer. Otherwise, if you are not using the media session, the application must implement this process.
For information about using or implementing the generic APIs for sources, MFTs, and sinks, see Media Foundation Pipeline.
If you are familiar with DirectShow, it is worth noting some ways in which Media Foundation pipeline components differ from DirectShow filters:
-
Pipeline components do not connect to each other. The application or the control layer is responsible for moving data from one component to the next.
-
Media sources do not push samples into the pipeline on a worker thread. Instead, Media Foundation uses a pull model where the application or the control layer requests samples from the source.
Control Layer
Most Media Foundation applications should use the control layer, because it handles almost all of the work of running the pipeline, and is also required for protected playback. Objects in the control layer include the following:
-
Media session: Controls the data flow through the pipeline.
-
Topology: Represents the connections between pipeline components.
-
Presentation clock: Provides a clock for scheduling when media data is rendered.
-
Source resolver. Creates a media source from a URL or byte stream.
-
Sequencer source. Enables an application to create playlists with smooth transitions between media sources. It can also be used to aggregate multiple sources and present them as a single source.
For information about the control layer, see Control Layer.
See Also
About the Media Foundation SDK
Send comments about this topic to Microsoft
Build date: 10/27/2008