RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Playing Multimedia Using BREW's IMedia API

BREW has supported multimedia presentation from the start. Now, its new IMedia interface makes taking advantage of BREW's rich support for audio and video playback easier than ever.

rom the earliest days of the BREW platform, its designers at Qualcomm have paid close attention to the demands of multimedia presentation. Early versions of BREW supported animated image display through the proprietary BREW Compressed Image (BCI) format as well as sound playback through the ISound, ISoundPlayer, and IRinger interfaces. With the advent of BREW 2.0 a few years ago, multimedia presentation in C and C++ has been streamlined through a single interface—the IMedia interface—which provides a single interface to audio and visual (still and video) multimedia. Imedia consists of an abstract interface (IMedia) and subclasses implementing codecs for popular standards including MIDI, MP3, AAC, 3GPP video, and JPEG, along with a helper class responsible for selecting the appropriate subclass. This makes IMedia the media presentation interface of choice for both existing and new BREW applications.

Understanding BREW's Multimedia Architecture
At first blush, especially if you're new to BREW, the IMedia interface and media playback architecture can seem overwhelming. However, it's really quite simple, being comprised of only three key parts:

  • The abstract BREW IMedia interface is responsible for managing media playback. It treats playback as an asynchronous activity, in which the controlling application sets various properties for playback (such as volume and display rectangle), invokes key operations to control playback (such as starting and stopping media presentation), and receives messages from the IMedia interface periodically through a callback function.
  • Subclasses of the IMedia interface implement specific codecs for playing back a single media data type, such as MP3, AAC, and MIDI audio, 3GPP video, or BMP or JPEG images. These interfaces can be created in the usual way via ISHELL_CreateInstance with the class id of a specific media player, such as AEECLSID_MEDIAMP3.
  • The BREW IMediaUtil interface implements a factory for obtaining a specific IMedia subclass given the data to present.
Using the IMedia interface is far simpler than you might think in just reading the documentation:
  1. Given the source data to play, create an appropriate subclass of IMedia to present the data.
  2. Set the IMedia instance's callback so that the instance can pass information about the media back to your application using IMEDIA_RegisterNotify.
  3. Configure any playback options (such as default volume or screen rectangle for drawing).
  4. Begin and control media playback, using handset or programmatic events (key presses, game actions, or so forth) to trigger IMedia methods such as IMEDIA_Play, IMEDIA_Pause, IMEDIA_Resume, and IMEDIA_Stop.
  5. Monitor the values sent to your application callback for information such as errors or the termination of playback and handle those notifications appropriately (for example, restarting playback if your application is looping audio or video).
  6. When playback is complete, release the IMedia instance and any other resources you've consumed.
While straightforward, it's instructive to actually see the IMedia methods in sample code to help fit the pieces of the puzzle together.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date