[xiph-commits] r6906 - in trunk/oggdsf: scripts

illiminable at dactyl.lonelymoon.com illiminable
Mon Jun 28 00:57:18 PDT 2004


src/lib/core/directshow/dsfOggDemux src/lib/core/ogg/libOOOggSeek
Message-ID: <20040628075718.331FC9AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Mon Jun 28 00:57:18 2004
New Revision: 6906

Added:
trunk/oggdsf/scripts/note2self.txt
Modified:
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
Log:
* Super Buggy Build.
* Fixed most of the network gunk.
* Made sure it doesn't try and build a seek table on a network conenction.

Added: trunk/oggdsf/scripts/note2self.txt
===================================================================
--- trunk/oggdsf/scripts/note2self.txt	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/scripts/note2self.txt	2004-06-28 07:57:15 UTC (rev 6906)
@@ -0,0 +1,8 @@
+Registering protocols for media types
+
+http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/registeringacustomfiletype.asp
+
+HKEY_CLASSES_ROOT
+  <protocol>
+     Extensions
+         <.ext1> = <Source GUID>
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp	2004-06-28 07:57:15 UTC (rev 6906)
@@ -35,6 +35,7 @@
:	mWasError(false)
,	mIsEOF(false)
,	mIsOpen(false)
+	,	mSeenResponse(false)
{
debugLog.open("G:\\httpdebug.log", ios_base::out);
WORD locWinsockVersion = MAKEWORD(1,1);
@@ -65,13 +66,14 @@
debugLog<<"DataProcessLoop: "<<endl;
int locNumRead = 0;
char* locBuff = NULL;
-	const unsigned long RECV_BUFF_SIZE = 4096;
+	const unsigned long RECV_BUFF_SIZE = 1024;
locBuff = new char[RECV_BUFF_SIZE];
while(true) {

locNumRead = recv(mSocket, locBuff, RECV_BUFF_SIZE, 0);
if (locNumRead == SOCKET_ERROR) {
-			debugLog<<"Socket error receiving"<<endl;
+			int locErr = WSAGetLastError();
+			debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
mWasError = true;
break;
}
@@ -81,9 +83,22 @@
mIsEOF = true;
break;
}
-        //Add to buffer
-		mStreamBuffer.write(locBuff, locNumRead);
-		debugLog<<"Added to buffer "<<locNumRead<<" bytes."<<endl;
+
+		if (mSeenResponse) {
+			//Add to buffer
+			mStreamBuffer.write(locBuff, locNumRead);
+			debugLog<<"Added to buffer "<<locNumRead<<" bytes."<<endl;
+		} else {
+			string locTemp = locBuff;
+			size_t locPos = locTemp.find("\n\n");
+			if (locPos != string::npos) {
+				//Found the break
+				mSeenResponse = true;
+				mLastResponse = locTemp.substr(0, locPos);
+				mStreamBuffer.write(locBuff + locPos + 2, locNumRead - (locPos + 2));
+				debugLog<<"Added to Buffer "<<locNumRead - (locPos+2)<<" bytes... first after response."<<endl;
+			}
+		}
}

delete locBuff;
@@ -117,7 +132,7 @@
}

mSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-	if (mSocket = INVALID_SOCKET) {
+	if (mSocket == INVALID_SOCKET) {
debugLog<<"Socket Invalid"<<endl;
//Failed
return false;
@@ -148,9 +163,16 @@
return false;
}

+	return true;


+}

+string HTTPFileSource::assembleRequest(string inFilePath) {
+	string retRequest;
+	retRequest = "GET " + inFilePath+ " HTTP/1.1\n" + "Host: " + mServerName+ "\n\n";
+	debugLog<<"Assembled Req : "<<endl<<retRequest<<endl;
+	return retRequest;
}

bool HTTPFileSource::httpRequest(string inRequest) {
@@ -220,7 +242,7 @@
return false;
} else {
locServerName = locTemp.substr(0, locPos);
-				locPath = locTemp.substr(locPos+1);
+				locPath = locTemp.substr(locPos);
}
}

@@ -251,7 +273,8 @@
bool HTTPFileSource::open(string inSourceLocation) {
//Open network connection and start feeding data into a buffer
//
-
+	mSeenResponse = false;
+	mLastResponse = "";
debugLog<<"Open:"<<endl;
bool locIsOK = setupSocket(inSourceLocation);

@@ -260,6 +283,9 @@
closeSocket();
return false;
}
+
+	debugLog<<"Sending request..."<<endl;
+	httpRequest(assembleRequest(mFileName));
debugLog<<"Socket ok... starting thread"<<endl;
locIsOK = startThread();


Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h	2004-06-28 07:57:15 UTC (rev 6906)
@@ -67,11 +67,13 @@
virtual bool setupSocket(string inSourceLocation);
virtual void closeSocket();
virtual bool splitURL(string inURL);
+	virtual string assembleRequest(string inFilePath);
bool httpRequest(string inRequest);
bool HTTPFileSource::startThread();
void DataProcessLoop();
string mServerName;
string mFileName;
+	string mLastResponse;
SOCKET mSocket;
stringstream mStreamBuffer;

@@ -79,4 +81,5 @@
bool mIsEOF;
bool mWasError;
bool mIsOpen;
+	bool mSeenResponse;
};

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp	2004-06-28 07:57:15 UTC (rev 6906)
@@ -578,15 +578,19 @@
mOggBuffer.registerVirtualCallback(this);

char* locBuff = new char[RAW_BUFFER_SIZE];
-
+	unsigned long locNumRead = 0;
+
//Feed the data in until we have seen all BOS pages.
while(!mStreamMapper->isReady()) {
//SOURCE ABSTRACTION::: read
//mSourceFile.read(locBuff, RAW_BUFFER_SIZE);
//
-		mDataSource->read(locBuff, RAW_BUFFER_SIZE);
+		locNumRead = mDataSource->read(locBuff, RAW_BUFFER_SIZE);
//
-		mOggBuffer.feed(locBuff, RAW_BUFFER_SIZE);
+		//BUG::: Need to actually see how many bytes were read !
+		if (locNumRead > 0) {
+			mOggBuffer.feed(locBuff, RAW_BUFFER_SIZE);
+		}

}
//Memory leak

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h	2004-06-28 07:57:15 UTC (rev 6906)
@@ -49,7 +49,7 @@
public IFileSourceFilter,
public IOggCallback
,	public BasicSeekable
-	,
+
{
public:
friend class OggStream;

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-06-27 22:03:47 UTC (rev 6905)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-06-28 07:57:15 UTC (rev 6906)
@@ -125,13 +125,21 @@
return mFileDuration;
}
bool AutoOggSeekTable::buildTable() {
-	mFile.open(mFileName.c_str(), ios_base::in | ios_base::binary);
-	const unsigned long BUFF_SIZE = 4096;
-	unsigned char* locBuff = new unsigned char[BUFF_SIZE];
-	while (!mFile.eof()) {
-		mFile.read((char*)locBuff, BUFF_SIZE);
-		mOggDemux.feed((const char*)locBuff, mFile.gcount());
+	//HACK::: To ensure we don't try and build a table on the network file.
+	if (mFileName.find("http") != 0) {
+		mFile.open(mFileName.c_str(), ios_base::in | ios_base::binary);
+		const unsigned long BUFF_SIZE = 4096;
+		unsigned char* locBuff = new unsigned char[BUFF_SIZE];
+		while (!mFile.eof()) {
+			mFile.read((char*)locBuff, BUFF_SIZE);
+			mOggDemux.feed((const char*)locBuff, mFile.gcount());
+		}
+		mFile.close();
+
+	} else {
+		mEnabled = false;
+		mSampleRate = 1;
}
-	mFile.close();
+
return true;
}
\ No newline at end of file



More information about the commits mailing list