[matroska] r754 - trunk/DvdMenuXtractor

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2004-09-08 13:36:24 +0400 (Wed, 08 Sep 2004)
New Revision: 754

Modified:
   trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
Log:
add a generic method to output commands
First Play PGC has 0:00 start and end time

Modified: trunk/DvdMenuXtractor/DvdMenuXtractor.cpp
===================================================================
--- trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-09-08 09:35:15 UTC (rev 753)
+++ trunk/DvdMenuXtractor/DvdMenuXtractor.cpp	2004-09-08 09:36:24 UTC (rev 754)
@@ -778,7 +778,58 @@
 	{
 		return wxString::Format("%d", rand() | (rand() << 16) );
 	}
+	
+	void AddCommands(int lvl, wxTextFile & XmlFile, const pgc_command_tbl_t * command_tbl)
+	{
+		if (command_tbl)
+		{
+			// Pre commands
+			if (command_tbl->nr_of_pre)
+			{
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
+				lvl++;
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
+				unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_pre * 8);
+				_buf[0] = command_tbl->nr_of_pre;
+				memcpy(&_buf[1], command_tbl->pre_cmds, command_tbl->nr_of_pre * 8);
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_pre * 8)+"</ChapProcessCommand>");
+				free(_buf);
+				lvl--;
+				XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
+			}
 
+			// Cell commands
+			if (command_tbl->nr_of_cell)
+			{
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
+				lvl++;
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
+				unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_cell * 8);
+				_buf[0] = command_tbl->nr_of_cell;
+				memcpy(&_buf[1], command_tbl->cell_cmds, command_tbl->nr_of_cell * 8);
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_cell * 8)+"</ChapProcessCommand>");
+				free(_buf);
+				lvl--;
+				XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
+			}
+
+			// Post commands
+			if (command_tbl->nr_of_post)
+			{
+				XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
+				lvl++;
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>2</ChapProcessTime>");
+				unsigned char *_buf= (unsigned char*) malloc(1+command_tbl->nr_of_post * 8);
+				_buf[0] = command_tbl->nr_of_post;
+				memcpy(&_buf[1], command_tbl->post_cmds, command_tbl->nr_of_post * 8);
+				XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+command_tbl->nr_of_post * 8)+"</ChapProcessCommand>");
+				free(_buf);
+				lvl--;
+				XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
+			}
+		}
+	}
+
 	void GenerateXMLScript()
 	{
 		CellListElem* cle;
@@ -818,7 +869,9 @@
 					lvl++;
 					wxString _myUID = CreateUID();
 					XmlFile.AddLine(IndentString(lvl)+"<ChapterUID>"+_myUID+"</ChapterUID>");
-//					XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>");
+					// the First Play PGC has no cell and no time
+					XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>");
+					XmlFile.AddLine(IndentString(lvl)+"<ChapterTimeEnd>00:00:00.000000000</ChapterTimeEnd>");
 					// display the UID for the lazy rippers
 					XmlFile.AddLine(IndentString(lvl)+"<ChapterDisplay>");
 						lvl++;
@@ -827,21 +880,8 @@
 					XmlFile.AddLine(IndentString(lvl)+"</ChapterDisplay>");
 					
 					XmlFile.AddLine(IndentString(lvl)+"<ChapterProcessPrivate>"+encodebase64(_PrivateFP,2)+"</ChapterProcessPrivate>");
-					// PGC pre-commands
-					if (IfoFile->FirstPlayPGC()->command_tbl && IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre)
-					{
-						XmlFile.AddLine(IndentString(lvl)+"<ChapterProcess>");
-						lvl++;
-						XmlFile.AddLine(IndentString(lvl)+"<ChapProcessTime>1</ChapProcessTime>");
-						unsigned char *_buf= (unsigned char*) malloc(1+IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8);
-						_buf[0] = IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre;
-						memcpy(&_buf[1], IfoFile->FirstPlayPGC()->command_tbl->pre_cmds, IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8);
-						XmlFile.AddLine(IndentString(lvl)+"<ChapProcessCommand>"+encodebase64(_buf,1+IfoFile->FirstPlayPGC()->command_tbl->nr_of_pre * 8)+"</ChapProcessCommand>");
-						free(_buf);
-						lvl--;
-						XmlFile.AddLine(IndentString(lvl)+"</ChapterProcess>");
-					}
-
+					// PGC commands
+					AddCommands(lvl, XmlFile, IfoFile->FirstPlayPGC()->command_tbl);
 					lvl--;
 				XmlFile.AddLine(IndentString(lvl)+"</ChapterAtom>");
 				lvl--;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.