hu.netmind.ogg
Class LogicalInputStream

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

public class LogicalInputStream
extends java.io.InputStream

A logical input stream is a single encoded media stream multiplexed into an ogg stream possibly with other logical streams.


Method Summary
 void close()
          Close this stream.
 long getGranulePosition()
          Get the current granule position of stream.
 byte[] getHeaderPacket()
          Get the header packet of this logical stream.
 int read()
          Read one byte from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream.
 int read(byte[] b)
          Read some bytes from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream.
 int read(byte[] b, int offset, int length)
          Read some bytes from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream.
 byte[] readPacket()
          Read a packet from the logical stream.
Note:If the packet was already read via the byte-wise read methods, this method returns the rest of the packet.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHeaderPacket

public byte[] getHeaderPacket()
                       throws java.io.IOException
Get the header packet of this logical stream. This header packet is identical to the first packet read with readPacket().

Throws:
java.io.IOException - If header packet does not exist.

close

public void close()
           throws java.io.IOException
Close this stream. This method does nothing, close the originator ogg input stream to free resources.

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.

read

public int read()
         throws java.io.IOException
Read one byte from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream. Use only if packet boundaries do not matter.

Specified by:
read in class java.io.InputStream
Returns:
The byte read, or -1 to indicate end of file.
Throws:
java.io.IOException - If an I/O error occurs.

getGranulePosition

public long getGranulePosition()
Get the current granule position of stream.

Returns:
The granule position of stream as given in ogg stream.

read

public int read(byte[] b)
         throws java.io.IOException
Read some bytes from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream. Use only if packet boundaries do not matter.

Overrides:
read in class java.io.InputStream
Parameters:
b - The buffer to fill.
Returns:
The number of bytes read, with -1 indicating end of stream.
Throws:
java.io.IOException - If an I/O error occurs.

read

public int read(byte[] b,
                int offset,
                int length)
         throws java.io.IOException
Read some bytes from the logical stream.
Note however, that by reading byte-wise, you may cross packet boundaries originally inserted into the stream. Use only if packet boundaries do not matter.

Overrides:
read in class java.io.InputStream
Parameters:
b - The buffer to fill.
offset - The offset for fill buffer.
length - The maximum length to read.
Returns:
The number of bytes read, with -1 indicating end of stream.
Throws:
java.io.IOException - If an I/O error occurs.

readPacket

public byte[] readPacket()
                  throws java.io.IOException
Read a packet from the logical stream.
Note:If the packet was already read via the byte-wise read methods, this method returns the rest of the packet.

Returns:
The next packet from the logical stream, or null if end of stream reached.
Throws:
java.io.IOException - If an I/O error occurs.