Usage
Java Advanced Audio Decoder

Java library

AAC decoder:
The AAC decoder needs to be instantiated with a DecoderSpecificInfo, which contains information about the following data. This info can be retrieved from the container, hence an AAC stream is never present without a container.
After that, the decodeFrame method can be called repeatedly to decode the frames. The resulting audio data (PCM) is stored in the SampleBuffer.

Decoder dec = new Decoder(decoderSpecificinfo);
SampleBuffer buf = new SampleBuffer();
dec.decodeFrame(aacFrame, buf);
//the aacFrame array contains the AAC frame to decode
byte[] audio = buf.getData(); //this array contains the raw PCM audio data


ADTS demultiplexer:
If the AAC data is stored in an ADTS container, the ADTSDemultiplexer can be used to parse an InputStream.

ADTSDemultiplexer adts = new ADTSDemultiplexer(inputStream);
byte[] decoderSpecificInfo = adts.getDecoderSpecificInfo();
byte[] frame;
while((frame = adts.readNextFrame())!=null) {
    //do something with the frame, e.g. pass it to the AAC decoder
}


MP4 demultiplexing API
To parse an MP4 container, you can use the net.sourceforge.jaad.mp4 package. Since the MP4 container format has many capabilities, the API supports more features than the ADTS demultiplexer. The central class is the MP4Container which can parse an InputStream.
For more features of the MP4 API, see the net.sourceforge.jaad.MP4Info class and the Javadoc.

MP4Container container = new MP4Container(inputStream);
Movie movie = container.getMovie();
List<Track> tracks = movie.getTracks(AudioTrack.AudioCodec.AAC);
if(tracks.size()>0) {
    Track track = tracks.get(0);
    byte[] decoderSpecificInfo = track.getDecoderSpecificInfo();
    byte[] frame = track.readNextFrame();
    //do something with the frame, e.g. pass it to the AAC decoder
}

Java Sound

You can also use JAAD indirectly with the Java Sound API.
When the jar-file is in your classpath, JAAD will be automatically registered as a service provider for Java Sound.
You just need to create a SourceDataLine and JAAD will be called if AAC audio data is detected.
For more information, read: http://www.oracle.com/technetwork/java/index-jsp-140234.html


Standalone application

Finally, JAAD can be used as a standalone application. The jar-Archive contains some simple command line implementations:

net.sourceforge.jaad.Main [-mp4] <infile> <outfile>decodes an AAC file to a WAV file
net.sourceforge.jaad.Play [-mp4] <infile>plays an AAC file
net.sourceforge.jaad.Radio <URL>plays an AAC radio stream from a Shoutcast/Icecast server
net.sourceforge.jaad.MP4Info [-b] <infile>prints information about an MP4 container

The optional parameter -mp4 for 'Main' and 'Play' indicates that the AAC data is stored in a MP4 container. Otherwise an ADTS container is expected.
The optional parameter -b for 'MP4Info' causes all MP4 boxes (atoms) to be printed.