The Java Media Framework

-Dr. Michael “Spike” Barlow

The second major section of the book, Chapters 7, 8 and 9, covers time-based media (that is, video and audio) and the JMF—Java Media Framework, a Java API dedicated to the processing of time-based media.

Fundamentally, the JMF is an extension to Java for handling audio and video (audio and video being the two primary forms of time-based media). More rigorously, the JMF API (Java Media Framework Application Programming Interface) is one of the official Java Optional Packages from Sun Microsystems that extends the functionality of the core Java Platform. Included in 2D Graphics and Imaging on the Java Platform this group of Optional Packages are others that are covered in the book: Java 3D and Java Advanced Imaging (JAI).

The JMF comprises some 200 odd additional classes pertaining to the handling of time-based media. Handling is used in the broadest sense to include playback, capture, processing, and transmission, for either local media or media from a remote site, and as part of either an applet or application. Among the possibilities the API affords are platform (hardware and OS) independent video conferencing, complete audio and video editing suites, empowering the latest mobile computing such as cellular phones and PDAs (Personal Digital Assistants), and when taken in conjunction with the other media APIs, completely integrated multimedia applications written entirely in Java and running on any platform.

JMF Coverage in the Book

The three chapters in this section of the book follow a progression of simple out-of-the-box utilization of the API to sophisticated usage, such as in combination with other specialized features and APIs of Java. Hence, a linear progression through the material is recommended as the default. However, those of you possessing a familiarity with time-based media or parts of the API might want to skip some of the introductory material.

The structure of the three chapters is as follows:

  • Chapter 7, “Time-Based Media and the JMF: An Introduction”— The first chapter of the section on the JMF serves as both an introduction to time-based media in general and to the JMF API. Some of the fundamental concepts and issues for both digital audio and video are introduced. Midway through the chapter is an introduction to the JMF API in terms of its features, promise, central concepts, and main classes.

  • Chapter 8, “Controlling and Processing Media with JMF”— This chapter serves as the core chapter of the JMF section, covering the key features of the JMF API. The topics covered include managers, data sources and sinks, multiplexing and demultiplexing, codecs, format conversion, effects, and the capture of media from devices.

  • Chapter 9, “RTP and Advanced Time-Based Media Topics”— This chapter covers some of the more advanced features of the JMF API. Chief among these topics is the Real-Time Transport Protocol (RTP) support within JMF and the corresponding ability to transmit or receive streaming media such as over the Internet. Also covered are issues such as extending the API and utilizing other APIs in conjunction with JMF.

Obtaining and Installing the JMF

The JMF extends the functionality of the Java platform and is an official Optional Package. As such, it is a free download available from Sun Microsystems' Java site: http://java.sun.com. Following the Products & APIs link will present the browser with a wealth of APIs; among them, the JMF can be found under the Optional Packages heading at the bottom of the page.

Alternatively, and more directly, Sun maintains a central Web page regarding the JMF: http://java.sun.com/products/java-media/jmf/index.html. You should definitely bookmark this URL: It not only has links for downloading the latest version of the JMF, but it also links to documentation and example programs, as well as the latest JMF-related news.

Sun provides several different versions of the JMF for download. These differ in the OS platform they are intended to run on. The current version, as of the time of writing, is v2.1.1a. At the previously mentioned central site, Sun provides links for a cross-platform Java version, a Windows Performance Pack, and a Solaris SPARC Performance Pack. A link is also provided to Blackdown's JMF implementation for Linux. All versions require JDK 1.1.6 or later for full functionality. Those of you who want to obtain the JMF without possessing the JDK should download and install that first.

Although the cross-platform version is pure byte code and will run on any machine supporting Java, it is recommended that you download and install the OS specific versions that matches your OS. This is because these implementations have been optimized with native code where appropriate, and hence should run faster than the cross-platform version. Thus, those of you who are running Windows 95, 98, or NT should download the Windows Performance Pack, those of you who are running on one of Sun's UNIX machines should download the Solaris SPARC Performance Pack, and those of you who are under Linux should download Blackdown's version of the JMF for Linux. Those of you who are not employing any of these (for example, on a Macintosh) should download the cross-platform version.

Sun provides detailed and specific instructions regarding the download and installation process. Those instructions are tailored to the specific version downloaded. Following the download links will take the browser through those instructions. Thus, specific download and installation instructions are not repeated here. Installation of any version of the JMF is quite simple, consisting of self-installing executables or the equivalent. However, those of you who want detailed installation instructions can find them at http://java.sun.com/products/java-media/jmf/2.1.1/setup.html.

Following the installation process, you should check that the JMF is available for usage. One means of checking this is to attempt to run the JMStudio demonstration program that is provided as part of the JMF. Discussed further in Chapter 7, JMStudio is a powerful application that demonstrates many of the capabilities of the JMF, such as playback, capture, and processing. Running JMStudio is as simple as typing java JMStudio at your command prompt. If the JMF installed properly, a small JMStudio window will pop up from which the various functions can be selected.

An alternative means of checking whether the JMF installed correctly is to point your browser at http://java.sun.com/products/java-media/jmf/2.1.1/jmfdiagnostics.html, Sun's JMF diagnostic page. As part of the installation process, the JMF is made available to your Web browser so that JMF-based applets can be run. The preceding URL tests this feature. Similarly, http://java.sun.com/products/java-media/jmf/2.1.1/samples/index.html contains JMF-based applets that will play movie trailers, providing that the JMF is installed on your machine, and it is arguably a more exciting means of testing the functionality of the newly installed JMF.

Additional JMF-Related Resources

A number of resources pertaining to the JMF are available on the Web. Sun's central JMF page, http://java.sun.com/products/java-media/jmf/index.html, acts as a clearing house for many, but not all, of these additional resources.

Two key resources that anyone undertaking serious JMF programming should possess are the API (class) documentation and the Programmer's Guide from Sun. The API documentation is a class-by-class description of the API. The Programmer's Guide is a comprehensive introduction to the API from its authors. Both these documents can be browsed online or downloaded to a user's machine. Both the online and downloadable version of these documents can be found linked from Sun's central JMF page.

Other resources at Sun's site include excellent sample programs, source code for the JMF itself and JMStudio, as well as user guides for JMStudio and JMFRegistry.

Sun maintains a free mailing list: jmf-interest, for those wanting to discuss the JMF. The details for subscribing to and posting to the list can be found at the following URL: http://java.sun.com/products/java-media/jmf/support.html. (It is also linked from Sun's main JMF site.) Joining the list is highly recommended for those undertaking programming in the JMF—the list is a small but helpful community with relatively low traffic (typically fewer than a dozen messages a day) with Sun engineers periodically monitoring and posting on the list. The list's past archives, found at http://archives.java.sun.com/archives/jmf-interest.html, contain a wealth of information.

Finally, it is worth noting that although the JMF comes with many audio and video codecs (the compression schemes that are used for audio and video and which dictate its format), further codecs can be installed. These additional codecs then expand the functionality of the JMF—JMF is then able to handle media of that format. Two popular codecs of note, MPEG-4 and DivX, can be incorporated into the JMF in this manner. IBM, through its AlphaWorks division, has provided an implementation of MPEG-4 for the JMF at http://www.alphaworks.ibm.com/tech/mpeg-4. DivX support, currently a popular video format on the Internet because its high compression and good visual quality, can be incorporated into the JMF by downloading the DivX codec from the DivX home page: http://www.divx.com/.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset