Working with contexts

Contexts define the flow of media content from an input to one or many outputs. You must configure a context before you can start playing media content.

To create a new context, call the function mmr_context_create(), passing the mm-renderer connection handle. The creation operation returns a context handle (the primary handle), which you use to manipulate the context by setting parameters, attaching inputs and outputs, and issuing playback commands. You can create as many contexts as you need to, as long as your application manages potentially conflicting playback situations.

The multimedia renderer doesn't allow contexts to exist after their primary handle is destroyed, but does allow you to open existing contexts. That is, additional, or secondary, context handles can be opened after the context is created. Calling mmr_context_close() using the primary context handle will not only close the context handle, but also stop playback, detach any inputs and outputs, and destroy the context. Because of this, it's important to ensure that any secondary context handles are properly closed. In addition, if your application terminates unexpectedly or disconnects from mm-renderer without explicitly closing the primary context handle, the context is destroyed.

When a context is no longer needed, you can destroy it by passing the context handle to the mmr_context_destroy() function.