Commit ad077485 authored by imalone's avatar imalone

Change oggz_comment_generate interface to require comment type and the end of FLAC metadata flag.


git-svn-id: http://svn.annodex.net/liboggz/trunk@2583 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent ba99f9cc
......@@ -241,28 +241,30 @@ 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
* \param packet_type Type of comment packet to generate,
* FLAC, OggPCM, Speex, Theora and Vorbis are supported
* \param FLAC_final_metadata_block Non-zero if there are no FLAC
* metadata blocks to follow (see note)
* \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 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
* 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 (and only
* block) via FLAC_final_metadata_block.
* \n 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);
oggz_comment_generate(OGGZ * oggz, long serialno,
OggzStreamContent packet_type,
int FLAC_final_metadata_block);
/**
* Free a packet and its payload.
......
......@@ -669,15 +669,15 @@ oggz_comments_encode (OGGZ * oggz, long serialno,
/* In Flac, OggPCM, Speex, Theora and Vorbis the comment packet will
be second in the stream, i.e. packetno=1, and it will have granulepos=0 */
ogg_packet *
oggz_comment_generate(OGGZ * oggz, long serialno) {
oggz_comment_generate(OGGZ * oggz, long serialno,
OggzStreamContent packet_type,
int FLAC_final_metadata_block) {
ogg_packet *c_packet;
unsigned char *buffer;
unsigned const char *preamble;
long preamble_length, comment_length, buf_size;
OggzStreamContent content = oggz_stream_get_content (oggz, serialno);
/* Some types use preambles in the comment packet. FLAC is notable;
n9-32 should contain the length of the comment data as 24bit unsigned
BE, and the first octet should be ORed with 0x01 if this is the last
......@@ -691,7 +691,7 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
{0x04, 0x00, 0x00, 0x00};
switch(content) {
switch(packet_type) {
case OGGZ_CONTENT_VORBIS:
preamble_length = sizeof preamble_vorbis;
preamble = preamble_vorbis;
......@@ -722,7 +722,7 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
buf_size = preamble_length + comment_length;
if(content == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff)
if(packet_type == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff)
{
return 0;
}
......@@ -738,18 +738,21 @@ oggz_comment_generate(OGGZ * oggz, long serialno) {
buffer = c_packet->packet;
if(preamble_length) {
memcpy(buffer, preamble, preamble_length);
if(content == OGGZ_CONTENT_FLAC)
{
/* MACRO */
writeint24be(c_packet->packet, 1, comment_length );
}
if(packet_type == OGGZ_CONTENT_FLAC) {
/* MACRO */
writeint24be(c_packet->packet, 1, comment_length );
if(FLAC_final_metadata_block)
{
c_packet->packet[0] |= 0x01;
}
}
buffer += preamble_length;
}
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)
if(packet_type != OGGZ_CONTENT_VORBIS)
{
c_packet->bytes -= 1;
}
......
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