[xiph-commits] r8381 - in trunk/oggdsf/src/lib/core:
directshow/dsfOggDemux ogg/libOOOggSeek
illiminable at motherfish-iii.xiph.org
illiminable at motherfish-iii.xiph.org
Mon Dec 13 21:30:17 PST 2004
Author: illiminable
Date: 2004-12-13 21:30:16 -0800 (Mon, 13 Dec 2004)
New Revision: 8381
Added:
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.h
Modified:
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/libOOOggSeek.vcproj
Log:
* Add recogniser automaton.
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp 2004-12-13 18:12:00 UTC (rev 8380)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.cpp 2004-12-14 05:30:16 UTC (rev 8381)
@@ -90,6 +90,137 @@
}
+
+unsigned long CachedHTTPFileSource::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 (mReadFile.readSeek(inPos)) {
+ return inPos;
+ } else {
+ return (unsigned long) -1;
+ }
+
+}
+
+unsigned long CachedHTTPFileSource::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((mReadFile.bytesAvail() == 0) || mWasError) {
+ //debugLog<<"read : Can't read is error or eof"<<endl;
+ return 0;
+ } else {
+ //debugLog<<"Reading from buffer"<<endl;
+
+ unsigned long locNumRead = mReadFile.read((unsigned char*)outBuffer, inNumBytes);
+ /* if (locNumRead == 0) {
+ mStreamBuffer.clear();
+ }*/
+
+ //debugLog<<locNumRead<<" bytes read from buffer"<<endl;
+ return locNumRead;
+ }
+ } //END CRITICAL SECTION
+}
+
+bool CachedHTTPFileSource::open(string inSourceLocation) {
+ //Open network connection and start feeding data into a buffer
+ //
+ // In sourcelocation is a http url
+ //
+
+ 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";
+
+ //*****************************************************
+ //TODO::: Need to do something about the filename...
+ //*****************************************************
+ locCacheFileName += StringHelper::numToString(locRand);
+ locCacheFileName += ".ogg";
+ //debugLog<<"Cache file = "<<locCacheFileName<<endl;
+ if(mReadFile.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 CachedHTTPFileSource::clear() {
+ //Reset flags.
+ mIsEOF = false;
+ mWasError = false;
+}
+bool CachedHTTPFileSource::isEOF() {
+ //{ //CRITICAL SECTION - PROTECTING STREAM BUFFER
+ // CAutoLock locLock(mBufferLock);
+ // //TODO:::
+ // 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
+ return false;
+}
+void CachedHTTPFileSource::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();
+}
void CachedHTTPFileSource::DataProcessLoop() {
//This loop sits here filling in holes
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h 2004-12-13 18:12:00 UTC (rev 8380)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/CachedHTTPFileSource.h 2004-12-14 05:30:16 UTC (rev 8381)
@@ -34,8 +34,8 @@
tRangeMap mRangeMap;
- fstream mReadFile;
- fstream mWriteFile;
+ SingleMediaFileCache mReadFile;
+ SingleMediaFileCache mWriteFile;
tMapEntry mCurrentReadRange;
tMapEntry mCurrentWriteRange;
Added: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.cpp 2004-12-13 18:12:00 UTC (rev 8380)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.cpp 2004-12-14 05:30:16 UTC (rev 8381)
@@ -0,0 +1,60 @@
+#include "StdAfx.h"
+#include ".\oggsrecogniser.h"
+
+OGGSRecogniser::OGGSRecogniser(void)
+: mState(OGGSRecogniser::STATE_START)
+{
+}
+
+OGGSRecogniser::~OGGSRecogniser(void)
+{
+}
+
+
+long OGGSRecogniser::feed(unsigned char* inBuff, unsigned long inNumBytes) {
+
+ for (unsigned long i = 0; i < inNumBytes; i++) {
+ switch (mState) {
+ case STATE_START:
+ //Haven't matched anything
+ if (inBuff[i] == 'O') {
+ mState = STATE_O;
+ }
+ break;
+ case STATE_O:
+ //Already matched an O
+ if (inBuff[i] == 'g') {
+ //Now advance t the g state
+ mState = STATE_G1;
+ } else {
+ //Anything but a g and we move back to the start state.
+ mState = STATE_START;
+ }
+ break;
+ case STATE_G1:
+ if (inBuff[i] == 'g') {
+ mState = STATE_G2;
+ } else {
+ mState = STATE_START;
+ }
+ break;
+ case STATE_G2:
+ if (inBuff[i] == 'S') {
+ mState = STATE_START;
+ return (i);
+ } else {
+ mState = STATE_START;
+ }
+
+ break;
+ default:
+ //Should never be in an invalid state.
+ throw 0;
+ }
+ }
+
+ return -1;
+}
+void OGGSRecogniser::resetState() {
+ mState = STATE_START;
+}
\ No newline at end of file
Added: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.h 2004-12-13 18:12:00 UTC (rev 8380)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OGGSRecogniser.h 2004-12-14 05:30:16 UTC (rev 8381)
@@ -0,0 +1,24 @@
+#pragma once
+
+class OGGSRecogniser
+{
+public:
+ OGGSRecogniser(void);
+ ~OGGSRecogniser(void);
+
+ enum eOggRecogState {
+ STATE_START = 0,
+ STATE_O,
+ STATE_G1,
+ STATE_G2
+
+
+ };
+
+ long feed(unsigned char* inBuff, unsigned long inNumBytes);
+ void resetState();
+
+protected:
+ eOggRecogState mState;
+
+};
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/libOOOggSeek.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/libOOOggSeek.vcproj 2004-12-13 18:12:00 UTC (rev 8380)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/libOOOggSeek.vcproj 2004-12-14 05:30:16 UTC (rev 8381)
@@ -260,15 +260,15 @@
RelativePath="libOOOggSeek.cpp">
</File>
<File
- RelativePath=".\OggBinarySeeker.cpp">
- </File>
- <File
RelativePath="OggSeekPoint.cpp">
</File>
<File
RelativePath="OggSeekTable.cpp">
</File>
<File
+ RelativePath=".\OGGSRecogniser.cpp">
+ </File>
+ <File
RelativePath="stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
@@ -312,15 +312,15 @@
RelativePath="libOOOggSeek.h">
</File>
<File
- RelativePath=".\OggBinarySeeker.h">
- </File>
- <File
RelativePath="OggSeekPoint.h">
</File>
<File
RelativePath="OggSeekTable.h">
</File>
<File
+ RelativePath=".\OGGSRecogniser.h">
+ </File>
+ <File
RelativePath="stdafx.h">
</File>
</Filter>
More information about the commits
mailing list