[xiph-commits] r3366 - in liboggz/trunk: include/oggz src/examples
src/liboggz
conrad at svn.annodex.net
conrad at svn.annodex.net
Sun Jan 20 17:52:54 PST 2008
Author: conrad
Date: 2008-01-20 17:52:54 -0800 (Sun, 20 Jan 2008)
New Revision: 3366
Modified:
liboggz/trunk/include/oggz/oggz_comments.h
liboggz/trunk/include/oggz/oggz_deprecated.h
liboggz/trunk/src/examples/modify-headers.c
liboggz/trunk/src/liboggz/Version_script.in
liboggz/trunk/src/liboggz/oggz_comments.c
Log:
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().
Modified: liboggz/trunk/include/oggz/oggz_comments.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_comments.h 2008-01-21 01:36:51 UTC (rev 3365)
+++ liboggz/trunk/include/oggz/oggz_comments.h 2008-01-21 01:52:54 UTC (rev 3366)
@@ -241,8 +241,6 @@
* 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 @@
* \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.
Modified: liboggz/trunk/include/oggz/oggz_deprecated.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_deprecated.h 2008-01-21 01:36:51 UTC (rev 3365)
+++ liboggz/trunk/include/oggz/oggz_deprecated.h 2008-01-21 01:52:54 UTC (rev 3366)
@@ -89,4 +89,39 @@
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__ */
Modified: liboggz/trunk/src/examples/modify-headers.c
===================================================================
--- liboggz/trunk/src/examples/modify-headers.c 2008-01-21 01:36:51 UTC (rev 3365)
+++ liboggz/trunk/src/examples/modify-headers.c 2008-01-21 01:52:54 UTC (rev 3366)
@@ -93,9 +93,7 @@
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 */
Modified: liboggz/trunk/src/liboggz/Version_script.in
===================================================================
--- liboggz/trunk/src/liboggz/Version_script.in 2008-01-21 01:36:51 UTC (rev 3365)
+++ liboggz/trunk/src/liboggz/Version_script.in 2008-01-21 01:52:54 UTC (rev 3366)
@@ -81,6 +81,8 @@
oggz_comment_remove_byname;
oggz_comment_generate;
+
+ oggz_comments_generate;
oggz_comments_copy;
oggz_packet_destroy;
Modified: liboggz/trunk/src/liboggz/oggz_comments.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_comments.c 2008-01-21 01:36:51 UTC (rev 3365)
+++ liboggz/trunk/src/liboggz/oggz_comments.c 2008-01-21 01:52:54 UTC (rev 3366)
@@ -704,12 +704,13 @@
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 @@
/* 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 @@
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)
More information about the commits
mailing list