org.xiph.speex.spi
Class SpeexAudioFileReader

java.lang.Object
  extended byjavax.sound.sampled.spi.AudioFileReader
      extended byorg.xiph.speex.spi.SpeexAudioFileReader

public class SpeexAudioFileReader
extends javax.sound.sampled.spi.AudioFileReader

Provider for Speex audio file reading services. This implementation can parse the format information from Speex audio file, and can produce audio input streams from files of this type.

Version:
$Revision: 1.9 $
Author:
Marc Gimpel, Wimba S.A. (marc@wimba.com)

Field Summary
static int OGG_HEADERSIZE
           
static java.lang.String OGGID
          The String that identifies the beginning of an Ogg packet.
static int SEGOFFSET
           
static int SPEEX_HEADERSIZE
          The size of the Speex header.
static java.lang.String SPEEXID
          The String that identifies the beginning of the Speex header.
 
Constructor Summary
SpeexAudioFileReader()
           
 
Method Summary
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
          Obtains the audio file format of the File provided.
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
          Obtains an audio input stream from the input stream provided.
protected  javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream bitStream, java.io.ByteArrayOutputStream baos, int mediaLength)
          Return the AudioFileFormat from the given InputStream.
protected  javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream, int medialength)
          Return the AudioFileFormat from the given InputStream.
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
          Obtains an audio input stream from the URL provided.
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
          Obtains an audio input stream from the File provided.
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
          Obtains an audio input stream from the input stream provided.
protected  javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream inputStream, int medialength)
          Obtains an audio input stream from the input stream provided.
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
          Obtains an audio input stream from the URL provided.
private static int readInt(byte[] data, int offset)
          Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OGG_HEADERSIZE

public static final int OGG_HEADERSIZE
See Also:
Constant Field Values

SPEEX_HEADERSIZE

public static final int SPEEX_HEADERSIZE
The size of the Speex header.

See Also:
Constant Field Values

SEGOFFSET

public static final int SEGOFFSET
See Also:
Constant Field Values

OGGID

public static final java.lang.String OGGID
The String that identifies the beginning of an Ogg packet.

See Also:
Constant Field Values

SPEEXID

public static final java.lang.String SPEEXID
The String that identifies the beginning of the Speex header.

See Also:
Constant Field Values
Constructor Detail

SpeexAudioFileReader

public SpeexAudioFileReader()
Method Detail

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Obtains the audio file format of the File provided. The File must point to valid audio file data.

Parameters:
file - the File from which file format information should be extracted.
Returns:
an AudioFileFormat object describing the audio file format.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.

Parameters:
url - the URL for which the AudioInputStream should be constructed.
Returns:
an AudioInputStream object based on the audio file data pointed to by the URL.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
Obtains an audio input stream from the input stream provided.

Parameters:
stream - the input stream from which the AudioInputStream should be constructed.
Returns:
an AudioInputStream object based on the audio file data contained in the input stream.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioFileFormat

protected javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream,
                                                                 int medialength)
                                                          throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                 java.io.IOException
Return the AudioFileFormat from the given InputStream.

Parameters:
stream - the input stream from which the AudioInputStream should be constructed.
medialength -
Returns:
an AudioInputStream object based on the audio file data contained in the input stream.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioFileFormat

protected javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream bitStream,
                                                                 java.io.ByteArrayOutputStream baos,
                                                                 int mediaLength)
                                                          throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                 java.io.IOException
Return the AudioFileFormat from the given InputStream. Implementation.

Parameters:
bitStream -
baos -
mediaLength -
Returns:
an AudioInputStream object based on the audio file data contained in the input stream.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Obtains an audio input stream from the File provided. The File must point to valid audio file data.

Parameters:
file - the File for which the AudioInputStream should be constructed.
Returns:
an AudioInputStream object based on the audio file data pointed to by the File.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.

Parameters:
url - the URL for which the AudioInputStream should be constructed.
Returns:
an AudioInputStream object based on the audio file data pointed to by the URL.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data.

Parameters:
stream - the input stream from which the AudioInputStream should be constructed.
Returns:
an AudioInputStream object based on the audio file data contained in the input stream.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

getAudioInputStream

protected javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream inputStream,
                                                                   int medialength)
                                                            throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                   java.io.IOException
Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data.

Parameters:
inputStream - the input stream from which the AudioInputStream should be constructed.
medialength -
Returns:
an AudioInputStream object based on the audio file data contained in the input stream.
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if the File does not point to a valid audio file data recognized by the system.
java.io.IOException - if an I/O exception occurs.

readInt

private static int readInt(byte[] data,
                           int offset)
Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).

Parameters:
data - the data to read.
offset - the offset from which to start reading.
Returns:
the integer value of the reassembled bytes.


Copyright © 1999-2004 Wimba S.A. All Rights Reserved.