00001 #pragma once 00002 00003 00004 00005 class CachedHTTPFileSource 00006 : public IFilterDataSource 00007 , public CAMThread 00008 , protected HTTPSocket 00009 { 00010 public: 00011 CachedHTTPFileSource(void); 00012 virtual ~CachedHTTPFileSource(void); 00013 00014 //Thread commands 00015 static const int THREAD_RUN = 0; 00016 static const int THREAD_EXIT = 1; 00017 // 00018 00019 //IFilterDataSource 00020 virtual unsigned long seek(unsigned long inPos); 00021 virtual void close(); 00022 virtual bool open(string inSourceLocation); 00023 virtual void clear(); 00024 virtual bool isEOF(); 00025 virtual unsigned long read(char* outBuffer, unsigned long inNumBytes); 00026 00027 //CAMThread pure virtuals 00028 DWORD ThreadProc(); 00029 protected: 00030 typedef pair<__int64, wstring> tMapValue; 00031 typedef pair<__int64, tMapValue> tMapEntry; 00032 00033 typedef map<__int64, tMapValue> tRangeMap; 00034 00035 tRangeMap mRangeMap; 00036 00037 SingleMediaFileCache mReadFile; 00038 SingleMediaFileCache mWriteFile; 00039 00040 tMapEntry mCurrentReadRange; 00041 tMapEntry mCurrentWriteRange; 00042 00043 //Cache helpers 00044 CachedHTTPFileSource::tMapEntry findNextHoleInData(__int64 inUpto); 00045 bool inRange(CachedHTTPFileSource::tMapEntry inTestRange, __int64 inTestValue); 00046 00047 bool startThread(); 00048 void DataProcessLoop(); 00049 CCritSec* mBufferLock; 00050 00051 };