Discovering All Installed Components

I hope that by this point you’re at least a little interested in what other kinds of components are available in QuickTime. It’s easy to discover them all, in much the same way we discovered the various MovieExporters and GraphicExporters: by providing a ComponentDescription template and using ComponentIdentifier.find( ). With a “blank” template, all components can be revealed.

How do I do that?

Example 4-4 discovers all installed components and logs their type, subtype, and description to standard out.

Example 4-4. Discovering all installed components

package com.oreilly.qtjnotebook.ch04;
 
import quicktime.*;
import quicktime.std.*;
import quicktime.std.comp.*;
import quicktime.util.QTUtils;
 
import com.oreilly.qtjnotebook.ch01.QTSessionCheck;
 
public class ComponentTour {
 
  public static void main (String[  ] args) {
      try {
          QTSessionCheck.check( );
          /* use this wildcard to show all components in QT
          */
          ComponentDescription wildcard =
              new ComponentDescription( ); 
          ComponentIdentifier ci = null;
          while ( (ci = ComponentIdentifier.find(ci, wildcard)) != null) {
              ComponentDescription cd = ci.getInfo( );
              System.out.println (cd.getName( ) + 
                                  " (" + 
                                  QTUtils.fromOSType (cd.getType( )) +
                                  "/" +
                                  QTUtils.fromOSType (cd.getSubType( )) +
                                  ") " + 
                                  cd.getInformationString( ));
          }
          
      } catch (QTException qte) {
          qte.printStackTrace( );
      }
  }
 
}

The resulting output is hundreds of lines long, looking something like this:

run-ch04-componenttour:
 [java] Apple MP3 Decoder (adec/.mp3) An AudioCodec that decodes MPEG-1, MPEG-2, 
MPEG-2.5 Layer III into linear PCM data
 [java] MPEG-4 AAC Decoder (adec/aac ) An AudioCodec that decodes MPEG-4 AAC into 
linear PCM data
 [java] Apple Lossless Decoder (adec/alac) An AudioCodec that decodes Apple Lossless 
into linear PCM data
 [java] Apple IMA4 Decoder (adec/ima4) An AudioCodec that decodes IMA4 into linear 
PCM data
 [java] MPEG-4 AAC Encoder (aenc/aac ) An AudioCodec that encodes linear PCM data 
into MPEG-4 AAC
 [java] Apple Lossless Encoder (aenc/alac) An AudioCodec that encodes linear PCM 
data into Apple Lossless
 [java] Apple IMA4 Encoder (aenc/ima4) An AudioCodec that encodes linear PCM data 
into IMA4
 [java] Applet (aplt/scpt) The component that runs script applications
 [java] Apple: AUConverter (aufc/conv) AudioConverter unit
 [java] Apple: AUVarispeed (aufc/vari) Apple's varispeed playback
[...]

What just happened?

The key is the line that gets a ComponentDescriptor via a no-arg constructor. This creates a completely blank template for ComponentIdentifier.find( ) to run against. Of course, if you just wanted to tour components of a specific type, you could pass in a type constant such as StdQTConstants.movieImportType, which would limit the search to MovieImporters, and thus indicate what kinds of formats QuickTime can import.

Documenting and explaining every kind of component is beyond the scope of this book—in fact, it filled up a whole volume of the old Inside Macintosh series. Still, a few of the important ones are listed in Table 4-1. Note that not all components have (or need) a Java wrapper class.

Table 4-1. Some important QuickTime for Java components

Type

Java wrapper class

Sample subtypes

"eat "

MovieImporter

"AVI“, "AIFF“, "MP3“, "SWF"

"spit "

MovieExporter

"VfW“, "MooV“, "mpg4"

"grip"

GraphicsImporter

"BMP“, "GIF“, "JPEG"

"grex"

GraphicsExporter

"BMP“, "JPEG"

"clok"

Clock (provides timing and callback services)

"tick“, "micr"

"mhlr"

MediaHandler

"vide“, "soun“, "text"

"imco"

None; image compressor (used for still images and video)

"jpeg“, "mp4v“, "h263"

"imdc"

None; image decompressor (used for still images and video)

"jpeg“, "mp4v“, "h263"

"rtpm"

None; real-time packetizer (used for streaming)

"263+“, "mpeg“, "mp4a“, "mp4v"

Note

Yep, “eat” and “spit” for movie importers and exporters. Hardy har har.

It’s important to remember that all types and subtypes are FOUR_CHAR_CODE s—any type or subtype seemingly shorter than that is padded with space characters.

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.