Commit 7d76ca05 authored by conrad's avatar conrad

simplify generation of comment packets: create oggz_comments_generate()

which does not require a packet_type argument (this is determined by parsing
the bos packet during oggz_write_feed()). Deprecate previous
oggz_comment_generate().


git-svn-id: http://svn.annodex.net/liboggz/trunk@3366 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 96a17310
......@@ -241,8 +241,6 @@ 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_WRITE)
* \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 Set this to zero unless the packet_type is
* FLAC, and there are no further metadata blocks to follow. See note below
* for details.
......@@ -262,9 +260,8 @@ oggz_comment_remove_byname (OGGZ * oggz, long serialno, char * name);
* \n See http://flac.sourceforge.net/format.html for more details.
*/
ogg_packet *
oggz_comment_generate(OGGZ * oggz, long serialno,
OggzStreamContent packet_type,
int FLAC_final_metadata_block);
oggz_comments_generate(OGGZ * oggz, long serialno,
int FLAC_final_metadata_block);
/*
* Copy comments between two streams.
......
......@@ -89,4 +89,39 @@ int oggz_set_metric_linear (OGGZ * oggz, long serialno,
ogg_int64_t granule_rate_numerator,
ogg_int64_t granule_rate_denominator);
/**
* DEPRECATED FUNCTION
* This function has been replaced with oggz_comments_generate(), which
* does not require the packet_type argument. Instead, the packet type is
* determined by the content type of the stream, which was discovered when
* the bos packet was passed to oggz_write_feed.
*
* Output a comment packet for the specified stream.
* \param oggz A OGGZ* handle (created with OGGZ_WRITE)
* \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 Set 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().
* \retval NULL content 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.
* \n As FLAC metadata blocks are limited in size to 16MB minus 1 byte, 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,
OggzStreamContent packet_type,
int FLAC_final_metadata_block);
#endif /* __OGGZ_DEPRECATED_H__ */
......@@ -93,9 +93,7 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
oggz_comments_copy (mhdata->reader, serialno, mhdata->writer, serialno);
oggz_comment_add_byname (mhdata->writer, serialno,
"EDITOR", "modify-headers");
op = oggz_comment_generate (mhdata->writer, serialno,
oggz_stream_get_content (mhdata->writer, serialno),
0);
op = oggz_comments_generate (mhdata->writer, serialno, 0);
}
/* Feed the packet into the writer */
......
......@@ -81,6 +81,8 @@
oggz_comment_remove_byname;
oggz_comment_generate;
oggz_comments_generate;
oggz_comments_copy;
oggz_packet_destroy;
......
......@@ -704,12 +704,13 @@ oggz_comments_encode (OGGZ * oggz, long serialno,
return actual_length;
}
/* 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 */
/* NB. Public use of this function is deprecated; the simpler
* oggz_comments_generate() automatically determines the packet_type */
ogg_packet *
oggz_comment_generate(OGGZ * oggz, long serialno,
OggzStreamContent packet_type,
int FLAC_final_metadata_block) {
int FLAC_final_metadata_block)
{
ogg_packet *c_packet;
unsigned char *buffer;
......@@ -749,21 +750,19 @@ oggz_comment_generate(OGGZ * oggz, long serialno,
/* No preamble for these */
break;
default:
return 0;
return NULL;
}
comment_length = oggz_comments_encode (oggz, serialno, 0, 0);
if(comment_length <= 0)
{
return 0;
}
if(comment_length <= 0) {
return NULL;
}
buf_size = preamble_length + comment_length;
if(packet_type == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff)
{
return 0;
}
if(packet_type == OGGZ_CONTENT_FLAC && comment_length >= 0x00ffffff) {
return NULL;
}
c_packet = malloc(sizeof *c_packet);
if(c_packet) {
......@@ -804,6 +803,20 @@ oggz_comment_generate(OGGZ * oggz, long serialno,
return c_packet;
}
/* 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_comments_generate(OGGZ * oggz, long serialno,
int FLAC_final_metadata_block)
{
OggzStreamContent packet_type;
packet_type = oggz_stream_get_content (oggz, serialno);
return oggz_comment_generate (oggz, serialno, packet_type,
FLAC_final_metadata_block);
}
void oggz_packet_destroy(ogg_packet *packet) {
if(packet) {
if(packet->packet)
......
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