\section{oggz.h File Reference}
\label{oggz_8h}\index{oggz.h@{oggz.h}}


The liboggz C API.  


{\ttfamily \#include $<$stdio.h$>$}\par
{\ttfamily \#include $<$sys/types.h$>$}\par
{\ttfamily \#include $<$ogg/ogg.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-constants.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-table.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-off\_\-t.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-read.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-stream.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-seek.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-write.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-io.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-comments.h$>$}\par
{\ttfamily \#include $<$oggz/oggz\_\-deprecated.h$>$}\par
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef void {\bf OGGZ}
\begin{DoxyCompactList}\small\item\em An opaque handle to an Ogg file. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
{\bf OGGZ} $\ast$ {\bf oggz\_\-new} (int flags)
\begin{DoxyCompactList}\small\item\em Create a new OGGZ object. \item\end{DoxyCompactList}\item 
{\bf OGGZ} $\ast$ {\bf oggz\_\-open} (const char $\ast$filename, int flags)
\begin{DoxyCompactList}\small\item\em Open an Ogg file, creating an OGGZ handle for it. \item\end{DoxyCompactList}\item 
{\bf OGGZ} $\ast$ {\bf oggz\_\-open\_\-stdio} (FILE $\ast$file, int flags)
\begin{DoxyCompactList}\small\item\em Create an OGGZ handle associated with a stdio stream. \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-flush} ({\bf OGGZ} $\ast$oggz)
\begin{DoxyCompactList}\small\item\em Ensure any associated io streams are flushed. \item\end{DoxyCompactList}\item 
long {\bf oggz\_\-run} ({\bf OGGZ} $\ast$oggz)
\begin{DoxyCompactList}\small\item\em Run an OGGZ until completion, or error. \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-run\_\-set\_\-blocksize} ({\bf OGGZ} $\ast$oggz, long blocksize)
\begin{DoxyCompactList}\small\item\em Set the blocksize to use internally for \doxyref{oggz\_\-run()}{p.}{oggz_8h_a0561df532fc37f98725007a79f898356} \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-close} ({\bf OGGZ} $\ast$oggz)
\begin{DoxyCompactList}\small\item\em Close an OGGZ handle. \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-get\_\-bos} ({\bf OGGZ} $\ast$oggz, long serialno)
\begin{DoxyCompactList}\small\item\em Determine if a given logical bitstream is at bos (beginning of stream). \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-get\_\-eos} ({\bf OGGZ} $\ast$oggz, long serialno)
\begin{DoxyCompactList}\small\item\em Determine if a given logical bitstream is at eos (end of stream). \item\end{DoxyCompactList}\item 
int {\bf oggz\_\-get\_\-numtracks} ({\bf OGGZ} $\ast$oggz)
\begin{DoxyCompactList}\small\item\em Query the number of tracks (logical bitstreams). \item\end{DoxyCompactList}\item 
long {\bf oggz\_\-serialno\_\-new} ({\bf OGGZ} $\ast$oggz)
\begin{DoxyCompactList}\small\item\em Request a new serialno, as required for a new stream, ensuring the serialno is not yet used for any other streams managed by this OGGZ. \item\end{DoxyCompactList}\item 
const char $\ast$ {\bf oggz\_\-content\_\-type} ({\bf OggzStreamContent} content)
\begin{DoxyCompactList}\small\item\em Return human-\/readable string representation of a content type. \item\end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
The liboggz C API. \subsection{Generic semantics}\label{oggz_8h_general}
All access is managed via an OGGZ handle. This can be instantiated in one of three ways:


\begin{DoxyItemize}
\item \doxyref{oggz\_\-open()}{p.}{oggz_8h_a65197cdd03f755f7ebfabf2fdff4c7db} -\/ Open a full pathname
\item \doxyref{oggz\_\-open\_\-stdio()}{p.}{oggz_8h_ac49e9de0bc4ef1d91b43b13605f98b19} -\/ Use an already opened FILE $\ast$
\item \doxyref{oggz\_\-new()}{p.}{oggz_8h_a6eb34d123389ae38d993601f9e7bb9d6} -\/ Create an anonymous OGGZ object, which you can later handle via memory buffers
\end{DoxyItemize}

To finish using an OGGZ handle, it should be closed with \doxyref{oggz\_\-close()}{p.}{oggz_8h_aadcfc04b2930660710bbcbc93140b783}.\subsection{Reading Ogg data}\label{oggz_8h_reading}
To read from Ogg files or streams you must instantiate an OGGZ handle with flags set to OGGZ\_\-READ, and provide an OggzReadPacket callback with \doxyref{oggz\_\-set\_\-read\_\-callback()}{p.}{group__read__api_ga6d5aae4f7f186fffe19d4fd3cd63148d}. See the \doxyref{Oggz Read API}{p.}{group__read__api} section for details.\subsection{Writing Ogg data}\label{oggz_8h_writing}
To write to Ogg files or streams you must instantiate an OGGZ handle with flags set to OGGZ\_\-WRITE, and provide an OggzWritePacket callback with oggz\_\-set\_\-write\_\-callback(). See the \doxyref{Oggz Write API}{p.}{group__write__api} section for details.\subsection{Seeking on Ogg data}\label{oggz_8h_seeking}
To seek while reading Ogg files or streams you must instantiate an OGGZ handle for reading, and ensure that an \doxyref{OggzMetric }{p.}{group__metric} function is defined to translate packet positions into units such as time. See the \doxyref{Oggz Seek API}{p.}{group__seek__api} section for details.\subsection{Overriding the IO methods}\label{oggz_8h_io}
When an OGGZ handle is instantiated by \doxyref{oggz\_\-open()}{p.}{oggz_8h_a65197cdd03f755f7ebfabf2fdff4c7db} or \doxyref{oggz\_\-open\_\-stdio()}{p.}{oggz_8h_ac49e9de0bc4ef1d91b43b13605f98b19}, Oggz uses stdio functions internally to access the raw data. However for some applications, the raw data cannot be accessed via stdio -\/-\/ this commonly occurs when integrating with media frameworks. For such applications, you can provide Oggz with custom IO methods that it should use to access the raw data. Oggz will then use these custom methods, rather than using stdio methods, to access the raw data internally.

For details, see \doxyref{$<$oggz/oggz\_\-io.h$>$ }{p.}{oggz__io_8h}.\subsection{Headers}\label{oggz_8h_headers}
\doxyref{oggz.h}{p.}{oggz_8h} provides direct access to libogg types such as ogg\_\-packet, defined in $<$ogg/ogg.h$>$. 

\subsection{Typedef Documentation}
\index{oggz.h@{oggz.h}!OGGZ@{OGGZ}}
\index{OGGZ@{OGGZ}!oggz.h@{oggz.h}}
\subsubsection[{OGGZ}]{\setlength{\rightskip}{0pt plus 5cm}typedef void {\bf OGGZ}}\label{oggz_8h_a672d218df13da45a4b41d5366211bfee}


An opaque handle to an Ogg file. 

This is returned by \doxyref{oggz\_\-open()}{p.}{oggz_8h_a65197cdd03f755f7ebfabf2fdff4c7db} or \doxyref{oggz\_\-new()}{p.}{oggz_8h_a6eb34d123389ae38d993601f9e7bb9d6}, and is passed to all other oggz\_\-$\ast$ functions. 

\subsection{Function Documentation}
\index{oggz.h@{oggz.h}!oggz\_\-close@{oggz\_\-close}}
\index{oggz\_\-close@{oggz\_\-close}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-close}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-close (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz}
\end{DoxyParamCaption}
)}\label{oggz_8h_aadcfc04b2930660710bbcbc93140b783}


Close an OGGZ handle. 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-OGGZ} & {\itshape oggz\/} does not refer to an existing OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-SYSTEM} & System error; check errno for details \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-content\_\-type@{oggz\_\-content\_\-type}}
\index{oggz\_\-content\_\-type@{oggz\_\-content\_\-type}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-content\_\-type}]{\setlength{\rightskip}{0pt plus 5cm}const char$\ast$ oggz\_\-content\_\-type (
\begin{DoxyParamCaption}
\item[{{\bf OggzStreamContent}}]{content}
\end{DoxyParamCaption}
)}\label{oggz_8h_ab1b16dec307b6544b5f82a60a14c8518}


Return human-\/readable string representation of a content type. 


\begin{DoxyRetVals}{Return values}
{\em string} & the name of the content type \\
\hline
{\em NULL} & {\itshape content\/} invalid \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-flush@{oggz\_\-flush}}
\index{oggz\_\-flush@{oggz\_\-flush}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-flush}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-flush (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz}
\end{DoxyParamCaption}
)}\label{oggz_8h_a8090c7e886af90dbea4dd5df8035dbf3}


Ensure any associated io streams are flushed. 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-OGGZ} & {\itshape oggz\/} does not refer to an existing OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-INVALID} & Operation not suitable for this OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-SYSTEM} & System error; check errno for details \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-get\_\-bos@{oggz\_\-get\_\-bos}}
\index{oggz\_\-get\_\-bos@{oggz\_\-get\_\-bos}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-get\_\-bos}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-get\_\-bos (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz, }
\item[{long}]{serialno}
\end{DoxyParamCaption}
)}\label{oggz_8h_a357244f9e73d219015d9ce8260ee08d3}


Determine if a given logical bitstream is at bos (beginning of stream). 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
{\em serialno} & Identify a logical bitstream within {\itshape oggz\/}, or -\/1 to query if all logical bitstreams in {\itshape oggz\/} are at bos \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 1} & The given stream is at bos \\
\hline
{\em 0} & The given stream is not at bos \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-SERIALNO} & {\itshape serialno\/} does not identify an existing logical bitstream in {\itshape oggz\/}. \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-get\_\-eos@{oggz\_\-get\_\-eos}}
\index{oggz\_\-get\_\-eos@{oggz\_\-get\_\-eos}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-get\_\-eos}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-get\_\-eos (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz, }
\item[{long}]{serialno}
\end{DoxyParamCaption}
)}\label{oggz_8h_aee6a754e123ec0fd347d1ed0d4d4b3b7}


Determine if a given logical bitstream is at eos (end of stream). 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
{\em serialno} & Identify a logical bitstream within {\itshape oggz\/}, or -\/1 to query if all logical bitstreams in {\itshape oggz\/} are at eos \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 1} & The given stream is at eos \\
\hline
{\em 0} & The given stream is not at eos \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-SERIALNO} & {\itshape serialno\/} does not identify an existing logical bitstream in {\itshape oggz\/}. \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-get\_\-numtracks@{oggz\_\-get\_\-numtracks}}
\index{oggz\_\-get\_\-numtracks@{oggz\_\-get\_\-numtracks}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-get\_\-numtracks}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-get\_\-numtracks (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz}
\end{DoxyParamCaption}
)}\label{oggz_8h_a0dd3be49fc94531e35546318c14b64e7}


Query the number of tracks (logical bitstreams). 

When reading, this number is incremented every time a new track is found, so the returned value is only correct once the OGGZ is no longer at bos (beginning of stream): see \doxyref{oggz\_\-get\_\-bos()}{p.}{oggz_8h_a357244f9e73d219015d9ce8260ee08d3} for determining this. 
\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of tracks in OGGZ 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em OGGZ\_\-ERR\_\-BAD\_\-SERIALNO} & {\itshape serialno\/} does not identify an existing logical bitstream in {\itshape oggz\/}. \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-new@{oggz\_\-new}}
\index{oggz\_\-new@{oggz\_\-new}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-new}]{\setlength{\rightskip}{0pt plus 5cm}{\bf OGGZ}$\ast$ oggz\_\-new (
\begin{DoxyParamCaption}
\item[{int}]{flags}
\end{DoxyParamCaption}
)}\label{oggz_8h_a6eb34d123389ae38d993601f9e7bb9d6}


Create a new OGGZ object. 


\begin{DoxyParams}{Parameters}
{\em flags} & OGGZ\_\-READ or OGGZ\_\-WRITE \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new OGGZ object 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} & on system error; check errno for details \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-open@{oggz\_\-open}}
\index{oggz\_\-open@{oggz\_\-open}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-open}]{\setlength{\rightskip}{0pt plus 5cm}{\bf OGGZ}$\ast$ oggz\_\-open (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{filename, }
\item[{int}]{flags}
\end{DoxyParamCaption}
)}\label{oggz_8h_a65197cdd03f755f7ebfabf2fdff4c7db}


Open an Ogg file, creating an OGGZ handle for it. 


\begin{DoxyParams}{Parameters}
{\em filename} & The file to open \\
\hline
{\em flags} & OGGZ\_\-READ or OGGZ\_\-WRITE \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new OGGZ handle 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} & System error; check errno for details \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-open\_\-stdio@{oggz\_\-open\_\-stdio}}
\index{oggz\_\-open\_\-stdio@{oggz\_\-open\_\-stdio}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-open\_\-stdio}]{\setlength{\rightskip}{0pt plus 5cm}{\bf OGGZ}$\ast$ oggz\_\-open\_\-stdio (
\begin{DoxyParamCaption}
\item[{FILE $\ast$}]{file, }
\item[{int}]{flags}
\end{DoxyParamCaption}
)}\label{oggz_8h_ac49e9de0bc4ef1d91b43b13605f98b19}


Create an OGGZ handle associated with a stdio stream. 


\begin{DoxyParams}{Parameters}
{\em file} & An open FILE handle \\
\hline
{\em flags} & OGGZ\_\-READ or OGGZ\_\-WRITE \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new OGGZ handle 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} & System error; check errno for details \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-run@{oggz\_\-run}}
\index{oggz\_\-run@{oggz\_\-run}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-run}]{\setlength{\rightskip}{0pt plus 5cm}long oggz\_\-run (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz}
\end{DoxyParamCaption}
)}\label{oggz_8h_a0561df532fc37f98725007a79f898356}


Run an OGGZ until completion, or error. 

This is a convenience function which repeatedly calls \doxyref{oggz\_\-read()}{p.}{group__read__api_ga3ce7a31de5da56375057436c6b5108f2} or \doxyref{oggz\_\-write()}{p.}{group__write__api_ga3c97d94ea425d64546adf9c368b71904} as appropriate. For an OGGZ opened for reading, an OggzReadPacket or OggzReadPage callback should have been set before calling this function. For an OGGZ opened for writing, either an OggzHungry callback should have been set before calling this function, or you can use this function to write out all unwritten Ogg pages which are pending. 
\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle previously opened for either reading or writing \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-OGGZ} & {\itshape oggz\/} does not refer to an existing OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-INVALID} & Operation not suitable for this OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-SYSTEM} & System error; check errno for details \\
\hline
{\em OGGZ\_\-ERR\_\-STOP\_\-OK} & Operation was stopped by a user callback returning OGGZ\_\-STOP\_\-OK \\
\hline
{\em OGGZ\_\-ERR\_\-STOP\_\-ERR} & Operation was stopped by a user callback returning OGGZ\_\-STOP\_\-ERR \\
\hline
{\em OGGZ\_\-ERR\_\-RECURSIVE\_\-WRITE} & Attempt to initiate writing from within an OggzHungry callback \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-run\_\-set\_\-blocksize@{oggz\_\-run\_\-set\_\-blocksize}}
\index{oggz\_\-run\_\-set\_\-blocksize@{oggz\_\-run\_\-set\_\-blocksize}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-run\_\-set\_\-blocksize}]{\setlength{\rightskip}{0pt plus 5cm}int oggz\_\-run\_\-set\_\-blocksize (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz, }
\item[{long}]{blocksize}
\end{DoxyParamCaption}
)}\label{oggz_8h_ad500c8ed7147f7fb1ddc6c915a6c10d7}


Set the blocksize to use internally for \doxyref{oggz\_\-run()}{p.}{oggz_8h_a0561df532fc37f98725007a79f898356} 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle previously opened for either reading or writing \\
\hline
{\em blocksize} & The blocksize to use within \doxyref{oggz\_\-run()}{p.}{oggz_8h_a0561df532fc37f98725007a79f898356} \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & Success \\
\hline
{\em OGGZ\_\-ERR\_\-BAD\_\-OGGZ} & {\itshape oggz\/} does not refer to an existing OGGZ \\
\hline
{\em OGGZ\_\-ERR\_\-INVALID} & Invalid blocksize ({\itshape run\_\-blocksize\/} $<$= 0) \\
\hline
\end{DoxyRetVals}
\index{oggz.h@{oggz.h}!oggz\_\-serialno\_\-new@{oggz\_\-serialno\_\-new}}
\index{oggz\_\-serialno\_\-new@{oggz\_\-serialno\_\-new}!oggz.h@{oggz.h}}
\subsubsection[{oggz\_\-serialno\_\-new}]{\setlength{\rightskip}{0pt plus 5cm}long oggz\_\-serialno\_\-new (
\begin{DoxyParamCaption}
\item[{{\bf OGGZ} $\ast$}]{oggz}
\end{DoxyParamCaption}
)}\label{oggz_8h_aaf89877e3e89408387d422f487bcf094}


Request a new serialno, as required for a new stream, ensuring the serialno is not yet used for any other streams managed by this OGGZ. 


\begin{DoxyParams}{Parameters}
{\em oggz} & An OGGZ handle \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A new serialno, not already occuring in any logical bitstreams in {\itshape oggz\/}. 
\end{DoxyReturn}
