Preface

Java has been a huge success in many fields—distributed enterprise applications, mobile phones, web applications—but one field that it has clearly flopped in is media. A sound API, javax.sound, suffices for simple playback and mixing of a handful of old formats, and was added to the Java core (the classes any Java runtime must include) in Java 2 Standard Edition (J2SE) 1.3. The optional package for media, Java Media Framework (JMF), fared much worse. After two releases, a 1.0 that provided only playback and a 2.0 that added streaming, transcoding, and some lower-level access, the product was slipped into maintenance mode and has seen little attention since 1999. In fact, the most monumental change to JMF in this time was the loss of a feature: MP3 support was removed in 2002, due to licensing concerns. Making things worse, JMF’s all-Java version had weak support for popular formats and codecs. Native editions could play more media, but Sun initially created versions only for Windows and Solaris, later providing minimal support to a third-party Linux port and absolutely no support for a Mac version. Setting aside the dubious premise of Solaris as a media production OS, this effectively made JMF practical only on Windows, eliminating Java’s cross-platform advantage.

Enter QuickTime, a multimedia framework originally introduced by Apple for the (“Classic”) Mac OS in late 1991. QuickTime defines both a file format (the QuickTime .mov format) and many APIs for working with time-based media. The provided functions allow applications to create media (either synthetically or via capture), manipulate it, and present it. Media types supported by QuickTime include sound and video, timed text (captions), graphics, interactivity, and a panoramic-image style of virtual reality (VR).

Unfortunately, despite having an industry-leading multimedia framework, in 1998 there was no straightforward means of exposing QuickTime to Java developers. And whereas most APIs start with an interface and then gain a reference implementation, Apple had an implementation and the native QuickTime libraries, but no Java interface. Compounding the problem, QuickTime was designed to be called from C (sometimes called “straight C” or “procedural C”) and thus lacked the object orientation a Java interface would call for.

Enter Biscotti

Apple’s “Biscotti” project took a remarkable approach to this problem—not only did the Biscotti designers provide a Java layer to make QuickTime calls, but they also fashioned an object-oriented API out of a non-OO framework. It helps that QuickTime is made up of a number of fairly elaborate structures, along with functions that work with them. The Biscotti designers saw that these structures could be combined into Java objects. For example, they took the Movie struct and many of the functions that worked with a movie, and fashioned these into the quicktime.std.Movie class. Functions such as StartMovie( ), StopMovie( ), CopyMovieSelection( ), and PasteMovieSelection( ) became the Java instance methods start( ), stop( ), copySelection( ), and pasteSelection( ), respectively. Biscotti, now known as QuickTime for Java, still has its quirks, but it’s a lot more Java-like than some other “wrapper” frameworks for Java.

Note

By comparison, the JOGL API, which offers a Java wrapper to the OpenGL graphics library, simply dumps the functions defined in the C header files into pseudo-objects with upward of 2,000 methods each!

Whatever Apple’s reasons for creating QuickTime for Java (QTJ), the application has been the beneficiary of many fortuitous advances. The most significant comes from QTJ’s nature as a Java wrapper around a native framework: as the native QuickTime grows, so does QTJ. In particular, when QuickTime supports a new format or codec, it is almost always available to QTJ immediately, without requiring any new QTJ development. When QuickTime added MPEG-4 support, QTJ picked it up for free. When Apple started selling songs on the iTunes Music Store, QTJ was able to play the encrypted AAC audio files right away.

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.