com.jmex.audio.stream
Class OggInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.jmex.audio.stream.AudioInputStream
              extended by com.jmex.audio.stream.OggInputStream
All Implemented Interfaces:
java.io.Closeable

public class OggInputStream
extends AudioInputStream

Decompresses an Ogg file as it streams from a source.

Version:
$Id: OggInputStream.java 4133 2009-03-19 20:40:11Z blaine.dev $
Author:
Arman Ozcelik, Joshua Slack

Field Summary
 
Fields inherited from class com.jmex.audio.stream.AudioInputStream
filters
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
OggInputStream(java.net.URL resource, float length)
          Creates an OggInputStream that decompressed the specified ogg file.
 
Method Summary
 int available()
          Returns 0 after EOF is reached, otherwise always return 1.
 int getBitRate()
           
 int getChannelCount()
           
 int getDepth()
           
 OggInputStream makeNew()
           
 boolean markSupported()
          OggInputStream does not support mark and reset.
 int read()
          Reads the next byte of data from this input stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from the input stream into an array of bytes.
 int read(java.nio.ByteBuffer b, int off, int len)
          Reads up to len bytes of data from the input stream into a ByteBuffer.
 void reset()
          OggInputStream does not support mark and reset.
 long skip(long n)
          Skips over and discards n bytes of data from the input stream.
 java.lang.String toString()
          Gets information on the ogg.
 
Methods inherited from class com.jmex.audio.stream.AudioInputStream
addFilter, getLength, getResource, setLength, sniffFormat
 
Methods inherited from class java.io.FilterInputStream
close, mark, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OggInputStream

public OggInputStream(java.net.URL resource,
                      float length)
               throws java.io.IOException
Creates an OggInputStream that decompressed the specified ogg file.

Throws:
java.io.IOException
Method Detail

getBitRate

public int getBitRate()
Specified by:
getBitRate in class AudioInputStream
Returns:
the bitrate of this stream

getDepth

public int getDepth()
Specified by:
getDepth in class AudioInputStream
Returns:
the bit depth of this stream

read

public int read()
         throws java.io.IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Overrides:
read in class java.io.FilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into an array of bytes.

Overrides:
read in class java.io.FilterInputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException

read

public int read(java.nio.ByteBuffer b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from the input stream into a ByteBuffer.

Specified by:
read in class AudioInputStream
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Returns 0 after EOF is reached, otherwise always return 1.

Programs should not count on this method to return the actual number of bytes that could be read without blocking.

Overrides:
available in class java.io.FilterInputStream
Returns:
1 before EOF and 0 after EOF is reached.
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
OggInputStream does not support mark and reset. This function does nothing.

Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
OggInputStream does not support mark and reset.

Overrides:
markSupported in class java.io.FilterInputStream
Returns:
false.

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Overrides:
skip in class java.io.FilterInputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
java.io.IOException

toString

public java.lang.String toString()
Gets information on the ogg.

Overrides:
toString in class java.lang.Object

getChannelCount

public int getChannelCount()
Specified by:
getChannelCount in class AudioInputStream
Returns:
number of channels in this stream

makeNew

public OggInputStream makeNew()
                       throws java.io.IOException
Specified by:
makeNew in class AudioInputStream
Throws:
java.io.IOException