Playback model

Updated: April 19, 2023

The mm-renderer playback model uses contexts to control individual media flows between an attached input and one or many attached outputs. All playback commands must be directed to specific contexts and all events reported by mm-renderer are associated with specific contexts.

Contexts

To define a media flow, a client application must create a context. Each context can play a stream of media content concurrently with and independently of other contexts, and direct output to different hardware devices or files. This design lets you create independent playback zones; for example, you could define one context for playback on headphones and another one for playback on speakers.

When your application creates a context, the mm-renderer service gives it a unique name but sets no other properties. The service also returns a handle that your application can use to access the context in subsequent operations, such as configuring the context's operations by defining parameters for the context itself, its input, and its outputs.

Which operations are available depends on the context's current input and outputs. For example, seeking to a new position doesn't apply for some input streams (e.g., radio stations) or devices (e.g., microphones). Note that you can use a context for operations other than playing; for instance, you can record audio by setting the output to a file and the input to an audio capture device (i.e., a microphone).

Outputs

Each context has to have one or more outputs attached before it can play anything, so it can determine where to send the content.

An output can be a file, an audio device, or a video device. Outputs need to be attached before the input. This is because when mm-renderer picks an engine plugin to play the input, the decision can be based on what kind of outputs are attached. Also, some plugins may not support detaching and reattaching outputs after the input is connected.

Inputs

Each context has to have one input attached, so it knows what to play.

When the input is attached, mm-renderer selects the appropriate engine plugin and attaches it to the context. The application must identify the input type because the service doesn't detect it.

The input type determines how mm-renderer responds to certain requests, such as seeking to a track position. Which input types are supported depends on the configuration of mm-renderer; however, the playback behavior for a given input type does not depend on it.

CAUTION:
Although the same input can be attached to multiple contexts, mm-renderer doesn't detect or manage conflicting playback operations—your application must manage potential conflicts.