The multimedia plug-and-play tool, mm-pnp, is a demo program that shows how to detect a mediastore,
upload its media information to a database, and play its media files.
Note:
This tool is not included with the QNX SDK for Apps and Media installer.
We document it here because you can request its source code through QNX customer support.
The mm-pnp tool serves the same overall purpose as the other test utilities—it demonstrates
how to use the platform multimedia services—so it makes sense to explain it in this guide.
The mm-pnp program provides a helpful reference for writing your own media apps because it performs
all common media-management tasks. However, this program doesn't directly access media content or manage media streams.
Instead, it uses other services to monitor which mediastores (i.e., devices) are attached and to synchronize and play their media
files. You can customize how mm-pnp does this for different device types
(e.g., iPods, USB sticks, CDs) by modifying its configuration file.
Source code
The
mm-pnp code provides a walkthrough of the API call sequences that detect when the user attaches
a mediastore and then access, extract, and play its content. The program is written in C and contains just over 3000 lines
of code, including whitespace, comments, and preprocessor directives. The code is organized into the following modules:
- plug and play
- Implements the main thread, which parses the command-line options and starts and stops child threads.
- config
- Defines default values for configuration options and parses the configuration file to extract and store
all user-specified options.
- PPS monitor
- Implements two child threads. One thread monitors Persistent Publish/Subscribe (PPS) mount objects to detect when
the user attaches a device. The other thread monitors QDB status objects to respond appropriately when
media databases are loaded or unloaded.
- DB manager
- Provides a callback mechanism so you can define your own responses to database status changes.
- sync
- Stores the lists of pending and active synchronizations and communicates with mm-sync,
which performs the synchronizations.
Also implements the thread that handles mm-sync events.
- playback
- Stores the list of playlists and communicates with mm-renderer, which plays them.
- linked list
- Defines data types used in lists and implements the functions for iterating through lists and for adding and removing
elements.
- logging
- Stores the verbosity level and the list of active logging destinations (e.g., sloginfo,
stdout). Also defines the functions for writing log entries.