Levels of Usage of the JMF API

The JMF affords the user a range of programming opportunities. These extend from using the JMF without ever writing a single line of code (using JMFStudio), through simple player programming as found in the example at the end of this chapter, all the way to extending the capabilities of the JMF by adding new formats, effects, or codecs (as discussed in Chapter 9).

This has two implications. First, it is possible to take a minimalist approach in learning the JMF: learning only the necessary features for the application required while still achieving the desired effect. Second, it is possible to learn the JMF in layers—starting with the easier concepts and applications and slowly delving into the underlying structure and complexity as and when it becomes desirable.

This part's chapters follow an approach of moving from a simple to a more complicated utilization of the API. The following subsections identify some of the most common levels of utilization that occur, though typically an individual's usage and knowledge don't correspond exactly to any of the following four categories.

Out of the Box with JMStudio

As a demonstration of the capabilities inherent in the JMF API, Sun has included an application known as JMStudio (Java Media Studio) in the JMF 2.1.1 bundle. The class file is found with all the classes from the JMF API in the file jmf.jar. Running the application is as simple as java JMStudio.

Despite its innocuous appearance (see Figure 7.13), JMStudio is a powerful application that supports playback, capture, transmission, and transcoding. In these later aspects of capture, transmission, and transcoding, it far exceeds the capabilities of free players, although as noted previously the JMF doesn't support all possible video and audio formats. (In particular, the important formats of RealMedia, Sorensen, and divX aren't to be found, whereas MPEG-2 and MPEG-4 are expected to appear in the next release.)

Figure 7.13. The innocuous appearing, yet extremely versatile, JMStudio application that comes as part of the JMF 2.1.1 distribution.


A complete discussion of JMStudio is beyond the scope of this part. Sun maintains documentation on the application at http://www.java.sun.com/products/java-media/jmf/2.1.1/jmstudio/jmstudio.html. Although JMStudio is chiefly a proof of concept, it is worth enumerating the functionality it provides because it is often more convenient to use JMStudio to perform a task (such as transcode between two formats) than write a one-off piece of code to carry out the same thing.

The features of JMStudio include

  • Support for multiple content types (architectures) and codecs.

  • Play audio and video.

    • From local file

    • From URL

    • From an RTP stream

  • Capture audio or video from devices connected to computer.

  • Export (transcode) media to a file.

  • Transmit media via RTP.

  • View the plugins (and progress there of) currently processing a media object.

In addition to all the functionality listed previously, this last feature is particularly useful for those wanting to learn about the API itself. By invoking the PlugIn Viewer, it is possible to see the individual objects chained together to form the processing, as well as observe such statistics as the frame rate and size. Figure 7.14 shows the PlugIn Viewer as a QuickTime video (encoded with the Cinepak codec) is decoded for play.

Figure 7.14. JMF's PlugIn Viewer in action.


Those only wanting to use the JMF indirectly through JMStudio will likely have sufficient knowledge by reading this chapter. However, reading the main portions of at least the following chapter will convey a far deeper understanding of how the JMF API works.

Simple Players

One of the common usages of the JMF is to incorporate audio or video play into an applet or application. As you will see with the example at the end of this chapter, that is a relatively painless and straightforward task. JMF provides a centralized manager from which can be obtained a player capable of dealing with a particular media object (content type and format). The player operates under a similar model to that of a modern VCR/DVD player: It can be started and stopped, as well as having its rate of play changed.

Programming at this level requires an understanding of the key concepts of the JMF (such as its model of time) together with the knowledge of some of the central classes in the API.

Those wanting to program the JMF at this level will likely only need to consult this and the earlier portions of the Chapter 8. However the deeper the knowledge of the API, the more subtle and complete control can be exercised over any players created. Further, if streaming capabilities are required, the first half of Chapter 9 will also need to be consulted.

Processing: Getting Under the Hood

The JMF provides powerful features for processing time-based media, including multiplexing, demultiplexing, transcoding, saving to a file, and so on. Although many users of the JMF will start off initially satisfied with simpler player applications, it is likely that a significant portion will move into these areas of more sophistication.

Processing is the topic of Chapter 8, and hence it serves as core material for those wanting to utilize the JMF in this manner. In addition, it is likely that most of the material covered in Chapter 9 will also be relevant to users with such applications in mind.

Extending the API, and Interfacing with Other APIs

The most sophisticated levels of usage of the JMF fall into two categories. The first category involves extending the API. The JMF is designed to be extensible so that users can write their own codecs, formats, effects, and so on and thus expand the JMF to suit their needs and constraints. This level of programming requires a strong familiarity with the API as well as the specialized knowledge concerning the feature being added. It is one of the topics covered in Chapter 9.

The second category involves employing the JMF as part of a larger, integrated application in which the processing can be chained or synchronized. An example of such an application includes feeding a JMF video into a Java 3D virtual world. Such applications have great potential, but require the programmer to have familiarity with all the APIs concerned. This synergy between APIs is covered in part (from a JMF perspective) in Chapter 9, and is the topic of Chapter 14, “Integrating Across the Java Media API.”

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

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