Getting started with multimedia
Introduction
This document has been reviewed for maemo 3.x.
This document explains how to get started developing multimedia applications and plugins in the maemo SDK.
This assumes you are familiar with the maemo SDK, if you are not, then read maemo tutorial.
Also it's recommended to read GStreamer's documentation.
Here is a diagram of the multimedia architecure from the N800 Media Player point of view. It's important if you plan to develop GStreamer plugins that can be used by the Media Player.
Application development
This example demonstrates how to use GStreamer's API to play PCM audio.
The source code can be downloaded from here.
In order for the application to work on the x86 target in the SDK, osssink should be available. It's provided by gstreamer0.10-plugins-good-extra which is not installed by default.
You can check if osssink is available (if you have gst-inspect) with:
gst-inspect-0.10 osssink
If you don't have osssink, you can install it with:
apt-get install gstreamer0.10-plugins-good-extra
And gst-inspect-0.10 with:
apt-get install gstreamer0.10-tools
Building and running
make af-sb-init.sh start run-standalone.sh ./wavlaunch
To use simply:
- Click Open to open the File Chooser.
- Browse to a wav file and select Open.
- Play to start playing.
Screenshot:
Many aspects of GStreamer's application development are described in the Application Developer Manual.
For more information about how to use GStreamer's API see the Core API Reference.
Plugin development
To have support for the new media format in the maemo SDK you need to compile a codec for that format and compile GStreamer plugin supporting that codec. Some plugins have the codec embedded and therefore do not need an additional library. To play some formats one unsually needs a demuxer GStreamer plugin as well. More information about the internals of GStreamer plugins can be found in the Plugin Writers Guide.
Codecs are libraries that enable the use of compression for digital audio and video. GStreamer plugins are loadable libraries that provide GStreamer elements that process video and audio streams.
The list of plugins for GStreamer is available here.
To add support for the new media format, you need:
- Codec from the codec's manufacturer.
- GStreamer plugins from the GStreamer website.
- Extract packages to the Scratchbox environment and follow the compiling instructions for the codec and the GStreamer plugins package
Install OGG Vorbis
To enable playback for ogg-vorbis audio files on the platform, take the following steps:
-
Get the integer-only implementation from here.
svn co http://svn.xiph.org/trunk/Tremor/
-
Build and install in Scratchbox.
./autogen.sh --prefix=/usr make install
- Get gst-plugins-bad-0.10.3.
-
There is one bug in the ivorbis element that makes not possible to use it twice; the following patch comes from gst-plugins-bad-0.10.4 and fixes that. Unfortunately, 0.10.4 requires a newer version of GStreamer's core.
Create ivorbis.diff:--- orig/ext/ivorbis/vorbisfile.c 2006/04/25 21:56:30 1.32 +++ mod/ext/ivorbis/vorbisfile.c 2006/07/15 11:57:00 1.33 @@ -580,6 +580,11 @@ /* FIX ME */ /* ivorbisfile->vf.seekable = TRUE; */ ivorbisfile->vf.seekable = FALSE; + if (ivorbisfile->adapter) { + gst_adapter_clear (ivorbisfile->adapter); + g_object_unref (ivorbisfile->adapter); + ivorbisfile->adapter = NULL; + } return gst_pad_activate_pull (sinkpad, TRUE); } else {
Now patch the source code.cat ivorbis.diff | patch -p1
-
Build and install in Scratchbox:
./configure --prefix=/usr make -C ext/ivorbis install
-
Check that it's there (if you have gstreamer-tools):
gst-inspect-0.10 tremor
-
If you want to try it:
gst-launch-0.10 filesrc location=test.ogg ! application/ogg ! tremor ! osssink
Deployment
Copy files from scratchbox to the device (into the same directory):
-
/usr/lib/libvorbisidec.so* -> /usr/lib/
-
/usr/lib/gstreamer-0.10/libgstivorbis.so -> /usr/lib/gstreamer-0.10
-
If you want to try it:
gst-launch-0.10 filesrc location=test.ogg ! application/ogg ! tremor ! dsppcmsink
The next step is to tell the file-manager and the media-player about the new format.
-
Add keys for "ogg-vorbis" to GConf.
The media engine on the device uses the GConf registry to store GStreamer pipeline configurations for supported media types.
-
Write osso_media_server_ogg-vorbis.schemas.
<gconfschemafile> <schemalist> <schema> <key>/schemas/apps/osso/osso_media_server/audio/application_ogg</key> <applyto>/apps/osso/osso_media_server/audio/application_ogg</applyto> <owner>osso_media_server</owner> <type>list</type> <list_type>string</list_type> <default>[application/ogg,tremor,dsppcmsink]</default> <locale name="C"></locale> </schema> </schemalist> </gconfschemafile>
-
Copy it to the device:
osso_media_server_ogg-vorbis.schemas -> /etc/gconf/schemas/
-
Load it into GConf:
gconftool-2 --makefile-install-rule /etc/gconf/schemas/osso_media_server_ogg-vorbis.schemas
- Reboot in order for the configuration to be properly loaded.
-
Write osso_media_server_ogg-vorbis.schemas.
At this moment you should be able to play Ogg Vorbis network streams, but local files require a special trick: you need to rename the file to .mp3.
Improve this page