Playing and Managing Video and DVDs

This chapter describes how to work with track sessions and play audio media on the MME.

For information about support for video on iPod devicess, see Video support in the chapter Working with iPods.

Playing and managing video

This section is explains how to play video files and how to manage video attributes.

Playing video files

The MME supports playback of the following encoded video formats in MP4 files:

Video files in the library table are identified by their ftype set to FTYPEVIDEO (2) or FTYPEAUDIOVIDEO (3). To play a video file, you need to:

  1. Configure the MME for video support, by adding a video output device to the MME's outputdevices table, and setting values and behaviors for this device. For instructions, see Configuring the MME for video support below.
  2. Create and set a track session that includes the video file you want to play, just as you would a track session with only audio files, or use the MME's Explore API to access the video file.
  3. Start and manage playback, just like you would playback of an audio file: call mme_play(), mme_stop(), etc.

For information about:


Note: When video playback reaches the end of file, it leaves the last image on the screen. If you want videos to end with a cleared screen, you must have the client application issue the necessary instructions, such as, for example, a call to mme_stop().

Managing video attributes

The MME provides an array of functions for managing videos while they are playing, including:

Playing and managing DVDs

The MME is designed to support the playing of:


Note: DVD and video support is platform-specific. If MME API functions that support DVD mediastores and video playback are called on a system that does not have the required io-media modules, these functions return an error with errorno set to ENOSYS.

Please contact us to discuss your DVD and video implementation requirements.


DVD synchronization

When the MME synchronizes a DVD, it creates in the library:

The file IDs (fids) for entire DVDs can be found by examining the library table entries where the ftype column has the value 5 (FTYPE_DEVICE from mme/interface.h).

The example below shows an SQL query to select all DVD entries in the library:



SELECT fid, title FROM library WHERE ftype=5;

Playing DVDs

The MME supports playing an entire DVD or only a part of the DVD, subject to legal limitations that may either restrict access to some parts of a DVD or impose playback of other parts, such as the copyright notice and warning.

When playing a DVD-video, you can use mme_video_get_info() to get information, such as codec, capture format, and aspect ratio for the video, and mme_video_set_properties() to set the video properties for output.

Playing an entire DVD

To play an entire audio or video DVD, simply include the fid for that DVD in your track session. With the entire DVD in the track session, you can call mme_button() to move around on the DVD, play media, and manage behavior. The MME delivers the appropriate events at all transitions during the DVD playback.

Playing specific parts of a DVD

To play specific parts of an audio or video DVD (title, chapter, etc.), you can place the fids for the parts of the DVD you want to play in a track session, then play the session. The MME will play only the specified part of the DVD, and deliver the event MME_EVENT_FINISHED when it has finished playing it.

Note that for DVD-videos legal restrictions may prevent playback of some parts of the DVD using this method. Similarly, attempts to use mme_button() to circumvent these restrictions will be rejected.

Starting playback from a specific DVD title and chapter

You can start playback at a title and specific chapter of an audio or video DVD by calling mme_seek_title_chapter() when you would use a command button:

  1. Create a track session with the file ID (fid) for the entire DVD.
  2. Set the tracksession.
  3. Call mme_play() to start playback.
  4. Once the navigator is active, call mme_seek_title_chapter() to seek to the desired title and chapter on the DVD.

Use mme_get_title_chapter() to get the number of titles and chapters in the current track, and the currently playing title and chapter numbers; use mme_seek_title_chapter() to seek to a specified title and chapter.

You can use these functions only if the MME_PLAYSUPPORT_NAVIGATION flag is set in the support member of the data structure mme_play_info_t. Call mme_play_get_info() to get this structure .

For sample code snippets, see the examples on the reference pages for mme_get_title_chapter() and mme_seek_title_chapter().

Setting the default preferred media language

To set the default preferred language for a media item, call mme_media_set_def_lang() with the lang argument pointing to a string with the requested language. You can also use mme_media_get_def_lang() to find out the currently set langauge.

See also Configuring Internationalization in the MME Configuration Guide.

Managing DVD access

The MME API provides functions that facilitate managing access to DVDs, offering client applications the ability to get disk regions.

For information about setting region playback codes (RPC) on ATAPI DVD devices, see dvddrivectl in the MME Utilities Reference.

Using DVD region codes

Region codes are used to set the regions for which a device is enabled, and to check the region of DVD-video discs before they are played. For example, if a user has a device enabled for regions 1 and 3, the HMI can check that a DVD-video disk is from one of these regions before allowing the user to play it.

Region codes are represented in bits 0 to 7, with bit 0 representing region 1, up to bit 7 representing region 8. The API takes a 32-bit region code, but the top 24 bits of the region are not currently used.

The function mme_dvd_get_disc_region() gets the region code of specific DVD-video discs that are inserted into the DVD drive. The bits that are returned from mme_dvd_get_disc_region() represent the regions in which the DVD-video disk may be played. If no bits are set, the DVD-video disk is regionless and can be played in any region.


Note: It is the responsibility of the user application to set and track device regions, and to inform the end user through the HMI of conditions where the regions for a DVD-video disk are incompatible with the regions set for the device.

DVD-video player

The DVD player runs on Intel x86 platforms; audio and video decoding are enhanced by Intel chips that support the Intel IPP library.

Required drivers and binaries

The DVD player requires the following QNX drivers:

The following binaries are specific to DVD playback:


Note: For information about video layers, see the Advanced Graphics Developer's Guide, in particular the chapter Working with Layers, Surfaces, and Contexts, and the “Layers” API.

Playing DVDs

You can use the standard MME API to play DVDs with the software DVD player. All you need to do is start srv-dvdplayer in addition to your other MME components:

# srv-dvdplayer -c /etc/system/config/files.dat &

The -c option sets the path to the keys required for playing encrypted DVDs. See Encrypted DVDs below.

To get debug information for srv-dvdplayer, use the -D option. For example:

# srv-dvdplayer -DDD &

For more information, see srv-dvdplayer in the MME Utilities reference.

Including srv-dvdplayer in a startup script

If you want to include starting srv-dvdplayer in a startup script, you should add start up instructions like those below before the io-media startup:

MM_INIT=not_the_default_path/lib/dll/mmedia srv-dvdplayer -c /etc/system/config/files.dat &
waitfor /dev/dvdplayer

Note: By default, srv-dvdplayer looks in /lib/dll/mmedia for the multimedia filters, but, as with io-media-generic, you can force it to look elsewhere by using the $MM_INIT environment variable (shown above).

After you have started srv-dvdplayer, you can follow the usual steps for creating a track session and playing the media:

  1. Insert a DVD.
  2. Create a track session.
  3. Set the track session.
  4. Start playback.
  5. Send DVD navigation and control commands, as required.

Note: When creating the track session, you can identify a DVD in the mediastores table by its storage type, which is set to MME_STORAGETYPE_DVDVIDEO.

DVD commands

Use the following functions to manage DVD playback and trick play, set video properties and get information:

Use the other standard MME functions to control other behavior and settings, such as volume level.


Note: Most commands for DVD playback and navigation are sent using the MME's mme_button() function, which behaves like the buttons on a DVD remote control. For more information about this and the other functions used for DVDs, see the MME API Library Reference.

Configuring the MME for software DVD playback

DVDs use the configuration settings for CDs. For more information, see the MME Configuration Guide.

For specific information about configuring the MME for video support, see Configuring the MME for video support below.

Encrypted DVDs

To play encrypted DVDs you must obtain commercial CSS decryption keys from the DVD Copy Control Association. To provide your encrypted keys to the DVD player, use the dvdkeymgr utility.

Playing encrypted DVDs

To play encrypted DVDs:

  1. Obtain commercial CSS decryption keys from the DVD Copy Control Association.
  2. Create a keys.txt file. For more information, see Input file on the dvdkeymgr page of the MME Utilities Reference.
  3. Use the dvdkeymgr utility to generate a DVD CSS decryption binary file: files.dat.
  4. Start srv-dvdplayer, using the -c option to set the path to the files.dat file.

dvdkeymgr

The utility dvdkeymgr takes the keys in the input file, keys.txt, located at path, and creates a CSS decryption binary file called files.dat. For example, the command line instructions below generates a files.dat file from the keys in the file /usr/keys.txt:

dvdkeymgr /usr/keys.txt

To enable srv-dvdplayer to play encrypted DVDs, after you have generated the files.dat file, you must place it in the same folder as srv-dvdplayer, or use srv-dvdplayer's -c option to point to the file.

For more information, see dvdkeymgr in the MME Utilities reference.

Configuring the MME for video support

To configure the MME for video support, you must add the URL of a video output device to the MME's outputdevices table, as follows:

INSERT INTO outputdevices(type, permanent, name, devicepath)
            VALUES(1, 1, 'defaultoutput2', 'gf:deviceentry?param1&param2');

The deviceentry string and its parameters correspond to the device entry in the /dev/io-display directory. It includes, in this order, separated by commas:

For example, in the deviceentry parameters in the string gf:8086,2772,0?layer=1&sublayer=2 ... identify the following:

If there is only one device, the device index can me omitted, and will default to 0 (zero).


Note:
  • For information about the modifiers that follow the question mark, see Adding modifiers to a video output device URL below.
  • For information about video layers, see the Advanced Graphics Developer's Guide, in particular the chapter Working with Layers, Surfaces, and Contexts, and the “Layers” API.
  • You should also configure io-media for optimal video performance. For more information, see Configuring io-media for optimal video performance in the MME Configuration Guide.

Adding modifiers to a video output device URL

The URL to the video output device may contain optional modifiers after the question mark (“?”), each modifier separated by an ampersand (“&”), to set default values and behaviors on the device. Supported modifiers are listed below:

index
Specify the GF display index.
layer
Specify the GF layer.
nsurfs
Specify the number of GF surfaces.
sublayer
Specify the SPU (subtitle) layer.

To specify the destination rectangle use:

dsth
Set the destination height, in pixels.
dstw
Set the destination width, in pixels.
dstx
Set the destination x coordinate.
dsty
Set the destination y coordinate.

To specify the aspect ratio of the pixels on the physical display use:

aspd
The aspect ratio denominator.
aspn
The aspect ratio numerator.

To set the color control on the output use:

bright
Specify the brightness, in direct GF units.
contrast
Specify the contrast, in direct GF units.
sat
Specify the color saturation, in direct GF units.

After playback has started, you can use the mme_video_set_properties() function to adjust playback parameters.

Configuring video output for the software DVD player

When configuring video output for the software DVD player, you must specify the layer and sublayer modifiers in the output URL string. For example, the modifiers in the string gf:8086,2772,0?layer=1&sublayer=2 ... are interpreted as follows:


Note: The ARGB layer used for subtitles does not support scaling. To keep the video and subtitle layers correclty aligned on screen, both are centered and not scaled.

Example: Defining a video output device

The example below shows how to define in the mme database schema, an audio output device and a video output device.

INSERT INTO outputdevices(type, permanent, name, devicepath)
            VALUES(1, 1, 'rearoutputaudio', 'snd:/dev/snd/pcmC0D3p');
INSERT INTO outputdevices(type, permanent, name, devicepath)
            VALUES(2, 1, 'rearoutputvideo', 'gf:8086,2772,0?aspn=72&aspd=77&bright=-20&sat=-10');