[xiph-cvs] cvs commit: ogg-tools/oggmerge oggmerge.c

Jack Moffitt jack at xiph.org
Mon Sep 3 20:01:37 PDT 2001



jack        01/09/03 20:01:37

  Modified:    oggmerge oggmerge.c
  Log:
  Write the header pages out at the beginning, in commandline
  order.  This is _absolutely_ essential for code to be able
  to detect substreams.

Revision  Changes    Path
1.5       +39 -0     ogg-tools/oggmerge/oggmerge.c

Index: oggmerge.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggmerge/oggmerge.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- oggmerge.c	2001/09/04 02:23:33	1.4
+++ oggmerge.c	2001/09/04 03:01:37	1.5
@@ -157,6 +157,7 @@
         filelist_t *file, *winner;
         unsigned long bytes;
         int serialno;
+	int first_pages = 1;
         ogg_page *page;
         char buf[BUFSIZE];
 
@@ -266,6 +267,44 @@
                         }
 
                         file = file->next;
+		}
+
+		/* Step 1.5: Write out the first page of each stream
+		** because headers must come together before any
+		** non-header pages.
+		*/
+		if (first_pages) {
+			first_pages = 0;
+			file = params.input;
+			while (file) {
+				if (file->page == NULL) {
+					fprintf(stderr, "Error: File %s didn't produce a header page.\n", file->name);
+					return 1;
+				}
+
+				page = file->page->og;
+
+				bytes = fwrite(page->header, 1, page->header_len, params.out);
+				if (bytes != page->header_len) {
+					fprintf(stderr, "Error: Output error writing to %s.\n", params.outfile);
+					return 1;
+				}
+				bytes = fwrite(page->body, 1, page->body_len, params.out);
+				if (bytes != page->body_len) {
+					fprintf(stderr, "Error: Output error writing to %s.\n", params.outfile);
+					return 1;
+				}
+			
+				free(page->header);
+				free(page->body);
+				free(page);
+				free(file->page);
+				file->page = NULL;
+
+				file = file->next;
+			}
+
+			continue;
                 }
 
                 /* Step 2: Pick the page with the lowest timestamp and 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list