Updated: October 28, 2024 |
To prepare for playing a video track, you must follow the same steps as when setting up audio playback. But you must use the Screen API instead of mm-renderer to configure output parameters; doing so gives you control over how and when content is displayed.
The code excerpts below show how to give mm-renderer an output URL of screen: to render video content on the full display, and an input URL that names a local video file or a network-accessible stream for playback. These scenarios demonstate a simple case when you want to use the full display because no other UI apps are running. At other times, you may want to restrict the content to a particular area, which requires using the Screen API and is demonstrated in Managing video windows.
/* Code to connect to mm-renderer and create a context goes here (see "Playing audio content" for an example of doing this) */ const mmr_error_info_t* errorInfo; // Attach a video output with a URL of "screen:" to use the full display int outputID = mmr_output_attach( ctxt_videorec, "screen:", "video" ); if (outputID == -1) { errorInfo = mmr_error_info(ctxt_videorec); /* Remaining error-handling code goes here */ return EXIT_FAILURE; }
// Attach an audio output with a URL of "snd:" to use the preferred device audio_device_output_id = mmr_output_attach( ctxt_videorec, "snd:", "audio" ); if (audio_device_output_id == -1) { errorInfo = mmr_error_info(ctxt_videorec); /* Remaining error-handling code goes here */ return EXIT_FAILURE; }
Using mmr_output_parameters(), you can configure any of the audio output parameters described in Parameters that affect how the output is delivered.
// Attach a local file as the input; use "track" as the type because // we're playing a single video track int inputID = mmr_input_attach( ctxt_videorec, "/fs/usb0/shape_of_you_video.mpg", "track" ); if (inputID == -1) { /* Error-handling code goes here */ return EXIT_FAILURE; } if ( mmr_play( ctxt_videorec ) < 0 ) { /* Error-handling code goes here */ return EXIT_FAILURE; }
For the input URL, we provide a hard-coded path to a local MPEG video file. In your program, you might need to use a variable; for example, if the track to be played is based on user selection. Also, when naming a file as input, you can prepend the URL with file: to make it clear that you're accessing a file. For the list of supported file extensions and associated video formats, see the product release notes.
rtp://10.222.97.225:49152Or, if the server is local, an AT sign can be used in place of the IP address:
rtp://@:49152
If the streaming server supports RTSP, using a standard rtsp: URL gives you access to any functionality that RTSP adds to RTP, such as playback on demand, pausing, seeking, and authentication (if your server supports them). See your server's documentation for details.
If the streaming server provides an SDP description of the RTP stream through a local file, you can use a file: URL. When you attach such an input, mm-renderer connects to the RTP server listed in the file to receive the data over RTP.
When playing a video file, you can manage playback in the same way as when playing an audio file.