org.gagravarr.ogg
Class OggPacketWriter

java.lang.Object
  extended by org.gagravarr.ogg.OggPacketWriter

public class OggPacketWriter
extends Object


Constructor Summary
protected OggPacketWriter(OggFile parentFile, int sid)
           
 
Method Summary
 void bufferPacket(OggPacket packet)
          Buffers the given packet up ready for writing to the stream, but doesn't write it to disk yet.
 void bufferPacket(OggPacket packet, boolean flush)
          Buffers the given packet up ready for writing to the file, and then writes it to the stream if indicated.
 void close()
          Writes all pending packets to the stream, with the last one containing the End Of Stream Flag, and then closes down.
 void flush()
          Writes all pending packets to the stream, splitting across pages as needed.
 long getCurrentGranulePosition()
           
 int getSid()
           
 int getSizePendingFlush()
          Returns the number of bytes (excluding headers) currently waiting to be written to disk.
 void setGranulePosition(long position)
          Sets the current granule position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OggPacketWriter

protected OggPacketWriter(OggFile parentFile,
                          int sid)
Method Detail

setGranulePosition

public void setGranulePosition(long position)
Sets the current granule position. The granule position will be applied to all un-flushed packets, and all future packets. As such, you should normally either call a flush just before or just after this call.


getCurrentGranulePosition

public long getCurrentGranulePosition()

getSid

public int getSid()

bufferPacket

public void bufferPacket(OggPacket packet)
Buffers the given packet up ready for writing to the stream, but doesn't write it to disk yet.


bufferPacket

public void bufferPacket(OggPacket packet,
                         boolean flush)
                  throws IOException
Buffers the given packet up ready for writing to the file, and then writes it to the stream if indicated.

Throws:
IOException

getSizePendingFlush

public int getSizePendingFlush()
Returns the number of bytes (excluding headers) currently waiting to be written to disk. RFC 3533 suggests that pages should normally be in the 4-8kb range. If this size exceeds just shy of 64kb, then multiple pages will be needed in the underlying stream.


flush

public void flush()
           throws IOException
Writes all pending packets to the stream, splitting across pages as needed.

Throws:
IOException

close

public void close()
           throws IOException
Writes all pending packets to the stream, with the last one containing the End Of Stream Flag, and then closes down.

Throws:
IOException


Copyright © 2012. All Rights Reserved.