liboggz  1.1.1
Data Structures | Functions
oggz_comments.h File Reference

Reading of comments. More...

#include <oggz/oggz.h>

Go to the source code of this file.

Data Structures

struct  OggzComment
 A comment. More...
 

Functions

const char * oggz_comment_get_vendor (OGGZ *oggz, long serialno)
 Retrieve the vendor string. More...
 
int oggz_comment_set_vendor (OGGZ *oggz, long serialno, const char *vendor_string)
 Set the vendor string. More...
 
const OggzCommentoggz_comment_first (OGGZ *oggz, long serialno)
 Retrieve the first comment. More...
 
const OggzCommentoggz_comment_next (OGGZ *oggz, long serialno, const OggzComment *comment)
 Retrieve the next comment. More...
 
const OggzCommentoggz_comment_first_byname (OGGZ *oggz, long serialno, char *name)
 Retrieve the first comment with a given name. More...
 
const OggzCommentoggz_comment_next_byname (OGGZ *oggz, long serialno, const OggzComment *comment)
 Retrieve the next comment following and with the same name as a given comment. More...
 
int oggz_comment_add (OGGZ *oggz, long serialno, OggzComment *comment)
 Add a comment. More...
 
int oggz_comment_add_byname (OGGZ *oggz, long serialno, const char *name, const char *value)
 Add a comment by name and value. More...
 
int oggz_comment_remove (OGGZ *oggz, long serialno, OggzComment *comment)
 Remove a comment. More...
 
int oggz_comment_remove_byname (OGGZ *oggz, long serialno, char *name)
 Remove all comments with a given name. More...
 
ogg_packet * oggz_comments_generate (OGGZ *oggz, long serialno, int FLAC_final_metadata_block)
 Output a comment packet for the specified stream. More...
 
int oggz_comments_copy (OGGZ *src, long src_serialno, OGGZ *dest, long dest_serialno)
 
void oggz_packet_destroy (ogg_packet *packet)
 Free a packet and its payload. More...
 

Detailed Description

Reading of comments.

Vorbis, Speex and Theora bitstreams use a comment format called "Vorbiscomment", defined here. Many standard comment names (such as TITLE, COPYRIGHT and GENRE) are defined in that document.

The following general features of Vorbiscomment are relevant to this API:

Each comment block contains one Vendor string, which can be retrieved with oggz_comment_get_vendor().

The rest of a comment block consists of name = value pairs, with the following restrictions:

Reading comments

Oggz contains API methods to iterate through all comments associated with the logical bitstreams of an OGGZ* handle (oggz_comment_first() and oggz_comment_next(), and to iterate through comments matching a particular name (oggz_comment_first_byname() and oggz_comment_next_byname()). Given that multiple comments may exist with the same name, you should not use oggz_comment_first_byname() as a simple "get" function.

Writing comments

For writing, Oggz contains API methods for adding comments (oggz_comment_add() and oggz_comment_add_byname()), for removing comments (oggz_comment_remove() and oggz_comment_remove_byname()) and for setting the vendor string (oggz_comment_set_vendor()).

Function Documentation

int oggz_comment_add ( OGGZ oggz,
long  serialno,
OggzComment comment 
)

Add a comment.

Parameters
oggzA OGGZ* handle (created with mode OGGZ_WRITE)
serialnoIdentify a logical bitstream within oggz
commentThe comment to add
Return values
0Success
OGGZ_ERR_BADoggz is not a valid OGGZ* handle
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_OUT_OF_MEMORYOut of memory
int oggz_comment_add_byname ( OGGZ oggz,
long  serialno,
const char *  name,
const char *  value 
)

Add a comment by name and value.

Parameters
oggzA OGGZ* handle (created with mode OGGZ_WRITE)
serialnoIdentify a logical bitstream within oggz
nameThe name of the comment to add
valueThe contents of the comment to add
Return values
0Success
OGGZ_ERR_BADoggz is not a valid OGGZ* handle
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_OUT_OF_MEMORYOut of memory
const OggzComment* oggz_comment_first ( OGGZ oggz,
long  serialno 
)

Retrieve the first comment.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
Returns
A read-only copy of the first comment.
Return values
NULLNo comments exist for this OGGZ* object, or serialno does not identify an existing logical bitstream in oggz.
const OggzComment* oggz_comment_first_byname ( OGGZ oggz,
long  serialno,
char *  name 
)

Retrieve the first comment with a given name.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
namethe name of the comment to retrieve.
Returns
A read-only copy of the first comment matching the given name.
Return values
NULLNo match was found, or serialno does not identify an existing logical bitstream in oggz.
Note
If name is NULL, the behaviour is the same as for oggz_comment_first()
const char* oggz_comment_get_vendor ( OGGZ oggz,
long  serialno 
)

Retrieve the vendor string.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
Returns
A read-only copy of the vendor string.
Return values
NULLNo vendor string is associated with oggz, or oggz is NULL, or serialno does not identify an existing logical bitstream in oggz.
const OggzComment* oggz_comment_next ( OGGZ oggz,
long  serialno,
const OggzComment comment 
)

Retrieve the next comment.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
commentThe previous comment.
Returns
A read-only copy of the comment immediately following the given comment.
Return values
NULLserialno does not identify an existing logical bitstream in oggz.
const OggzComment* oggz_comment_next_byname ( OGGZ oggz,
long  serialno,
const OggzComment comment 
)

Retrieve the next comment following and with the same name as a given comment.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
commentA comment
Returns
A read-only copy of the next comment with the same name as comment.
Return values
NULLNo further comments with the same name exist for this OGGZ* object, or serialno does not identify an existing logical bitstream in oggz.
int oggz_comment_remove ( OGGZ oggz,
long  serialno,
OggzComment comment 
)

Remove a comment.

Parameters
oggzA OGGZ* handle (created with OGGZ_WRITE)
serialnoIdentify a logical bitstream within oggz
commentThe comment to remove.
Return values
1Success: comment removed
0No-op: comment not found, nothing to remove
OGGZ_ERR_BADoggz is not a valid OGGZ* handle
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_BAD_SERIALNOserialno does not identify an existing logical bitstream in oggz.
int oggz_comment_remove_byname ( OGGZ oggz,
long  serialno,
char *  name 
)

Remove all comments with a given name.

Parameters
oggzA OGGZ* handle (created with OGGZ_WRITE)
serialnoIdentify a logical bitstream within oggz
nameThe name of the comments to remove
Return values
>= 0The number of comments removed
OGGZ_ERR_BADoggz is not a valid OGGZ* handle
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_BAD_SERIALNOserialno does not identify an existing logical bitstream in oggz.
int oggz_comment_set_vendor ( OGGZ oggz,
long  serialno,
const char *  vendor_string 
)

Set the vendor string.

Parameters
oggzA OGGZ* handle
serialnoIdentify a logical bitstream within oggz
vendor_stringThe contents of the vendor string to add
Return values
0Success
OGGZ_ERR_BADoggz is not a valid OGGZ* handle
OGGZ_ERR_INVALIDOperation not suitable for this OGGZ
OGGZ_ERR_OUT_OF_MEMORYOut of memory
Note
The vendor string should identify the library used to produce the stream, e.g. libvorbis 1.0 used "Xiph.Org libVorbis I 20020717". If copying a bitstream it should be the same as the source.
ogg_packet* oggz_comments_generate ( OGGZ oggz,
long  serialno,
int  FLAC_final_metadata_block 
)

Output a comment packet for the specified stream.

Parameters
oggzA OGGZ* handle (created with OGGZ_WRITE)
serialnoIdentify a logical bitstream within oggz
FLAC_final_metadata_blockSet this to zero unless the packet_type is FLAC, and there are no further metadata blocks to follow. See note below for details.
Returns
A comment packet for the stream. When no longer needed it should be freed with oggz_packet_destroy().
Return values
NULLcontent type does not support comments, not enough memory or comment was too long for FLAC
Note
FLAC streams may contain multiple metadata blocks of different types. When encapsulated in Ogg the first of these must be a Vorbis comment packet but PADDING, APPLICATION, SEEKTABLE, CUESHEET and PICTURE may follow. The last metadata block must have its first bit set to 1. Since liboggz does not know whether you will supply more metadata blocks you must tell it if this is the last (or only) metadata block by setting FLAC_final_metadata_block to 1.
As FLAC metadata blocks are limited in size to 16MB minus 1 byte, this function will refuse to produce longer comment packets for FLAC.
See http://flac.sourceforge.net/format.html for more details.
void oggz_packet_destroy ( ogg_packet *  packet)

Free a packet and its payload.

Parameters
packetA packet previously returned from a function such as oggz_comment_generate(). User generated packets should not be passed.