Package org.xiph.speex.spi
Class SpeexAudioFileReader
java.lang.Object
javax.sound.sampled.spi.AudioFileReader
org.xiph.speex.spi.SpeexAudioFileReader
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.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAudioFileFormat
(File file) Obtains the audio file format of the File provided.getAudioFileFormat
(InputStream stream) Obtains an audio input stream from the input stream provided.protected AudioFileFormat
getAudioFileFormat
(InputStream stream, int medialength) Return the AudioFileFormat from the given InputStream.protected AudioFileFormat
getAudioFileFormat
(InputStream bitStream, ByteArrayOutputStream baos, int mediaLength) Return the AudioFileFormat from the given InputStream.getAudioFileFormat
(URL url) Obtains an audio input stream from the URL provided.getAudioInputStream
(File file) Obtains an audio input stream from the File provided.getAudioInputStream
(InputStream stream) Obtains an audio input stream from the input stream provided.protected AudioInputStream
getAudioInputStream
(InputStream inputStream, int medialength) Obtains an audio input stream from the input stream provided.getAudioInputStream
(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).
-
Field Details
-
OGG_HEADERSIZE
public static final int OGG_HEADERSIZE- See Also:
-
SPEEX_HEADERSIZE
public static final int SPEEX_HEADERSIZEThe size of the Speex header.- See Also:
-
SEGOFFSET
public static final int SEGOFFSET- See Also:
-
OGGID
The String that identifies the beginning of an Ogg packet.- See Also:
-
SPEEXID
The String that identifies the beginning of the Speex header.- See Also:
-
-
Constructor Details
-
SpeexAudioFileReader
public SpeexAudioFileReader()
-
-
Method Details
-
getAudioFileFormat
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException Obtains the audio file format of the File provided. The File must point to valid audio file data.- Specified by:
getAudioFileFormat
in classAudioFileReader
- Parameters:
file
- the File from which file format information should be extracted.- Returns:
- an AudioFileFormat object describing the audio file format.
- Throws:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioFileFormat
public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Specified by:
getAudioFileFormat
in classAudioFileReader
- 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioFileFormat
public AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException Obtains an audio input stream from the input stream provided.- Specified by:
getAudioFileFormat
in classAudioFileReader
- 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioFileFormat
protected AudioFileFormat getAudioFileFormat(InputStream stream, int medialength) throws UnsupportedAudioFileException, 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioFileFormat
protected AudioFileFormat getAudioFileFormat(InputStream bitStream, ByteArrayOutputStream baos, int mediaLength) throws UnsupportedAudioFileException, 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioInputStream
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException Obtains an audio input stream from the File provided. The File must point to valid audio file data.- Specified by:
getAudioInputStream
in classAudioFileReader
- 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioInputStream
public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Specified by:
getAudioInputStream
in classAudioFileReader
- 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioInputStream
public AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data.- Specified by:
getAudioInputStream
in classAudioFileReader
- 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.IOException
- if an I/O exception occurs.
-
getAudioInputStream
protected AudioInputStream getAudioInputStream(InputStream inputStream, int medialength) throws UnsupportedAudioFileException, 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:
UnsupportedAudioFileException
- if the File does not point to a valid audio file data recognized by the system.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.
-