[xiph-commits] r8643 - in trunk/oggdsf/src: lib/helper/libOOOggChef tools/mod_oggchef

ozone at motherfish-iii.xiph.org ozone at motherfish-iii.xiph.org
Thu Jan 6 05:22:46 PST 2005


Author: ozone
Date: 2005-01-06 05:22:45 -0800 (Thu, 06 Jan 2005)
New Revision: 8643

Modified:
   trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp
   trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h
   trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h
   trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp
Log:
oggdsf:
 * Changed libOOOggChef so it can used cached seek table files
 * Fix a bug in mod_oggchef so it, well, actually runs
 * Changed mog_oggchef to use cached .seektable files on the server


Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp	2005-01-06 12:49:04 UTC (rev 8642)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp	2005-01-06 13:22:45 UTC (rev 8643)
@@ -65,18 +65,40 @@
 {
 }
 
-
 bool wantOnlyCMML(const vector<string>* inWantedMIMETypes)
 {
 	return (	inWantedMIMETypes->size() == 1
 			&&	inWantedMIMETypes->at(0) == "text/x-cmml");
 }
 
+bool fileExists(const string inFilename)
+{
+	// Behold, the world's most C++-portable filename-checking mechanism!
+
+	fstream locFile;
+
+	locFile.open(inFilename.c_str(), ios_base::in | ios_base::binary);
+	if (locFile.is_open()) {
+		locFile.close();
+		return true;
+	} else {
+		locFile.close();
+		return false;
+	}
+}
+
 /** The starting time offset's units is in seconds, while the wanted MIME types
     is a vector of strings, which will be matched against the MIME type in the
-	AnxData header of the logical bitstream. */
+	AnxData header of the logical bitstream.  You may optionally ask
+	AnnodexRecomposer to use a cached representation of the seek table (which is
+	computationally expensive to build) by passing the a filename in the
+	inCachedSeekTableFilename parameter.  If the file does not exist,
+	AnnodexRecomposer will write out the constructed seek table to the filename
+	given.  (If the file cannot be written for any reason, you will receive no
+	warning.  Yell at me if this is a serious issue.)
+  */
 void AnnodexRecomposer::recomposeStreamFrom(double inStartingTimeOffset,
-	const vector<string>* inWantedMIMETypes)
+	const vector<string>* inWantedMIMETypes, string inCachedSeekTableFilename)
 {
 	mWantedMIMETypes = inWantedMIMETypes;
 
@@ -95,7 +117,15 @@
 	// the stream headers, and the byte position of the user's requested start
 	// time
 	AutoAnxSeekTable *locSeekTable = new AutoAnxSeekTable(mFilename);
-	locSeekTable->buildTable();
+	if (inCachedSeekTableFilename != "" && fileExists(inCachedSeekTableFilename)) {
+		locSeekTable->buildTableFromFile(inCachedSeekTableFilename);
+	} else {
+		locSeekTable->buildTable();
+	}
+
+	if (inCachedSeekTableFilename != "" && !fileExists(inCachedSeekTableFilename)) {
+		locSeekTable->serialiseInto(inCachedSeekTableFilename);
+	}
 	
 	// Find out where the non-header packets (i.e. the stream body) starts
 
@@ -478,4 +508,3 @@
 
 	return true;
 }
-

Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h	2005-01-06 12:49:04 UTC (rev 8642)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h	2005-01-06 13:22:45 UTC (rev 8643)
@@ -54,7 +54,7 @@
 	AnnodexRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData);
 	~AnnodexRecomposer(void);
 
-	void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes);
+	void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes, const string inCachedSeekTableFilename = "");
 	bool acceptOggPage(OggPage* inOggPage);
 
     AnnodexRecomposer(const AnnodexRecomposer&);  // Don't copy me
@@ -85,6 +85,7 @@
 	fstream mDebugFile;
 
 	string mFilename;
+	string mCachedSeekTableFilename;
 
 	unsigned long mAnnodexSerialNumber;
 

Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h	2005-01-06 12:49:04 UTC (rev 8642)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h	2005-01-06 13:22:45 UTC (rev 8643)
@@ -44,10 +44,14 @@
 class LIBOOOGGCHEF_API IRecomposer
 {
 public:
+	// TODO: We should probably make the constructor take in the cached seek
+	// table file name, rather than the recomposeStreamFrom method, but this
+	// works, so what the hey ...
+
 	IRecomposer(void);
 	virtual ~IRecomposer(void);
 
 	/// Recompose a stream from a particular time offset and/or only selecting certain logical bitstreams (specified as MIME types)
-	virtual void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes) = 0;
+	virtual void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes, const string inCachedSeekTableFilename = "") = 0;
 };
 

Modified: trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp
===================================================================
--- trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp	2005-01-06 12:49:04 UTC (rev 8642)
+++ trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp	2005-01-06 13:22:45 UTC (rev 8643)
@@ -55,7 +55,6 @@
 #include <libOOOggChef/AnnodexRecomposer.h>
 #include <libOOOggChef/IRecomposer.h>
 
-
 #include <algorithm>
 #include <iostream>
 #include <fstream>
@@ -153,12 +152,13 @@
 	apr_uri_t *locURI = &(inRequest->parsed_uri);
 
 	// Ignore the request if it's not directed at this module
-	if (strcmp(inRequest->handler, "oggchef")) {
+	if (strcmp(inRequest->handler, "mod_oggchef") != 0) {
 		return DECLINED;
 	}
 
 	// Grab the local filename (which is determined by the requested URL)
 	string locFilename = inRequest->filename;
+	string locCachedSeekTableFilename = locFilename + ".seektable";
 
 	// Make a name=value table of the CGI query parameters
 	apr_table_t* locCGITable = make_cgi_table (inRequest, locURI->query);
@@ -198,7 +198,7 @@
 	}
 
 	if (locRecomposer) {
-		locRecomposer->recomposeStreamFrom(locRequestedStartTime, locOutputMIMETypes);
+		locRecomposer->recomposeStreamFrom(locRequestedStartTime, locOutputMIMETypes, locCachedSeekTableFilename);
 		delete locRecomposer;
 	}
 



More information about the commits mailing list