<p>Libogg contains a set of functions used in the decoding process.
<p>
All the <b>libogg</b> specific functions are declared in "ogg/ogg.h".
<p>
<p>Decoding is based around the ogg synchronization layer. The <ahref="ogg_sync_state.html">ogg_sync_state</a> struct coordinates between incoming data and the decoder. We read data into the synchronization layer, submit the data to the stream, and output raw packets to the decoder.
<p>Decoding through the Ogg layer follows a specific logical sequence. A read loop follows these logical steps:
<ul>
<li>Expose a buffer using <ahref="ogg_sync_buffer.html">ogg_sync_buffer()</a>.
<li>Read data into the buffer, using fread() or a similar function.
<li>Call <ahref="ogg_sync_wrote.html">ogg_sync_wrote()</a> to tell the synchronization layer how many bytes you wrote into the buffer.
<li>Write out the data using <ahref="ogg_sync_pageout.html">ogg_sync_pageout</a>.
<li>Submit the completed page to the streaming layer with <ahref="ogg_stream_pagein.html">ogg_stream_pagein</a>.
<li>Output a packet of data to the codec-specific decoding layer using <ahref="ogg_stream_packetout.html">ogg_stream_packetout</a>.
</ul>
<p>In practice, streams are more complex, and Ogg also must handle headers, incomplete or dropped pages, and other errors in input.
<p>Libogg contains a set of functions used in the encoding process.
<p>
All the <b>libogg</b> specific functions are declared in "ogg/ogg.h".
<p>
<p>When encoding, the encoding engine will output raw packets which must be placed into an Ogg bitstream.
<p>Raw packets are inserted into the stream, and an <ahref="ogg_page.html">ogg_page</a> is output when enough packets have been written to create a full page. The pages output are pointers to buffered packet segments, and can then be written out and saved as an ogg stream.
<p>There are a couple of basic steps:
<ul>
<li>Use the encoding engine to produce a raw packet of data.
<li>Call <ahref="ogg_stream_packetin.html">ogg_stream_packetin</a> to submit a raw packet to the stream.
<li>Use <ahref="ogg_stream_pageout.html">ogg_stream_pageout</a> to output a page, if enough data has been submitted. Otherwise, continue submitting data.
<p>Libogg contains several functions which are generally useful when using Ogg streaming, whether encoding or decoding.
<p>
All the <b>libogg</b> specific functions are declared in "ogg/ogg.h".
<p>
<p>These functions can be used to manipulate some of the basic elements of Ogg - streams and pages. Streams and pages are important during both the encode and decode process.
<dd>Pointer to the packet's data. This is treated as an opaque type by the ogg layer.</dd>
<dt><i>bytes</i></dt>
<dd>Indicates the size of the packet data in bytes. Packets can be of arbitrary size.</dd>
<dt><i>b_o_s</i></dt>
<dd>Flag indicating whether this packet begins a logical bitstream. <tt>1</tt> indicates this is the first packet, <tt>0</tt> indicates any other position in the stream.</dd>
<dt><i>e_o_s</i></dt>
<dd>Flag indicating whether this packet ends a bitstream. <tt>1</tt> indicates the last packet, <tt>0</tt> indicates any other position in the stream.</dd>
<dt><i>granulepos</i></dt>
<dd>A number indicating the position of this packet in the decoded data. This is the last sample, frame or other unit of information ('granule') that can be completely decoded from this packet.</dd>
<dt><i>packetno</i></dt>
<dd>Sequential number of this packet in the ogg bitstream.<dd>