The libvorbis library does not provide any system interface; a full-featured demonstration player included with the library distribtion provides example code for a variety of system interfaces as well as a working example of using libvorbis in production code.
The Ogg pages returned from ogg_sync_pageout need not be decoded further to be used as landmarks in seeking; seeking can be either a rough process of simply jumping to approximately intuited portions of the bitstream, or it can be a precise bisection process that captures pages and inspects data position. When seeking, however, sequential multiplexing (chaining) must be accounted for; beginning play in a new logical bitstream requires initializing a synthesis engine with the headers from that bitstream. Vorbis bitstreams do not make use of concurent multiplexing (grouping).
typedef struct { unsigned char *packet; long bytes; long b_o_s; long e_o_s; size64 granulepos; } ogg_packet;
typedef struct { unsigned char *header; long header_len; unsigned char *body; long body_len; } ogg_page;
Zero indicates the flag is cleared (this is not the initial page of a logical bitstream). Nonzero indicates the flag is set (this is the initial page of a logical bitstream).
Zero (unset) indicates that the body data begins with a new packet. Nonzero (set) indicates that the first packet data on the page is a continuation from the preceeding page.
Zero (unset) indicates that this is not the last page of a logical bitstream. Nonzero (set) indicates that this is the last page of a logical bitstream and that no addiitonal pages belonging to this bitstream may follow.
The units of the framenumber are determined by media mapping. A vorbis audio bitstream, for example, defines one frame to be the channel values from a single sampling period (eg, a 16 bit stereo bitstream consists of two samples of two bytes for a total of four bytes, thus a frame would be four bytes). A video stream defines one frame to be a single frame of video.
ogg_stream_clear does not call free() on the pointer os, allowing use of this call on stream structures in static or automatic storage. ogg_stream_destroyis a complimentary function that frees the pointer as well.
Returns zero on success and non-zero on failure. This function always succeeds.
ogg_stream_clear does not call free() on the pointer os, allowing use of that call on stream structures in static or automatic storage.
Returns zero on success and non-zero on failure. This function always succeeds.
Returns zero on success, nonzero on failure.
Returns zero on success, nonzero on failure.
Returns zero if the next packet is not ready to be read (not buffered or incomplete), positive if it returned a complete packet in op and negative if there is a gap, extra bytes or corruption at this position in the bitstream (essentially that the bitstream had to be recaptured). A negative value is not necessarily an error. It would be a common occurence when seeking, for example, which requires recapture of the bitstream at the position decoding continued.
Iff the return value is positive, ogg_stream_packetout placed
a packet in op. The data in
Returns zero on success and non-zero on failure.
Returns zero if there is no complete page ready for reading. Returns
nonzero when it has placed data for a complete page into
og. Note that the storage returned in og points into internal
storage; the pointers in og are valid until the next call to
ogg_stream_pageout, ogg_stream_packetin,
ogg_stream_reset, ogg_stream_clear or
ogg_stream_destroy.
Note that if used during encode, it does not alter the stream's serial
number. In addition, the next page produced during encoding will be
marked as the 'initial' page of the logical bitstream.
When used during decode, this simply clears the data buffer of any
pending pages. Beginning and end of stream cues are read from the
bitstream and are unaffected by reset.
Returns zero on success and non-zero on failure. This function always
succeeds.
ogg_sync_buffer exposes a buffer area into which the decoder
copies the next (up to) size bytes. We expose the buffer
(rather than taking a buffer) in order to avoid an extra copy many
uses; this way, for example, read() can transfer data
directly into the stream buffer without first needing to place it in
temporary storage.
Returns a pointer into oy's internal bitstream sync buffer;
the remaining space in the sync buffer is at least size
bytes. The decoder need not write all of size bytes;
ogg_sync_wrote is used to inform the engine how many bytes
were actually written. Use of ogg_sync_wrote after writing
into the exposed buffer is mandantory.
ogg_sync_clear does not call free() on the pointer
oy, allowing use of this call on sync structures in static
or automatic storage. ogg_sync_destroyis a complimentary
function that frees the pointer as well.
Returns zero on success and non-zero on failure. This function always
succeeds.
ogg_sync_clear does not call free() on the pointer
oy, allowing use of that call on stream structures in static
or automatic storage.
Returns zero on success and non-zero on failure. This function always
succeeds.
Returns zero on success and non-zero on failure. This function always
succeeds.
Returns zero when there's no complete pages buffered for
retrieval. Returns negative when a loss of sync or recapture occurred
(this is not necessarily an error; recapture would be required after
seeking, for example). Returns positive when a page is returned in
og. Note that the data in og points into the sync
buffer storage; the pointers are valid until the next call to
ogg_sync_buffer, ogg_sync_clear,
ogg_sync_destroy or ogg_sync_reset.
Returns zero on success, nonzero on failure.
Returns zero on success and non-zero on failure; failure occurs only
when the number of bytes written were larger than the buffer.
Ogg Vorbis is the first Ogg audio CODEC. Anyone may
freely use and distribute the Ogg and Vorbis specification,
whether in a private, public or corporate capacity. However,
Xiphophorus and the Ogg project (xiph.org) reserve the right to set
the Ogg/Vorbis specification and certify specification compliance.
Xiphophorus's Vorbis software CODEC implementation is distributed
under the Lesser/Library GNU Public License. This does not restrict
third parties from distributing independent implementations of Vorbis
software under other licenses.
OggSquish, Vorbis, Xiphophorus and their logos are trademarks (tm) of
Xiphophorus. These pages are
copyright (C) 1994-2000 Xiphophorus. All rights reserved.
int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
Used during decoding to buffer the given complete, pre-verified page
for decoding into raw Ogg packets. The given page must be framed,
normally produced by ogg_sync_pageout, and from the logical
bitstream associated with os (the serial numbers must match).
The contents of the given page are copied; ogg_stream_pagein
retains no pointers into og storage.
int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
Used during encode to read complete pages from the stream buffer. The
returned page is ready for sending out to the real world.
int ogg_stream_reset(ogg_stream_state *os);
Resets the given stream's state to that of a blank, unused stream;
this may be used during encode or decode.
char *ogg_sync_buffer(ogg_sync_state *oy, long size);
This call is used to buffer a raw bitstream for framing and
verification. ogg_sync_buffer handles stream capture and
recapture, checksumming, and division into Ogg pages (as required by
ogg_stream_pagein).
int ogg_sync_clear(ogg_sync_state *oy);
ogg_sync_clear
Clears and deallocates the internal storage of the given Ogg sync
buffer. After clearing, the sync structure is not initialized for
use; ogg_sync_init must be called to reinitialize for use.
Use ogg_sync_reset to reset the sync state and buffer to a
fresh, intiialized state.
int ogg_sync_destroy(ogg_sync_state *oy);
Clears and deallocates the internal storage of the given Ogg sync
buffer, then frees the storage associated with the pointer
oy.
int ogg_sync_init(ogg_sync_state *oy);
Initializes the sync buffer oy for use.
int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
Reads complete, framed, verified Ogg pages from the sync buffer,
placing the page data in og.
int ogg_sync_reset(ogg_sync_state *oy);
ogg_sync_reset resets the sync state in oy to a
clean, empty state. This is useful, for example, when seeking to a
new location in a bitstream.
int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
Used to inform the sync state as to how many bytes were actually
written into the exposed sync buffer. It must be equal to or less
than the size of the buffer requested.
Ogg is a Xiphophorus effort to
protect essential tenets of Internet multimedia from corporate
hostage-taking; Open Source is the net's greatest tool to keep
everyone honest. See About
Xiphophorus for details.