[xiph-commits] r10811 - in trunk/oggdsf/src/lib/core/directshow: . dsfOggDemux2

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sun Feb 12 14:05:48 PST 2006


Author: illiminable
Date: 2006-02-12 14:05:01 -0800 (Sun, 12 Feb 2006)
New Revision: 10811

Added:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IFilterDataSource.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggBaseTime.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggDecoder.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggOutputPin.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ReadMe.txt
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ds_guids.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.def
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.h
Log:
* Merge new demuxer (Dont' use this rev.)

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,85 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "datasourcefactory.h"
+
+DataSourceFactory::DataSourceFactory(void)
+{
+}
+
+DataSourceFactory::~DataSourceFactory(void)
+{
+}
+
+IFilterDataSource* DataSourceFactory::createDataSource(string inSourceLocation) {
+	string locType = identifySourceType(inSourceLocation);
+
+	if(locType.length() == 1) {
+		//File...
+		return new FilterFileSource;
+	} else if (locType == "\\\\") {
+		//Network share...
+		return new FilterFileSource;
+	} else if (locType == "http") {
+		//Http stream
+		//return new HTTPFileSource;
+		return new HTTPStreamingFileSource;
+	} else {
+		//Something else
+		return NULL;
+	}
+}
+
+string DataSourceFactory::identifySourceType(string inSourceLocation) {
+	size_t locPos = inSourceLocation.find(':');
+	if (locPos == string::npos) {
+		//No colon... not a normal file. See if it's a network share...
+
+		//Make sure it's long enough...
+		if (inSourceLocation.length() > 2) {
+			string retStr = inSourceLocation.substr(0,2);
+			if (retStr == "\\\\") {
+				//A "\\" is a network share
+				return retStr;
+			} else {
+				//Not a network share.
+				return "";
+			}
+		} else {
+			//Too short
+			return "";
+		}
+	} else {
+		string retStr = inSourceLocation.substr(0,locPos);
+		return retStr;
+	}
+	
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/DataSourceFactory.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,45 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "IFilterDataSource.h"
+#include "FilterFileSource.h"
+#include "HTTPFileSource.h"
+
+#include "HTTPStreamingFileSource.h"
+class OGG_DEMUX2_API DataSourceFactory
+{
+public:
+	DataSourceFactory(void);
+	~DataSourceFactory(void);
+
+	static IFilterDataSource* createDataSource(string inSourceLocation);
+	static string identifySourceType(string inSourceLocation);
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,63 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "filterfilesource.h"
+
+FilterFileSource::FilterFileSource(void)
+{
+}
+
+FilterFileSource::~FilterFileSource(void)
+{
+	mSourceFile.close();
+}
+
+unsigned long FilterFileSource::seek(unsigned long inPos) {
+	mSourceFile.seekg(inPos, ios_base::beg);
+	return mSourceFile.tellg();
+}
+void FilterFileSource::close() {
+	mSourceFile.close();
+}
+bool FilterFileSource::open(string inSourceLocation, unsigned long) {
+	mSourceFile.open(inSourceLocation.c_str(), ios_base::in|ios_base::binary);
+	return mSourceFile.is_open();
+}
+void FilterFileSource::clear() {
+	mSourceFile.clear();
+}
+bool FilterFileSource::isEOF() {
+	return mSourceFile.eof();
+}
+unsigned long FilterFileSource::read(char* outBuffer, unsigned long inNumBytes) {
+	mSourceFile.read(outBuffer, inNumBytes);
+	return mSourceFile.gcount();
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/FilterFileSource.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,58 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 <fstream>
+#include <string>
+
+using namespace std;
+#include "IFilterDataSource.h"
+class OGG_DEMUX2_API FilterFileSource
+	:	public IFilterDataSource
+{
+public:
+	FilterFileSource(void);
+	virtual ~FilterFileSource(void);
+
+	//IFilterDataSource Interface
+	virtual unsigned long seek(unsigned long inPos);
+	virtual void close();
+	virtual bool open(string inSourceLocation, unsigned long inStartByte = 0);
+	virtual void clear();
+	virtual bool isEOF();
+	virtual bool isError()								{	return false;	}
+	virtual unsigned long read(char* outBuffer, unsigned long inNumBytes);
+	virtual string shouldRetryAt()						{		return "";		}
+	//
+
+protected:
+	fstream mSourceFile;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,466 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "httpfilesource.h"
+
+#define OGGCODECS_LOGGING
+HTTPFileSource::HTTPFileSource(void)
+	:	mBufferLock(NULL)
+	,	mIsChunked(false)
+	,	mIsFirstChunk(true)
+	,	mChunkRemains(0)
+	,	mNumLeftovers(0)
+{
+	mBufferLock = new CCritSec;
+#ifdef OGGCODECS_LOGGING
+	debugLog.open("d:\\zen\\logs\\htttp.log", ios_base::out | ios_base::app);
+	fileDump.open("d:\\zen\\logs\\filedump.ogg", ios_base::out|ios_base::binary);
+	rawDump.open("D:\\zen\\logs\\rawdump.out", ios_base::out|ios_base::binary);
+#endif
+	mInterBuff = new unsigned char[RECV_BUFF_SIZE* 2];
+
+}
+
+HTTPFileSource::~HTTPFileSource(void)
+{
+	//debugLog<<"About to close socket"<<endl;
+	close();
+	//debugLog<<"Winsock ended"<<endl;
+#ifdef OGGCODECS_LOGGING
+	debugLog.close();
+	fileDump.close();
+	rawDump.close();
+#endif
+	delete mBufferLock;
+	delete[] mInterBuff;
+}
+
+void HTTPFileSource::unChunk(unsigned char* inBuff, unsigned long inNumBytes) 
+{
+
+	//This method is a bit rough and ready !!
+	ASSERT(inNumBytes > 2);
+	rawDump.write((char*)inBuff, inNumBytes);
+	//debugLog<<"UnChunk"<<endl;
+	unsigned long locNumBytesLeft = inNumBytes;
+
+	memcpy((void*)(mInterBuff + mNumLeftovers), (const void*)inBuff, inNumBytes);
+	locNumBytesLeft +=  mNumLeftovers;
+	mNumLeftovers = 0;
+	unsigned char* locWorkingBuffPtr = mInterBuff;
+
+	//debugLog<<"inNumBytes = "<<inNumBytes<<endl;
+
+	while (locNumBytesLeft > 8) {
+		//debugLog<<"---"<<endl;
+		//debugLog<<"Bytes left = "<<locNumBytesLeft<<endl;
+		//debugLog<<"ChunkRemaining = "<<mChunkRemains<<endl;
+
+		if (mChunkRemains == 0) {
+			//debugLog<<"Zero bytes of chunk remains"<<endl;
+
+			//Assign to a string for easy manipulation of the hex size
+			string locTemp;
+		
+			if (mIsFirstChunk) {
+				//debugLog<<"It's the first chunk"<<endl;
+				mIsFirstChunk = false;
+				locTemp = (char*)locWorkingBuffPtr;
+			} else {
+				//debugLog<<"Not the first chunk"<<endl;
+				//debugLog<<"Skip bytes = "<<(int)locWorkingBuffPtr[0]<<(int)locWorkingBuffPtr[1]<<endl;
+				locTemp = (char*)(locWorkingBuffPtr + 2);
+				locWorkingBuffPtr+=2;
+				locNumBytesLeft -= 2;
+			}
+
+	/*		if (mLeftOver != "") {
+				debugLog<<"Sticking the leftovers back together..."<<endl;
+				locTemp = mLeftOver + locTemp;
+				mLeftOver = "";
+			}*/
+
+			size_t locChunkSizePos = locTemp.find("\r\n");
+			
+			
+			if (locChunkSizePos != string::npos) {
+				//debugLog<<"Found the size bytes "<<endl;
+				//Get a string representation of the hex string that tells us the size of the chunk
+				string locChunkSizeStr = locTemp.substr(0, locChunkSizePos);
+				//debugLog<<"Sizingbuytes " << locChunkSizeStr<<endl;
+				char* locDummyPtr = NULL;
+
+				//Convert it to a number
+				mChunkRemains = strtol(locChunkSizeStr.c_str(), &locDummyPtr, 16);
+
+				//debugLog<<"Chunk reamining "<<mChunkRemains<<endl;
+				//The size of the crlf 's and the chunk size value
+				unsigned long locGuffSize = (unsigned long)(locChunkSizeStr.size() + 2);
+				locWorkingBuffPtr +=  locGuffSize;
+				locNumBytesLeft -= locGuffSize;
+			} else {
+				//debugLog<<"************************************** "<<endl;
+			
+
+			}
+		}
+
+		//This is the end of file
+		if (mChunkRemains == 0) {
+			//debugLog<<"EOF"<<endl;
+			return;
+		}
+
+		//If theres less bytes than the remainder of the chunk
+		if (locNumBytesLeft < mChunkRemains) {
+			//debugLog<<"less bytes remain than the chunk needs"<<endl;
+			
+			mFileCache.write((const unsigned char*)locWorkingBuffPtr, locNumBytesLeft );
+			fileDump.write((char*)locWorkingBuffPtr, locNumBytesLeft);
+			locWorkingBuffPtr += locNumBytesLeft;
+			mChunkRemains -= locNumBytesLeft;
+			locNumBytesLeft = 0;
+		} else {
+			//debugLog<<"more bytes remain than the chunk needs"<<endl;
+			mFileCache.write((const unsigned char*)locWorkingBuffPtr, mChunkRemains );
+			fileDump.write((char*)locWorkingBuffPtr, mChunkRemains);
+			locWorkingBuffPtr += mChunkRemains;
+			locNumBytesLeft -= mChunkRemains;
+			mChunkRemains = 0;
+		}
+
+	}
+
+	if (locNumBytesLeft != 0) {
+		//debugLog<<"There is a non- zero amount of bytes leftover... buffer them up for next time..."<<endl;
+		memcpy((void*)mInterBuff, (const void*)locWorkingBuffPtr, locNumBytesLeft);
+		mNumLeftovers = locNumBytesLeft;
+	}
+}
+void HTTPFileSource::DataProcessLoop() {
+	//debugLog<<"DataProcessLoop: "<<endl;
+	int locNumRead = 0;
+	char* locBuff = NULL;
+	DWORD locCommand = 0;
+	bool locSeenAny = false;
+	debugLog<<"Starting dataprocessloop"<<endl;
+
+	locBuff = new char[RECV_BUFF_SIZE];
+
+	while(true) {
+		if(CheckRequest(&locCommand) == TRUE) {
+			debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+			delete[] locBuff;
+			return;
+		}
+		//debugLog<<"About to call recv"<<endl;
+		locNumRead = recv(mSocket, locBuff, RECV_BUFF_SIZE, 0);
+		//debugLog<<"recv complete"<<endl;
+		if (locNumRead == SOCKET_ERROR) {
+			int locErr = WSAGetLastError();
+			debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
+			mWasError = true;
+			break;
+		}
+
+		if (locNumRead == 0) {
+			debugLog<<"Read last bytes..."<<endl;
+			mIsEOF = true;
+			delete[] locBuff;
+			return;
+		}
+
+		{//CRITICAL SECTION - PROTECTING BUFFER STATE
+			CAutoLock locLock(mBufferLock);
+			//debugLog <<"Num Read = "<<locNumRead<<endl;
+			if (mSeenResponse) {
+				//Add to buffer
+
+				if (mIsChunked) {
+					unChunk((unsigned char*)locBuff, locNumRead);
+				} else {
+					mFileCache.write((const unsigned char*)locBuff, locNumRead);
+				}
+			
+				//Dump to file
+				//fileDump.write(locBuff, locNumRead);
+			} else {
+				//if (!locSeenAny) {
+				//	locSeenAny = true;
+				//	//Start of response
+				//	if (locBuff[0] != '2') {
+				//		mWasError = true;
+				//		delete[] locBuff;
+				//		return;
+				//	}
+				//}
+				string locTemp = locBuff;
+				//debugLog<<"Binary follows... "<<endl<<locTemp<<endl;
+				size_t locPos = locTemp.find("\r\n\r\n");
+				if (locPos != string::npos) {
+					//Found the break
+					//debugLog<<"locPos = "<<locPos<<endl;
+					mSeenResponse = true;
+					mLastResponse = locTemp.substr(0, locPos);
+					debugLog<<"HTTP Response:"<<endl;
+					debugLog<<mLastResponse<<endl;
+
+					unsigned short locResponseCode = getHTTPResponseCode(mLastResponse);
+
+					mRetryAt = "";
+					if (locResponseCode == 301) {
+						size_t locLocPos = mLastResponse.find("Location: ");
+						if (locLocPos != string::npos) {
+							locLocPos += 10;
+							size_t locEndPos = mLastResponse.find("\r", locLocPos);
+							if (locEndPos != string::npos) {
+								if (locEndPos > locLocPos) {
+									mRetryAt = mLastResponse.substr(locLocPos, locEndPos - locLocPos);
+									debugLog<<"Retry URL = "<<mRetryAt<<endl;
+								}
+							}
+						}
+
+						debugLog<<"Setting error to true"<<endl;
+						mIsEOF = true;
+						mWasError = true;
+						//close();
+					} else if (locResponseCode >= 300) {
+						debugLog<<"Setting error to true"<<endl;
+						mIsEOF = true;
+						mWasError = true;
+						//close();
+					}
+
+					if (locTemp.find("Transfer-Encoding: chunked") != string::npos) {
+						mIsChunked = true;
+					}
+
+					char* locBuff2 = locBuff + locPos + 4;  //View only - don't delete.
+					locTemp = locBuff2;
+
+					if (mIsChunked) {
+						if (locNumRead - locPos - 4 > 0) {
+							unChunk((unsigned char*)locBuff2, locNumRead - locPos - 4);
+						}
+					} else {
+                        //debugLog<<"Start of data follows"<<endl<<locTemp<<endl;
+						if (locNumRead - locPos - 4 > 0) {
+							mFileCache.write((const unsigned char*)locBuff2, (locNumRead - (locPos + 4)));
+						}
+					}
+				}
+			}
+		} //END CRITICAL SECTION
+	}
+
+	delete[] locBuff;
+}
+
+unsigned short HTTPFileSource::getHTTPResponseCode(string inHTTPResponse)
+{
+	size_t locPos = inHTTPResponse.find(" ");
+	if (locPos != string::npos) {
+		string locCodeString = inHTTPResponse.substr(locPos + 1, 3);
+		try {
+			unsigned short locCode = (unsigned short)StringHelper::stringToNum(locCodeString);
+			return locCode;
+		} catch(...) {
+			return 0;
+		}
+	} else {
+		return 0;
+	}
+}
+string HTTPFileSource::shouldRetryAt()
+{
+	return mRetryAt;
+}
+
+DWORD HTTPFileSource::ThreadProc(void) {
+	//debugLog<<"ThreadProc:"<<endl;
+	while(true) {
+		DWORD locThreadCommand = GetRequest();
+		
+		switch(locThreadCommand) {
+			case THREAD_EXIT:
+				
+				Reply(S_OK);
+				return S_OK;
+
+			case THREAD_RUN:
+				
+				Reply(S_OK);
+				DataProcessLoop();
+				break;
+				//return S_OK;
+		}
+
+
+	}
+	return S_OK;
+}
+unsigned long HTTPFileSource::seek(unsigned long inPos) {
+	//Close the socket down
+	//Open up a new one to the same place.
+	//Make the partial content request.
+	//debugLog<<"Seeking to "<<inPos<<endl;
+	if (mFileCache.readSeek(inPos)) {
+		return inPos;
+	} else {
+		return (unsigned long) -1;
+	}
+	
+}
+
+
+void HTTPFileSource::close() {
+	//Killing thread
+	//debugLog<<"HTTPFileSource::close()"<<endl;
+	if (ThreadExists() == TRUE) {
+		//debugLog<<"Calling Thread to EXIT"<<endl;
+		CallWorker(THREAD_EXIT);
+		//debugLog<<"Killing thread..."<<endl;
+		Close();
+		//debugLog<<"After Close called on CAMThread"<<endl;
+	}
+
+
+	
+	//debugLog<<"Closing socket..."<<endl;
+	//Close the socket down.
+	closeSocket();
+}
+
+bool HTTPFileSource::startThread() {
+	if (ThreadExists() == FALSE) {
+		Create();
+	}
+	CallWorker(THREAD_RUN);
+	return true;
+}
+bool HTTPFileSource::open(string inSourceLocation, unsigned long inStartByte) {
+	//Open network connection and start feeding data into a buffer
+	//
+	mSeenResponse = false;
+	mLastResponse = "";
+	//debugLog<<"Open: "<<inSourceLocation<<endl;
+
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		
+		//Init rand number generator
+		LARGE_INTEGER locTicks;
+		QueryPerformanceCounter(&locTicks);
+		srand((unsigned int)locTicks.LowPart);
+
+		int locRand = rand();
+
+		string locCacheFileName = getenv("TEMP");
+		//debugLog<<"Temp = "<<locCacheFileName<<endl;
+		locCacheFileName += "\\filecache";
+		
+		locCacheFileName += StringHelper::numToString(locRand);
+		locCacheFileName += ".ogg";
+		//debugLog<<"Cache file  = "<<locCacheFileName<<endl;
+		if(mFileCache.open(locCacheFileName)) {
+			//debugLog<<"OPEN : Cach file opened"<<endl;
+		}
+	} //END CRITICAL SECTION
+
+	bool locIsOK = setupSocket(inSourceLocation);
+
+	if (!locIsOK) {
+		//debugLog<<"Setup socket FAILED"<<endl;
+		closeSocket();
+		return false;
+	}
+
+	//debugLog<<"Sending request..."<<endl;
+
+	//How is filename already set ??
+	httpRequest(assembleRequest(mFileName));
+	//debugLog<<"Socket ok... starting thread"<<endl;
+	locIsOK = startThread();
+
+
+	return locIsOK;
+}
+void HTTPFileSource::clear() {
+	//Reset flags.
+	debugLog<<"Setting error to false";
+	mIsEOF = false;
+	mWasError = false;
+	mRetryAt = "";
+}
+bool HTTPFileSource::isError()
+{
+	return mWasError;
+}
+bool HTTPFileSource::isEOF() {
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		unsigned long locSizeBuffed = mFileCache.bytesAvail();;
+	
+		//debugLog<<"isEOF : Amount Buffered avail = "<<locSizeBuffed<<endl;
+		if ((locSizeBuffed == 0) && mIsEOF) {
+			//debugLog<<"isEOF : It is EOF"<<endl;
+			return true;
+		} else {
+			//debugLog<<"isEOF : It's not EOF"<<endl;
+			return false;
+		}
+	} //END CRITICAL SECTION
+
+}
+unsigned long HTTPFileSource::read(char* outBuffer, unsigned long inNumBytes) {
+	//Reads from the buffer, will return 0 if nothing in buffer.
+	// If it returns 0 check the isEOF flag to see if it was the end of file or the network is just slow.
+
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		
+		//debugLog<<"Read:"<<endl;
+		if((mFileCache.bytesAvail() == 0) || mWasError) {
+			//debugLog<<"read : Can't read is error or eof"<<endl;
+			return 0;
+		} else {
+			//debugLog<<"Reading from buffer"<<endl;
+			
+			unsigned long locNumRead = mFileCache.read((unsigned char*)outBuffer, inNumBytes);
+
+			if (locNumRead > 0) {
+				debugLog<<locNumRead<<" bytes read from buffer"<<endl;
+			}
+			return locNumRead;
+		}
+	} //END CRITICAL SECTION
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPFileSource.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,92 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "oggdllstuff.h"
+
+#include "HTTPSocket.h"
+#include "SingleMediaFileCache.h"
+#include "IFilterDataSource.h"
+#include <string>
+#include <sstream>
+#include <fstream>
+
+using namespace std;
+
+class OGG_DEMUX2_API HTTPFileSource
+	:	public IFilterDataSource
+	,	public CAMThread
+	,	protected HTTPSocket	
+{
+public:
+	HTTPFileSource(void);
+	virtual ~HTTPFileSource(void);
+
+	//Thread commands
+	static const int THREAD_RUN = 0;
+	static const int THREAD_EXIT = 1;
+
+	//IFilterDataSource Interface
+	virtual unsigned long seek(unsigned long inPos);
+	virtual void close() ;
+	virtual bool open(string inSourceLocation, unsigned long inStartByte = 0);
+	virtual void clear();
+	virtual bool isEOF();
+	virtual bool isError();
+	virtual unsigned long read(char* outBuffer, unsigned long inNumBytes);
+	virtual string shouldRetryAt();
+
+	//CAMThread pure virtuals
+	DWORD HTTPFileSource::ThreadProc();
+
+protected:
+	void unChunk(unsigned char* inBuff, unsigned long inNumBytes);
+	unsigned short getHTTPResponseCode(string inHTTPResponse);
+	bool startThread();
+	void DataProcessLoop();
+
+	SingleMediaFileCache mFileCache;
+
+	bool mIsChunked;
+	unsigned long mChunkRemains;
+
+	bool mIsFirstChunk;
+	string mRetryAt;
+
+	fstream debugLog;
+	fstream fileDump;
+	fstream rawDump;
+
+	unsigned char* mInterBuff;
+	unsigned long mNumLeftovers;
+	static	const unsigned long RECV_BUFF_SIZE = 1024;
+
+	CCritSec* mBufferLock;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,217 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 ".\httpsocket.h"
+
+HTTPSocket::HTTPSocket(void)
+	:	mWasError(false)
+	,	mIsEOF(false)
+	,	mIsOpen(false)
+	,	mSeenResponse(false)
+{
+	//debugLog2.open("G:\\logs\\httpsocket.log", ios_base::out);
+
+	//Setup the socket API
+	WORD locWinsockVersion = MAKEWORD(1,1);
+	WSADATA locWinsockData;
+	int locRet= 0;
+
+	locRet = WSAStartup(locWinsockVersion, &locWinsockData);
+	if ((locRet != 0) || (locWinsockData.wVersion != locWinsockVersion)) {
+		//Failed to setup.
+		//debugLog2<<"Failed to start winsock V "<<locWinsockData.wVersion<<endl;
+		WSACleanup();
+		throw 0;
+	}
+
+	//debugLog2<<"Winsock started"<<endl;
+}
+
+HTTPSocket::~HTTPSocket(void)
+{
+	//debugLog2<<"Winsock ended"<<endl;
+	//debugLog2.close();
+	
+	WSACleanup();
+}
+
+
+bool HTTPSocket::setupSocket(string inSourceLocation) 
+{
+
+	mSourceLocation = inSourceLocation;
+	//debugLog2<<"Setup Socket:"<<endl;
+	IN_ADDR locAddress;  //iaHost
+	LPHOSTENT locHostData;;  //lpHost
+
+	bool locValidURL = splitURL(inSourceLocation);
+
+	locAddress.S_un.S_addr = inet_addr(mServerName.c_str());
+	
+
+	if (locAddress.S_un.S_addr == INADDR_NONE) {
+		locHostData = gethostbyname(mServerName.c_str());
+	} else {
+		locHostData = gethostbyaddr((const char*)&locAddress, sizeof(struct in_addr), AF_INET);
+	}
+
+
+
+	if (locHostData == NULL) {
+		//debugLog2<<"LocHostData is NULL"<<endl;
+		//Failed
+		return false;
+	}
+
+	mSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (mSocket == INVALID_SOCKET) {
+		//debugLog2<<"Socket Invalid"<<endl;
+		//Failed
+		return false;
+	}
+
+
+	LPSERVENT locServiceData; //lpServEnt
+	SOCKADDR_IN locServiceSocketAddr; //saServer
+	
+	if (mPort == 0) {
+		locServiceData = getservbyname("http", "tcp");
+		if (locServiceData == NULL) {
+			locServiceSocketAddr.sin_port = htons(80);
+		} else {
+			locServiceSocketAddr.sin_port = locServiceData->s_port;
+		}
+	} else {
+		//Explicit port
+		locServiceSocketAddr.sin_port = htons(mPort);
+	}
+
+
+
+	locServiceSocketAddr.sin_family = AF_INET;
+	locServiceSocketAddr.sin_addr = *((LPIN_ADDR)*locHostData->h_addr_list);
+
+
+	int locRetVal = 0;
+	locRetVal = connect(mSocket, (LPSOCKADDR)&locServiceSocketAddr, sizeof(SOCKADDR_IN));
+	if (locRetVal == SOCKET_ERROR) {
+		//debugLog2<<"Failed to connect..."<<endl;
+		closesocket(mSocket);
+		return false;
+	}
+
+	return true;
+
+
+}
+
+string HTTPSocket::assembleRequest(string inFilePath, unsigned long inStartByte) {
+	string retRequest;
+	retRequest = "GET " + inFilePath+ " HTTP/1.1\r\n" + "Host: " + mServerName+ "\r\n" + "Connection: close";
+	
+	if (inStartByte != 0) {
+		retRequest = retRequest + "\r\n" + "Range: bytes=" + StringHelper::numToString(inStartByte) + "-";
+	}
+	
+	retRequest += "\r\n\r\n";
+	//debugLog2<<"Assembled Req : "<<endl<<retRequest<<endl;
+	return retRequest;
+}
+
+bool HTTPSocket::httpRequest(string inRequest) {
+	//debugLog2<<"Http Request:"<<endl;
+	int locRetVal = send(mSocket, inRequest.c_str(), (int)inRequest.length(), 0);
+
+	if (locRetVal == SOCKET_ERROR) {
+		//debugLog2<<"Socket error on send"<<endl;
+		closesocket(mSocket);
+		return false;
+	}
+	return true;
+}
+
+bool HTTPSocket::splitURL(string inURL) {
+	//debugLog2<<"Split url:"<<endl;
+	string locProtocol;
+	string locServerName;
+	string locPath;
+	string locPort;
+	string locTemp;
+	size_t locPos2;
+	size_t locPos = inURL.find(':');
+	if (locPos == string::npos) {
+		//No colon... not a url or file... failure.
+		return false;
+	} else {
+		locProtocol = inURL.substr(0, locPos);
+		locTemp = inURL.substr(locPos+1);
+		locPos = locTemp.find("//");
+		if ((locPos == string::npos) || (locPos != 0)) {
+			return false;
+		} else {
+            locTemp = locTemp.substr(locPos+2);
+			locPos = locTemp.find('/');
+			if (locPos == string::npos) {
+				return false;
+			} else {
+				locPos2 = locTemp.find(':');
+				if (locPos2 == string::npos) {
+					locServerName = locTemp.substr(0, locPos);
+					locPath = locTemp.substr(locPos);
+				} else if (locPos2 < locPos) {
+					//Explicit port specification
+					locPort = locTemp.substr(locPos2 + 1, locPos - locPos2 - 1);
+					locServerName = locTemp.substr(0, locPos2);
+					locPath = locTemp.substr(locPos);
+				}
+
+			}
+		}
+		
+	}
+
+	mServerName = locServerName;
+	mFileName = locPath;
+	if (locPort != "") {
+		//TODO::: Error checking needed
+		mPort = atoi(locPort.c_str());
+	} else {
+		mPort = 0;
+	}
+	//debugLog2<<"Proto : "<<locProtocol<<endl<<"Server : "<<locServerName<<endl<<" Path : "<<mFileName<<" Port : "<<mPort<<endl;
+	return true;
+
+}
+void HTTPSocket::closeSocket() {
+	//debugLog2<<"Close Socket:"<<endl;
+	int ret = closesocket(mSocket);
+	ret = ret;
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPSocket.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,65 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 <fstream>
+#include <string>
+#include <winsock.h>
+using namespace std;
+
+class OGG_DEMUX2_API HTTPSocket
+{
+public:
+	HTTPSocket(void);
+	virtual ~HTTPSocket(void);
+
+	virtual bool setupSocket(string inSourceLocation);
+	virtual void closeSocket();
+	virtual bool splitURL(string inURL);
+	virtual string assembleRequest(string inFilePath, unsigned long inStartByte = 0);
+	//virtual string assembleRequest(string inFilePath);
+	bool httpRequest(string inRequest);
+protected:
+	string mServerName;
+	string mFileName;
+	unsigned short mPort;
+	string mLastResponse;
+	SOCKET mSocket;
+
+	string mSourceLocation;
+
+	bool mIsEOF;
+	bool mWasError;
+	bool mIsOpen;
+	bool mSeenResponse;
+
+	//fstream debugLog2;
+
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,625 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 "HTTPStreamingFileSource.h"
+
+#define OGGCODECS_LOGGING
+HTTPStreamingFileSource::HTTPStreamingFileSource(void)
+	:	mBufferLock(NULL)
+	,	mIsChunked(false)
+	,	mIsFirstChunk(true)
+	,	mChunkRemains(0)
+	,	mNumLeftovers(0)
+	,	mCurrentAbsoluteReadPosition(0)
+	,	mMemoryBuffer(NULL)
+	,	mContentLength(-1)
+	,	mIsBufferFilling(false)
+	,	mFirstPass(true)
+	,	mStreamStartBuffer(NULL)
+	,	mStreamStartBufferLength(0)
+	,	mApparentReadPosition(0)
+{
+	mBufferLock = new CCritSec;
+#ifdef OGGCODECS_LOGGING
+	debugLog.open("d:\\zen\\logs\\htttp.log", ios_base::out | ios_base::app);
+	fileDump.open("d:\\zen\\logs\\filedump.ogg", ios_base::out|ios_base::binary);
+	rawDump.open("D:\\zen\\logs\\rawdump.out", ios_base::out|ios_base::binary);
+#endif
+	
+	mInterBuff = new unsigned char[RECV_BUFF_SIZE* 2];
+	mMemoryBuffer = new CircularBuffer(MEMORY_BUFFER_SIZE);
+	mStreamStartBuffer = new unsigned char[STREAM_START_BUFFER_SIZE];
+
+}
+
+HTTPStreamingFileSource::~HTTPStreamingFileSource(void)
+{
+	//debugLog<<"About to close socket"<<endl;
+	close();
+	//debugLog<<"Winsock ended"<<endl;
+#ifdef OGGCODECS_LOGGING
+	debugLog.close();
+	fileDump.close();
+	rawDump.close();
+#endif
+	delete mBufferLock;
+	delete[] mInterBuff;
+
+	delete mMemoryBuffer;
+	delete[] mStreamStartBuffer;
+}
+
+void HTTPStreamingFileSource::unChunk(unsigned char* inBuff, unsigned long inNumBytes) 
+{
+
+	//This method is a bit rough and ready !!
+	ASSERT(inNumBytes > 2);
+	rawDump.write((char*)inBuff, inNumBytes);
+	debugLog<<"UnChunk"<<endl;
+	unsigned long locNumBytesLeft = inNumBytes;
+
+	memcpy((void*)(mInterBuff + mNumLeftovers), (const void*)inBuff, inNumBytes);
+	locNumBytesLeft +=  mNumLeftovers;
+	mNumLeftovers = 0;
+	unsigned char* locWorkingBuffPtr = mInterBuff;
+
+	debugLog<<"inNumBytes = "<<inNumBytes<<endl;
+
+	while (locNumBytesLeft > 8) {
+		debugLog<<"---"<<endl;
+		debugLog<<"Bytes left = "<<locNumBytesLeft<<endl;
+		debugLog<<"ChunkRemaining = "<<mChunkRemains<<endl;
+
+		if (mChunkRemains == 0) {
+			debugLog<<"Zero bytes of chunk remains"<<endl;
+
+			//Assign to a string for easy manipulation of the hex size
+			string locTemp;
+		
+			if (mIsFirstChunk) {
+				debugLog<<"+++++++++++++++ It's the first chunk ++++++++++++"<<endl;
+				mIsFirstChunk = false;
+				locTemp = (char*)locWorkingBuffPtr;
+			} else {
+				debugLog<<"Not the first chunk"<<endl;
+				debugLog<<"Skip bytes = "<<(int)locWorkingBuffPtr[0]<<(int)locWorkingBuffPtr[1]<<endl;
+				locTemp = (char*)(locWorkingBuffPtr + 2);
+				locWorkingBuffPtr+=2;
+				locNumBytesLeft -= 2;
+			}
+
+	/*		if (mLeftOver != "") {
+				debugLog<<"Sticking the leftovers back together..."<<endl;
+				locTemp = mLeftOver + locTemp;
+				mLeftOver = "";
+			}*/
+
+			size_t locChunkSizePos = locTemp.find("\r\n");
+			
+			
+			if (locChunkSizePos != string::npos) {
+				debugLog<<"Found the size bytes "<<endl;
+				//Get a string representation of the hex string that tells us the size of the chunk
+				string locChunkSizeStr = locTemp.substr(0, locChunkSizePos);
+				debugLog<<"!!!!! Sizing bytes " << locChunkSizeStr<<endl;
+				char* locDummyPtr = NULL;
+
+				//Convert it to a number
+				mChunkRemains = strtol(locChunkSizeStr.c_str(), &locDummyPtr, 16);
+
+				//debugLog<<"Chunk reamining "<<mChunkRemains<<endl;
+				//The size of the crlf 's and the chunk size value
+				unsigned long locGuffSize = (unsigned long)(locChunkSizeStr.size() + 2);
+				locWorkingBuffPtr +=  locGuffSize;
+				locNumBytesLeft -= locGuffSize;
+			} else {
+				debugLog<<"******************* FAILED TO FIND SIZE BYTES "<<endl;
+			
+
+			}
+		}
+
+		//This is the end of file
+		if (mChunkRemains == 0) {
+			debugLog<<" ??? EOF ???"<<endl;
+			return;
+		}
+
+		debugLog<<"locNumBytesLeft = "<<locNumBytesLeft<<endl;
+		debugLog<<"mChunkRemains = "<<mChunkRemains<<endl;
+		//If theres less bytes than the remainder of the chunk
+		if (locNumBytesLeft < mChunkRemains) {
+			//debugLog<<"less bytes remain than the chunk needs"<<endl;
+			
+			mMemoryBuffer->write((const unsigned char*)locWorkingBuffPtr, locNumBytesLeft );
+			fileDump.write((char*)locWorkingBuffPtr, locNumBytesLeft);
+			locWorkingBuffPtr += locNumBytesLeft;
+			mChunkRemains -= locNumBytesLeft;
+			locNumBytesLeft = 0;
+		} else {
+			//debugLog<<"more bytes remain than the chunk needs"<<endl;
+			mMemoryBuffer->write((const unsigned char*)locWorkingBuffPtr, mChunkRemains );
+			fileDump.write((char*)locWorkingBuffPtr, mChunkRemains);
+			locWorkingBuffPtr += mChunkRemains;
+			locNumBytesLeft -= mChunkRemains;
+			mChunkRemains = 0;
+		}
+
+	}
+
+	if (locNumBytesLeft != 0) {
+		debugLog<<"There is a non- zero amount of bytes leftover... buffer them up for next time..."<<endl;
+		memcpy((void*)mInterBuff, (const void*)locWorkingBuffPtr, locNumBytesLeft);
+		mNumLeftovers = locNumBytesLeft;
+	}
+
+	//Debugging
+	if (strcmp((const char*)mInterBuff, "1000") == 0) {
+		debugLog<<"---- Probably failure point"<<endl;
+		int x= x;
+	}
+}
+void HTTPStreamingFileSource::DataProcessLoop() {
+	//debugLog<<"DataProcessLoop: "<<endl;
+	int locNumRead = 0;
+	char* locBuff = NULL;
+	DWORD locCommand = 0;
+	bool locSeenAny = false;
+	debugLog<<"Starting dataprocessloop"<<endl;
+
+	mIsBufferFilling = false;
+
+	locBuff = new char[RECV_BUFF_SIZE];
+
+	while(true) {
+		if (mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) {
+			//Need to keep reading
+			if(CheckRequest(&locCommand) == TRUE) {
+				if (GetRequest() == THREAD_EXIT) {
+					debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+					delete[] locBuff;
+					return;
+				} else {
+					
+					Reply(S_OK);
+				}
+			}
+		} else {
+			//Got enough data, wait for a new job
+
+			mIsBufferFilling = false;
+			if (GetRequest() == THREAD_EXIT) {	//Block until we have a new job
+				debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+				delete[] locBuff;
+				return;
+			} else {
+				Reply(S_OK);
+			}
+		}
+
+		mIsBufferFilling = true;
+		//if(CheckRequest(&locCommand) == TRUE) {
+		//	debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
+		//	delete[] locBuff;
+		//	return;
+		//}
+		//debugLog<<"About to call recv"<<endl;
+		locNumRead = recv(mSocket, locBuff, RECV_BUFF_SIZE, 0);
+		//debugLog<<"recv complete"<<endl;
+		if (locNumRead == SOCKET_ERROR) {
+			int locErr = WSAGetLastError();
+			debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
+			mWasError = true;
+			break;
+		}
+
+		if (locNumRead == 0) {
+			debugLog<<"Read last bytes..."<<endl;
+			mIsEOF = true;
+			delete[] locBuff;
+			return;
+		}
+
+		{//CRITICAL SECTION - PROTECTING BUFFER STATE
+			CAutoLock locLock(mBufferLock);
+			//debugLog <<"Num Read = "<<locNumRead<<endl;
+			if (mSeenResponse) {
+				//Add to buffer
+
+				if (mIsChunked) {
+					unChunk((unsigned char*)locBuff, locNumRead);
+				} else {
+					mMemoryBuffer->write((const unsigned char*)locBuff, locNumRead);
+				}
+			
+				//Dump to file
+				//fileDump.write(locBuff, locNumRead);
+			} else {
+				//if (!locSeenAny) {
+				//	locSeenAny = true;
+				//	//Start of response
+				//	if (locBuff[0] != '2') {
+				//		mWasError = true;
+				//		delete[] locBuff;
+				//		return;
+				//	}
+				//}
+				string locTemp = locBuff;
+				//debugLog<<"Binary follows... "<<endl<<locTemp<<endl;
+				size_t locPos = locTemp.find("\r\n\r\n");
+				if (locPos != string::npos) {
+					//Found the break
+					//debugLog<<"locPos = "<<locPos<<endl;
+					mSeenResponse = true;
+					mLastResponse = locTemp.substr(0, locPos);
+					debugLog<<"HTTP Response:"<<endl;
+					debugLog<<mLastResponse<<endl;
+
+					unsigned short locResponseCode = getHTTPResponseCode(mLastResponse);
+
+					mRetryAt = "";
+					if (locResponseCode == 301) {
+						size_t locLocPos = mLastResponse.find("Location: ");
+						if (locLocPos != string::npos) {
+							locLocPos += 10;
+							size_t locEndPos = mLastResponse.find("\r", locLocPos);
+							if (locEndPos != string::npos) {
+								if (locEndPos > locLocPos) {
+									mRetryAt = mLastResponse.substr(locLocPos, locEndPos - locLocPos);
+									debugLog<<"Retry URL = "<<mRetryAt<<endl;
+								}
+							}
+						}
+
+						debugLog<<"Setting error to true"<<endl;
+						mIsEOF = true;
+						mWasError = true;
+						//close();
+					} else if (locResponseCode >= 300) {
+						debugLog<<"Setting error to true"<<endl;
+						mIsEOF = true;
+						mWasError = true;
+						//close();
+					} else {
+						//Good response
+
+						//Check for content-length
+						mContentLength = -1;
+						size_t locContentLengthPos = mLastResponse.find("Content-Length: ");
+						if (locContentLengthPos != string::npos) {
+							locContentLengthPos += 16;
+
+							size_t locEndPos = mLastResponse.find("\r", locContentLengthPos);
+							if ((locEndPos != string::npos) && (locEndPos > locContentLengthPos)) {
+								string locLengthString = mLastResponse.substr(locContentLengthPos, locEndPos - locContentLengthPos);
+
+								
+								try {
+									__int64 locContentLength = StringHelper::stringToNum(locLengthString);
+									mContentLength = locContentLength;
+								} catch(...) {
+									mContentLength = -1;
+								}
+							}
+						}
+					}
+
+					if (locTemp.find("Transfer-Encoding: chunked") != string::npos) {
+						mIsChunked = true;
+					}
+
+					char* locBuff2 = locBuff + locPos + 4;  //View only - don't delete.
+					locTemp = locBuff2;
+
+					if (mIsChunked) {
+						if (locNumRead - locPos - 4 > 0) {
+							unChunk((unsigned char*)locBuff2, locNumRead - locPos - 4);
+						}
+					} else {
+                        //debugLog<<"Start of data follows"<<endl<<locTemp<<endl;
+						if (locNumRead - locPos - 4 > 0) {
+							mMemoryBuffer->write((const unsigned char*)locBuff2, (locNumRead - (locPos + 4)));
+						}
+					}
+				}
+			}
+		} //END CRITICAL SECTION
+	}
+
+	delete[] locBuff;
+}
+
+unsigned short HTTPStreamingFileSource::getHTTPResponseCode(string inHTTPResponse)
+{
+	size_t locPos = inHTTPResponse.find(" ");
+	if (locPos != string::npos) {
+		string locCodeString = inHTTPResponse.substr(locPos + 1, 3);
+		try {
+			unsigned short locCode = (unsigned short)StringHelper::stringToNum(locCodeString);
+			return locCode;
+		} catch(...) {
+			return 0;
+		}
+	} else {
+		return 0;
+	}
+}
+string HTTPStreamingFileSource::shouldRetryAt()
+{
+	return mRetryAt;
+}
+
+DWORD HTTPStreamingFileSource::ThreadProc(void) {
+	//debugLog<<"ThreadProc:"<<endl;
+	while(true) {
+		DWORD locThreadCommand = GetRequest();
+		
+		switch(locThreadCommand) {
+			case THREAD_EXIT:
+				
+				Reply(S_OK);
+				return S_OK;
+
+			case THREAD_RUN:
+				
+				Reply(S_OK);
+				DataProcessLoop();
+				break;
+				//return S_OK;
+		}
+
+
+	}
+	return S_OK;
+}
+unsigned long HTTPStreamingFileSource::seek(unsigned long inPos) 
+{
+	//Close the socket down
+	//Open up a new one to the same place.
+	//Make the partial content request.
+	//debugLog<<"Seeking to "<<inPos<<endl;
+
+	//Keep track of the absolute position we are looking at in the file.
+	
+	mFirstPass = false;
+	if (mCurrentAbsoluteReadPosition <= mStreamStartBufferLength) {
+		//The network stream is still within the start buffer
+		mApparentReadPosition = inPos;
+		return inPos;
+	} else {
+	
+		mCurrentAbsoluteReadPosition = inPos;
+	
+	
+	
+	
+	
+		if ((mContentLength != -1) || (inPos == 0)) {
+			close();
+			closeSocket();
+			clear();
+
+			open(mSourceLocation, inPos);
+			return inPos;
+
+		} else {
+			return (unsigned long) -1;
+		}
+	}
+	//if (mFileCache.readSeek(inPos)) {
+	//	return inPos;
+	//} else {
+	//	return (unsigned long) -1;
+	//}
+	
+}
+
+
+void HTTPStreamingFileSource::close() {
+	//Killing thread
+	//debugLog<<"HTTPStreamingFileSource::close()"<<endl;
+	if (ThreadExists() == TRUE) {
+		//debugLog<<"Calling Thread to EXIT"<<endl;
+		CallWorker(THREAD_EXIT);
+		//debugLog<<"Killing thread..."<<endl;
+		Close();
+		//debugLog<<"After Close called on CAMThread"<<endl;
+	}
+
+
+	
+	//debugLog<<"Closing socket..."<<endl;
+	//Close the socket down.
+	closeSocket();
+}
+
+bool HTTPStreamingFileSource::startThread() {
+	if (ThreadExists() == FALSE) {
+		Create();
+	}
+	CallWorker(THREAD_RUN);
+	return true;
+}
+bool HTTPStreamingFileSource::open(string inSourceLocation, unsigned long inStartByte) {
+	//Open network connection and start feeding data into a buffer
+	//
+	mSeenResponse = false;
+	mLastResponse = "";
+	//debugLog<<"Open: "<<inSourceLocation<<endl;
+
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		
+		////Init rand number generator
+		//LARGE_INTEGER locTicks;
+		//QueryPerformanceCounter(&locTicks);
+		//srand((unsigned int)locTicks.LowPart);
+
+		//int locRand = rand();
+
+		//string locCacheFileName = getenv("TEMP");
+		////debugLog<<"Temp = "<<locCacheFileName<<endl;
+		//locCacheFileName += "\\filecache";
+		//
+		//locCacheFileName += StringHelper::numToString(locRand);
+		//locCacheFileName += ".ogg";
+		//debugLog<<"Cache file  = "<<locCacheFileName<<endl;
+		//if(mFileCache.open(locCacheFileName)) {
+		//	//debugLog<<"OPEN : Cach file opened"<<endl;
+		//}
+
+		mMemoryBuffer->reset();
+	} //END CRITICAL SECTION
+
+	bool locIsOK = setupSocket(inSourceLocation);
+
+	if (!locIsOK) {
+		//debugLog<<"Setup socket FAILED"<<endl;
+		closeSocket();
+		return false;
+	}
+
+	//debugLog<<"Sending request..."<<endl;
+
+	//How is filename already set ??
+	httpRequest(assembleRequest(mFileName, inStartByte));
+	//debugLog<<"Socket ok... starting thread"<<endl;
+	locIsOK = startThread();
+
+
+	return locIsOK;
+}
+void HTTPStreamingFileSource::clear() {
+	//Reset flags.
+	debugLog<<"Setting error to false";
+	mIsEOF = false;
+	mWasError = false;
+	mRetryAt = "";
+	mIsFirstChunk = true;
+	mChunkRemains = 0;
+	mNumLeftovers = 0;
+	
+	//TODO::: Check if this should really be here
+	mFirstPass = true;
+
+	mCurrentAbsoluteReadPosition = 0;
+	mApparentReadPosition = 0;
+	//mSourceLocation = "";
+	//mContentLength = -1;
+}
+bool HTTPStreamingFileSource::isError()
+{
+	return mWasError;
+}
+bool HTTPStreamingFileSource::isEOF() {
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		unsigned long locSizeBuffed = mMemoryBuffer->numBytesAvail(); //mFileCache.bytesAvail();;
+	
+		//debugLog<<"isEOF : Amount Buffered avail = "<<locSizeBuffed<<endl;
+		if ((locSizeBuffed == 0) && mIsEOF) {
+			//debugLog<<"isEOF : It is EOF"<<endl;
+			return true;
+		} else {
+			//debugLog<<"isEOF : It's not EOF"<<endl;
+			return false;
+		}
+	} //END CRITICAL SECTION
+
+}
+unsigned long HTTPStreamingFileSource::read(char* outBuffer, unsigned long inNumBytes) {
+	//Reads from the buffer, will return 0 if nothing in buffer.
+	// If it returns 0 check the isEOF flag to see if it was the end of file or the network is just slow.
+
+	unsigned long locNumRead = 0;
+	{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+		CAutoLock locLock(mBufferLock);
+		
+		if (!mFirstPass && (mApparentReadPosition < mStreamStartBufferLength)) {
+			//In this case we have done a seekback and need to serve the request from the start buffer
+			unsigned long locBytesStillBuffered = mStreamStartBufferLength - mApparentReadPosition;
+
+			unsigned long locBytesToRead = (inNumBytes <= locBytesStillBuffered)	?	inNumBytes
+																					:	locBytesStillBuffered;
+
+			memcpy((void*)outBuffer, (const void*)(mStreamStartBuffer + mApparentReadPosition), locBytesToRead);
+			mApparentReadPosition += locBytesToRead;
+			locNumRead = locBytesToRead;
+
+		} else {
+			//debugLog<<"Read:"<<endl;
+			if((mMemoryBuffer->numBytesAvail() == 0) || mWasError) {
+				//debugLog<<"read : Can't read is error or eof"<<endl;
+				//return 0;
+			} else {
+				//debugLog<<"Reading from buffer"<<endl;
+				
+				//Allow short reads from buffer
+				locNumRead = mMemoryBuffer->read((unsigned char*)outBuffer, inNumBytes, true);
+
+				//Handle the special start of stream buffer
+				if (mFirstPass && (locNumRead > 0) && (mStreamStartBufferLength < STREAM_START_BUFFER_SIZE)) {
+					//If we are still on the first pass (which means we are still parsing header info)
+					//	then we copy this into the start buffer
+
+					unsigned long locSpaceLeftInStartBuffer = STREAM_START_BUFFER_SIZE - mStreamStartBufferLength;
+
+					//There is at least 1 byte of space left
+					unsigned long locBytesToCopy = (locNumRead <= locSpaceLeftInStartBuffer)	?	locNumRead
+																								:	locSpaceLeftInStartBuffer;
+
+					memcpy((void*)(mStreamStartBuffer + mStreamStartBufferLength), (const void*)outBuffer, locBytesToCopy);
+					mStreamStartBufferLength += locBytesToCopy;
+				}
+
+
+				if (locNumRead > 0) {
+					debugLog<<locNumRead<<" bytes read from buffer at "<<mCurrentAbsoluteReadPosition<< endl;
+				}
+
+				mCurrentAbsoluteReadPosition += locNumRead;
+
+				//if (mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) {
+				//	CallWorker(THREAD_RUN);
+				//}
+				//return locNumRead;
+
+			}
+		}
+	} //END CRITICAL SECTION
+
+	if ((mMemoryBuffer->numBytesAvail() <= MEMORY_BUFFER_LOW_TIDE) && (!mIsBufferFilling) && (!mIsEOF)) {
+		CallWorker(THREAD_RUN);
+	}
+
+	
+	return locNumRead;
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/HTTPStreamingFileSource.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,125 @@
+
+//===========================================================================
+//Copyright (C) 2003-2006 Zentaro Kavanagh
+//
+//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 "oggdllstuff.h"
+
+#include "HTTPSocket.h"
+#include "IFilterDataSource.h"
+#include <string>
+#include <sstream>
+#include <fstream>
+
+using namespace std;
+
+class OGG_DEMUX2_API HTTPStreamingFileSource
+	:	public IFilterDataSource
+	,	public CAMThread
+	,	protected HTTPSocket	
+{
+public:
+	HTTPStreamingFileSource(void);
+	virtual ~HTTPStreamingFileSource(void);
+
+	//Consts
+	static const unsigned long MEMORY_BUFFER_SIZE = 1024 * 1024 * 2;	//2 megs
+	static const unsigned long MEMORY_BUFFER_LOW_TIDE = 1024 * 512 * 3; //1.5 megs
+	//Thread commands
+	static const int THREAD_RUN = 0;
+	static const int THREAD_EXIT = 1;
+
+	//IFilterDataSource Interface
+	virtual unsigned long seek(unsigned long inPos);
+	virtual void close() ;
+	virtual bool open(string inSourceLocation, unsigned long inStartByte = 0);
+	virtual void clear();
+	virtual bool isEOF();
+	virtual bool isError();
+	virtual unsigned long read(char* outBuffer, unsigned long inNumBytes);
+	virtual string shouldRetryAt();
+
+	
+	//CAMThread pure virtuals
+	DWORD ThreadProc();
+
+
+
+protected:
+	void unChunk(unsigned char* inBuff, unsigned long inNumBytes);
+	unsigned short getHTTPResponseCode(string inHTTPResponse);
+	bool startThread();
+	void DataProcessLoop();
+
+	//SingleMediaFileCache mFileCache;
+	CircularBuffer* mMemoryBuffer;
+
+	bool mIsChunked;
+	unsigned long mChunkRemains;
+
+	bool mIsBufferFilling;
+
+	bool mIsFirstChunk;
+	string mRetryAt;
+
+	fstream debugLog;
+	fstream fileDump;
+	fstream rawDump;
+
+	unsigned char* mInterBuff;
+	unsigned long mNumLeftovers;
+	static	const unsigned long RECV_BUFF_SIZE = 1024;
+	static const unsigned long STREAM_START_BUFFER_SIZE = 32 * 1024;
+
+	//Fix for seekback on headers - since we only maintain a forward buffer. The seek back to start which occurs
+	//	right after the headers are processed, will generally trigger a stream reset. But an annodex server,
+	//	will serve out a file with completely different serial numbers, making it impossible to map the streams
+	//	using the originally gathered information.
+	//
+	//Now we are going to buffer up the first part of the file into yet another buffer. Also keep track
+	//	of what the absolute byte position is we have read up to so far from the stream. When we receive a seek request,
+	//	we check if the current read position is within this new buffer.
+	//
+	//If it is, then we can set a flag, and respond to read requests from this new buffer, up until the point
+	//	where the stream was before the seek, then switch back to serving out live streaming data.
+	unsigned long mCurrentAbsoluteReadPosition;
+	bool mFirstPass;
+
+	unsigned char* mStreamStartBuffer;
+	unsigned long mStreamStartBufferLength;
+
+	unsigned long mApparentReadPosition;
+	
+	//
+
+	__int64 mContentLength;
+
+	CCritSec* mBufferLock;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IFilterDataSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IFilterDataSource.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IFilterDataSource.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,50 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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>
+using namespace std;
+class OGG_DEMUX2_API IFilterDataSource
+{
+public:
+	//Empty Constructor and destructor to ensure proper deletion
+	IFilterDataSource(void)							{}
+	virtual ~IFilterDataSource(void)				{}
+
+	virtual unsigned long seek(unsigned long inPos) = 0;
+	virtual void close()  = 0;
+	virtual bool open(string inSourceLocation, unsigned long inStartByte = 0) = 0;
+	virtual void clear() = 0;
+	virtual bool isEOF() = 0;
+	virtual bool isError() = 0;
+	virtual unsigned long read(char* outBuffer, unsigned long inNumBytes) = 0;
+	virtual string shouldRetryAt() = 0;
+	
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggBaseTime.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggBaseTime.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggBaseTime.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,8 @@
+
+#pragma once
+class IOggBaseTime {
+public:
+	
+	virtual __int64 getGlobalBaseTime() = 0;
+
+};
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggDecoder.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggDecoder.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggDecoder.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,34 @@
+#pragma once
+//
+//#ifndef LOOG_INT64
+//# ifdef WIN32
+//#  define LOOG_INT64 signed __int64
+//# else  /* assume POSIX */
+//#  define LOOG_INT64 int64_t
+//# endif
+//#endif
+//
+
+#include <libOOOgg/libOOOgg.h>
+#include <libOOOggSeek/IOggDecoderSeek.h>
+#include <string>
+using namespace std;
+class IOggDecoder 
+	:	public IOggDecoderSeek
+{
+public:
+	enum eAcceptHeaderResult {
+		AHR_ALL_HEADERS_RECEIVED,
+		AHR_MORE_HEADERS_TO_COME,
+		AHR_INVALID_HEADER,
+		AHR_UNEXPECTED,
+		AHR_NULL_POINTER,
+
+	};
+	virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule) = 0;
+	virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule) = 0;
+	virtual eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket) = 0;
+	virtual string getCodecShortName() = 0;
+	virtual string getCodecIdentString() = 0;
+	
+};
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggOutputPin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggOutputPin.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/IOggOutputPin.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,8 @@
+
+#pragma once
+class IOggOutputPin {
+public:
+	virtual bool notifyStreamBaseTime(__int64 inStreamTime) = 0;
+	virtual __int64 getGlobalBaseTime() = 0;
+
+};
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,746 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 "OggDemuxPacketSourceFilter.h"
+#include "OggStreamMapper.h"
+
+// This template lets the Object factory create us properly and work with COM infrastructure.
+CFactoryTemplate g_Templates[] = 
+{
+    { 
+		L"OggDemuxFilter",						// Name
+	    &CLSID_OggDemuxPacketSourceFilter,            // CLSID
+	    OggDemuxPacketSourceFilter::CreateInstance,	// Method to create an instance of MyComponent
+        NULL,									// Initialization function
+        NULL									// Set-up information (for filters)
+    }
+	
+	//,
+
+	//{ 
+	//	L"illiminable About Page",				// Name
+	//    &CLSID_PropsAbout,						// CLSID
+	//    PropsAbout::CreateInstance,				// Method to create an instance of MyComponent
+ //       NULL,									// Initialization function
+ //       NULL									// Set-up information (for filters)
+ //   }
+
+};
+
+// Generic way of determining the number of items in the template
+int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); 
+
+//COM Creator Function
+CUnknown* WINAPI OggDemuxPacketSourceFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
+{
+	OggDemuxPacketSourceFilter *pNewObject = new OggDemuxPacketSourceFilter();
+    if (pNewObject == NULL) {
+        *pHr = E_OUTOFMEMORY;
+    }
+    return pNewObject;
+} 
+//COM Interface query function
+STDMETHODIMP OggDemuxPacketSourceFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+{
+	if (riid == IID_IFileSourceFilter) {
+		*ppv = (IFileSourceFilter*)this;
+		((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+	//} else if (riid == IID_IMediaSeeking) {
+	//	*ppv = (IMediaSeeking*)this;
+	//	((IUnknown*)*ppv)->AddRef();
+	//	return NOERROR;
+	/*} else if (riid == IID_ISpecifyPropertyPages) {
+		*ppv = (ISpecifyPropertyPages*)this;
+		((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+	*/
+	}  else if (riid == IID_IAMFilterMiscFlags) {
+		*ppv = (IAMFilterMiscFlags*)this;
+		((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+	//} else if (riid == IID_IAMMediaContent) {
+	//	//debugLog<<"Queries for IAMMediaContent///"<<endl;
+	//	*ppv = (IAMMediaContent*)this;
+	//	((IUnknown*)*ppv)->AddRef();
+	//	return NOERROR;
+	}  else if (riid == IID_IOggBaseTime) {
+		*ppv = (IOggBaseTime*)this;
+		//((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+	}
+
+
+	
+
+	return CBaseFilter::NonDelegatingQueryInterface(riid, ppv); 
+}
+OggDemuxPacketSourceFilter::OggDemuxPacketSourceFilter(void)
+	:	CBaseFilter(NAME("OggDemuxPacketSourceFilter"), NULL, m_pLock, CLSID_OggDemuxPacketSourceFilter)
+	,	mDataSource(NULL)
+	,	mSeenAllBOSPages(false)
+	,	mSeenPositiveGranulePos(false)
+	,	mPendingPage(NULL)
+	,	mJustReset(true)
+	,	mSeekTable(NULL)
+	,	mGlobalBaseTime(0)
+{
+	//Why do we do this, should the base class do it ?
+	m_pLock = new CCritSec;
+
+	mSourceFileLock = new CCritSec;
+	mDemuxLock = new CCritSec;
+	mStreamLock = new CCritSec;
+
+	mStreamMapper = new OggStreamMapper(this, m_pLock);
+
+	
+}
+
+OggDemuxPacketSourceFilter::~OggDemuxPacketSourceFilter(void)
+{
+	delete mStreamMapper;
+	delete mSeekTable;
+	//TODO::: Delete the locks
+
+	delete mDemuxLock;
+	delete mStreamLock;
+	delete mSourceFileLock;
+
+	mDataSource->close();
+	delete mDataSource;
+}
+//IMEdiaStreaming
+STDMETHODIMP OggDemuxPacketSourceFilter::Run(REFERENCE_TIME tStart) 
+{
+	CAutoLock locLock(m_pLock);
+	return CBaseFilter::Run(tStart);
+
+	
+
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::Pause(void) 
+{
+	CAutoLock locLock(m_pLock);
+	if (m_State == State_Stopped) {
+		if (ThreadExists() == FALSE) {
+			Create();
+		}
+		CallWorker(THREAD_RUN);
+	}
+	HRESULT locHR = CBaseFilter::Pause();
+	
+	return locHR;
+	
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::Stop(void) 
+{
+	CAutoLock locLock(m_pLock);
+	CallWorker(THREAD_EXIT);
+	Close();
+	DeliverBeginFlush();
+	//mSetIgnorePackets = true;
+	DeliverEndFlush();
+	
+	return CBaseFilter::Stop();
+
+
+}
+void OggDemuxPacketSourceFilter::DeliverBeginFlush() 
+{
+	CAutoLock locLock(m_pLock);
+	
+	for (unsigned long i = 0; i < mStreamMapper->numPins(); i++) {
+		mStreamMapper->getPinByIndex(i)->DeliverBeginFlush();
+	}
+
+	//Should this be here or endflush or neither ?
+	
+	//debugLog<<"Calling reset stream from begin flush"<<endl;
+	resetStream();
+}
+
+void OggDemuxPacketSourceFilter::DeliverEndFlush() 
+{
+	CAutoLock locLock(m_pLock);
+	for (unsigned long i = 0; i < mStreamMapper->numPins(); i++) {
+		//mStreamMapper->getOggStream(i)->flush();
+		mStreamMapper->getPinByIndex(i)->DeliverEndFlush();
+	}
+
+	
+	//if (mSetIgnorePackets == true) {
+	//	mStreamMapper->toStartOfData();
+	//	for (unsigned long i = 0; i < mStreamMapper->numStreams(); i++) {
+	//		//mStreamMapper->getOggStream(i)->flush();
+	//		mStreamMapper->getOggStream(i)->getPin()->DeliverEndFlush();
+	//	}
+
+	//} else {
+	//
+	//	for (unsigned long i = 0; i < mStreamMapper->numStreams(); i++) {
+	//		mStreamMapper->getOggStream(i)->flush();
+	//		mStreamMapper->getOggStream(i)->getPin()->DeliverEndFlush();
+	//	}
+	//}
+	//mSetIgnorePackets = false;
+}
+void OggDemuxPacketSourceFilter::DeliverEOS() 
+{
+	//mStreamMapper->toStartOfData();
+
+	for (unsigned long i = 0; i < mStreamMapper->numPins(); i++) {
+		//mStreamMapper->getOggStream(i)->flush();
+		mStreamMapper->getPinByIndex(i)->DeliverEndOfStream();
+		
+	}
+	//debugLog<<"Calling reset stream from DeliverEOS"<<endl;
+	resetStream();
+}
+
+void OggDemuxPacketSourceFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) 
+{
+	
+	for (unsigned long i = 0; i < mStreamMapper->numPins(); i++) {
+		mStreamMapper->getPinByIndex(i)->DeliverNewSegment(tStart, tStop, dRate);
+	}
+}
+
+void OggDemuxPacketSourceFilter::resetStream() {
+	{
+		CAutoLock locDemuxLock(mDemuxLock);
+		CAutoLock locSourceLock(mSourceFileLock);
+
+		//Close up the data source
+		mDataSource->clear();
+
+		mDataSource->close();
+		delete mDataSource;
+		mDataSource = NULL;
+		
+
+		mOggBuffer.clearData();
+
+		//Before opening make the interface
+		mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
+
+		mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
+		mDataSource->seek(0);   //Should always be zero for now.
+
+		//TODO::: Should be doing stuff with the demux state here ? or packetiser ?>?
+		
+		mJustReset = true;   //TODO::: Look into this !
+	}
+}
+bool OggDemuxPacketSourceFilter::acceptOggPage(OggPage* inOggPage)
+{
+	if (!mSeenAllBOSPages) {
+		if (!inOggPage->header()->isBOS()) {
+			mSeenAllBOSPages = true;
+			mBufferedPages.push_back(inOggPage);
+			return true;
+		} else {
+			return mStreamMapper->acceptOggPage(inOggPage);
+		}
+	} else if (!mSeenPositiveGranulePos) {
+		if (inOggPage->header()->GranulePos() > 0) {
+			mSeenPositiveGranulePos = true;
+		}
+		mBufferedPages.push_back(inOggPage);
+		return true;
+	} else {
+		//OGGCHAIN::: Here, need to check for an eos, and reset stream, else do it in strmapper
+		return mStreamMapper->acceptOggPage(inOggPage);
+	}
+}
+HRESULT OggDemuxPacketSourceFilter::SetUpPins()
+{
+	CAutoLock locDemuxLock(mDemuxLock);
+	CAutoLock locSourceLock(mSourceFileLock);
+	
+	unsigned short locRetryCount = 0;
+	const unsigned short RETRY_THRESHOLD = 3;
+
+	//Create and open a data source
+	mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
+	mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
+	
+	//Error check
+	
+	//Register a callback
+	mOggBuffer.registerVirtualCallback(this);
+
+	char* locBuff = new char[SETUP_BUFFER_SIZE];
+	unsigned long locNumRead = 0;
+
+	//Feed the data in until we have seen all BOS pages.
+	while(!mSeenPositiveGranulePos) {			//mStreamMapper->allStreamsReady()) {
+	
+		locNumRead = mDataSource->read(locBuff, SETUP_BUFFER_SIZE);
+	
+		if (locNumRead > 0) {
+			mOggBuffer.feed((const unsigned char*)locBuff, locNumRead);
+		}
+
+		if (mDataSource->isEOF() || mDataSource->isError()) {
+			if (mDataSource->isError() && (mDataSource->shouldRetryAt() != "") && (locRetryCount < RETRY_THRESHOLD)) {
+				mOggBuffer.clearData();
+				string locNewLocation = mDataSource->shouldRetryAt();
+				//debugLog<<"Retrying at : "<<locNewLocation<<endl;
+				delete mDataSource;
+				mDataSource = DataSourceFactory::createDataSource(locNewLocation.c_str());
+				mDataSource->open(locNewLocation.c_str());
+				locRetryCount++;
+			} else {
+				//debugLog<<"Bailing out"<<endl;
+				delete[] locBuff;
+				return VFW_E_CANNOT_RENDER;
+			}
+		}
+	}
+	
+	//mStreamMapper->setAllowDispatch(true);
+	//mStreamMapper->();			//Flushes all streams and sets them to ignore the right number of headers.
+	mOggBuffer.clearData();
+	mDataSource->seek(0);			//TODO::: This is bad for streams.
+
+	//debugLog<<"COMPLETED SETUP"<<endl;
+	delete[] locBuff;
+	return S_OK;
+
+
+}
+
+vector<OggPage*> OggDemuxPacketSourceFilter::getMatchingBufferedPages(unsigned long inSerialNo)
+{
+	vector<OggPage*> locList;
+	for (size_t i = 0; i < mBufferedPages.size(); i++) {
+		if (mBufferedPages[i]->header()->StreamSerialNo() == inSerialNo) {
+			locList.push_back(mBufferedPages[i]->clone());
+		}
+	}
+	return locList;
+}
+void OggDemuxPacketSourceFilter::removeMatchingBufferedPages(unsigned long inSerialNo)
+{
+	vector<OggPage*> locNewList;
+	int locSize = mBufferedPages.size();
+	for (int i = 0; i < locSize; i++) {
+		if (mBufferedPages[i]->header()->StreamSerialNo() != inSerialNo) {
+			locNewList.push_back(mBufferedPages[i]);
+		} else {
+			delete mBufferedPages[i];
+		}
+	}
+	mBufferedPages = locNewList;
+
+}
+
+
+
+int OggDemuxPacketSourceFilter::GetPinCount() 
+{
+	//TODO::: Implement
+	return mStreamMapper->numPins();
+}
+CBasePin* OggDemuxPacketSourceFilter::GetPin(int inPinNo) 
+{
+	if (inPinNo < 0) {
+		return NULL;
+	}
+	return mStreamMapper->getPinByIndex(inPinNo);
+}
+
+//IFileSource Interface
+STDMETHODIMP OggDemuxPacketSourceFilter::GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType) 
+{
+	////Return the filename and mediatype of the raw data
+	LPOLESTR x = SysAllocString(mFileName.c_str());
+	*outFileName = x;
+
+	//TODO:::
+	
+	return S_OK;
+}
+
+
+STDMETHODIMP OggDemuxPacketSourceFilter::Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType) 
+{
+	////Initialise the file here and setup all the streams
+	CAutoLock locLock(m_pLock);
+
+
+
+	mFileName = inFileName;
+
+	if (mFileName.find(L"XsZZfQ__WiiPFD.anx") == mFileName.size() - 18){
+		mFileName = mFileName.substr(0, mFileName.size() - 18);
+		
+	}
+
+	//debugLog<<"Loading : "<<StringHelper::toNarrowStr(mFileName)<<endl;
+
+	//debugLog << "Opening source file : "<<StringHelper::toNarrowStr(mFileName)<<endl;
+	//mSeekTable = new AutoOggSeekTable(StringHelper::toNarrowStr(mFileName));
+	//mSeekTable->buildTable();
+	//
+	HRESULT locHR = SetUpPins();
+
+	if (locHR == S_OK) {
+		//mSeekTable = new AutoOggChainGranuleSeekTable(StringHelper::toNarrowStr(mFileName));
+		//int locNumPins = GetPinCount();
+
+		//OggDemuxPacketSourcePin* locPin = NULL;
+		//for (int i = 0; i < locNumPins; i++) {
+		//	locPin = (OggDemuxPacketSourcePin*)GetPin(i);
+		//	
+		//	
+		//	mSeekTable->addStream(locPin->getSerialNo(), locPin->getDecoderInterface());
+		//}
+		//mSeekTable->buildTable();
+		return S_OK;
+	} else {
+		return locHR;
+	}
+
+	//TODO:::
+	//return S_OK;
+}
+
+//IAMFilterMiscFlags Interface
+ULONG OggDemuxPacketSourceFilter::GetMiscFlags(void) 
+{
+	return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+}
+
+//CAMThread Stuff
+DWORD OggDemuxPacketSourceFilter::ThreadProc(void) {
+	
+	while(true) {
+		DWORD locThreadCommand = GetRequest();
+	
+		switch(locThreadCommand) {
+			case THREAD_EXIT:
+	
+				Reply(S_OK);
+				return S_OK;
+
+			case THREAD_RUN:
+	
+				Reply(S_OK);
+				DataProcessLoop();
+				break;
+		}
+	}
+	return S_OK;
+}
+
+void OggDemuxPacketSourceFilter::notifyPinConnected()
+{
+	if (mStreamMapper->allStreamsReady()) {
+		//Setup the seek table.
+		if (mSeekTable == NULL) {
+			mSeekTable = new AutoOggChainGranuleSeekTable(StringHelper::toNarrowStr(mFileName));
+			int locNumPins = GetPinCount();
+
+			OggDemuxPacketSourcePin* locPin = NULL;
+			for (int i = 0; i < locNumPins; i++) {
+				locPin = (OggDemuxPacketSourcePin*)GetPin(i);
+				
+				
+				mSeekTable->addStream(locPin->getSerialNo(), locPin->getDecoderInterface());
+			}
+			mSeekTable->buildTable();
+		}
+	}
+}
+HRESULT OggDemuxPacketSourceFilter::DataProcessLoop() 
+{
+	//Mess with the locking mechanisms at your own risk.
+
+
+	//debugLog<<"Starting DataProcessLoop :"<<endl;
+	DWORD locCommand = 0;
+	char* locBuff = new  char[4096];			//Deleted before function returns...
+	//TODO::: Make this a member variable ^^^^^
+	bool locKeepGoing = true;
+	unsigned long locBytesRead = 0;
+	bool locIsEOF = true;
+	{
+		CAutoLock locSourceLock(mSourceFileLock);
+		locIsEOF = mDataSource->isEOF();
+	}
+
+	while(true) {
+		if(CheckRequest(&locCommand) == TRUE) {
+			//debugLog<<"DataProcessLoop : Thread Command issued... leaving loop."<<endl;
+			delete[] locBuff;
+			return S_OK;
+		}
+		//debugLog<<"Looping..."<<endl;
+		{
+			CAutoLock locSourceLock(mSourceFileLock);
+
+
+			locBytesRead = mDataSource->read(locBuff, 4096);
+			mJustReset = false;
+		}
+		//debugLog <<"DataProcessLoop : gcount = "<<locBytesRead<<endl;
+		{
+			CAutoLock locDemuxLock(mDemuxLock);
+			//CAutoLock locStreamLock(mStreamLock);
+			if (mJustReset) {		//To avoid blocking problems... restart the loop if it was just reset while waiting for lock.
+				continue;
+			}
+			locKeepGoing = ((mOggBuffer.feed((const unsigned char*)locBuff, locBytesRead)) == (OggDataBuffer::FEED_OK));;
+		}
+		if (!locKeepGoing) {
+			//debugLog << "DataProcessLoop : Feed in data buffer said stop"<<endl;
+			//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+			DeliverEOS();
+		}
+		{
+			CAutoLock locSourceLock(mSourceFileLock);
+			locIsEOF = mDataSource->isEOF();
+		}
+		if (locIsEOF) {
+			//debugLog << "DataProcessLoop : EOF"<<endl;
+			//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+			DeliverEOS();
+		}
+	}
+
+	//debugLog<<"DataProcessLoop : Exiting. Deliver EOS"<<endl;
+
+	//Shuold we flush ehre ?
+	delete[] locBuff;
+	
+	//return value ??
+	return S_OK;
+}
+
+
+
+
+STDMETHODIMP OggDemuxPacketSourceFilter::GetCapabilities(DWORD* inCapabilities) 
+{
+	if ((mSeekTable != NULL) && (mSeekTable->enabled()))  {
+		//debugLog<<"GetCaps "<<mSeekingCap<<endl;
+		*inCapabilities = mSeekingCap;
+		return S_OK;
+	} else {
+		//debugLog<<"Get Caps failed !!!!!!!"<<endl;
+		*inCapabilities = 0;
+		return S_OK;;
+	}
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetDuration(LONGLONG* outDuration) 
+{
+	if ((mSeekTable != NULL) && (mSeekTable->enabled())) {
+		//debugLog<<"GetDuration = " << mSeekTable->fileDuration()<<" ds units"<<endl;
+		*outDuration = mSeekTable->fileDuration();
+		return S_OK;
+	} else {
+		return E_NOTIMPL;
+	}
+
+
+}
+	 
+STDMETHODIMP OggDemuxPacketSourceFilter::CheckCapabilities(DWORD *pCapabilities)
+{
+	//debugLog<<"CheckCaps	: Not impl"<<endl;
+
+	//TODO:::
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::IsFormatSupported(const GUID *pFormat)
+{
+	//ASSERT(pFormat != NULL);
+	if (*pFormat == TIME_FORMAT_MEDIA_TIME) {
+		//debugLog<<"IsFormatSupported	: TRUE"<<endl;
+		return S_OK;
+	} else {
+		//debugLog<<"IsFormatSupported	: FALSE !!!"<<endl;
+		return S_FALSE;
+	}
+
+
+	
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::QueryPreferredFormat(GUID *pFormat){
+	//debugLog<<"QueryPrefferedTimeFormat	: MEDIA TIME"<<endl;
+	*pFormat = TIME_FORMAT_MEDIA_TIME;
+	return S_OK;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::SetTimeFormat(const GUID *pFormat){
+	//debugLog<<"SetTimeForamt : NOT IMPL"<<endl;
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetTimeFormat( GUID *pFormat){
+	*pFormat = TIME_FORMAT_MEDIA_TIME;
+	return S_OK;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetStopPosition(LONGLONG *pStop){
+	if ((mSeekTable != NULL) && (mSeekTable->enabled()))  {
+
+		//debugLog<<"GetStopPos = " << mSeekTable->fileDuration()<<" ds units"<<endl;
+		*pStop = mSeekTable->fileDuration();
+		return S_OK;
+	} else {
+		//debugLog<<"GetStopPos NOT IMPL"<<endl;
+		return E_NOTIMPL;
+	}
+
+
+
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetCurrentPosition(LONGLONG *pCurrent)
+{
+	//TODO::: Implement this properly
+
+	//debugLog<<"GetCurrentPos = NOT_IMPL"<<endl;
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat){
+	//debugLog<<"ConvertTimeForamt : NOT IMPL"<<endl;
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags){
+
+
+	CAutoLock locLock(m_pLock);
+	
+	if ((mSeekTable != NULL) && (mSeekTable->enabled()))  {
+	
+		CAutoLock locSourceLock(mSourceFileLock);
+		DeliverBeginFlush();
+
+		//Find the byte position for this time.
+		if (*pCurrent > mSeekTable->fileDuration()) {
+			*pCurrent = mSeekTable->fileDuration();
+		} else if (*pCurrent < 0) {
+			*pCurrent = 0;
+		}
+
+		OggGranuleSeekTable::tSeekPair locStartPos = mSeekTable->seekPos(*pCurrent);
+		
+		
+		//For now, seek to the position directly, later we will discard the preroll
+		//Probably don't ever want to do this. We want to record the desired time,
+		//	and it will be up to the decoders to drop anything that falss before it.
+		//*pCurrent = locStartPos.first;
+
+		{
+			//debugLog<<"       : Delivering End Flush..."<<endl;
+			DeliverEndFlush();
+			//debugLog<<"       : End flush Delviered."<<endl;
+			DeliverNewSegment(*pCurrent, mSeekTable->fileDuration(), 1.0);
+		}
+
+		//.second is the file position.
+		mDataSource->seek(locStartPos.second.first);
+	
+		return S_OK;
+	} else {
+		//debugLog<<"Seek not IMPL"<<endl;
+		return E_NOTIMPL;
+	}
+
+
+
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetPositions(LONGLONG *pCurrent, LONGLONG *pStop)
+{
+	//debugLog<<"Getpos : Not IMPL"<<endl;
+	//debugLog<<"GetPos : Current = HARDCODED 2 secs , Stop = "<<mSeekTable->fileDuration()/UNITS <<" secs."<<endl;
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest){
+	//debugLog<<"****GetAvailable : NOT IMPL"<<endl;
+	if ((mSeekTable != NULL) && (mSeekTable->enabled()))  {
+		//debugLog<<"Get Avail ok"<<endl;
+		*pEarliest = 0;
+		//debugLog<<"+++++ Duration is "<<mSeekTable->fileDuration()<<endl;
+		*pLatest = mSeekTable->fileDuration();
+		return S_OK;
+	} else {
+		return E_NOTIMPL;
+	}
+
+
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::SetRate(double dRate)
+{
+	//debugLog<<"Set RATE : NOT IMPL"<<endl;
+
+	return E_NOTIMPL;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetRate(double *dRate)
+{
+
+	*dRate = 1.0;
+	return S_OK;;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::GetPreroll(LONGLONG *pllPreroll)
+{
+
+	*pllPreroll = 0;
+	//debugLog<<"GetPreroll : HARD CODED TO 0"<<endl;
+	return S_OK;
+}
+STDMETHODIMP OggDemuxPacketSourceFilter::IsUsingTimeFormat(const GUID *pFormat) {
+	if (*pFormat == TIME_FORMAT_MEDIA_TIME) {
+		//debugLog<<"IsUsingTimeFormat : MEDIA TIME TRUE"<<endl;
+		return S_OK;
+	} else {
+		//debugLog<<"IsUsingTimeFormat : MEDIA TIME FALSE !!!!"<<endl;
+		return S_FALSE;
+	}
+
+
+}
+
+
+//HHHH:::
+bool OggDemuxPacketSourceFilter::notifyStreamBaseTime(__int64 inStreamBaseTime)
+{
+	if (inStreamBaseTime > mGlobalBaseTime) {
+		mGlobalBaseTime = inStreamBaseTime;
+	}
+	return true;
+}
+__int64 OggDemuxPacketSourceFilter::getGlobalBaseTime()
+{
+	return mGlobalBaseTime;
+}
+
+

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,160 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 "BasicSeekPassThrough.h"
+#include "IFilterDataSource.h"
+#include "IOggBaseTime.h"
+//#include "OggStreamMapper.h"
+#include <libOOOgg/OggDataBuffer.h>
+
+#include <libOOOggSeek/AutoOggChainGranuleSeekTable.h>
+#include "DataSourceFactory.h"
+
+class OggStreamMapper;
+
+class OggDemuxPacketSourceFilter
+	:	public CBaseFilter
+	,	public CAMThread
+	,	public IFileSourceFilter
+	,	public IOggCallback
+	,	public IOggBaseTime
+	,	public BasicSeekPassThrough
+	//,	public ISpecifyPropertyPages
+	,	public IAMFilterMiscFlags
+	//,	public IAMMediaContent
+{
+public:
+	OggDemuxPacketSourceFilter(void);
+	virtual ~OggDemuxPacketSourceFilter(void);
+	enum eThreadCommands {
+		THREAD_EXIT = 0,
+		THREAD_PAUSE = 1,
+		THREAD_RUN = 2
+	};
+	//Com Stuff
+	DECLARE_IUNKNOWN
+
+	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+	static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
+
+	//Streaming MEthods
+	STDMETHODIMP Run(REFERENCE_TIME tStart);
+	STDMETHODIMP Pause(void);
+	STDMETHODIMP Stop(void);
+
+	//IOggCallback Interface
+	virtual bool acceptOggPage(OggPage* inOggPage);
+
+	//PURE VIRTUALS From CBaseFilter
+	virtual int GetPinCount();
+	virtual CBasePin* GetPin(int inPinNo);
+
+	//PURE VIRTUALS from CAMThread
+	virtual DWORD ThreadProc(void);
+
+	//IFileSource Interface
+	virtual STDMETHODIMP GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType);
+	virtual STDMETHODIMP Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType);
+
+	//IAMFilterMiscFlags Interface
+	ULONG STDMETHODCALLTYPE GetMiscFlags(void);
+
+	//IMediaSeeking
+	virtual STDMETHODIMP GetDuration(LONGLONG* outDuration);
+	virtual STDMETHODIMP GetCapabilities(DWORD* inCapabilities);
+	 
+	virtual STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);
+	virtual STDMETHODIMP IsFormatSupported(const GUID *pFormat);
+	virtual STDMETHODIMP QueryPreferredFormat(GUID *pFormat);
+	virtual STDMETHODIMP SetTimeFormat(const GUID *pFormat);
+	virtual STDMETHODIMP GetTimeFormat( GUID *pFormat);
+	
+	virtual STDMETHODIMP GetStopPosition(LONGLONG *pStop);
+	virtual STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);
+	virtual STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat);
+	virtual STDMETHODIMP SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags);
+	virtual STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);
+	virtual STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);
+	virtual STDMETHODIMP SetRate(double dRate);
+	virtual STDMETHODIMP GetRate(double *dRate);
+	virtual STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);
+	virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
+
+	vector<OggPage*> getMatchingBufferedPages(unsigned long inSerialNo);
+	void removeMatchingBufferedPages(unsigned long inSerialNo);
+
+	CCritSec* streamLock()			{		return mStreamLock;		}
+
+	virtual void notifyPinConnected();
+
+	//HHHH:::
+	virtual bool notifyStreamBaseTime(__int64 inStreamBaseTime);
+
+	//IOggBaseTime Interface
+	virtual __int64 getGlobalBaseTime();
+	//
+protected:
+	static const unsigned long SETUP_BUFFER_SIZE = 24;
+	virtual HRESULT SetUpPins();
+
+	void resetStream();
+	HRESULT DataProcessLoop();
+
+	void DeliverEOS();
+	void DeliverBeginFlush();
+	void DeliverEndFlush();
+	void DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+
+	CCritSec* mSourceFileLock;
+	CCritSec* mDemuxLock;
+	CCritSec* mStreamLock;
+
+	wstring mFileName;
+
+	bool mSeenAllBOSPages;
+	bool mSeenPositiveGranulePos;
+	OggPage* mPendingPage;
+	vector<OggPage*> mBufferedPages;
+
+	OggDataBuffer mOggBuffer;
+	IFilterDataSource* mDataSource;
+	OggStreamMapper* mStreamMapper;
+
+	AutoOggChainGranuleSeekTable* mSeekTable;
+
+
+	bool mJustReset;
+
+	//HHHH:::
+	__int64 mGlobalBaseTime;
+
+	//double mPlaybackRate;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,367 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 ".\OggDemuxPacketsourcepin.h"
+
+OggDemuxPacketSourcePin::	OggDemuxPacketSourcePin(		TCHAR* inObjectName
+												,	OggDemuxPacketSourceFilter* inParentFilter
+												,	CCritSec* inFilterLock
+												,	OggPacket* inIdentHeader
+												,	unsigned long inSerialNo)
+	:	CBaseOutputPin(			NAME("Ogg Demux Output Pin")
+							,	inParentFilter
+							,	inFilterLock
+							,	&mFilterHR
+							,	L"Ogg Stream" )
+	,	mIdentHeader(inIdentHeader)
+	,	mSerialNo(inSerialNo)
+	,	mIsStreamReady(false)
+	,	mAcceptingData(false)
+	,	mNumBuffers(0)
+	,	mDataQueue(NULL)
+	,	mFilterHR(S_OK)
+{
+
+	mPacketiserLock = new CCritSec;
+	
+		//(BYTE*)inBOSPage->createRawPageData();
+	mPacketiser.setPacketSink(this);
+
+
+	//Subvert COM and do this directly... this way, the source filter won't expose the interface to the
+	// graph but we can still delegate to it.
+	IMediaSeeking* locSeeker = NULL;
+	locSeeker = (IMediaSeeking*)inParentFilter;
+	SetDelegate(locSeeker);
+}
+STDMETHODIMP OggDemuxPacketSourcePin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+{
+	if (riid == IID_IMediaSeeking) {
+		//debugLog<<"Pin queried for IMediaSeeking"<<endl;
+		*ppv = (IMediaSeeking*)this;
+		((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+	} else if (riid == IID_IOggOutputPin) {
+		*ppv = (IOggOutputPin*)this;
+		//((IUnknown*)*ppv)->AddRef();
+		return NOERROR;		
+	}
+
+	return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv); 
+}
+OggDemuxPacketSourcePin::~OggDemuxPacketSourcePin(void)
+{
+	//Since we didn't addref the filter when we set the seek delegate onto it, we have to avoid
+	//	it getting released, so set it to NULL, to avoid the destructor releasing it.
+	SetDelegate(NULL);
+	//delete[] mBOSAsFormatBlock;
+	//delete mBOSPage;
+	delete mIdentHeader;
+	delete mDataQueue;
+
+	delete mPacketiserLock;
+
+
+}
+
+bool OggDemuxPacketSourcePin::acceptOggPage(OggPage* inOggPage)
+{
+	CAutoLock locPackLock(mPacketiserLock);
+	if (mIsStreamReady) {
+		mAcceptingData = true;
+		return mPacketiser.acceptOggPage(inOggPage);
+	} else {
+		delete inOggPage;
+	}
+	return false;
+}
+BYTE* OggDemuxPacketSourcePin::getIdentAsFormatBlock()
+{
+	return (BYTE*)mIdentHeader->packetData();
+}
+
+unsigned long OggDemuxPacketSourcePin::getIdentSize()
+{
+	return mIdentHeader->packetSize();
+}
+
+unsigned long OggDemuxPacketSourcePin::getSerialNo()
+{
+	return mSerialNo;//mBOSPage->header()->StreamSerialNo();
+}
+
+IOggDecoder* OggDemuxPacketSourcePin::getDecoderInterface()
+{
+	if (mDecoderInterface == NULL) {
+		IOggDecoder* locDecoder = NULL;
+		if (IsConnected()) {
+			IPin* locPin = GetConnected();
+			if (locPin != NULL) {
+				locPin->QueryInterface(IID_IOggDecoder, (void**)&locDecoder);
+			}
+		}
+
+		mDecoderInterface = locDecoder;
+	}
+	return mDecoderInterface;
+	
+}
+HRESULT OggDemuxPacketSourcePin::GetMediaType(int inPosition, CMediaType* outMediaType) 
+{
+	//Put it in from the info we got in the constructor.
+	if (inPosition == 0) {
+		AM_MEDIA_TYPE locAMMediaType;
+		locAMMediaType.majortype = MEDIATYPE_OggPacketStream;
+
+		locAMMediaType.subtype = MEDIASUBTYPE_None;
+		locAMMediaType.formattype = FORMAT_OggIdentHeader;
+		locAMMediaType.cbFormat = getIdentSize();
+		locAMMediaType.pbFormat = getIdentAsFormatBlock();
+		locAMMediaType.pUnk = NULL;
+	
+			
+	
+		CMediaType locMediaType(locAMMediaType);		
+		*outMediaType = locMediaType;
+		return S_OK;
+	} else {
+		return VFW_S_NO_MORE_ITEMS;
+	}
+}
+HRESULT OggDemuxPacketSourcePin::CheckMediaType(const CMediaType* inMediaType) {
+	if (		(inMediaType->majortype == MEDIATYPE_OggPacketStream) 
+			&&	(inMediaType->subtype == MEDIASUBTYPE_None)
+			&&	(inMediaType->formattype == FORMAT_OggIdentHeader)) {
+			//&&	(inMediaType->cbFormat == mBOSPage->pageSize()) {
+
+		return S_OK;
+	} else {
+		return E_FAIL;
+	}
+}
+HRESULT OggDemuxPacketSourcePin::DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest) 
+{
+	HRESULT locHR = S_OK;
+
+	ALLOCATOR_PROPERTIES locReqAlloc = *inoutInputRequest;
+	ALLOCATOR_PROPERTIES locActualAlloc;
+
+	//locReqAlloc.cbAlign = 1;
+	//locReqAlloc.cbBuffer = 65536; //BUFFER_SIZE;
+	//locReqAlloc.cbPrefix = 0;
+	//locReqAlloc.cBuffers = NUM_PAGE_BUFFERS; //NUM_BUFFERS;
+
+	locHR = inoutAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
+
+	if (locHR != S_OK) {
+		return locHR;
+	}
+
+	mNumBuffers = locActualAlloc.cBuffers;
+	
+	locHR = inoutAllocator->Commit();
+
+	return locHR;
+
+}
+
+
+//Pin Conenction Methods
+HRESULT OggDemuxPacketSourcePin::BreakConnect()
+{
+	delete mDataQueue;
+	mDataQueue = NULL;
+	return CBaseOutputPin::BreakConnect();
+}
+HRESULT OggDemuxPacketSourcePin::CompleteConnect(IPin *inReceivePin)
+{
+	IOggDecoder* locDecoder = NULL;
+	inReceivePin->QueryInterface(IID_IOggDecoder, (void**)&locDecoder);
+	if (locDecoder != NULL) {
+		mDecoderInterface = locDecoder;
+
+		IOggDecoder::eAcceptHeaderResult locResult = mDecoderInterface->showHeaderPacket(mIdentHeader->clone());
+		if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
+			mIsStreamReady = true;
+
+		} else {
+			OggPacketiser locPacketiser;
+			locPacketiser.setPacketSink(this);
+			OggDemuxPacketSourceFilter* locParent = (OggDemuxPacketSourceFilter*)m_pFilter;
+			vector<OggPage*> locList = locParent->getMatchingBufferedPages(mSerialNo);
+			
+			for (size_t i = 0; i < locList.size(); i++) {
+				locPacketiser.acceptOggPage(locList[i]);
+			}
+
+			locParent->removeMatchingBufferedPages(mSerialNo);
+
+			
+		}
+
+		if (mIsStreamReady) {
+			HRESULT locHR = CBaseOutputPin::CompleteConnect(inReceivePin);
+			if (locHR == S_OK) {
+				((OggDemuxPacketSourceFilter*)m_pFilter)->notifyPinConnected();
+				mDataQueue = new COutputQueue (inReceivePin, &mFilterHR, FALSE, TRUE,1,TRUE, mNumBuffers);
+				return S_OK;
+			}  else {
+				return locHR;
+			}
+			
+		}	
+
+		
+	}
+	return E_FAIL;
+	
+}
+
+bool OggDemuxPacketSourcePin::dispatchPacket(StampedOggPacket* inPacket)
+{
+	CAutoLock locStreamLock(((OggDemuxPacketSourceFilter*)m_pFilter)->streamLock());
+
+
+	//Set up the sample info
+	IMediaSample* locSample = NULL;
+	REFERENCE_TIME locStart = inPacket->startTime();
+	REFERENCE_TIME locStop = inPacket->endTime();
+	
+	//Get a delivery buffer
+	HRESULT	locHR = GetDeliveryBuffer(&locSample, &locStart, &locStop, NULL);
+	
+	//Error checks
+	if (locHR != S_OK) {
+		//Stopping, fluching or error
+
+		delete inPacket;
+		return false;
+	}
+
+	//Set time stamps. These are granule pos, and may be -1
+	locSample->SetTime(&locStart, &locStop);
+	
+	locSample->SetMediaTime(&locStart, &locStop);
+	locSample->SetSyncPoint(TRUE);
+	
+
+	// Create a pointer for the samples buffer
+	BYTE* locBuffer = NULL;
+	locSample->GetPointer(&locBuffer);
+
+	if (locSample->GetSize() >= inPacket->packetSize()) {
+
+		memcpy((void*)locBuffer, (const void*)inPacket->packetData(), inPacket->packetSize());
+		locSample->SetActualDataLength(inPacket->packetSize());
+
+		locHR = mDataQueue->Receive(locSample);
+
+		if (locHR != S_OK) {
+			//debugLog << "Failure... Queue rejected sample..."<<endl;
+			//Stopping ??
+
+			delete inPacket;
+			return false;
+		} else {
+			delete inPacket;
+			return true;
+		}
+	} else {
+		//DbgLog((LOG_TRACE, 2, "* BUFFER TOO SMALL... FATALITY !!"));
+		throw 0;
+	}	
+}
+bool OggDemuxPacketSourcePin::acceptStampedOggPacket(StampedOggPacket* inPacket)
+{
+	if (mAcceptingData) {
+		return dispatchPacket(inPacket);
+	} else {
+		//This handles callbacks with header packets
+		IOggDecoder::eAcceptHeaderResult locResult;
+		if ((mDecoderInterface != NULL) && (!mIsStreamReady)) {
+			locResult = mDecoderInterface->showHeaderPacket(inPacket);
+			if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
+				mIsStreamReady = true;
+			}
+		}
+		delete inPacket;
+		return true;
+	}
+}
+
+//Pin streaming methods
+HRESULT OggDemuxPacketSourcePin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
+{
+	NewSegment(tStart, tStop, dRate);
+
+	if (mDataQueue != NULL) {
+		mDataQueue->NewSegment(tStart, tStop, dRate);
+	}
+
+	return S_OK;
+}
+HRESULT OggDemuxPacketSourcePin::DeliverEndOfStream(void)
+{
+	if (mDataQueue != NULL) {
+		mDataQueue->EOS();
+	}
+    return S_OK;
+}
+
+HRESULT OggDemuxPacketSourcePin::DeliverEndFlush(void)
+{
+	CAutoLock locPackLock(mPacketiserLock);
+	
+	if (mDataQueue != NULL) {
+		mDataQueue->EndFlush();
+	}
+
+	mPacketiser.reset();
+    return S_OK;
+}
+
+HRESULT OggDemuxPacketSourcePin::DeliverBeginFlush(void)
+{
+	if (mDataQueue != NULL) {
+		mDataQueue->BeginFlush();
+	}
+	
+    return S_OK;
+}
+
+bool OggDemuxPacketSourcePin::notifyStreamBaseTime(__int64 inStreamTime)
+{
+	return ((OggDemuxPacketSourceFilter*)m_pFilter)->notifyStreamBaseTime(inStreamTime);
+}
+__int64 OggDemuxPacketSourcePin::getGlobalBaseTime()
+{
+	return ((OggDemuxPacketSourceFilter*)m_pFilter)->getGlobalBaseTime();
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,117 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 <libOOOgg/OggPacket.h>
+#include <libOOOgg/IOggCallback.h>
+#include <libOOOgg/OggPacketiser.h>
+#include "IOggDecoder.h"
+#include "IOggOutputPin.h"
+
+class OggDemuxPacketSourcePin
+	:	public CBaseOutputPin
+	,	public BasicSeekPassThrough
+	,	public IOggCallback
+	,	public IOggOutputPin
+	,	protected IStampedOggPacketSink
+{
+public:
+
+	DECLARE_IUNKNOWN
+	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+	//OggDemuxPacketSourcePin(void);
+	OggDemuxPacketSourcePin(	TCHAR* inObjectName, 
+							OggDemuxPacketSourceFilter* inParentFilter,
+							CCritSec* inFilterLock,
+							OggPacket* inIdentHeader,
+							unsigned long inSerialNo);
+							//StreamHeaders* inHeaderSource, 
+							//CMediaType* inMediaType,
+							//wstring inPinName,
+							//bool inAllowSeek,
+							//unsigned long inNumBuffers,
+							//unsigned long inBufferSize);
+	virtual ~OggDemuxPacketSourcePin(void);
+
+	static const unsigned long NUM_PAGE_BUFFERS = 100;
+
+	unsigned long getSerialNo();
+	IOggDecoder* getDecoderInterface();
+	bool isStreamReady()							{		return mIsStreamReady;				}
+	void setIsStreamReady(bool inIsStreamReady)		{		mIsStreamReady = inIsStreamReady;	}
+
+	//IOggCallback Interface
+	virtual bool acceptOggPage(OggPage* inOggPage);
+
+
+	//CBasePin virtuals
+	virtual HRESULT GetMediaType(int inPosition, CMediaType* outMediaType);
+	virtual HRESULT CheckMediaType(const CMediaType* inMediaType);
+	virtual HRESULT DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest);
+
+	//Pin Conenction Methods
+	virtual HRESULT BreakConnect();
+	virtual HRESULT CompleteConnect(IPin *inReceivePin);
+
+	//Pin streaming methods
+	virtual HRESULT DeliverNewSegment(REFERENCE_TIME inStart, REFERENCE_TIME inStop, double inRate);
+	virtual HRESULT DeliverEndOfStream(void);
+	virtual HRESULT DeliverEndFlush(void);
+	virtual HRESULT DeliverBeginFlush(void);
+
+	//IOggOutputPin interface
+	virtual bool notifyStreamBaseTime(__int64 inStreamTime);
+	virtual __int64 getGlobalBaseTime();
+protected:
+	//IStampedOggPacketSink
+	virtual bool acceptStampedOggPacket(StampedOggPacket* inPacket);
+	virtual bool dispatchPacket(StampedOggPacket* inPacket);
+
+	//What is this actually for ?
+	HRESULT mFilterHR;
+
+	BYTE* getIdentAsFormatBlock();
+	unsigned long getIdentSize();
+	unsigned long mSerialNo;
+
+	CCritSec* mPacketiserLock;
+
+	unsigned long mNumBuffers;
+	
+	OggPacket* mIdentHeader;
+	IOggDecoder* mDecoderInterface;
+	OggPacketiser mPacketiser;
+
+	COutputQueue* mDataQueue;
+
+	bool mIsStreamReady;
+	bool mAcceptingData;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,136 @@
+#include "StdAfx.h"
+#include ".\oggstreammapper.h"
+
+OggStreamMapper::OggStreamMapper(OggDemuxPacketSourceFilter* inParentFilter, CCritSec* inParentFilterLock)
+	:	mStreamState(eStreamState::STRMAP_READY)
+	,	mParentFilter(inParentFilter)
+	,	mParentFilterLock(inParentFilterLock)
+	,	mFishHeadPacket(NULL)
+	,	mSkeletonSerialNo(0)
+{
+}
+
+OggStreamMapper::~OggStreamMapper(void)
+{
+	for (size_t i = 0; i < mPins.size(); i++) {
+		delete mPins[i];
+	}
+}
+OggDemuxPacketSourcePin* OggStreamMapper::getPinByIndex(unsigned long inIndex)
+{
+	if (inIndex < mPins.size()) {
+		return mPins[inIndex];
+	} else {
+		return NULL;
+	}
+}
+bool OggStreamMapper::acceptOggPage(OggPage* inOggPage)
+{
+	
+	switch (mStreamState) {
+		case STRMAP_READY:
+			//WARNING::: Partial fall through
+			if (inOggPage->header()->isBOS()) {
+				mStreamState = STRMAP_PARSING_BOS_PAGES;
+			} else {
+				mStreamState = STRMAP_ERROR;
+				delete inOggPage;
+				return false;
+			}
+			//Partial fall through
+		case STRMAP_PARSING_BOS_PAGES:
+			//WARNING::: Partial fall through
+			if (!allStreamsReady()) {
+				if (inOggPage->header()->isBOS()) {
+					return addNewPin(inOggPage);
+				} else {
+					mStreamState = STRMAP_DATA;
+				}
+			}
+			//Partial fall through
+		case STRMAP_DATA:
+			{
+				if (mFishHeadPacket != NULL) {
+					if (inOggPage->header()->StreamSerialNo() == mSkeletonSerialNo) {
+						int x= 2;
+					}
+				}
+				OggDemuxPacketSourcePin* locPin = getMatchingPin(inOggPage->header()->StreamSerialNo());
+				if (locPin != NULL) {
+					return locPin->acceptOggPage(inOggPage);
+				} else {
+					//Ignore unknown streams
+					delete inOggPage;
+					return true;
+				}
+				
+			}
+			break;
+		case STRMAP_FINISHED:
+			return false;
+		case STRMAP_ERROR:
+			return false;
+			
+	}
+	
+
+}
+
+bool OggStreamMapper::allStreamsReady()
+{
+	bool locAllReady = true;
+	//OggDemuxPacketSourcePin* locPin = NULL;
+	for (size_t i = 0; i < mPins.size(); i++) {
+		locAllReady = locAllReady && (mPins[i]->isStreamReady());
+	}	
+
+	return locAllReady && (mPins.size() > 0);
+}
+
+bool OggStreamMapper::isFishHead(OggPage* inOggPage)
+{
+	StampedOggPacket* locPacket = inOggPage->getStampedPacket(0);
+
+	if (locPacket == NULL) {
+		return false;
+	} else {
+		if ((strncmp((const char*)locPacket->packetData(), "fishead\0", 8)) == 0) {
+			return true;
+		}
+	}
+	return false;
+}
+
+bool OggStreamMapper::handleFishHead(OggPage* inOggPage)
+{
+	mFishHeadPacket = inOggPage->getStampedPacket(0)->clone();
+	mSkeletonSerialNo = inOggPage->header()->StreamSerialNo();
+	delete inOggPage;
+	return true;
+}
+bool OggStreamMapper::addNewPin(OggPage* inOggPage)
+{
+	//FISH::: Catch the fishead here.
+
+	if (isFishHead(inOggPage)) {
+		return handleFishHead(inOggPage);
+	} else {
+		OggDemuxPacketSourcePin* locNewPin = new OggDemuxPacketSourcePin(NAME("OggPageSourcePin"), mParentFilter, mParentFilterLock, inOggPage->getPacket(0)->clone(), inOggPage->header()->StreamSerialNo());
+		//locNewPin->AddRef();
+		delete inOggPage;
+		mPins.push_back(locNewPin);
+		return true;
+	}
+}
+
+OggDemuxPacketSourcePin* OggStreamMapper::getMatchingPin(unsigned long inSerialNo)
+{
+	OggDemuxPacketSourcePin* locPin = NULL;
+	for (size_t i = 0; i < mPins.size(); i++) {
+		locPin = mPins[i];
+		if (locPin->getSerialNo() == inSerialNo) {
+			return locPin;
+		}
+	}
+	return NULL;
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggStreamMapper.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,52 @@
+#pragma once
+
+//#include "OggDemuxPacketSourcePin.h"
+//#include "OggDemuxPacketSourceFilter.h"
+
+#include <libOOOgg/IOggCallback.h>
+#include <vector>
+using namespace std;
+
+
+class OggStreamMapper
+	:	public IOggCallback
+{
+public:
+
+	enum eStreamState {
+		STRMAP_READY,
+		STRMAP_PARSING_BOS_PAGES,
+		STRMAP_PARSING_HEADERS,
+		STRMAP_DATA,
+		STRMAP_FINISHED,
+		STRMAP_ERROR
+
+	};
+	OggStreamMapper(OggDemuxPacketSourceFilter* inParentFilter, CCritSec* inParentFilterLock);
+	virtual ~OggStreamMapper(void);
+
+	//IOggCallback Interface
+	virtual bool acceptOggPage(OggPage* inOggPage);
+
+	eStreamState streamState();
+
+	bool allStreamsReady();
+
+	unsigned long numPins()				{		return mPins.size();		}
+	OggDemuxPacketSourcePin* getPinByIndex(unsigned long inIndex);
+
+protected:
+	eStreamState mStreamState;
+	vector<OggDemuxPacketSourcePin*> mPins;
+	OggDemuxPacketSourceFilter* mParentFilter;
+	CCritSec* mParentFilterLock;
+
+	OggPacket* mFishHeadPacket;
+	unsigned long mSkeletonSerialNo;
+
+	bool addNewPin(OggPage* inOggPage);
+	OggDemuxPacketSourcePin* getMatchingPin(unsigned long inSerialNo);
+
+	bool handleFishHead(OggPage* inOggPage);
+	bool isFishHead(OggPage* inOggPage);
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ReadMe.txt
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ReadMe.txt	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ReadMe.txt	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,40 @@
+========================================================================
+    DYNAMIC LINK LIBRARY : dsfOggDemux2 Project Overview
+========================================================================
+
+AppWizard has created this dsfOggDemux2 DLL for you.  
+This file contains a summary of what you will find in each of the files that
+make up your dsfOggDemux2 application.
+
+
+dsfOggDemux2.vcproj
+    This is the main project file for VC++ projects generated using an Application Wizard. 
+    It contains information about the version of Visual C++ that generated the file, and 
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+dsfOggDemux2.cpp
+    This is the main DLL source file.
+
+	When created, this DLL does not export any symbols. As a result, it  
+	will not produce a .lib file when it is built. If you wish this project 
+	to be a project dependency of some other project, you will either need to 
+	add code to export some symbols from the DLL so that an export library 
+	will be produced, or you can set the Ignore Input Library property to Yes 
+	on the General propert page of the Linker folder in the project's Property 
+	Pages dialog box.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named dsfOggDemux2.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,285 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 "regwrap.h"
+
+RegWrap::RegWrap(void)
+{
+}
+
+RegWrap::~RegWrap(void)
+{
+}
+
+LONG RegWrap::addKeyVal(HKEY inHive, string inKeyName, string inValueName, string inValue) {
+	//Open or create keyname
+	//Add a value called ValueName with value inValue.
+
+	//LONG RegCreateKeyEx(
+	//	HKEY hKey,
+	//	LPCTSTR lpSubKey,
+	//	DWORD Reserved,
+	//	LPTSTR lpClass,
+	//	DWORD dwOptions,
+	//	REGSAM samDesired,
+	//	LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+	//	PHKEY phkResult,
+	//	LPDWORD lpdwDisposition
+	//);
+
+
+	//LONG RegSetValueEx(
+	//	HKEY hKey,
+	//	LPCTSTR lpValueName,
+	//	DWORD Reserved,
+	//	DWORD dwType,
+	//	const BYTE* lpData,
+	//	DWORD cbData
+	//);
+
+
+	//fstream debugLog;
+	//debugLog.open("G:\\reg.log", ios_base::out);
+	//debugLog <<"Key = "<<inKeyName<<endl<<"ValueName = "<<inValueName<<endl<<"Value = "<<inValue<<endl;
+	HKEY locKey;
+	DWORD locDisp;
+	LONG retVal = RegCreateKeyEx(	inHive,
+									inKeyName.c_str(),
+									NULL,
+									NULL,
+									REG_OPTION_NON_VOLATILE,
+									KEY_ALL_ACCESS,
+									NULL,
+									&locKey,
+									&locDisp);
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Create Failed"<<endl;
+		return retVal;
+	}
+
+	retVal = RegSetValueEx(		locKey,
+								inValueName.c_str(),
+								NULL,
+								REG_SZ,
+								(const BYTE*)inValue.c_str(),
+								(DWORD)(inValue.length()+1));
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Set Value Failed"<<endl;
+		return retVal;
+	}
+	
+	RegCloseKey(locKey);
+
+	//debugLog.close();
+	return retVal;
+
+}
+
+bool RegWrap::deleteKeyRecurse(HKEY inHive, string inKeyName, string inSubKeyToDelete) {
+	HKEY locKey;
+	LONG retVal;
+
+	retVal = RegOpenKeyEx(	inHive,
+							inKeyName.c_str(),
+							NULL,
+							KEY_ALL_ACCESS,
+							&locKey);
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Key not found"<<endl;
+		return false;
+	}
+
+	retVal = SHDeleteKeyA(locKey, inSubKeyToDelete.c_str());
+	RegCloseKey(locKey);
+	return true;
+
+}
+
+
+
+bool RegWrap::removeKeyVal(HKEY inHive, string inKeyName, string inValueName) {
+	//LONG RegDeleteValue(
+	//	HKEY hKey,
+	//	LPCTSTR lpValueName
+	//);
+
+	HKEY locKey;
+	LONG retVal;
+
+	retVal = RegOpenKeyEx(	inHive,
+							inKeyName.c_str(),
+							NULL,
+							KEY_ALL_ACCESS,
+							&locKey);
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Key not found"<<endl;
+		return false;
+	}
+
+	retVal = RegDeleteValue(locKey, inValueName.c_str());
+	RegCloseKey(locKey);
+	if (retVal != ERROR_SUCCESS) {
+		return false;
+	} else {
+		return true;
+	}
+}
+
+bool RegWrap::valueExists(HKEY inHive, string inKeyName, string inValueName) {
+
+	//LONG RegQueryValueEx(
+	//	HKEY hKey,
+	//	LPCTSTR lpValueName,
+	//	LPDWORD lpReserved,
+	//	LPDWORD lpType,
+	//	LPBYTE lpData,
+	//	LPDWORD lpcbData
+	//);
+
+	//LONG RegOpenKeyEx(
+	//	HKEY hKey,
+	//	LPCTSTR lpSubKey,
+	//	DWORD ulOptions,
+	//	REGSAM samDesired,
+	//	PHKEY phkResult
+	//);
+
+	//fstream debugLog;
+	//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer\Player\Extensions\Descriptions
+	//debugLog.open("G:\\val.log", ios_base::out);
+	HKEY locKey;
+	LONG retVal;
+	//debugLog<<"Querying : Key = "<<inKeyName<<endl<<"Value = "<<inValueName<<endl;
+
+	retVal = RegOpenKeyEx(	inHive,
+							inKeyName.c_str(),
+							NULL,
+							KEY_ALL_ACCESS,
+							&locKey);
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Key not found"<<endl;
+		return false;
+	}
+
+	retVal = RegQueryValueEx(	locKey,
+								inValueName.c_str(),
+								NULL,
+								NULL,
+								NULL,
+								NULL);
+
+	RegCloseKey(locKey);
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Value not found"<<endl;
+		return false;
+	} else {
+		//debugLog<<"Value found"<<endl;
+		return true;
+	}
+
+}
+
+string RegWrap::findNextEmptyMediaPlayerDesc() {
+	char locNum[6];
+	string foundNum = "";
+	for (long i = 1; i < 24; i++) {
+		itoa(i, (char*)&locNum, 10);
+		if (!RegWrap::valueExists(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\Descriptions", (char*)&locNum)) {
+			foundNum = (char*)&locNum;
+			break;
+		}
+
+	}
+	return foundNum;
+}
+
+bool RegWrap::removeMediaDesc() {
+	HKEY locKey;
+	LONG retVal;
+
+	retVal = RegOpenKeyEx(	HKEY_LOCAL_MACHINE,
+							"SOFTWARE\\illiminable\\oggcodecs",
+							NULL,
+							KEY_ALL_ACCESS,
+							&locKey);
+
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Key not found"<<endl;
+		return false;
+	}
+
+	DWORD locBuffSize = 16;
+	char locBuff[16];
+
+	retVal = RegQueryValueEx(	locKey,
+								"MediaDescNum",
+								NULL,
+								NULL,
+								(BYTE*)&locBuff,
+								&locBuffSize);
+
+	RegCloseKey(locKey);
+	if (retVal != ERROR_SUCCESS) {
+		//debugLog<<"Value not found"<<endl;
+		return false;
+	} else {
+		RegWrap::removeKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\Descriptions", locBuff);
+		RegWrap::removeKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\MUIDescriptions", locBuff);
+		RegWrap::removeKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\Types", locBuff);
+		RegWrap::removeKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\illiminable\\oggcodecs", "MediaDescNum");
+		//debugLog<<"Value found"<<endl;
+		return true;
+		
+	}
+
+
+}
+bool RegWrap::addMediaPlayerDesc(string inDesc, string inExts) {
+	if (!RegWrap::valueExists(HKEY_LOCAL_MACHINE, "SOFTWARE\\illiminable\\oggcodecs", "MediaDescNum")) {
+		string locDescNum = "";
+		string locFull = inDesc+" ("+inExts+")";
+		locDescNum = RegWrap::findNextEmptyMediaPlayerDesc();
+		if (locDescNum == "") {
+			return false;
+		}
+		RegWrap::addKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\illiminable\\oggcodecs", "MediaDescNum", locDescNum.c_str());
+		RegWrap::addKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\Descriptions", locDescNum, locFull.c_str());
+		RegWrap::addKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\MUIDescriptions", locDescNum, inDesc.c_str());
+		RegWrap::addKeyVal(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\Types", locDescNum, inExts.c_str());
+		return true;
+	}
+
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/RegWrap.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,22 @@
+#pragma once
+#include <shlwapi.h>
+
+//This class really shouldn't be part of this project, but i got lazy !
+//This is a pretty inefficient way to do it but its easy.
+
+#include <string>
+using namespace std;
+class OGG_DEMUX2_API RegWrap
+{
+public:
+	RegWrap(void);
+	~RegWrap(void);
+
+	static LONG		addKeyVal(HKEY inHive, string inKeyName, string inValueName, string inValue);
+	static bool		valueExists(HKEY inHive, string inKeyName, string inValueName);
+	static string	findNextEmptyMediaPlayerDesc();
+	static bool		addMediaPlayerDesc(string inDesc, string inExts);
+	static bool		removeKeyVal(HKEY inHive, string inKeyName, string inValueName);
+	static bool		removeMediaDesc();
+	static bool		deleteKeyRecurse(HKEY inHive, string inKeyName, string inSubKeyToDelete);
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,125 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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 ".\singlemediafilecache.h"
+
+SingleMediaFileCache::SingleMediaFileCache(void)
+	:	mBytesWritten(0)
+	,	mIsComplete(false)
+	,	mReadPtr(0)
+{
+	//debugLog.open("G:\\logs\\mediacache.log", ios_base::out);
+}
+
+SingleMediaFileCache::~SingleMediaFileCache(void)
+{
+	//debugLog.close();
+}
+
+bool SingleMediaFileCache::open(string inFileName) {
+	mBytesWritten = 0;
+	//debugLog<<"Opening "<<inFileName<<endl;
+	mLocalFile.open(inFileName.c_str(), ios_base::in|ios_base::out|ios_base::binary|ios_base::trunc);
+
+	if (mLocalFile.is_open()) {
+		//debugLog<<"File open...."<<endl;
+	} else {
+		//debugLog<<"File open FAILED"<<endl;
+	}
+	return mLocalFile.is_open();
+}
+void SingleMediaFileCache::close() {
+	mLocalFile.close();
+	
+}
+bool SingleMediaFileCache::write(const unsigned char* inBuff, unsigned long inBuffSize) {
+	//debugLog<<"Writeing "<<inBuffSize<<endl;
+	//debugLog<<"Read Ptr = "<<mLocalFile.tellg();
+	//debugLog<<"Write Ptr = "<<mLocalFile.tellp();
+	mLocalFile.seekp(0, ios_base::end);
+	if (inBuffSize != 0) {
+		mLocalFile.write((const char*)inBuff, inBuffSize);
+		mBytesWritten += inBuffSize;
+	}
+
+	if (mLocalFile.fail()) {
+		//debugLog<<"*** Write put into FAIL"<<endl;
+	}
+	return !(mLocalFile.fail());
+}
+unsigned long SingleMediaFileCache::read(unsigned char* outBuff, unsigned long inBuffSize) {
+	//debugLog<<"Read request for "<<inBuffSize<<"  got ";
+	//debugLog<<"Read Ptr = "<<mLocalFile.tellg();
+	//debugLog<<"Write Ptr = "<<mLocalFile.tellp();
+	mLocalFile.seekg(mReadPtr);
+	unsigned long locBytesAvail = bytesAvail();
+	if (locBytesAvail >= inBuffSize) {
+        mLocalFile.read((char*)outBuff, inBuffSize);
+        //debugLog<<mLocalFile.gcount()<<endl;
+		mReadPtr+=mLocalFile.gcount();
+		return mLocalFile.gcount();
+	} else if (locBytesAvail > 0) {
+		mLocalFile.read((char*)outBuff, locBytesAvail);
+		//debugLog<<locBytesAvail<<endl;
+		mReadPtr += locBytesAvail;
+		return locBytesAvail;
+	} else {
+		//debugLog << "NOTHING"<<endl;
+		return 0;
+	}
+	
+}
+bool SingleMediaFileCache::readSeek(unsigned long inSeekPos) {
+	if (inSeekPos < mBytesWritten) {
+		//debugLog<<"Seeking to "<<inSeekPos<<endl;
+		mReadPtr = inSeekPos;
+		return true;
+	} else {
+		return false;
+	}
+}
+
+unsigned long SingleMediaFileCache::totalBytes() {
+	return mBytesWritten;
+}
+unsigned long SingleMediaFileCache::bytesAvail() {
+	if (mLocalFile.fail()) {
+		//debugLog<<"bytesAvail : File is in fail state"<<endl;
+	}
+	//debugLog<<"bytesAvail : Byteswritten = "<<mBytesWritten<<endl;
+	//if ((!mLocalFile.fail()) && (mBytesWritten > 0)) {
+	if (mBytesWritten > 0) {
+		//debugLog<<"bytes Avail = "<<mBytesWritten - mReadPtr<<endl;
+		return mBytesWritten - mReadPtr;
+	} else {
+		return 0;
+	}
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/SingleMediaFileCache.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,67 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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
+
+//This class will be a cache of a single media file.
+//It will only allow a single chunk of data to be cached...
+// ie you can't cache bytes 0-1000 and 2000-3000...
+// only consecutive blocks for now.
+//
+//Data can be read randomly... but only written sequentially.
+//Will act as a buffer so that data read off the network can be put straight
+// into the file and then read as needed.
+
+#include <string>
+#include <fstream>
+using namespace std;
+class OGG_DEMUX2_API SingleMediaFileCache
+{
+public:
+	SingleMediaFileCache(void);
+	~SingleMediaFileCache(void);
+
+	bool open(string inFileName);
+	void close();
+	bool write(const unsigned char* inBuff, unsigned long inBuffSize);
+	unsigned long read(unsigned char* outBuff, unsigned long inBuffSize);
+	bool readSeek(unsigned long inSeekPos);
+	unsigned long totalBytes();
+	unsigned long bytesAvail();
+
+protected:
+	fstream mLocalFile;
+
+	unsigned long mBytesWritten;
+	unsigned long mReadPtr;
+	
+	//fstream debugLog;
+	bool mIsComplete;
+};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ds_guids.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ds_guids.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/ds_guids.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,138 @@
+#pragma once
+
+//// {4BB64C4A-1674-436b-A49D-D6B3B64DBD60}
+//DEFINE_GUID(CLSID_PropsAbout, 
+//0x4bb64c4a, 0x1674, 0x436b, 0xa4, 0x9d, 0xd6, 0xb3, 0xb6, 0x4d, 0xbd, 0x60);
+
+
+
+//************* Old GUID
+////New section
+//// {31CA0186-1FF0-4181-AA38-3CA4040BD260}
+//DEFINE_GUID(CLSID_OggDemuxSourceFilter, 
+//0x31ca0186, 0x1ff0, 0x4181, 0xaa, 0x38, 0x3c, 0xa4, 0x4, 0xb, 0xd2, 0x60);
+//**********************************
+
+// {C9361F5A-3282-4944-9899-6D99CDC5370B}
+DEFINE_GUID(CLSID_OggDemuxPacketSourceFilter, 
+0xc9361f5a, 0x3282, 0x4944, 0x98, 0x99, 0x6d, 0x99, 0xcd, 0xc5, 0x37, 0xb);
+
+
+// {60891713-C24F-4767-B6C9-6CA05B3338FC}
+DEFINE_GUID(MEDIATYPE_OggPacketStream, 
+0x60891713, 0xc24f, 0x4767, 0xb6, 0xc9, 0x6c, 0xa0, 0x5b, 0x33, 0x38, 0xfc);
+
+// {95388704-162C-42a9-8149-C3577C12AAF9}
+DEFINE_GUID(FORMAT_OggIdentHeader, 
+0x95388704, 0x162c, 0x42a9, 0x81, 0x49, 0xc3, 0x57, 0x7c, 0x12, 0xaa, 0xf9);
+
+// {43F0F818-10B0-4c86-B9F1-F6B6E2D33462}
+DEFINE_GUID(IID_IOggDecoder, 
+0x43f0f818, 0x10b0, 0x4c86, 0xb9, 0xf1, 0xf6, 0xb6, 0xe2, 0xd3, 0x34, 0x62);
+
+
+// {83D7F506-53ED-4f15-B6D8-7D8E9E72A918}
+DEFINE_GUID(IID_IOggOutputPin, 
+0x83d7f506, 0x53ed, 0x4f15, 0xb6, 0xd8, 0x7d, 0x8e, 0x9e, 0x72, 0xa9, 0x18);
+
+// {EB5AED9C-8CD0-4c4b-B5E8-F5D10AD1314D}
+DEFINE_GUID(IID_IOggBaseTime, 
+0xeb5aed9c, 0x8cd0, 0x4c4b, 0xb5, 0xe8, 0xf5, 0xd1, 0xa, 0xd1, 0x31, 0x4d);
+
+
+//// {3913F0AB-E7ED-41c4-979B-1D1FDD983C07}
+//DEFINE_GUID(MEDIASUBTYPE_FLAC, 
+//0x3913f0ab, 0xe7ed, 0x41c4, 0x97, 0x9b, 0x1d, 0x1f, 0xdd, 0x98, 0x3c, 0x7);
+//
+//
+//// {8A0566AC-42B3-4ad9-ACA3-93B906DDF98A}
+//DEFINE_GUID(MEDIASUBTYPE_Vorbis, 
+//0x8a0566ac, 0x42b3, 0x4ad9, 0xac, 0xa3, 0x93, 0xb9, 0x6, 0xdd, 0xf9, 0x8a);
+//
+//// {25A9729D-12F6-420e-BD53-1D631DC217DF}
+//DEFINE_GUID(MEDIASUBTYPE_Speex, 
+//0x25a9729d, 0x12f6, 0x420e, 0xbd, 0x53, 0x1d, 0x63, 0x1d, 0xc2, 0x17, 0xdf);
+//
+//
+//
+//// {44E04F43-58B3-4de1-9BAA-8901F852DAE4}
+//DEFINE_GUID(FORMAT_Vorbis, 
+//0x44e04f43, 0x58b3, 0x4de1, 0x9b, 0xaa, 0x89, 0x1, 0xf8, 0x52, 0xda, 0xe4);
+//
+//// {78701A27-EFB5-4157-9553-38A7854E3E81}
+//DEFINE_GUID(FORMAT_Speex, 
+//0x78701a27, 0xefb5, 0x4157, 0x95, 0x53, 0x38, 0xa7, 0x85, 0x4e, 0x3e, 0x81);
+//
+//// {1CDC48AC-4C24-4b8b-982B-7007A29D83C4}
+//DEFINE_GUID(FORMAT_FLAC, 
+//0x1cdc48ac, 0x4c24, 0x4b8b, 0x98, 0x2b, 0x70, 0x7, 0xa2, 0x9d, 0x83, 0xc4);
+//
+//
+//// {05187161-5C36-4324-A734-22BF37509F2D}
+//DEFINE_GUID(CLSID_TheoraDecodeFilter, 
+//0x5187161, 0x5c36, 0x4324, 0xa7, 0x34, 0x22, 0xbf, 0x37, 0x50, 0x9f, 0x2d);
+//
+//// {D124B2B1-8968-4ae8-B288-FE16EA34B0CE}
+//DEFINE_GUID(MEDIASUBTYPE_Theora, 
+//0xd124b2b1, 0x8968, 0x4ae8, 0xb2, 0x88, 0xfe, 0x16, 0xea, 0x34, 0xb0, 0xce);
+//
+//// {A99F116C-DFFA-412c-95DE-725F99874826}
+//DEFINE_GUID(FORMAT_Theora, 
+//0xa99f116c, 0xdffa, 0x412c, 0x95, 0xde, 0x72, 0x5f, 0x99, 0x87, 0x48, 0x26);
+
+//This structure defines the type of input we accept on the input pin... Stream/Annodex
+
+
+//Structure defining the registration details of the filter
+const REGFILTER2 OggDemuxPacketSourceFilterReg = {
+		1,
+		MERIT_NORMAL,
+		0,
+        NULL
+		
+};
+
+
+//struct sVorbisFormatBlock {
+//	unsigned long vorbisVersion;
+//	unsigned long samplesPerSec;
+//	unsigned long minBitsPerSec;
+//	unsigned long avgBitsPerSec;
+//	unsigned long maxBitsPerSec;
+//	unsigned char numChannels;
+//};
+//
+//struct sSpeexFormatBlock {
+//	unsigned long speexVersion;
+//	unsigned long samplesPerSec;
+//	unsigned long minBitsPerSec;
+//	unsigned long avgBitsPerSec;
+//	unsigned long maxBitsPerSec;
+//	unsigned long numChannels;
+//
+//};
+//
+//struct sFLACFormatBlock {
+//	unsigned short numChannels;
+//	unsigned long numBitsPerSample;
+//	unsigned long samplesPerSec;
+//
+//};
+//
+//struct sTheoraFormatBlock {
+//	unsigned long theoraVersion;
+//	unsigned long outerFrameWidth;
+//	unsigned long outerFrameHeight;
+//	unsigned long pictureWidth;
+//	unsigned long pictureHeight;
+//	unsigned long frameRateNumerator;
+//	unsigned long frameRateDenominator;
+//	unsigned long aspectNumerator;
+//	unsigned long aspectDenominator;
+//	unsigned long maxKeyframeInterval;
+//	unsigned long targetBitrate;
+//	unsigned char targetQuality;
+//	unsigned char xOffset;
+//	unsigned char yOffset;
+//	unsigned char colourSpace;
+//};

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.cpp
===================================================================

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.def
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.def	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.def	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,7 @@
+LIBRARY	dsfOggDemux2
+EXPORTS 
+	DllMain				PRIVATE
+    DllGetClassObject   PRIVATE
+    DllCanUnloadNow     PRIVATE
+    DllRegisterServer   PRIVATE
+    DllUnregisterServer PRIVATE

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="dsfOggDemux2"
+	ProjectGUID="{304B710A-7355-471C-A4A8-9E8F6D640E6D}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\ogg;..\..\ogg;..\libDirectshowAbstracts;..\..\..\helper"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFOGGDEMUX2_EXPORTS"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"
+				CallingConvention="2"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="Strmbasd.lib Msvcrtd.lib Winmm.lib Strmiids.lib  Quartz.lib wsock32.lib shlwapi.lib"
+				OutputFile="$(OutDir)/dsfOggDemux2.dll"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug&quot;"
+				ModuleDefinitionFile="dsfOggDemux2.def"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/dsfOggDemux2.pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/dsfOggDemux2.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\ogg;..\..\ogg;..\libDirectshowAbstracts;..\..\..\helper"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFOGGDEMUX2_EXPORTS"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="3"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"
+				CallingConvention="2"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="Strmbase.lib Winmm.lib  Strmiids.lib  Quartz.lib wsock32.lib shlwapi.lib"
+				OutputFile="$(OutDir)/dsfOggDemux2.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="C:\DXSDK\Lib;&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release&quot;"
+				ModuleDefinitionFile="dsfOggDemux2.def"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/dsfOggDemux2.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\DataSourceFactory.cpp">
+			</File>
+			<File
+				RelativePath=".\dsfOggDemux2.def">
+			</File>
+			<File
+				RelativePath=".\FilterFileSource.cpp">
+			</File>
+			<File
+				RelativePath=".\HTTPFileSource.cpp">
+			</File>
+			<File
+				RelativePath=".\HTTPSocket.cpp">
+			</File>
+			<File
+				RelativePath=".\HTTPStreamingFileSource.cpp">
+			</File>
+			<File
+				RelativePath=".\OggDemuxPacketSourceFilter.cpp">
+			</File>
+			<File
+				RelativePath=".\OggDemuxPacketSourcePin.cpp">
+			</File>
+			<File
+				RelativePath=".\oggdllstuff.cpp">
+			</File>
+			<File
+				RelativePath=".\OggStreamMapper.cpp">
+			</File>
+			<File
+				RelativePath=".\RegWrap.cpp">
+			</File>
+			<File
+				RelativePath=".\SingleMediaFileCache.cpp">
+			</File>
+			<File
+				RelativePath=".\stdafx.cpp">
+				<FileConfiguration
+					Name="Debug|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32">
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"/>
+				</FileConfiguration>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath=".\DataSourceFactory.h">
+			</File>
+			<File
+				RelativePath=".\ds_guids.h">
+			</File>
+			<File
+				RelativePath=".\FilterFileSource.h">
+			</File>
+			<File
+				RelativePath=".\HTTPFileSource.h">
+			</File>
+			<File
+				RelativePath=".\HTTPSocket.h">
+			</File>
+			<File
+				RelativePath=".\HTTPStreamingFileSource.h">
+			</File>
+			<File
+				RelativePath=".\IFilterDataSource.h">
+			</File>
+			<File
+				RelativePath=".\IOggBaseTime.h">
+			</File>
+			<File
+				RelativePath=".\IOggDecoder.h">
+			</File>
+			<File
+				RelativePath=".\IOggFilterSeeker.h">
+			</File>
+			<File
+				RelativePath=".\IOggOutputPin.h">
+			</File>
+			<File
+				RelativePath=".\OggDemuxPacketSourceFilter.h">
+			</File>
+			<File
+				RelativePath=".\OggDemuxPacketSourcePin.h">
+			</File>
+			<File
+				RelativePath=".\oggdllstuff.h">
+			</File>
+			<File
+				RelativePath=".\OggStreamMapper.h">
+			</File>
+			<File
+				RelativePath=".\RegWrap.h">
+			</File>
+			<File
+				RelativePath=".\SingleMediaFileCache.h">
+			</File>
+			<File
+				RelativePath=".\stdafx.h">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,122 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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 "oggdllstuff.h"
+#include "RegWrap.h"
+
+//#define DONT_TOUCH_REGISTRY
+
+
+extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
+BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
+{
+    return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
+}
+
+
+//The folowing two functions do the registration and deregistration of the dll and it's contained com objects.
+STDAPI DllRegisterServer()
+{
+	
+	//TO DO::: Should we be releasing the filter mapper even when we return early ?
+    HRESULT hr;
+    IFilterMapper2* locFilterMapper = NULL;
+	
+    hr = AMovieDllRegisterServer2(TRUE);
+	if (FAILED(hr)) {
+		
+        return hr;
+	}
+	
+	
+
+    hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void **)&locFilterMapper);
+
+	
+	if (FAILED(hr)) {
+        return hr;
+	}
+	
+	hr = locFilterMapper->RegisterFilter(
+		CLSID_OggDemuxPacketSourceFilter,						// Filter CLSID. 
+		L"Ogg Demux Packet Source Filter",							// Filter name.
+        NULL,										// Device moniker. 
+        &CLSID_LegacyAmFilterCategory,				// Direct Show general category
+        L"Ogg Demux Packet Source Filter",							// Instance data. ???????
+        &OggDemuxPacketSourceFilterReg								// Pointer to filter information.
+    );
+
+#if (!defined(DONT_TOUCH_REGISTRY))
+	//Only call once... if you need multiple you have to fix the hack job in RegWrap !
+	RegWrap::addMediaPlayerDesc("Ogg File",  "*.ogg;*.ogv;*.oga;*.spx");
+	RegWrap::deleteKeyRecurse(HKEY_CLASSES_ROOT, ".OGG", "ShellEx");
+#endif
+
+
+
+
+    locFilterMapper->Release();
+
+    return hr;
+
+}
+
+STDAPI DllUnregisterServer()
+{
+#if (!defined(DONT_TOUCH_REGISTRY))
+	//This is not a general purpose function.
+	RegWrap::removeMediaDesc();
+#endif
+   HRESULT hr;
+    IFilterMapper2* locFilterMapper = NULL;
+
+    hr = AMovieDllRegisterServer2(FALSE);
+	if (FAILED(hr)) {
+		
+        return hr;
+	}
+ 
+    hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
+            IID_IFilterMapper2, (void **)&locFilterMapper);
+
+	if (FAILED(hr)) {
+        return hr;
+	}
+	
+
+    hr = locFilterMapper->UnregisterFilter(&CLSID_LegacyAmFilterCategory, 
+            L"Ogg Demux Packet Source Filter", CLSID_OggDemuxPacketSourceFilter);
+
+	//
+    locFilterMapper->Release();
+    return hr;
+
+}

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/oggdllstuff.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,66 @@
+//===========================================================================
+//Copyright (C) 2003, 2004, 2005 Zentaro Kavanagh
+//
+//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
+
+#ifndef INC_OGGDLLSTUFF
+#define INC_OGGDLLSTUFF
+
+
+
+////Ignore the wanrings in the directshow base classses
+//#pragma warning( push )
+//#pragma warning( disable : 4312 )
+
+
+#include <streams.h>
+#include <pullpin.h>
+#include <initguid.h>
+
+//#pragma warning( pop )
+
+
+#ifdef LIBOOOGG_EXPORTS
+#define LIBOOOGG_API __declspec(dllexport)
+#else
+#define LIBOOOGG_API __declspec(dllimport)
+#endif
+
+
+#ifdef DSFOGGDEMUX2_EXPORTS
+#pragma message("----> Exporting from Ogg Demux...")
+#define OGG_DEMUX2_API __declspec(dllexport)
+#else
+#pragma message("<---- Importing from Ogg Demux...")
+#define OGG_DEMUX2_API __declspec(dllimport)
+#endif
+
+
+#endif
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.cpp	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.cpp	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// dsfOggDemux2.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.h	2006-02-12 22:03:07 UTC (rev 10810)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/stdafx.h	2006-02-12 22:05:01 UTC (rev 10811)
@@ -0,0 +1,68 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//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.
+//===========================================================================
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+// TODO: reference additional headers your program requires here
+#include <vector>
+#include <fstream>
+#include <iostream>
+using namespace std;
+
+#ifdef LIBOOOGG_EXPORTS
+#define LIBOOOGG_API __declspec(dllexport)
+#else
+#define LIBOOOGG_API __declspec(dllimport)
+#endif
+#include <Dshow.h>
+#include <Initguid.h>
+#include <Qnetwork.h>
+#include "oggdllstuff.h"
+#include "OggDemuxPacketSourceFilter.h"
+#include "ds_guids.h"
+#include "OggDemuxPacketSourcePin.h"
+
+
+//#include "OggStreamMapper.h"
+//#include "OggStream.h"
+//#include "StreamHeaders.h"
+
+
+



More information about the commits mailing list