[cvs-annodex] commit (/annodex): libannodex/trunk/src/libannodex/anx_private.h libannodex/trunk/src/libannodex/anx_write.c

conrad nobody at lists.annodex.net
Tue Jan 18 19:13:43 EST 2005


Update of /annodex (new revision 673)

Modified files:
   libannodex/trunk/src/libannodex/anx_private.h
   libannodex/trunk/src/libannodex/anx_write.c

Log Message:
add new CMML bos page


Modified: libannodex/trunk/src/libannodex/anx_private.h
===================================================================
--- libannodex/trunk/src/libannodex/anx_private.h	2005-01-18 07:05:53 UTC (rev 672)
+++ libannodex/trunk/src/libannodex/anx_private.h	2005-01-18 08:13:42 UTC (rev 673)
@@ -97,6 +97,7 @@
   int need_bos;
   int need_anxdata;
   int need_anno_anxdata;
+  int need_cmml_bos;
   int need_head;
   int need_mapping_eos;
   int secondary_headers_remaining;

Modified: libannodex/trunk/src/libannodex/anx_write.c
===================================================================
--- libannodex/trunk/src/libannodex/anx_write.c	2005-01-18 07:05:53 UTC (rev 672)
+++ libannodex/trunk/src/libannodex/anx_write.c	2005-01-18 08:13:42 UTC (rev 673)
@@ -48,6 +48,12 @@
 /* set to 0 or 1 */
 #define FLUSH_ALWAYS 0
 
+#define CMML_IDENTIFIER "CMML"
+#define CMML_HEADER_SIZE 28
+#define CMML_VERSION_MAJOR 2
+#define CMML_VERSION_MINOR 0
+#define CMML_GRANULE_RATE_N 1000
+#define CMML_GRANULE_RATE_D 1
 #define CMML_CONTENT_TYPE "text/x-cmml"
 #define EMPTY_CLIP "<clip/>"
 
@@ -519,6 +525,37 @@
 }
 
 static long
+anx_init_cmml_bos_packet (ANNODEX * annodex)
+{
+  unsigned char buf[CMML_HEADER_SIZE];
+  char * b = (char *)buf;
+
+  strncpy ((char *)b, CMML_IDENTIFIER, 4);
+  b[4] = '\0';
+  b[5] = '\0';
+  b[6] = '\0';
+  b[7] = '\0';
+  b += 8;
+
+  *(ogg_int16_t *)b = _le_16 (CMML_VERSION_MAJOR);
+  b += 2;
+
+  *(ogg_int16_t *)b = _le_16 (CMML_VERSION_MINOR);
+  b += 2;
+
+  *(ogg_int64_t *)b = _le_64 (CMML_GRANULE_RATE_N);
+  b += 8;
+
+  *(ogg_int64_t *)b = _le_64 (CMML_GRANULE_RATE_D);
+  b += 8;
+
+  return anx_packet_init (annodex, buf, CMML_HEADER_SIZE,
+			  annodex->anno_serialno,
+			  0 /* granulepos */, 1 /* bos */, 0 /* eos */,
+			  OGGZ_FLUSH_AFTER);
+}
+
+static long
 anx_init_head_packet (ANNODEX * annodex)
 {
   AnxWriter * writer = &annodex->x.writer;
@@ -537,7 +574,7 @@
 
   return anx_packet_init (annodex, (unsigned char *)writer->anno_buf, input_n,
 			  annodex->anno_serialno, 0 /* granulepos */,
-			  1 /* bos */, 0 /* eos */,
+			  0 /* bos */, 0 /* eos */,
 			  OGGZ_FLUSH_AFTER);
 }
 
@@ -827,12 +864,12 @@
       anx_init_mapping_packet (annodex);
       writer->need_mapping = 0;
       made_packet = 1;
-    } else if (writer->need_head) {
+    } else if (writer->need_cmml_bos) {
 #ifdef DEBUG
-      printf ("anx_writer_sync: NEED head\n");
+      printf ("anx_writer_sync: NEED CMML BOS\n");
 #endif
-      anx_init_head_packet (annodex);
-      writer->need_head = 0;
+      anx_init_cmml_bos_packet (annodex);
+      writer->need_cmml_bos = 0;
       made_packet = 1;
     } else if (writer->need_bos) {
 #ifdef DEBUG
@@ -866,7 +903,6 @@
 #ifdef DEBUG
       printf ("anx_writer_sync: NEED CMML anxdata\n");
 #endif
-      /*anx_init_anno_bos_packet (annodex);*/
       anx_init_anxdata_packet (annodex, &writer->anno_track);
       writer->need_anno_anxdata = 0;
       made_packet = 1;
@@ -887,6 +923,13 @@
       if (l == NULL) {
 	writer->need_anxdata = 0;
       }
+    } else if (writer->need_head) {
+#ifdef DEBUG
+      printf ("anx_writer_sync: NEED head\n");
+#endif
+      anx_init_head_packet (annodex);
+      writer->need_head = 0;
+      made_packet = 1;
     } else if (writer->secondary_headers_remaining > 0) {
 #ifdef DEBUG
       printf ("anx_write_sync: NEED %d secondaries remaing\n",
@@ -1087,6 +1130,7 @@
   writer->need_bos = 1;
   writer->need_anxdata = 1;
   writer->need_anno_anxdata = 1;
+  writer->need_cmml_bos = 1;
   writer->need_head = 1;
   writer->need_mapping_eos = 1;
   writer->secondary_headers_remaining = 0;
@@ -1115,8 +1159,8 @@
   writer->anno_track.id = NULL;
   writer->anno_track.content_type = cmml_content_type;
   writer->anno_track.nr_header_packets = 1;
-  writer->anno_track.granule_rate_n = 1000;
-  writer->anno_track.granule_rate_d = 1;
+  writer->anno_track.granule_rate_n = CMML_GRANULE_RATE_N;
+  writer->anno_track.granule_rate_d = CMML_GRANULE_RATE_D;
 
   writer->eos = 0; /* end of stream */
 


-- 
conrad



More information about the cvs-annodex mailing list