hu.netmind.ogg
Interface PagingAlgorithm

All Known Implementing Classes:
DefaultPagingAlgorithm

public interface PagingAlgorithm

This interface describes a paging algorithm, which can be used to produce pages for the ogg stream. All decisions about grouping and timing of writing pages are delegated to a class implementing this interface. All methods of this interface will be called by the container page factory.
Note: currently the algorithm cannot specify to break up a packet to multiple pages. Only the page factory can break up packets, when the packet exceeds the maximum page size.


Method Summary
 boolean handleNewPacket(Page page, Packet packet)
          When a new packet arrives, this method is called to decide, whether to append packet to the current page or not.
 boolean handleWritePage(Page page)
          Called when a page is about to be written.
 

Method Detail

handleNewPacket

boolean handleNewPacket(Page page,
                        Packet packet)
When a new packet arrives, this method is called to decide, whether to append packet to the current page or not. Note, that there is always a current page, although it may be currently empty.

Parameters:
page - The existing page.
packet - The packet arrived.
Returns:
True, if packet should be appended to page, false if current page should close, and a new page should be started to include packet.

handleWritePage

boolean handleWritePage(Page page)
Called when a page is about to be written. This method can be used to implement custom grouping/multiplexing with other logical streams. Note, that the page factory tries to write pages every time a full page is ready (according to handleNewPacket() of this interface, and also when other pages are written to the target ogg stream, by other logical streams.
Note:Design this implementation carefully. A wrong implementation could hang the ogg stream (eg. if the page is always refused to be written).

Parameters:
page - The page which can be written.
Returns:
True, if the page should be written, false if it should be withheld.