<p>Returns the unique serial number for the logical bitstream of this page. Each page contains the serial number for the logical bitstream that it belongs to.
<i>n</i> is the version number. In the current version of Ogg, the version number is always 0. Nonzero return values indicate an error in page encoding.</li>
<p>This function is used to check the error or readiness condition of an <ahref="ogg_stream_state.html">ogg_stream_state</a> structure.
<p>It is safe practice to ignore unrecoverable errors (such as an internal error caused by a malloc() failure) returned by ogg stream synchronization calls. Should an
internal error occur, the <ahref="ogg_stream_state.html">ogg_stream_state</a> structure will be cleared (equivalent to a
call to
<ahref="ogg_stream_clear.html">ogg_stream_clear</a>) and subsequent calls
using this <ahref="ogg_stream_state.html">ogg_stream_state</a> will be
noops. Error detection is then handled via a single call to
ogg_stream_check at the end of the operational block. </p>
int ogg_stream_check(<ahref="ogg_stream_state.html">ogg_stream_state</a> *os);
</b></pre>
</td>
</tr>
</table>
<h3>Parameters</h3>
<dl>
<dt><i>os</i></dt>
<dd>Pointer to a previously declared <ahref="ogg_stream_state.html">ogg_stream_state</a> struct.</dd>
</dl>
<h3>Return Values</h3>
<blockquote>
<li>
0 is returned if the <ahref="ogg_stream_state.html">ogg_stream_state</a> structure is initialized and ready.</li>
<li>
nonzero is returned if the structure was never initialized, or if an unrecoverable internal error occurred in a previous call using the passed in <ahref="ogg_stream_state.html">ogg_stream_state</a> struct.</li>
<p>This function clears and frees the internal memory used by the <ahref="ogg_sync_state.html">ogg_stream_state</a> struct, but does not free the structure itself. It is safe to call ogg_stream_clear on the same structure more than once.
<p>This function checks for remaining packets inside the stream and forces remaining packets into a page, regardless of the size of the page.
<p>This should only be used when you want to flush an undersized page from the middle of the stream. Otherwise, <ahref="ogg_stream_pageout.html">ogg_stream_pageout</a> or <ahref="ogg_stream_pageout_fill.html">ogg_stream_pageout_fill</a> should always be used.
<p>This function can also be used to verify that all packets have been flushed. If the return value is 0, all packets have been placed into a page. Like <ahref="ogg_stream_pageout.html">ogg_stream_pageout</a>, it should generally be called in a loop until available packet data has been flushes, since even a single packet may span multiple pages.
int ogg_stream_flush(<ahref="ogg_stream_state.html">ogg_stream_state</a> *os, <ahref="ogg_page.html">ogg_page</a> *og);
</b></pre>
</td>
</tr>
</table>
<h3>Parameters</h3>
<dl>
<dt><i>os</i></dt>
<dd>Pointer to a previously declared <ahref="ogg_stream_state.html">ogg_stream_state</a> struct, which represents the current logical bitstream.</dd>
<dt><i>og</i></dt>
<dd>Pointer to a page of data. The remaining packets in the stream will be placed into this page, if any remain.
</dl>
<h3>Return Values</h3>
<blockquote>
<li>0 means that all packet data has already been flushed into pages, and there are no packets to put into the page. 0 is also returned in the case of an <ahref="ogg_stream_state.html">ogg_stream_state</a> that has been cleared explicitly or implicitly due to an internal error.</li>
<li>
Nonzero means that remaining packets have successfully been flushed into the page.</li>
<p>This function flushes available packets into pages, similar to
<ahref="ogg_stream_flush.html">ogg_stream_flush()</a>, but
allows applications to explicitly request a specific page spill
size.</p>
<p>This function checks for remaining packets inside the stream and forces remaining packets into pages of approximately the requested size.
This should be used when you want to flush all remaining data from a stream. <ahref="ogg_stream_flush.html">ogg_stream_flush</a> may be used instead if a particular page size isn't important.
<p>This function can be used to verify that all packets have been flushed. If the return value is 0, all packets have been placed into a page. Generally speaking, it should be called in a loop until all packets are flushed, since even a single packet may span multiple pages.
int ogg_stream_flush_fill(<ahref="ogg_stream_state.html">ogg_stream_state</a> *os, <ahref="ogg_page.html">ogg_page</a> *og, int fillbytes);
</b></pre>
</td>
</tr>
</table>
<h3>Parameters</h3>
<dl>
<dt><i>os</i></dt>
<dd>Pointer to a previously declared <ahref="ogg_stream_state.html">ogg_stream_state</a> struct, which represents the current logical bitstream.</dd>
<dt><i>og</i></dt>
<dd>Pointer to a page of data. The remaining packets in the stream will be placed into this page, if any remain.
<dt><i>fillbytes</i></dt>
<dd>Packet data watermark in bytes.</dd>
</dl>
<h3>Return Values</h3>
<blockquote>
<li>0 means that all packet data has already been flushed into pages, and there are no packets to put into the page. 0 is also returned in the case of an <ahref="ogg_stream_state.html">ogg_stream_state</a> that has been cleared explicitly or implicitly due to an internal error.</li>
<li>
Nonzero means that remaining packets have successfully been flushed into the page.</li>
<p>This function is used to initialize an <ahref="ogg_sync_state.html">ogg_stream_state</a> struct and allocates appropriate memory in preparation for encoding or decoding.
<p>It also assigns the stream a given serial number.
int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
</b></pre>
</td>
</tr>
</table>
<h3>Parameters</h3>
<dl>
<dt><i>os</i></dt>
<dd>Pointer to a previously declared <a
href="ogg_stream_state.html">ogg_stream_state</a> struct. Before this function is called, an <ahref="ogg_page.html">ogg_page</a> should be submitted to the stream using <ahref="ogg_stream_pagein.html">ogg_stream_pagein()</a>.</dd>
<dt><i>op</i></dt>
<dd>Pointer to the packet to be filled in with pointers to the new data.
This will typically be submitted to a codec for decode after this
function is called. The pointers are only valid until the next call
on this stream state.</dd>
</dl>
<h3>Return Values</h3>
<blockquote>
<ul>
<li>-1 if we are out of sync and there is a gap in the data. This is usually a recoverable error and subsequent calls to ogg_stream_packetout are likely to succeed. <i>op</i> has not been updated.</li>
<li>0 if there is insufficient data available to complete a packet, or on unrecoverable internal error occurred. <i>op</i> has not been updated.
<li>1 if a packet was assembled normally. <i>op</i> contains the next packet from the stream.</li>