Class SpeexAudioFileReader

java.lang.Object
javax.sound.sampled.spi.AudioFileReader
org.xiph.speex.spi.SpeexAudioFileReader

public class SpeexAudioFileReader extends 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.2 $
Author:
Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
  • Field Details

  • 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 class AudioFileReader
      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 class 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:
      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 class 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:
      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 class 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:
      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 class 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:
      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 class 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:
      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.