QuickTime for Java
Encyclopedia
QuickTime for Java or QTJ is a software library that allows software written in the Java programming language
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 to provide multimedia
Multimedia
Multimedia is media and content that uses a combination of different content forms. The term can be used as a noun or as an adjective describing a medium as having multiple content forms. The term is used in contrast to media which use only rudimentary computer display such as text-only, or...

 functionality, by making calls into the native QuickTime
QuickTime
QuickTime is an extensible proprietary multimedia framework developed by Apple Inc., capable of handling various formats of digital video, picture, sound, panoramic images, and interactivity. The classic version of QuickTime is available for Windows XP and later, as well as Mac OS X Leopard and...

 library. In practice, it allows Java applications on Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

, Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 and Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 to support the capture, editing, playback, and export of many different media formats and codecs
Codec
A codec is a device or computer program capable of encoding or decoding a digital data stream or signal. The word codec is a portmanteau of "compressor-decompressor" or, more commonly, "coder-decoder"...

.

QTJ has been deprecated by Apple.

History

Owen W. Linzmayer, in Apple Confidential 2.0, traces QuickTime for Java's genesis back to Kaleida Labs
Kaleida Labs
Kaleida Labs was one of several joint ventures between Apple Computer and IBM in a period of alliance between the two companies during the early 1990s. The two computer giants sought to counter the influence of Microsoft and the growing dominance of its Windows operating system...

, a spin-off company created by Apple Computer
Apple Computer
Apple Inc. is an American multinational corporation that designs and markets consumer electronics, computer software, and personal computers. The company's best-known hardware products include the Macintosh line of computers, the iPod, the iPhone and the iPad...

 and IBM
IBM
International Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...

, noting that it and some Unicode text classes were the only Mac software salvaged from the four-year, $150 million disaster. Ported to the Mac OS, it was developed under the code-name "Biscotti", and first released as a public beta in 1999. . Later versions were installed by default with Mac OS and Mac OS X, and was an optional part of the QuickTime install for Windows. As of QuickTime 7, QTJ is part of the standard QuickTime install on Windows, and QuickTime itself is installed by default with iTunes
ITunes
iTunes is a media player computer program, used for playing, downloading, and organizing digital music and video files on desktop computers. It can also manage contents on iPod, iPhone, iPod Touch and iPad....

.

QTJ 6.1

In 2003, Apple issued a Java 1.4.1 implementation that broke any QTJ applications that tried to run under 1.4.1 on Mac OS X. The underlying problem was Apple's move from Carbon
Carbon (API)
Carbon is one of Apple Inc.'s procedural application programming interfaces for the Macintosh operating system. It provides C programming language access to Macintosh system services...

 to Cocoa
Cocoa (API)
Cocoa is Apple's native object-oriented application programming interface for the Mac OS X operating system and—along with the Cocoa Touch extension for gesture recognition and animation—for applications for the iOS operating system, used on Apple devices such as the iPhone, the iPod Touch, and...

 for their AWT
Abstract Window Toolkit
The Abstract Window Toolkit is Java's original platform-independent windowing, graphics, and user-interface widget toolkit. The AWT is now part of the Java Foundation Classes — the standard API for providing a graphical user interface for a Java program.AWT is also the GUI toolkit for a...

 implementation, and the removal of a Java-to-native library called "JDirect" that QTJ relied on. QTJ applications could still run under Java 1.3.1, but apps that did not specify the version of Java they required, or that needed 1.4 features, were rendered unusable.

Later that year, Apple released a new version of QTJ that dealt with the incompatibilities, by offering a compatible but scaled-down version of the GUI classes. This 6.1 version of QTJ also radically changed the API, so that instead of having developers create GUI components and associate Movies or other renderable objects with them, the developers now needed to start with the Movie and request a suitable component from a factory. The new version also neglected to provide a component to show a visual preview of the input from a capture device, such as a webcam
Webcam
A webcam is a video camera that feeds its images in real time to a computer or computer network, often via USB, ethernet, or Wi-Fi.Their most popular use is the establishment of video links, permitting computers to act as videophones or videoconference stations. This common use as a video camera...

 or camcorder
Camcorder
A camcorder is an electronic device that combines a video camera and a video recorder into one unit. Equipment manufacturers do not seem to have strict guidelines for the term usage...

.

Design

QTJ lays an object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 API on top of the native C-based QuickTime library. It does this by associating common structs and the functions that work with them into classes. For example, the Movie struct is the basis of the class quicktime.std.movies.Movie, with functions like NewMovieFromFile and GetMovieTrackCount becoming the instance methods fromFile and getTrackCount respectively. The result is more like a genuine object-oriented API than other C-to-Java adaptations (such as JOGL
Java OpenGL
Java OpenGL is a wrapper library that allows OpenGL to be used in the Java programming language. It was originally developed by Kenneth Bradley Russell and Christopher John Kline, and was further developed by the Sun Microsystems Game Technology Group. Since 2010, it has been an independent open...

, which dumps the OpenGL header file
Header file
Some programming languages use header files. These files allow programmers to separate certain elements of a program's source code into reusable files. Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers...

s into classes with thousands of static methods).

The Cocoa-based QTKit is a similar attempt to put an object-oriented layer atop the procedural QuickTime library, using Objective-C
Objective-C
Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it...

.

Apple's use of the top-level package
Java package
A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula. Java packages can be stored in compressed files called JAR files, allowing classes to download faster as a group rather than one at a time...

 name quicktime violates the Java Language's Specification convention that packages use a reverse-domain-name scheme, such as com.apple.quicktime. However, as Apple owns the "QuickTime" trademark, there is no realistic chance of a namespace
Namespace
In general, a namespace is a container that provides context for the identifiers it holds, and allows the disambiguation of homonym identifiers residing in different namespaces....

 collision, the prevention of which is the purpose of the package naming convention.

It is important to remember that QTJ is not a Java implementation of QuickTime, it is a Java wrapper around native QuickTime calls. For this reason, it can only run on systems that have the QuickTime libraries installed, namely the classic Mac OS (which is no longer supported), Mac OS X, and Windows.

Features

QTJ offers access to most of the native QuickTime library, including
  • Playback
  • Editing
  • Capture
  • Graphic import and export
  • Movie import and export
  • Sample-level access


As a wrapper around QuickTime, QTJ also inherits support for a vast collection of media formats and codecs, including MPEG-1
MPEG-1
MPEG-1 is a standard for lossy compression of video and audio. It is designed to compress VHS-quality raw digital video and CD audio down to 1.5 Mbit/s without excessive quality loss, making video CDs, digital cable/satellite TV and digital audio broadcasting possible.Today, MPEG-1 has become...

, MPEG-4
MPEG-4
MPEG-4 is a method of defining compression of audio and visual digital data. It was introduced in late 1998 and designated a standard for a group of audio and video coding formats and related technology agreed upon by the ISO/IEC Moving Picture Experts Group under the formal standard ISO/IEC...

, H.264
H.264/MPEG-4 AVC
H.264/MPEG-4 Part 10 or AVC is a standard for video compression, and is currently one of the most commonly used formats for the recording, compression, and distribution of high definition video...

, AAC
Advanced Audio Coding
Advanced Audio Coding is a standardized, lossy compression and encoding scheme for digital audio. Designed to be the successor of the MP3 format, AAC generally achieves better sound quality than MP3 at similar bit rates....

, Sorenson Video
Sorenson codec
Sorenson codec may refer to either of three proprietary video codecs: Sorenson Video, Sorenson Video 3 or Sorenson Spark. Sorenson Video is also known as Sorenson Video Codec, Sorenson Video Quantizer or SVQ...

, Flash
FLV
Flash Video is a container file format used to deliver video over the Internet using Adobe Flash Player versions 6–11. Flash Video content may also be embedded within SWF files. There are two different video file formats known as Flash Video: FLV and F4V. The audio and video data within FLV files...

, 3GPP
3GPP
The 3rd Generation Partnership Project is a collaboration between groups of telecommunications associations, known as the Organizational Partners...

, WAV
WAV
Waveform Audio File Format , is a Microsoft and IBM audio file format standard for storing an audio bitstream on PCs...

, AIFF
AIFF
Audio Interchange File Format is an audio file format standard used for storing sound data for personal computers and other electronic audio devices...

, and more. Since QuickTime itself can be extended, QTJ can pick up support for formats such as DivX
DivX
DivX is a brand name of products created by DivX, Inc. , including the DivX Codec which has become popular due to its ability to compress lengthy video segments into small sizes while maintaining relatively high visual quality.There are two DivX codecs; the regular MPEG-4 Part 2 DivX codec and the...

 and Ogg Vorbis through the use of third-party QuickTime components.

Code Example

The following example shows an AWT file-selection dialog and then tries to import and play the selected media file.


import java.io.File;
import java.awt.*;

import quicktime.*;
import quicktime.std.movies.Movie;
import quicktime.app.view.QTFactory;
import quicktime.io.*;

public class TrivialQTJPlayer extends Frame {

public static void main (String[] args) {
try {
QTSession.open;
Frame f = new TrivialQTJPlayer;
f.pack;
f.setVisible (true);
} catch (Exception e) {
e.printStackTrace;
}
}
public TrivialQTJPlayer
throws QTException {
FileDialog fd = new FileDialog
(this, "TrivialJMFPlayer", FileDialog.LOAD);
fd.setVisible(true);
File f = new File (fd.getDirectory, fd.getFile);
OpenMovieFile omf = OpenMovieFile.asRead (new QTFile (f));
Movie m = Movie.fromFile (omf);
Component c = QTFactory.makeQTComponent(m).asComponent;
add (c);
m.start;
}
}


Most of the code in this example involves itself with setting up the GUI. The only calls to QTJ are the calls to OpenMovieFile.asRead and Movie.fromFile, which create a QuickTime movie from the specified file, and the calls to create an AWT component from the QTFactory. This example puts the movie into the frame and immediately starts playing it; if a control bar (aka a "scrubber") were desired, you would create a MovieController from the Movie and then create a component from the controller, rather than from the movie.

Status and Outlook

QTJ's acceptance is limited by its nature as a wrapper around Apple's proprietary QuickTime library. It does not exist for any platform other than Mac and Windows, and cannot until and unless Apple ports QuickTime to another platform, such as Linux.

Currently most of QTJ is broken on recent windows-running computers. Windows machines that use the no-execute (NX) page-protection security feature of recent CPUs cannot run even the demos without changing the configuration. This can be easily verified by a developer via a test-run of one of the demos coming with QTJ. An "execution protection violation" is reported and the program is aborted by Windows. This renders QTJ unsuitable for end-user application development due to the necessary complicated configuration of the NX feature.

Following the 2003 release of QTJ 6.1, Apple has made few updates to QTJ, mostly fixing bugs. Notably, QuickTime 7 was the first version of QuickTime not to be accompanied or followed by a QTJ release that wrapped the new native API's. QuickTime 7's new API's, such as those for working with metadata and with frame-reordering codecs, are not available to QTJ programmers. Apple has also not offered new classes to provide the capture preview functionality that was present in versions of QTJ prior to 6.1. Indeed, QTJ is dependent on some native API's that Apple no longer recommends, most notably QuickDraw
QuickDraw
QuickDraw is the 2D graphics library and associated Application Programming Interface which is a core part of the classic Apple Macintosh operating system. It was initially written by Bill Atkinson and Andy Hertzfeld. QuickDraw still exists as part of the libraries of Mac OS X, but has been...

.

See also

  • Java Media Framework
    Java Media Framework
    The Java Media Framework is a Java library that enables audio, video and other time-based media to be added to Java applications and applets...

  • Xuggler - Java API for video encoding and decoding that works on Mac, Linux and Windows.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK