Commit 0b7481cc authored by conrad's avatar conrad

apply patches from Ian Malone adding oggz_packet_destroy() (for freeing

an ogg_packet* created by liboggz), fixing a typo in the FLAC comment length
checking, and improving oggz_comment_generate() documentation,
 - oggz_comment_generate_doc.diff
 - oggz_packet_destroy.diff
 - patch_oggz_comment_generate.diff


git-svn-id: http://svn.annodex.net/liboggz/trunk@2581 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4f96fe9a
......@@ -225,18 +225,35 @@ oggz_comment_remove_byname (OGGZ * oggz, long serialno, char * name);
* Output a comment packet for the specified stream
* \param oggz A OGGZ* handle (created with OGGZ_ENCODE)
* \param serialno Identify a logical bitstream within \a oggz
* \returns A comment packet for the stream. The packet and its contents must
* be freed by the caller.
* \returns A comment packet for the stream. When no longer needed it
* should be freed with oggz_packet_destroy().
* \retval NULL content type does not support comments, not enough memory
* or comment was too long for FLAC
* \note In a FLAC comment packet the first bit of the packet data must be
* set if it is the last header packet. This must be done manually as liboggz
* cannot tell if there are more header packets to come. E.g.
* \note Supported streams are FLAC (but see below), OggPCM, Speex,
* Theora and Vorbis.
* \note FLAC users: 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. This bit is \b not set in the returned packet,
* since liboggz does not know whether you will supply more metadata blocks.
* If there are no following metadata blocks you must set it manually e.g.
* \code packet->packet |= 0x01;
* \endcode
* Additionally FLAC metadata blocks are limited to 16MB minus 1 byte of
* content, this function will refuse to produce longer comment packets
* for FLAC.
* \n See http://flac.sourceforge.net/format.html for more details.
*/
ogg_packet *
oggz_comment_generate(OGGZ * oggz, long serialno);
/**
* Free a packet and its payload.
* \param packet A packet previously returned from a function such
* as oggz_comment_generate(). User generated packets should not be passed.
*/
void oggz_packet_destroy (ogg_packet *packet);
#ifdef __cplusplus
}
......
......@@ -698,7 +698,7 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
buf_size = preamble_length + comment_length;
if(content == OGGZ_CONTENT_FLAC && comment_length >= 0x0fff)
if(content == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff)
{
return 0;
}
......@@ -721,9 +721,14 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
}
buffer += preamble_length;
}
/* The framing byte for Vorbis shouldn't affect any of the other
types. */
oggz_comments_encode (oggz, serialno, buffer, comment_length);
c_packet->bytes = buf_size;
/* The framing byte for Vorbis shouldn't affect any of the other
types, but strip it anyway. */
if(content != OGGZ_CONTENT_VORBIS)
{
c_packet->bytes -= 1;
}
} else {
free(c_packet);
c_packet = 0;
......@@ -731,3 +736,14 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
return c_packet;
}
void oggz_packet_destroy(ogg_packet *packet) {
if(packet) {
if(packet->packet)
{
free(packet->packet);
}
free(packet);
}
return;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment