[xiph-commits] r10106 - in trunk/oggdsf: build/oggcodecs
src/lib/core/directshow/dsfOggDemux
illiminable at svn.xiph.org
illiminable at svn.xiph.org
Sat Oct 1 01:20:22 PDT 2005
Author: illiminable
Date: 2005-10-01 01:20:12 -0700 (Sat, 01 Oct 2005)
New Revision: 10106
Modified:
trunk/oggdsf/build/oggcodecs/oggcodecs.vdproj
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/FilterFileSource.h
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/IFilterDataSource.h
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
Log:
* Add a new isError to the data source interface
* No longer hangs on 404 or other error from server.
Modified: trunk/oggdsf/build/oggcodecs/oggcodecs.vdproj
===================================================================
--- trunk/oggdsf/build/oggcodecs/oggcodecs.vdproj 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/build/oggcodecs/oggcodecs.vdproj 2005-10-01 08:20:12 UTC (rev 10106)
@@ -21,6 +21,12 @@
}
"Entry"
{
+ "MsmKey" = "8:_0334FF23A9CE7C3807ABB7808659A808"
+ "OwnerKey" = "8:_A0E68123D9D541DFA9691752981C903A"
+ "MsmSig" = "8:_UNDEFINED"
+ }
+ "Entry"
+ {
"MsmKey" = "8:_054BE8EA6F5E45A7AB2066734E998570"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -735,6 +741,12 @@
}
"Entry"
{
+ "MsmKey" = "8:_CE3F3614A250A32BEFE6FA8B7C33D4B9"
+ "OwnerKey" = "8:_A0E68123D9D541DFA9691752981C903A"
+ "MsmSig" = "8:_UNDEFINED"
+ }
+ "Entry"
+ {
"MsmKey" = "8:_D2048C8B212841C88E42F6ADDCA8B0A2"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -889,6 +901,26 @@
}
"File"
{
+ "{A582A373-4685-4296-BEFE-614B80A702C3}:_0334FF23A9CE7C3807ABB7808659A808"
+ {
+ "SourcePath" = "8:libCMMLParse.dll"
+ "TargetName" = "8:libCMMLParse.dll"
+ "Tag" = "8:"
+ "Folder" = "8:_371AD289B6DB4693BDF7568485051F1E"
+ "Condition" = "8:"
+ "Transitive" = "11:FALSE"
+ "Vital" = "11:TRUE"
+ "ReadOnly" = "11:FALSE"
+ "Hidden" = "11:FALSE"
+ "System" = "11:FALSE"
+ "Permanent" = "11:FALSE"
+ "SharedLegacy" = "11:FALSE"
+ "PackageAs" = "3:1"
+ "Register" = "3:1"
+ "Exclude" = "11:TRUE"
+ "IsDependency" = "11:TRUE"
+ "IsolateTo" = "8:"
+ }
"{A582A373-4685-4296-BEFE-614B80A702C3}:_1ED42AE022EB477985E46FA18A63F9A5"
{
"SourcePath" = "8:..\\..\\AUTHORS"
@@ -1109,6 +1141,26 @@
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}
+ "{A582A373-4685-4296-BEFE-614B80A702C3}:_CE3F3614A250A32BEFE6FA8B7C33D4B9"
+ {
+ "SourcePath" = "8:libCMMLTags.dll"
+ "TargetName" = "8:libCMMLTags.dll"
+ "Tag" = "8:"
+ "Folder" = "8:_371AD289B6DB4693BDF7568485051F1E"
+ "Condition" = "8:"
+ "Transitive" = "11:FALSE"
+ "Vital" = "11:TRUE"
+ "ReadOnly" = "11:FALSE"
+ "Hidden" = "11:FALSE"
+ "System" = "11:FALSE"
+ "Permanent" = "11:FALSE"
+ "SharedLegacy" = "11:FALSE"
+ "PackageAs" = "3:1"
+ "Register" = "3:1"
+ "Exclude" = "11:TRUE"
+ "IsDependency" = "11:TRUE"
+ "IsolateTo" = "8:"
+ }
"{A582A373-4685-4296-BEFE-614B80A702C3}:_D9BE90D398094F15B881B22369C3A231"
{
"SourcePath" = "8:..\\..\\VERSIONS"
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/FilterFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/FilterFileSource.h 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/FilterFileSource.h 2005-10-01 08:20:12 UTC (rev 10106)
@@ -31,6 +31,7 @@
#pragma once
#include <fstream>
+#include <string>
using namespace std;
#include "IFilterDataSource.h"
@@ -47,7 +48,9 @@
virtual bool open(string inSourceLocation);
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:
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.cpp 2005-10-01 08:20:12 UTC (rev 10106)
@@ -31,6 +31,7 @@
#include "stdafx.h"
#include "httpfilesource.h"
+#define OGGCODECS_LOGGING
HTTPFileSource::HTTPFileSource(void)
: mBufferLock(NULL)
, mIsChunked(false)
@@ -68,7 +69,7 @@
//This method is a bit rough and ready !!
ASSERT(inNumBytes > 2);
rawDump.write((char*)inBuff, inNumBytes);
- //debugLog<<"UnChunk"<<endl;
+ debugLog<<"UnChunk"<<endl;
unsigned long locNumBytesLeft = inNumBytes;
memcpy((void*)(mInterBuff + mNumLeftovers), (const void*)inBuff, inNumBytes);
@@ -170,12 +171,13 @@
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;
+ debugLog<<"Thread Data Process loop received breakout signal..."<<endl;
delete[] locBuff;
return;
}
@@ -184,13 +186,13 @@
//debugLog<<"recv complete"<<endl;
if (locNumRead == SOCKET_ERROR) {
int locErr = WSAGetLastError();
- //debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
+ debugLog<<"Socket error receiving - Err No = "<<locErr<<endl;
mWasError = true;
break;
}
if (locNumRead == 0) {
- //debugLog<<"Read last bytes..."<<endl;
+ debugLog<<"Read last bytes..."<<endl;
mIsEOF = true;
delete[] locBuff;
return;
@@ -228,7 +230,35 @@
//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) {
+ 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;
}
@@ -237,10 +267,14 @@
locTemp = locBuff2;
if (mIsChunked) {
- unChunk((unsigned char*)locBuff2, locNumRead - locPos - 4);
+ if (locNumRead - locPos - 4 > 0) {
+ unChunk((unsigned char*)locBuff2, locNumRead - locPos - 4);
+ }
} else {
//debugLog<<"Start of data follows"<<endl<<locTemp<<endl;
- mFileCache.write((const unsigned char*)locBuff2, (locNumRead - (locPos + 4)));
+ if (locNumRead - locPos - 4 > 0) {
+ mFileCache.write((const unsigned char*)locBuff2, (locNumRead - (locPos + 4)));
+ }
}
}
}
@@ -250,6 +284,25 @@
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;
@@ -268,6 +321,8 @@
DataProcessLoop();
break;
}
+
+
}
return S_OK;
}
@@ -295,6 +350,8 @@
Close();
//debugLog<<"After Close called on CAMThread"<<endl;
}
+
+
//debugLog<<"Closing socket..."<<endl;
//Close the socket down.
@@ -357,9 +414,15 @@
}
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);
@@ -388,7 +451,7 @@
//debugLog<<"read : Can't read is error or eof"<<endl;
return 0;
} else {
- //debugLog<<"Reading from buffer"<<endl;
+ debugLog<<"Reading from buffer"<<endl;
unsigned long locNumRead = mFileCache.read((unsigned char*)outBuffer, inNumBytes);
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/HTTPFileSource.h 2005-10-01 08:20:12 UTC (rev 10106)
@@ -58,13 +58,16 @@
virtual bool open(string inSourceLocation);
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();
@@ -74,6 +77,7 @@
unsigned long mChunkRemains;
bool mIsFirstChunk;
+ string mRetryAt;
fstream debugLog;
fstream fileDump;
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/IFilterDataSource.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/IFilterDataSource.h 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/IFilterDataSource.h 2005-10-01 08:20:12 UTC (rev 10106)
@@ -43,6 +43,8 @@
virtual bool open(string inSourceLocation) = 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;
};
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp 2005-10-01 08:07:48 UTC (rev 10105)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp 2005-10-01 08:20:12 UTC (rev 10106)
@@ -32,6 +32,8 @@
#include "stdafx.h"
#include "oggdemuxsourcefilter.h"
+#define OGGCODECS_LOGGING
+
//-------------------
// This template lets the Object factory create us properly and work with COM infrastructure.
CFactoryTemplate g_Templates[] =
@@ -117,7 +119,7 @@
mStreamMapper = new OggStreamMapper(this);
#ifdef OGGCODECS_LOGGING
- debugLog.open("g:\\logs\\sourcelog.log", ios_base::out);
+ debugLog.open("d:\\zen\\logs\\sourcelog.log", ios_base::out);
#endif
}
@@ -220,9 +222,9 @@
CAutoLock locLock(m_pLock);
mFileName = inFileName;
- //debugLog<<"Loading : "<<StringHelper::toNarrowStr(mFileName)<<endl;
+ debugLog<<"Loading : "<<StringHelper::toNarrowStr(mFileName)<<endl;
- //debugLog << "Opening source file : "<<StringHelper::toNarrowStr(mFileName)<<endl;
+ debugLog << "Opening source file : "<<StringHelper::toNarrowStr(mFileName)<<endl;
mSeekTable = new AutoOggSeekTable(StringHelper::toNarrowStr(mFileName));
mSeekTable->buildTable();
@@ -619,7 +621,7 @@
CAutoLock locDemuxLock(mDemuxLock);
CAutoLock locSourceLock(mSourceFileLock);
-
+ debugLog<<"SETUP PINS"<<endl;
//Create and open a data source
mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
@@ -640,6 +642,11 @@
if (locNumRead > 0) {
mOggBuffer.feed((const unsigned char*)locBuff, locNumRead);
}
+
+ if (mDataSource->isEOF() || mDataSource->isError()) {
+ debugLog<<"Bailing out"<<endl;
+ return VFW_E_CANNOT_RENDER;
+ }
}
mStreamMapper->setAllowDispatch(true);
More information about the commits
mailing list