module Stream:sig
..end
type
stream
The stream
values track the current encode/decode state of the
current logical bitstream.
type
packet
A data packet to pass to the decoder
val create : ?serial:nativeint -> unit -> stream
Create a stream
.
val serialno : stream -> nativeint
Get a stream's serial number.
val eos : stream -> bool
Returns true if the end of stream has been reached.
val get_page : ?fill:int -> stream -> Ogg.Page.t
This function forms packets into pages. Internally, it assembles the accumulated packet bodies into an Ogg page suitable for writing to a stream.
If no fill
argument is passed, this function will only return
a page when a "reasonable" amount of packet data is available.
Normally this is appropriate since it limits the overhead of the
Ogg page headers in the bitstream.
If a fill
argument is passed, this function will return a page when at
least four packets have been accumulated and accumulated packet data meets
or exceeds the specified number of bytes, and/or when the accumulated
packet data meets/exceeds the maximum page size regardless of accumulated
packet count.
Call flush_page
if immediate page generation is desired. This
may be occasionally necessary, for example, to limit the temporal
latency of a variable bitrate stream.
val put_page : stream -> Ogg.Page.t -> unit
This function adds a complete page to the bitstream.
In a typical decoding situation, this function would be called after
using Sync.read
to create a valid Page.t
Raises Bad_data
if the serial number of the page did not match the
serial number of the bitstream, or the page version was incorrect.
val get_packet : stream -> packet
This function assembles a data packet for output to the codec decoding engine.
Each successive call returns the next complete packet built from those segments.
In a typical decoding situation, this should be used after calling
put_page
to submit a page of data to the bitstream.
This function should *not* be used. Because of ocaml's paradigm, it is necessary to copy each packet since they are only valid until this function is called again. When dealing with many packets, this will lead to multiple unecessary memory allocation and desallocation.
Raises Not_enough_data
if more data is needed and another page should be submitted.
Raises Out_of_sync
if we are out of sync and there is a gap in the data.
val peek_packet : stream -> packet
This function assembles a data packet for output to the codec decoding engine without advancing the stream.
Raises Not_enough_data
if more data is needed and another page should be submitted.
Raises Out_of_sync
if we are out of sync and there is a gap in the data
val peek_granulepos : stream -> Stdlib.Int64.t
This function picks up the granule position of the next packet in the stream without advancing it.
Raises Not_enough_data
if more data is needed and another page should be submitted.
Raises Out_of_sync
if we are out of sync and there is a gap in the data
val skip_packet : stream -> unit
This function discards the next packet in the stream.
Raises Not_enough_data
if more data is needed and another page should be submitted.
Raises Out_of_sync
if we are out of sync and there is a gap in the data
val put_packet : stream -> packet -> unit
This function submits a packet to the bitstream for page encapsulation. After this is called, more packets can be submitted, or pages can be written out.
This function is provided to ease ogg strea multiplexing, where packet submission order is important. It should not be used to encoder further data.
val flush_page : stream -> Ogg.Page.t
This function checks for remaining packets inside the stream and forces remaining packets into a page, regardless of the size of the page.
This should only be used when you want to flush an undersized page from the
middle of the stream. Otherwise, get_page
should always be used.
This function can be used to verify that all packets have been flushed.
Raises Not_enough_data
if all packet data has already been flushed into pages,
and there are no packets to put into the page.
val packet_granulepos : packet -> Stdlib.Int64.t
Returns a packet's granule position.