Many mobile phones today support the Mobile Media API (MMAPI) under JSR-135. Using MMAPI, you can easily develop robust and useful Java mobile video applications. In this two-part article, JavaWorld contributor Srijeeb Roy shows you how to develop and test a mobile video application using JSR-135. In Part 1 you will learn how to capture and record video content using JME (Java Micro Edition). In Part 2 you will learn how to store your video content on a server using the Generic Connection Framework (GCF) over the HTTP protocol.
Multimedia processing using MMAPI can be considered in two parts:
- Data delivery protocol handling
- Data content handling
Data delivery protocol handling involves reading data from a source (from a capture device or a file, for instance) into a media-processing system. Data content handling involves processing the media data (that is, parsing or decoding it) and rendering the media to an output device -- to a video display, for example.
MMAPI provides two high-level classes to help you with these tasks. The
javax.microedition.media.protocol.DataSource class deals with data delivery protocol handling, and the
javax.microedition.media.Player interface deals with data content handling. To help the developer, a
Manager class (
Before you continue to the hands-on portion of this article, you should download and install a JDK version 1.5 or later (1.6 or later if you're using Windows Vista) and the Sun Java Wireless Toolkit. I used Sun Java Wireless Toolkit 2.5.1 for CLDC Early Access while writing this article.
Once you've installed these packages, open the Wireless Toolkit. You will see a screen that looks like the one below.
Now click the New Project icon or choose File -> New Project. In the New Project pop-up menu, enter
MobileVideoApp as the a project name and
com.srijeeb.jme.MobileVideoApp as the MIDlet class name, as shown in Figure 2. Alternately, you can unzip the source code supplied along with this article in the <Your-WTK-Installation-Directory>/apps/MobileVideoApp directory and open the project using the Open Project option. (Throughout this tutorial, <Your-WTK-Installation-Directory> represents the directory where you installed the Wireless Toolkit.)
Once you click Create Project, a window will pop up where you can edit the project settings. You need to change the settings on the API Selection page to match our target platform. Change the Target Platform drop-down option to JTWI. Make sure that the profile is set to MIDP 2.0 and the configuration is checked as CLDC 1.0. Also, make sure the Mobile Media API (JSR 135) checkbox is checked in the Optional area. The screen will look like Figure 3. Click OK to move on.
Determining the MMAPI-related features supported by a mobile device
Before going further, it is worth mentioning that not all Java-enabled mobile devices support JSR-135, and a few that do support it don't support video recording. To help you discover the features of a mobile device related to media processing, MMAPI has provided few system properties that you can query using the
Let's begin by trying to determine the features that the mobile device we'll be executing our code on supports. For this example, I will compare results from two mobile handsets: the Nokia 3230 and the Nokia 6600. The specifications for both mobile phones claim that they support JSR-135.