[xiph-commits] r3363 - in liboggz/trunk: include/oggz src/examples
src/liboggz
conrad at svn.annodex.net
conrad at svn.annodex.net
Thu Jan 17 23:10:39 PST 2008
Author: conrad
Date: 2008-01-17 23:10:32 -0800 (Thu, 17 Jan 2008)
New Revision: 3363
Modified:
liboggz/trunk/include/oggz/oggz_comments.h
liboggz/trunk/src/examples/modify-headers.c
liboggz/trunk/src/liboggz/Version_script.in
liboggz/trunk/src/liboggz/oggz_comments.c
Log:
add oggz_comments_copy() API function, and use it in modify-headers example
to produce a new set of comments, and add a comment
Modified: liboggz/trunk/include/oggz/oggz_comments.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_comments.h 2008-01-17 07:49:41 UTC (rev 3362)
+++ liboggz/trunk/include/oggz/oggz_comments.h 2008-01-18 07:10:32 UTC (rev 3363)
@@ -266,6 +266,19 @@
OggzStreamContent packet_type,
int FLAC_final_metadata_block);
+/*
+ * Copy comments between two streams.
+ * \param src A OGGZ* handle
+ * \param src_serialno Identify a logical bitstream within \a src
+ * \param dest A OGGZ* handle (created with OGGZ_WRITE)
+ * \param dest_serialno Identify a logical bitstream within \a dest
+ * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle
+ * \retval OGGZ_ERR_INVALID Operation not suitable for \a dest
+ */
+int
+oggz_comments_copy (OGGZ * src, long src_serialno,
+ OGGZ * dest, long dest_serialno);
+
/**
* Free a packet and its payload.
* \param packet A packet previously returned from a function such
Modified: liboggz/trunk/src/examples/modify-headers.c
===================================================================
--- liboggz/trunk/src/examples/modify-headers.c 2008-01-17 07:49:41 UTC (rev 3362)
+++ liboggz/trunk/src/examples/modify-headers.c 2008-01-18 07:10:32 UTC (rev 3363)
@@ -62,7 +62,6 @@
read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
MHData * mhdata = (MHData *)user_data;
- ogg_packet * new_op = op;
int flush;
int ret;
@@ -90,9 +89,17 @@
#endif
/* Do something with the packet data */
+ if (op->packetno == 1) {
+ 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->reader, serialno),
+ 0);
+ }
/* Feed the packet into the writer */
- if ((ret = oggz_write_feed (mhdata->writer, new_op, serialno, flush, NULL)) != 0) {
+ if ((ret = oggz_write_feed (mhdata->writer, op, serialno, flush, NULL)) != 0) {
printf ("oggz_write_feed: %d\n", ret);
}
Modified: liboggz/trunk/src/liboggz/Version_script.in
===================================================================
--- liboggz/trunk/src/liboggz/Version_script.in 2008-01-17 07:49:41 UTC (rev 3362)
+++ liboggz/trunk/src/liboggz/Version_script.in 2008-01-18 07:10:32 UTC (rev 3363)
@@ -79,7 +79,10 @@
oggz_comment_add_byname;
oggz_comment_remove;
oggz_comment_remove_byname;
+
oggz_comment_generate;
+ oggz_comments_copy;
+
oggz_packet_destroy;
local:
Modified: liboggz/trunk/src/liboggz/oggz_comments.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_comments.c 2008-01-17 07:49:41 UTC (rev 3362)
+++ liboggz/trunk/src/liboggz/oggz_comments.c 2008-01-18 07:10:32 UTC (rev 3363)
@@ -484,6 +484,33 @@
}
}
+int
+oggz_comments_copy (OGGZ * src, long src_serialno,
+ OGGZ * dest, long dest_serialno)
+{
+ const OggzComment * comment;
+
+ if (src == NULL || dest == NULL) return OGGZ_ERR_BAD_OGGZ;
+
+ if (dest->flags & OGGZ_WRITE) {
+ if (OGGZ_CONFIG_WRITE) {
+ oggz_comment_set_vendor (dest, dest_serialno,
+ oggz_comment_get_vendor (src, src_serialno));
+
+ for (comment = oggz_comment_first (src, src_serialno); comment;
+ comment = oggz_comment_next (src, src_serialno, comment)) {
+ oggz_comment_add (dest, dest_serialno, comment);
+ }
+ } else {
+ return OGGZ_ERR_DISABLED;
+ }
+ } else {
+ return OGGZ_ERR_INVALID;
+ }
+
+ return 0;
+}
+
/* Internal API */
int
oggz_comments_init (oggz_stream_t * stream)
@@ -601,6 +628,9 @@
/* Vendor string */
vendor_length = strlen (stream->vendor);
actual_length = 4 + vendor_length;
+#ifdef DEBUG
+ printf ("oggz_comments_encode: vendor = %s\n", stream->vendor);
+#endif
/* user comment list length */
actual_length += 4;
More information about the commits
mailing list