[xiph-commits] r8379 - trunk/oggdsf/src/lib/core/directshow/dsfOggDemux

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Mon Dec 13 06:54:45 PST 2004


Author: illiminable
Date: 2004-12-13 06:54:44 -0800 (Mon, 13 Dec 2004)
New Revision: 8379

Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h
Log:
* Starting to  flesh out some of the cache code.

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp	2004-12-13 12:02:31 UTC (rev 8378)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp	2004-12-13 14:54:44 UTC (rev 8379)
@@ -2,9 +2,102 @@
 #include ".\cachedhttpfilesource.h"
 
 CachedHTTPFileSource::CachedHTTPFileSource(void)
+
 {
 }
 
 CachedHTTPFileSource::~CachedHTTPFileSource(void)
 {
 }
+
+CachedHTTPFileSource::tMapEntry CachedHTTPFileSource::findNextHoleInData(__int64 inUpto)
+{
+
+	tRangeMap::iterator locIt = mRangeMap.upper_bound(inUpto);
+
+	//Get the entry correspondingto this value.
+	// The decrement is because of the stupid way the bound works in map.
+	// The decrement of upper bound gives what you would expect a lower_bound function *should*
+	//  return... ie the thing lower than the given key.
+	tMapEntry locEntry = *(--locIt);
+	tMapEntry locNextEntry = *(++locIt);
+
+	//If we are in range, then we already have this
+	if (inRange(locEntry, inUpto)) {
+		bool locDone = false;
+		
+		while (locIt != mRangeMap.end()) {
+			//If the end of this range equals the start of the next range, then there is no hole here !
+			if (locEntry.second.first == (locNextEntry.first)) {
+				locEntry = *(locIt);
+				locNextEntry = *(++locIt);
+			
+			} else {
+				//There is a hole... since the end value of the current range is not the same as the start of the next range
+				// So there is a hole from here.end+1 to next.start - 1
+				tMapEntry retEntry;
+				retEntry.first = locEntry.second.first + 1;
+				retEntry.second.first = - 1;		//The end becomes -1 until something goes in
+				return retEntry;
+
+			}
+		}
+	} else {
+		//This upto point is not in a known range.
+		tMapEntry retEntry;
+		retEntry.first = locEntry.second.first + 1;
+		retEntry.second.first = - 1;			//The end becomes -1 until something goes in
+		return retEntry;
+
+	}
+}
+
+bool CachedHTTPFileSource::startThread() {
+	if (ThreadExists() == FALSE) {
+		Create();
+	}
+	CallWorker(THREAD_RUN);
+	return true;
+}
+
+DWORD CachedHTTPFileSource::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;
+}
+bool CachedHTTPFileSource::inRange(CachedHTTPFileSource::tMapEntry inTestRange, __int64 inTestValue) {
+
+	return ((inTestRange.first <= inTestValue) && (inTestRange.second.first >= inTestValue));
+
+	
+}
+void CachedHTTPFileSource::DataProcessLoop() {
+	//This loop sits here filling in holes
+
+
+	//WHILE still holes
+	//	hole = findNextHoleInData();
+	//	requestByteRange(hole)
+	//WEND
+
+
+}
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h	2004-12-13 12:02:31 UTC (rev 8378)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h	2004-12-13 14:54:44 UTC (rev 8379)
@@ -1,5 +1,7 @@
 #pragma once
 
+
+
 class CachedHTTPFileSource
 	:	public IFilterDataSource
 	,	public CAMThread
@@ -25,7 +27,23 @@
 	//CAMThread pure virtuals
 	DWORD ThreadProc();
 protected:
+	typedef pair<__int64, wstring> tMapValue;
+	typedef pair<__int64, tMapValue> tMapEntry;
 
+	typedef map<__int64, tMapValue> tRangeMap;
+
+	tRangeMap mRangeMap;
+
+	fstream mReadFile;
+	fstream mWriteFile;
+
+	tMapEntry mCurrentReadRange;
+	tMapEntry mCurrentWriteRange;
+
+	//Cache helpers
+	CachedHTTPFileSource::tMapEntry findNextHoleInData(__int64 inUpto);
+	bool inRange(CachedHTTPFileSource::tMapEntry inTestRange, __int64 inTestValue);
+
 	bool startThread();
 	void DataProcessLoop();
 	CCritSec* mBufferLock;



More information about the commits mailing list