Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Comparing J2ME Multimedia Options

 

MMAPI 1.1, MIDP 2.0 Media API, and Advanced Multimedia Supplements




The Mobile Media API (MMAPI) is an optional package within the Java 2 Platform, Micro Edition (J2ME), that provides a standard API for rendering and capturing time-based media, such as audio tracks and video clips. Developed within the Java Community process as JSR 135, MMAPI was designed to be flexible and platform-independent; it makes no assumptions about media formats, protocols, or features supported by various devices. MMAPI is already making its way into mobile devices; the Nokia 3650, for example, includes an implementation. Other devices that support MMAPI can be found at "J2ME Devices."

This article services the latest developments in MMAPI: the new security considerations raised in MMAPI 1.1, the differences between MMAPI and the MIDP 2.0 Media API, J2ME Wireless Toolkit 2.2 support for MMAPI, and JSR 234, Advanced Multimedia Supplements. If you're looking for a tutorial on MMAPI as well as code samples, for an audio/video player, for instance, see the articles "The J2ME Mobile Media API" and "Taking Pictures With MMAPI."

Overview of MMAPI Components

MMAPI has four main components:

  • Player is used to play content. It provides methods to manage a Player's life-cycle, and to manage various playback features.
  • Manager is the overall controller of the media. It creates Players.
  • DataSource represents a protocol handler, usually not visible to the application developer. The protocol handler reads the media data and fetches it to Player for playback.
  • Control controls various features of Player and playback operations.

Supported MMAPI Controls

MMAPI has 12 controls, in the package javax.microedition.control:

  • MetaDataControl retrieves metadata information from the media.
  • MIDIControl provides access to MIDI rendering and transmitting devices.
  • GUIControl represents a control that provides a UI component.
  • PitchControl raises or lowers the playback pitch without changing the playback speed.
  • RateControl controls the playback rate.
  • TempoControl controls the tempo of a MIDI song.
  • VolumeControl controls the volume.
  • VideoControl controls the display of visual content.
  • FramePositioningControl enables precise positioning to a video frame.
  • RecordControl records what is currently being played by the Player.
  • StopTimeControl enables an application to define a preset stop time for a Player.
  • ToneControl is an interface that enables playback of user-defined tone sequences.

Be aware that not all MMAPI implementations support all types of controls. You can find out what a device does support by calling System.getProperty(String key). The specification defines these properties:

  • microedition.media.version returns a string representing the version of MMAPI implemented, "1.0" or "1.1" if MMAPI is supported, or null if it isn't.
  • supports.mixing returns true if mixing is supported, false if it isn't.
  • supports.audio.capture returns true if audio capture is supported, false if it isn't.
  • supports.video.capture returns true if video capture is supported, false if it isn't.
  • supports.recording returns true if recording is supported, false if it isn't.
  • audio.encodings returns a string representing the supported audio capture formats, or null if audio capture isn't supported.
  • video.encodings returns a string representing the supported video capture formats, or null if video capture isn't supported.
  • video.snapshot.encodings returns a string representing the supported image capture formats, or null if video snapshot isn't supported.
  • streamable.contents returns a string representing the supported streamable content types, in MIME syntax.

In addition to the properties supported by System.getProperty(), the Manager class provides a couple of useful static methods:

  • String[] getSupportedContentTypes(String protocol) takes a protocol such as "http" and returns the content types supported for that protocol.
  • String[] getSupportedProtocols(String contentType) takes a content type in MIME syntax, such as video/mpeg, and returns the protocols that can be used to deliver that content type.

MMAPI 1.1

MMAPI 1.1 is a maintenance update of MMAPI 1.0. It primarily fixes documentation problems, adds some new definitions, and revises documentation related to the MIDP 2.0 security framework. It makes no changes to classes, interfaces, or method signatures.

The MMAPI specification does not define a security framework of its own, but MMAPI implementations are subject to security mechanisms provided by the underlying profile and configuration. Some MMAPI methods are defined to throw a SecurityException if the caller lacks appropriate security permissions. Therefore, an MMAPI implementation must guarantee that:

  • The SecurityException is thrown when the caller does not have the permissions necessary to execute the method.
  • The method can be used when the appropriate permissions have been granted.

The security issues of MMAPI concern recording, network access, and access to local data stores. Recording raises concerns about users' privacy; the application may silently access recording functionality to record and distribute private conversations. In addition, security practices that are in place for accessing remote and local resources must be followed. To gain access to recording functionality, networks, or local data stores, an MMAPI-based application must obtain the appropriate permissions, which are implementation-specific.

MMAPI and the J2ME Wireless Toolkit 2.2

Release 2.2 of the J2ME Wireless Toolkit implements JSR 135. The toolkit comes with an emulator skin, MediaControlSkin, whose focus is on multimedia playback and control. The emulator's MMAPI implementation supports the following media types:

Supported Media Types in the J2ME Wireless Toolkit 2.2 Emulator's MMAPI Implementation
MIME Type Description
audio/midi MIDI files
audio/sp-midi Scalable Polyphony MIDI
audio/x-tone-seq MIDP 2.0 tone sequence
audio/x-wav WAV PCM sampled audio
image/gif FIG 89a (animated GIF)
video/mpeg MPEG video
video/vnd.sun.rgb565 Video capture

MMAPI MIDlets

The toolkit also comes with several MMAPI demos. A particularly interesting demo is Pausing Audio Test, which is part of the mmademo project. It demonstrates how a well-developed MMAPI MIDlet should behave. For example, you need to be aware that MIDlets may be paused by events such as incoming phone calls, as shown in Figure 1, and program accordingly. Your MIDlets should release important device resources when they're paused, and reallocate or restart those resources when the MIDlet is resumed. Any players that are rendering content when a MIDlet is paused should be stopped – your user won't thank you if the William Tell Overture plays all the way through an important business call.

Figure 1: A Well-Behaved MIDlet

Comparing MMAPI and the MIDP 2.0 Media API

The MIDP 2.0 Media API is a direct subset of MMAPI, intended for devices with very limited resources running MIDP 2.0 – although the same subset can also be adopted by other J2ME profiles requiring sound support. This API fulfills the requirements set by the MIDP expert group, including:

  • Low-footprint audio playback
  • No dependence on particular protocols or content formats
  • Support for tone generation
  • Support for general media flow controls such as start, stop, seek, etc.
  • Support for media type-specific controls such as volume
  • Support for capability query

As a result of these requirements, the MIDP 2.0 Media API differs from MMAPI in several ways:

  • It's audio-only; it excludes all Controls specific to video or graphics.
  • It doesn't support synchronizing simultaneous playback of multiple Players using a common time base.
  • It doesn't support custom protocols by way of custom DataSources; the javax.microedition.media.protocol package is excluded.
  • A simplified version of Manager is used.

Comparing MMAPI and Advanced Multimedia Supplements

JSR 135 introduced basic playback functionality for audio and video. JSR 234, Advanced Multimedia Supplements, will support recent hardware innovations by defining an optional package for advanced multimedia functionality. The new APIs will rely on and add to the features of MMAPI in J2ME/CLDC environments. The aim is to offer better support for camera and radio, as well as access to advanced audio processing. Some of the capabilities described in the specification:

  • Access to camera-specific controls such as brightness and contrast, flash, lighting modes, and zooming
  • Proper access to radio and other channel- and frequency-based media sources, including radio data systems
  • Access to advanced audio processing capabilities like an equalizer and audio effects
  • Media output direction, the ability to choose whether audio is played through a speaker or headset

Conclusion

The MMAPI optional package provides some nice functionality not previously available to applications running on MIDP-enabled devices. Its extensible architecture creates an opportunity to bring still more capabilities to mobile devices. This article described the main components of the Mobile Media API, discussed the changes in its 1.1 release, and explained the relationships between MMAPI, the MIDP 2.0 Media API, and the Advanced Multimedia Supplements. If you'd like to see MMAPI in action, download the J2ME Wireless Toolkit 2.2 and explore the projects mmademo and Audiodemo.

For More Information

Acknowledgments

Special thanks to Vincent Hardy of Sun Microsystems, whose feedback helped me improve this article.

About the Author

Qusay H. Mahmoud provides Java technology consulting and training services. He has published dozens of articles on Java mobile technology, and is the author of Distributed Programming with Java (Manning Publications, 1999) and Learning Wireless Java (O'Reilly, 2002).




Reader Feedback
Excellent   Good   Fair   Poor  

If you have other comments or ideas for future technical tips, please type them here:

Comments:
If you would like a reply to your comment, please submit your email address:
Note: We may not respond to all submitted comments.

Have a question about Java programming? Use Java Online Support.



Back To Top