hu.netmind.ogg
Class PageFactory

java.lang.Object
  extended by hu.netmind.ogg.PageFactory

public class PageFactory
extends java.lang.Object

This class creates pages for the physical ogg stream. By default, pages will be created to form an ideal page size of 4-8 kB, but this algorithm can be (and is advised to be) overidden, to implement custom paging functionality (eg.: coordinating with other logical streams to determine whether it is time to write pages).


Constructor Summary
PageFactory(OggOutputStream oggStream)
          Initialize the page factory with owner ogg stream.
 
Method Summary
 void close()
          Close this page factory.
 PagingAlgorithm getPagingAlgorithm()
           
 int getSerial()
          Get the serial number associated with this page factory.
 void setPagingAlgorithm(PagingAlgorithm pagingAlgorithm)
           
 void writePacket(Packet packet)
          This method is called by the logical stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageFactory

public PageFactory(OggOutputStream oggStream)
Initialize the page factory with owner ogg stream.

Parameters:
oggStream - The ogg stream this page factory will work into.
Method Detail

getSerial

public int getSerial()
Get the serial number associated with this page factory. This number is unique across all page factories working into the same ogg stream.

Returns:
The serial number.

writePacket

public void writePacket(Packet packet)
                 throws java.io.IOException
This method is called by the logical stream. All arriving packets will be organized into pages, but may be written anytime later, according to the paging algorithm.

Parameters:
packet - The packet to write.
Throws:
java.io.IOException - If the ogg stream had an error, or packet could not be included into current page.

close

public void close()
           throws java.io.IOException
Close this page factory. This means write all remaining data to ogg stream, including the eos page. If currently the bos packet is written, a page will be created with both the bos and eos flag set.

Throws:
java.io.IOException - If the ogg stream throws an exception.

getPagingAlgorithm

public PagingAlgorithm getPagingAlgorithm()

setPagingAlgorithm

public void setPagingAlgorithm(PagingAlgorithm pagingAlgorithm)