hu.netmind.ogg
Class OggInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by hu.netmind.ogg.OggInputStream
All Implemented Interfaces:
java.io.Closeable

public class OggInputStream
extends java.io.InputStream

This is the starting point for decoding an ogg stream. From an instance of this class, initialized with an ogg input stream, logical streams may be acquired and decoded.
To get logical streams from this ogg stream, there are several methods, which all are compatible with eachother:


Each logical stream will block until data becomes available for them, note also, that data will arrive in the same order as encoded, so a logical stream may block until the data before it is read from another logical stream. All newly returned logical streams will have extacly one packet data already in them (the header packet), so it is guaranteed, that the first packet read will not block.


Constructor Summary
OggInputStream(java.io.InputStream stream)
          Construct the ogg stream with an input stream.
 
Method Summary
 int available()
          Method is proxied to given stream.
 void close()
          Close this stream.
 LogicalStreamListener getListener()
           
 LogicalInputStream getLogicalInputStream()
          Get the next logical stream.
 java.util.Collection getLogicalInputStreams()
          Get all logical streams which are currently available without blocking.
 boolean isLogicalStreamAvailable()
          Ask whether the next call to getLogicalInputStream() will block or not.
 int read()
          Method is proxied to given stream.
 int read(byte[] b)
          Method is proxied to given stream.
 int read(byte[] b, int offset, int length)
          Method is proxied to given stream.
 void setListener(LogicalStreamListener listener)
           
 void waitForClose()
          This method blocks until the end of stream is reached.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OggInputStream

public OggInputStream(java.io.InputStream stream)
               throws java.io.IOException
Construct the ogg stream with an input stream.

Parameters:
stream - The stream to decode as an ogg stream.
Throws:
java.io.IOException - If pre-read fails.
Method Detail

isLogicalStreamAvailable

public boolean isLogicalStreamAvailable()
Ask whether the next call to getLogicalInputStream() will block or not.

Returns:
True, if the next call to getLogicalInputStream() will not block.

getLogicalInputStream

public LogicalInputStream getLogicalInputStream()
Get the next logical stream. If none is available, this method blocks until one becomes available, or stream is closed.

Returns:
The logical input stream read, or null if stream ended.

waitForClose

public void waitForClose()
This method blocks until the end of stream is reached. This method is useful, if you have a listener registered, and want to block the main thread until all logical streams ended processing.
Note:You cannot use the getLogicalInputStream(), and isLogicalStreamAvailable() methods, when using this method.


getLogicalInputStreams

public java.util.Collection getLogicalInputStreams()
                                            throws java.io.IOException
Get all logical streams which are currently available without blocking.

Returns:
A collection of logical streams, possibly empty.
Throws:
java.io.IOException - If an I/O error occurs.

close

public void close()
           throws java.io.IOException
Close this stream. This method closes the original input stream too.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - If an I/O error occurs.

available

public int available()
              throws java.io.IOException
Method is proxied to given stream. Don't use this method, as it manipulates the physical ogg stream directly.

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException - If an I/O error occurs.

read

public int read()
         throws java.io.IOException
Method is proxied to given stream. Don't use this method, as it manipulates the physical ogg stream directly.

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException - If an I/O error occurs.

read

public int read(byte[] b)
         throws java.io.IOException
Method is proxied to given stream. Don't use this method, as it manipulates the physical ogg stream directly.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException - If an I/O error occurs.

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException
Method is proxied to given stream. Don't use this method, as it manipulates the physical ogg stream directly.

Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException - If an I/O error occurs.

getListener

public LogicalStreamListener getListener()

setListener

public void setListener(LogicalStreamListener listener)