Package org.xiph.speex.spi
Class SpeexAudioFileReader
- java.lang.Object
-
- javax.sound.sampled.spi.AudioFileReader
-
- org.xiph.speex.spi.SpeexAudioFileReader
-
public class SpeexAudioFileReader extends javax.sound.sampled.spi.AudioFileReaderProvider 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.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
-
Field Summary
Fields Modifier and Type Field Description static intOGG_HEADERSIZEstatic java.lang.StringOGGIDThe String that identifies the beginning of an Ogg packet.static intSEGOFFSETstatic intSPEEX_HEADERSIZEThe size of the Speex header.static java.lang.StringSPEEXIDThe String that identifies the beginning of the Speex header.
-
Constructor Summary
Constructors Constructor Description SpeexAudioFileReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.File file)Obtains the audio file format of the File provided.javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.InputStream stream)Obtains an audio input stream from the input stream provided.protected javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.InputStream stream, int medialength)Return the AudioFileFormat from the given InputStream.protected javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.io.InputStream bitStream, java.io.ByteArrayOutputStream baos, int mediaLength)Return the AudioFileFormat from the given InputStream.javax.sound.sampled.AudioFileFormatgetAudioFileFormat(java.net.URL url)Obtains an audio input stream from the URL provided.javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.io.File file)Obtains an audio input stream from the File provided.javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.io.InputStream stream)Obtains an audio input stream from the input stream provided.protected javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.io.InputStream inputStream, int medialength)Obtains an audio input stream from the input stream provided.javax.sound.sampled.AudioInputStreamgetAudioInputStream(java.net.URL url)Obtains an audio input stream from the URL provided.private static intreadInt(byte[] data, int offset)Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
-
-
-
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
-
-
Method Detail
-
getAudioFileFormat
public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOExceptionObtains the audio file format of the File provided. The File must point to valid audio file data.- Specified by:
getAudioFileFormatin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionObtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Specified by:
getAudioFileFormatin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionObtains an audio input stream from the input stream provided.- Specified by:
getAudioFileFormatin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionReturn 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.IOExceptionReturn 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.IOExceptionObtains an audio input stream from the File provided. The File must point to valid audio file data.- Specified by:
getAudioInputStreamin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionObtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Specified by:
getAudioInputStreamin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionObtains an audio input stream from the input stream provided. The stream must point to valid audio file data.- Specified by:
getAudioInputStreamin classjavax.sound.sampled.spi.AudioFileReader- 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.IOExceptionObtains 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.
-
-