Getting started with multimedia in the maemo 2.2 SDK

Introduction

This document describes:

  • How to test multimedia support using a simple example application.
  • How to add plugins to the maemo 2.2 SDK to enhance multimedia support.

By default, the maemo development platform supports PCM audio playback.

The required prerequisites are:

  • Maemo 2.2 SDK
  • Alsa OSS emulation support is enabled in the host

To view all GStreamer documentation, go to http://gstreamer.freedesktop.org/documentation/.

Application development

Many aspects of GStreamer application development are described in the Application Developer Manual document, which is available on the GStreamer website. This document is recommended as preliminary reading.

The example application used in this document demonstrates how to use the GStreamer API to play PCM audio and the ESD API to play a simple sounds (such as button clicks).

Firstly, to get ESD running in your development environment, you must follow a few basic steps.

  1. Start the ESD in the host side of your computer
  2. Copy /.esd_auth to /scratchbox/users/username/home/username.
  3. Make sure that the tmp/.esd directory is in place. (Your host may create it or a similar directory, such as /tmp/.esd-uid. Just symlink /tmp/.esd to that directory.)

The application sources can be downloaded from the maemo.org repository.

Building and running example application type

       $ make       $ ./wavlaunch       

Figure 1 illustrates an example of the main view.

Nokia 770 multimedia example: Main view

Figure 1. Nokia 770 multimedia example: Main view

In the main view, you can select

  • Open to open File Chooser.
  • Play to start playing the wav file.

Figure 2 illustrates the File Chooser.

Nokia 770 multimedia example: File Open view

Figure 2. Nokia 770 multimedia example: File Open view

Browse to a wav file and select Open.



Figure 3 illustrates the wav file playing screen.

Nokia 770 multimedia example: Play File

Figure 3. Nokia 770 multimedia example: Play File

To start playing a wav file, select Play.

For more information about how to use the GStreamer API see the Core API Reference. If you have Devhelp installed, it is available there too.

Plugin development

To have support for the new media format in the maemo 2.2 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 format one 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 process video and audio streams.

The list of plugins for the GStreamer is available in http://gstreamer.freedesktop.org/documentation/.

To add support for the new media format, you need:

  • Codec from the codec's manufacturer.
  • GStreamer plugings from the GStreamer website.
  • Extract packages to the Scratchbox environment and follow the compiling instructions for the codec and the GStreamer plugins package

To enable playback for ogg-vorbis audio files on the platform, take the following steps:

  1. Take the tremor from: http://svn.xiph.org/trunk/Tremor/
  2. Build and install in Scratchbox, use --prefix=/usr to have it in the default library path.
  3. Get the CVS version or a release that is later than 0.10.3 of gst-plugins-bad from the gstreamer repository.
  4. Build and install in Scratchbox, use --prefix=/usr to have it in the default library path. This must now detect the installed Tremor library and build the tremor element.
  5. Copy files from scratchbox to the device (into the same directory):
    • /usr/lib/libvorbisidec.so* -> root@n770:/usr/lib/
    • /usr/lib/gstreamer-0.10/libgstivorbis.so -> root@n770:/usr/lib/gstreamer-0.10
  6. Check that it works (this needs the gst-tools on the device): gst-inspect-0.10 tremor

The next step is to tell the file-manager and the media-player about the new format. Again the steps are illustrate how to add support for ogg-vorbis audio files.

  1. 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 following device: osso_media_server_ogg-vorbis.schemas -> root@n770:/etc/gconf/schemas/
    • Load into gconf: gconftool-2 --makefile-install-rule /etc/gconf/schemas/osso_media_server_ogg-vorbis.schemas
  2. Add a mime-data entry to the mime-type database.

    The mime-type database is a freedesktop.org standard. It uses xml files to describe how to determine the mime-type of a file.

    • Write ogg-vorbis.xml.
                     <?xml version="1.0" encoding="UTF-8"?>
                     <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
                      <mime-type type="audio/x-vorbis">                   <glob
      pattern="*.ogg"/>                   <magic priority="50">             
             <match type="string" value="OggS" offset="0"/>                 
       </magic>                   <comment>OGG audio</comment>        
              </mime-type>               </mime-info>               
    • Copy it to the device: ogg-vorbis.xml -> root@n770:/usr/share/mime/packages/
    • Refresh the mime cache: update-mime-database /usr/share/mime
    • Add "audio/x-vorbis" to /usr/share/applications/hildon/osso-music-player.desktop
    • update-desktop-database
  3. Add filemanager icons.

    On the device, standard icons for audio files are already installed. Below symbolic links are used to associate this icon with ogg-vorbis audio files.

    • cd /usr/share/icons/hicolor/26x26/mimetypes
    • ln -s ../hildon/qgn_list_gene_music_file.png gnome-mime-audio-vorbis.png
    • ln -s ../hildon/qgn_list_gene_music_file.png gnome-mime-audio-x-vorbis.png
    • cd /usr/share/icons/hicolor/scalable/mimetypes
    • ln -s ../hildon/qgn_list_gene_music_file.png gnome-mime-audio-x-vorbis.png
    • ln -s ../hildon/qgn_list_gene_music_file.png gnome-mime-audio-vorbis.png
    • gtk-update-icon-cache -f /usr/share/icons/hicolor/

To verify, you can select a file in the file manager and choose Details from the context menu. This gives the same mime-type as entered before. If this works, double-clicking the file also loads the media-player and the selected file.

This information may contain references to third-party information, software and/or services. Such third-party references in this document do not imply endorsement by Nokia of the third party in any way. Your use of third party software shall be governed by and subject to you agreeing to the terms of separate software licenses and Nokia shall not be responsible or liable for any part of such dealings.


Improve this page