org.gagravarr.ogg
Class OggPacketReader

java.lang.Object
  extended by org.gagravarr.ogg.OggPacketReader
Direct Known Subclasses:
VorbisInfoTool.InfoPacketReader

public class OggPacketReader
extends Object


Constructor Summary
OggPacketReader(InputStream inp)
           
 
Method Summary
 OggPacket getNextPacket()
          Returns the next packet in the file, or null if no more packets remain.
 OggPacket getNextPacketWithSid(int sid)
          Returns the next packet with the given SID (Stream ID), or null if no more packets remain.
 void skipToGranulePosition(int sid, long granulePosition)
          Skips forward until the first packet with a Granule Position of equal or greater than that specified.
 void skipToSequenceNumber(int sid, int sequenceNumber)
          Skips forward until the first packet with a Sequence Number of equal or greater than that specified.
 void unreadPacket(OggPacket packet)
          Un-reads a packet, leaving it ready to be feteched by the next call to getNextPacket().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OggPacketReader

public OggPacketReader(InputStream inp)
Method Detail

getNextPacket

public OggPacket getNextPacket()
                        throws IOException
Returns the next packet in the file, or null if no more packets remain. Call OggPacket.isBeginningOfStream() to detect if it is the first packet in the stream or not, and use OggPacket.getSid() to track which stream it belongs to.

Throws:
IOException

getNextPacketWithSid

public OggPacket getNextPacketWithSid(int sid)
                               throws IOException
Returns the next packet with the given SID (Stream ID), or null if no more packets remain. Any packets from other streams will be silently discarded.

Throws:
IOException

unreadPacket

public void unreadPacket(OggPacket packet)
Un-reads a packet, leaving it ready to be feteched by the next call to getNextPacket(). Only one packet may be unread. Normally used when identifying a stream, to leave the initial packet ready for a decoder


skipToSequenceNumber

public void skipToSequenceNumber(int sid,
                                 int sequenceNumber)
                          throws IOException
Skips forward until the first packet with a Sequence Number of equal or greater than that specified. Call getNextPacket() to retrieve this packet. This method advances across all streams, but only searches the specified one.

Parameters:
sid - The ID of the stream who's packets we will search
sequenceNumber - The sequence number we're looking for
Throws:
IOException

skipToGranulePosition

public void skipToGranulePosition(int sid,
                                  long granulePosition)
                           throws IOException
Skips forward until the first packet with a Granule Position of equal or greater than that specified. Call getNextPacket() to retrieve this packet. This method advances across all streams, but only searches the specified one.

Parameters:
sid - The ID of the stream who's packets we will search
granulePosition - The granule position we're looking for
Throws:
IOException


Copyright © 2012. All Rights Reserved.