[xiph-commits] r8717 - in trunk/oggdsf: sln/oggdsf_all src/tools/CMMLDump

ozone at motherfish-iii.xiph.org ozone at motherfish-iii.xiph.org
Mon Jan 10 03:56:49 PST 2005


Author: ozone
Date: 2005-01-10 03:56:48 -0800 (Mon, 10 Jan 2005)
New Revision: 8717

Modified:
   trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
   trunk/oggdsf/src/tools/CMMLDump/CMMLDump.cpp
Log:
oggdsf:
 * CMMLDump tool now uses libCMMLParse to parse each CMML entity in the .anx file

Modified: trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
===================================================================
--- trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln	2005-01-10 11:39:31 UTC (rev 8716)
+++ trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln	2005-01-10 11:56:48 UTC (rev 8717)
@@ -1110,6 +1110,8 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMMLDump", "..\..\src\tools\CMMLDump\CMMLDump.vcproj", "{3A7DAD80-4C79-48FB-B779-8CEA4EE9CF90}"
 	ProjectSection(ProjectDependencies) = postProject
 		{223ACC19-608E-4E1B-A054-067F0CACB272} = {223ACC19-608E-4E1B-A054-067F0CACB272}
+		{899EB7AD-26BF-4495-9BE5-EADECCC288B2} = {899EB7AD-26BF-4495-9BE5-EADECCC288B2}
+		{AD38DCC6-B431-4B32-8569-74F3376EF2DA} = {AD38DCC6-B431-4B32-8569-74F3376EF2DA}
 		{2DA569EC-3E22-4BC9-A242-C7A56EB9C6F4} = {2DA569EC-3E22-4BC9-A242-C7A56EB9C6F4}
 	EndProjectSection
 EndProject

Modified: trunk/oggdsf/src/tools/CMMLDump/CMMLDump.cpp
===================================================================
--- trunk/oggdsf/src/tools/CMMLDump/CMMLDump.cpp	2005-01-10 11:39:31 UTC (rev 8716)
+++ trunk/oggdsf/src/tools/CMMLDump/CMMLDump.cpp	2005-01-10 11:56:48 UTC (rev 8717)
@@ -36,8 +36,9 @@
 
 #include <libOOOgg/libOOOgg.h>
 #include <libOOOgg/dllstuff.h>
-#include <libWinCMMLParse/libWinCMMLParse.h>
-#include <libWinCMMLParse/CMMLParser.h>
+#include <libCMMLTags/libCMMLTags.h>
+#include <libCMMLParse/libCMMLParse.h>
+#include <libCMMLParse/CMMLParser.h>
 
 #include <iostream>
 #include <fstream>
@@ -113,17 +114,56 @@
 					char *locPacketData = (char *) inOggPage->getPacket(i)->packetData();
 
 					// Add a terminating '\0'
-					char *locMyPacketData = (char *) malloc(locPacketSize + 1);
-					locMyPacketData = (char *) memcpy(locMyPacketData, locPacketData, locPacketSize);
+					char *locMyPacketData = new char[locPacketSize + 1];
+					(void) memcpy(locMyPacketData, locPacketData, locPacketSize);
 					locMyPacketData[locPacketSize] = '\0';
 
 					// Get the packet's time in seconds
 					LOOG_INT64 locPacketGranulePos = inOggPage->header()->GranulePos();
 					float locPacketStartTimeInSeconds = (float) locPacketGranulePos/ (float) 1000;
 
-					printf("%.2f seconds:\n%s", locPacketStartTimeInSeconds, locMyPacketData);
+					// Let's make the CMML parsing library decide whether it's a <head>
+					// or <clip> tag -- after all, that's what it's there for :)
+					
+					wstring locPacketDataWString = StringHelper::toWStr(locMyPacketData);
 
-					free(locMyPacketData);
+					CMMLParser locCMMLParser;
+					C_CMMLTag *locCMMLTag = NULL;
+
+					// Try parsing it as a <head> tag
+					C_HeadTag *locHeadTag = new C_HeadTag;
+					bool locDidParseHead = 
+						locCMMLParser.parseHeadTag(locPacketDataWString, locHeadTag);
+					if (locDidParseHead) {
+						locCMMLTag = locHeadTag;
+					}
+
+					// Try parsing it as a <clip> tag
+					C_ClipTag *locClipTag = new C_ClipTag;
+					bool locDidParseClip = 
+						locCMMLParser.parseClipTag(locPacketDataWString, locClipTag);
+					if (locDidParseClip) {
+						// Only succeed if parsing it as a <head> tag didn't work
+						if (!locDidParseHead) {
+							locCMMLTag = locClipTag;
+						} else {
+							cout << "Parsed successfully as both a <clip> and <head>:" << endl;
+							wcout << locPacketDataWString << endl;
+						}
+					}
+
+					if (locCMMLTag == NULL) {
+						cout << "Couldn't parse as either <clip> or <head>:" << endl;
+						wcout << locPacketDataWString << endl;
+					}
+
+					if (locDidParseClip) {
+						cout << locPacketStartTimeInSeconds << " seconds:" << endl;
+					}
+					wcout << locCMMLTag->toString() << endl;
+
+					delete locCMMLTag;
+					delete locMyPacketData;
 				}
 			}
 



More information about the commits mailing list