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

ozone at motherfish-iii.xiph.org ozone at motherfish-iii.xiph.org
Thu Jan 6 23:29:31 PST 2005


Author: ozone
Date: 2005-01-06 23:29:30 -0800 (Thu, 06 Jan 2005)
New Revision: 8648

Added:
   trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.cpp
   trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.h
   trunk/oggdsf/src/lib/helper/libOOOggChef/utils.cpp
   trunk/oggdsf/src/lib/helper/libOOOggChef/utils.h
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/lib/helper/libOOOggChef/libOOOggChef.vcproj
   trunk/oggdsf/src/lib/helper/libilliCore/StringHelper.cpp
   trunk/oggdsf/src/tools/mod_oggchef/apr_stdcall.h
   trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp
Log:
oggdsf:
 * Changed IRecomposer's interface, so that cached seektable files are now the concern of the subclasses's constructors, rather than the recomposeStreamFrom method
 * Split off some functions to a separate utils.cpp file
 * Initial checkin of CMMLRecomposer class (which doesn't do anything useful yet)
 * Beginning of mod_oggchef support for CMML slicing'n'dicing



Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.cpp	2005-01-07 07:29:30 UTC (rev 8648)
@@ -35,6 +35,7 @@
 #include "stdafx.h"
 
 #include <libOOOggChef/AnnodexRecomposer.h>
+#include <libOOOggChef/utils.h>
 
 #include <libOOOgg/libOOOgg.h>
 #include <libOOOggSeek/AutoAnxSeekTable.h>
@@ -51,13 +52,24 @@
 
 #undef DEBUG
 
-
-AnnodexRecomposer::AnnodexRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData)
+/** You may optionally ask
+	AnnodexRecomposer to use a cached representation of the seek table (which is
+	computationally expensive to build) by passing 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.)
+ */
+AnnodexRecomposer::AnnodexRecomposer(string inFilename,
+									 BufferWriter inBufferWriter,
+									 void* inBufferWriterUserData,
+									 string inCachedSeekTableFilename)
 	:	mFilename(inFilename)
 	,	mDemuxState(SEEN_NOTHING)
 	,	mDemuxParserState(LOOK_FOR_HEADERS)
 	,	mBufferWriter(inBufferWriter)
 	,	mBufferWriterUserData(inBufferWriterUserData)
+	,	mCachedSeekTableFilename(inCachedSeekTableFilename)
 {
 }
 
@@ -65,40 +77,12 @@
 {
 }
 
-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.  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.)
+	AnxData header of the logical bitstream.
   */
 void AnnodexRecomposer::recomposeStreamFrom(double inStartingTimeOffset,
-	const vector<string>* inWantedMIMETypes, string inCachedSeekTableFilename)
+	const vector<string>* inWantedMIMETypes)
 {
 	mWantedMIMETypes = inWantedMIMETypes;
 
@@ -117,14 +101,14 @@
 	// the stream headers, and the byte position of the user's requested start
 	// time
 	AutoAnxSeekTable *locSeekTable = new AutoAnxSeekTable(mFilename);
-	if (inCachedSeekTableFilename != "" && fileExists(inCachedSeekTableFilename)) {
-		locSeekTable->buildTableFromFile(inCachedSeekTableFilename);
+	if (mCachedSeekTableFilename != "" && fileExists(mCachedSeekTableFilename)) {
+		locSeekTable->buildTableFromFile(mCachedSeekTableFilename);
 	} else {
 		locSeekTable->buildTable();
 	}
 
-	if (inCachedSeekTableFilename != "" && !fileExists(inCachedSeekTableFilename)) {
-		locSeekTable->serialiseInto(inCachedSeekTableFilename);
+	if (mCachedSeekTableFilename != "" && !fileExists(mCachedSeekTableFilename)) {
+		locSeekTable->serialiseInto(mCachedSeekTableFilename);
 	}
 	
 	// Find out where the non-header packets (i.e. the stream body) starts
@@ -290,14 +274,6 @@
 # undef strcasecmp
 #endif
 
-bool wantOnlyPacketBody(const vector<string>* inWantedMIMETypes)
-{
-	// TODO: This should check for packet bodies generally, not text/x-cmml
-
-	return (	inWantedMIMETypes->size() == 1
-			&&	inWantedMIMETypes->at(0) == "text/x-cmml");
-}
-
 bool AnnodexRecomposer::acceptOggPage(OggPage* inOggPage)
 {
 	if (mDemuxParserState == LOOK_FOR_HEADERS) {

Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/AnnodexRecomposer.h	2005-01-07 07:29:30 UTC (rev 8648)
@@ -48,13 +48,11 @@
 class LIBOOOGGCHEF_API AnnodexRecomposer : public IRecomposer, public IOggCallback
 {
 public:
-	typedef bool (*BufferWriter) (unsigned char *buffer, unsigned long bufferSize, void *userData);
-
 	AnnodexRecomposer(void);
-	AnnodexRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData);
+	AnnodexRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData, const string inCachedSeekTableFilename = "");
 	~AnnodexRecomposer(void);
 
-	void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes, const string inCachedSeekTableFilename = "");
+	void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes);
 	bool acceptOggPage(OggPage* inOggPage);
 
     AnnodexRecomposer(const AnnodexRecomposer&);  // Don't copy me
@@ -77,8 +75,6 @@
 		LOOK_FOR_BODY,
 	};
 
-	void sendPage(OggPage* inOggPage);
-
 	BufferWriter mBufferWriter;
 	void* mBufferWriterUserData;
 

Added: trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.cpp
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.cpp	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.cpp	2005-01-07 07:29:30 UTC (rev 8648)
@@ -0,0 +1,84 @@
+//===========================================================================
+//Copyright (C) 2005 Zentaro Kavanagh
+//Copyright (C) 2005 Commonwealth Scientific and Industrial Research
+//                   Organisation (CSIRO) Australia
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
+
+#include "stdafx.h"
+
+#include <libOOOggChef/AnnodexRecomposer.h>
+#include <libOOOggChef/CMMLRecomposer.h>
+#include <libOOOggChef/utils.h>
+
+#include <libOOOgg/libOOOgg.h>
+
+#include <assert.h>
+
+#include <fstream>
+#include <iostream>
+#include <string>
+#include <vector>
+
+using namespace std;
+
+CMMLRecomposer::CMMLRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData)
+	:	mFilename(inFilename)
+	,	mBufferWriter(inBufferWriter)
+	,	mBufferWriterUserData(inBufferWriterUserData)
+{
+}
+
+
+CMMLRecomposer::~CMMLRecomposer(void)
+{
+}
+
+	
+void CMMLRecomposer::recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes)
+{
+	// If the only wants only CMML, well, just serve out the CMML
+	if (wantOnlyCMML(inWantedMIMETypes)) {
+		sendFile(mFilename, mBufferWriter, mBufferWriterUserData);
+	} else {
+		// TODO: Implement other output types :)
+		const char *locCrapx0r = "NOT IMPLEMENTED YET\r\n";
+		mBufferWriter((unsigned char *) locCrapx0r,
+			(unsigned long) strlen(locCrapx0r),
+			mBufferWriterUserData);
+	}
+}
+
+
+bool CMMLRecomposer::acceptOggPage(OggPage* inOggPage)
+{
+	return true;
+}
+


Property changes on: trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.h	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.h	2005-01-07 07:29:30 UTC (rev 8648)
@@ -0,0 +1,71 @@
+//===========================================================================
+//Copyright (C) 2005 Zentaro Kavanagh
+//Copyright (C) 2005 Commonwealth Scientific and Industrial Research
+//                   Organisation (CSIRO) Australia
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
+
+#pragma once
+
+
+#include "IRecomposer.h"
+
+#include <libOOOgg/libOOOgg.h>
+#include <libOOOggChef/libOOOggChef.h>
+
+#include <string>
+#include <vector>
+
+using namespace std;
+
+class LIBOOOGGCHEF_API CMMLRecomposer : public IRecomposer, public IOggCallback
+{
+public:
+	CMMLRecomposer(void);
+	CMMLRecomposer(string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData);
+	~CMMLRecomposer(void);
+
+	void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes);
+	bool acceptOggPage(OggPage* inOggPage);
+
+    CMMLRecomposer(const CMMLRecomposer&);  // Don't copy me
+    CMMLRecomposer &operator=(const CMMLRecomposer&);  // Don't assign men
+
+protected:
+
+	BufferWriter mBufferWriter;
+	void* mBufferWriterUserData;
+
+	fstream mDebugFile;
+
+	string mFilename;
+
+	const vector<string>* mWantedMIMETypes;
+};


Property changes on: trunk/oggdsf/src/lib/helper/libOOOggChef/CMMLRecomposer.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/IRecomposer.h	2005-01-07 07:29:30 UTC (rev 8648)
@@ -35,6 +35,7 @@
 #pragma once
 
 #include <libOOOggChef/libOOOggChef.h>
+#include <libOOOggChef/utils.h>
 
 #include <string>
 #include <vector>
@@ -44,14 +45,11 @@
 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, const string inCachedSeekTableFilename = "") = 0;
+	virtual void recomposeStreamFrom(double inStartingTimeOffset, const vector<string>* inWantedMIMETypes) = 0;
 };
 

Modified: trunk/oggdsf/src/lib/helper/libOOOggChef/libOOOggChef.vcproj
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/libOOOggChef.vcproj	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/libOOOggChef.vcproj	2005-01-07 07:29:30 UTC (rev 8648)
@@ -120,6 +120,9 @@
 				RelativePath=".\AnnodexRecomposer.cpp">
 			</File>
 			<File
+				RelativePath=".\CMMLRecomposer.cpp">
+			</File>
+			<File
 				RelativePath=".\IRecomposer.cpp">
 			</File>
 			<File
@@ -140,6 +143,9 @@
 						UsePrecompiledHeader="1"/>
 				</FileConfiguration>
 			</File>
+			<File
+				RelativePath=".\utils.cpp">
+			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
@@ -149,6 +155,9 @@
 				RelativePath=".\AnnodexRecomposer.h">
 			</File>
 			<File
+				RelativePath=".\CMMLRecomposer.h">
+			</File>
+			<File
 				RelativePath=".\IRecomposer.h">
 			</File>
 			<File
@@ -157,6 +166,9 @@
 			<File
 				RelativePath=".\stdafx.h">
 			</File>
+			<File
+				RelativePath=".\utils.h">
+			</File>
 		</Filter>
 		<Filter
 			Name="Resource Files"

Added: trunk/oggdsf/src/lib/helper/libOOOggChef/utils.cpp
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/utils.cpp	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/utils.cpp	2005-01-07 07:29:30 UTC (rev 8648)
@@ -0,0 +1,98 @@
+//===========================================================================
+//Copyright (C) 2005 Zentaro Kavanagh
+//Copyright (C) 2005 Commonwealth Scientific and Industrial Research
+//                   Organisation (CSIRO) Australia
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
+
+#include "stdafx.h"
+
+#include <libOOOggChef/utils.h>
+
+#include <fstream>
+#include <string>
+#include <vector>
+
+
+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;
+	}
+}
+
+
+
+bool wantOnlyPacketBody(const vector<string>* inWantedMIMETypes)
+{
+	// TODO: This should check for packet bodies generally, not text/x-cmml
+
+	return (	inWantedMIMETypes->size() == 1
+			&&	inWantedMIMETypes->at(0) == "text/x-cmml");
+}
+
+
+bool sendFile(const string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData)
+{
+	// If I had a dollar for every single time I've had to write this silly loop ...
+
+	fstream locFile;
+
+	locFile.open(inFilename.c_str(), ios_base::in | ios_base::binary);
+	
+	const unsigned short BUFFER_SIZE = 8192;
+	unsigned char *locBuffer = new unsigned char[BUFFER_SIZE];
+	while (!locFile.eof()) {
+		locFile.read((char *)locBuffer, BUFFER_SIZE);
+
+		unsigned long locBytesRead = locFile.gcount();
+		inBufferWriter(locBuffer, locBytesRead, inBufferWriterUserData);
+	}
+
+	delete [] locBuffer;
+
+	return true;
+}
\ No newline at end of file


Property changes on: trunk/oggdsf/src/lib/helper/libOOOggChef/utils.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/oggdsf/src/lib/helper/libOOOggChef/utils.h
===================================================================
--- trunk/oggdsf/src/lib/helper/libOOOggChef/utils.h	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libOOOggChef/utils.h	2005-01-07 07:29:30 UTC (rev 8648)
@@ -0,0 +1,53 @@
+//===========================================================================
+//Copyright (C) 2005 Zentaro Kavanagh
+//Copyright (C) 2005 Commonwealth Scientific and Industrial Research
+//                   Organisation (CSIRO) Australia
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
+#pragma once
+
+
+#include <string>
+#include <vector>
+
+/// Often used by IRecomposer's subclasses' constructor, and elsewhere
+typedef bool (*BufferWriter) (unsigned char *buffer, unsigned long bufferSize, void *userData);
+
+/// Check whether the user requested only CMML in the list of MIME types
+bool wantOnlyCMML(const vector<string>* inWantedMIMETypes);
+
+/// Check whether we should serve out only the packet bodies given the list of MIME types
+bool wantOnlyPacketBody(const vector<string>* inWantedMIMETypes);
+
+/// a.k.a. World's most stupid stat() function
+bool fileExists(const string inFilename);
+
+/// Push out the entire contents of file to the inBufferWriter function
+bool sendFile(const string inFilename, BufferWriter inBufferWriter, void* inBufferWriterUserData);


Property changes on: trunk/oggdsf/src/lib/helper/libOOOggChef/utils.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/oggdsf/src/lib/helper/libilliCore/StringHelper.cpp
===================================================================
--- trunk/oggdsf/src/lib/helper/libilliCore/StringHelper.cpp	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/lib/helper/libilliCore/StringHelper.cpp	2005-01-07 07:29:30 UTC (rev 8648)
@@ -60,7 +60,7 @@
 
 	//LPCWSTR retPtr = new wchar_t[retVal.length() + 1];
 	for (std::wstring::const_iterator i = inString.begin(); i != inString.end(); i++) {
-		retVal.append(1, *i);
+		retVal.append(1, (char) *i);
 	}
 	
 

Modified: trunk/oggdsf/src/tools/mod_oggchef/apr_stdcall.h
===================================================================
--- trunk/oggdsf/src/tools/mod_oggchef/apr_stdcall.h	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/tools/mod_oggchef/apr_stdcall.h	2005-01-07 07:29:30 UTC (rev 8648)
@@ -43,10 +43,13 @@
 
 #ifdef WIN32
 # define AP_MODULE_ENTRY_POINT __cdecl
+# define C_FUNCTION_POINTER __cdecl
 #else
 # define AP_MODULE_ENTRY_POINT
+# define C_FUNCTION_POINTER
 #endif
 
+
 /* We also need to override the function typedefs in the Apache header files,
    because the included Apache headers will think our functions are __stdcall,
    rather than __cdecl, which is what they actually are.  So, we need to typecast

Modified: trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp
===================================================================
--- trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp	2005-01-07 06:38:55 UTC (rev 8647)
+++ trunk/oggdsf/src/tools/mod_oggchef/mod_oggchef.cpp	2005-01-07 07:29:30 UTC (rev 8648)
@@ -53,6 +53,7 @@
 #include <libOOOggSeek/AutoAnxSeekTable.h>
 #include <libOOOggSeek/AutoOggSeekTable.h>
 #include <libOOOggChef/AnnodexRecomposer.h>
+#include <libOOOggChef/CMMLRecomposer.h>
 #include <libOOOggChef/IRecomposer.h>
 
 #include <algorithm>
@@ -64,9 +65,23 @@
 #undef DEBUG
 
 
+// Higher-order functional programming 101 (bite me Zen :)
+
+typedef int (C_FUNCTION_POINTER *tIntToInt) (int);
+string transformString (const string &inString, tIntToInt inCFunctionToApply)
+{
+	string locString = inString;
+
+	transform(locString.begin(), locString.end(), locString.begin(), inCFunctionToApply);
+
+	return locString;
+}
+
+
 bool isAnnodexFile (string locFilename)
 {
 	string locExtension = locFilename.substr(locFilename.length() - 4);
+	locExtension = transformString(locExtension, tolower);
 
 	return (locExtension == ".anx" || locExtension == ".axv" || locExtension == ".axa");
 }
@@ -74,10 +89,19 @@
 bool isOggFile (string locFilename)
 {
 	string locExtension = locFilename.substr(locFilename.length() - 4);
+	locExtension = transformString(locExtension, tolower);
 
 	return (locExtension == ".ogg" || locExtension == ".ogm");
 }
 
+bool isCMMLFile (string locFilename)
+{
+	string locExtension = locFilename.substr(locFilename.length() - 5);
+	locExtension = transformString(locExtension, tolower);
+
+	return (locExtension == ".cmml");
+}
+
 typedef pair<float, char *> tQualityPair;
 
 bool qualityPairComparator (const tQualityPair &p1, const tQualityPair &p2)
@@ -188,9 +212,11 @@
 	// file according to the user's wishes
 	IRecomposer *locRecomposer = NULL;
 	if (isAnnodexFile(locFilename)) {
-		locRecomposer = new AnnodexRecomposer(locFilename, httpDataSender, inRequest);
+		locRecomposer = new AnnodexRecomposer(locFilename, httpDataSender, inRequest, locCachedSeekTableFilename);
 	} else if (isOggFile(locFilename)) {
 		//locRecomposer = new OggRecomposer(locOutputMIMETypes);
+	} else if (isCMMLFile(locFilename)) {
+		locRecomposer = new CMMLRecomposer(locFilename, httpDataSender, inRequest);
 	} else {
 		// We should never get here
 		ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, inRequest,
@@ -198,7 +224,7 @@
 	}
 
 	if (locRecomposer) {
-		locRecomposer->recomposeStreamFrom(locRequestedStartTime, locOutputMIMETypes, locCachedSeekTableFilename);
+		locRecomposer->recomposeStreamFrom(locRequestedStartTime, locOutputMIMETypes);
 		delete locRecomposer;
 	}
 



More information about the commits mailing list