[xiph-commits] r6886 -
illiminable at dactyl.lonelymoon.com
illiminable
Sat Jun 26 09:37:25 PDT 2004
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux
Message-ID: <20040626163725.C7D529AAAB at dactyl.lonelymoon.com>
Author: illiminable
Date: Sat Jun 26 09:37:25 2004
New Revision: 6886
Added:
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.h
Modified:
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
Log:
* File source now fully abstracted behind an abstract DataSource Interface... hopefully should just be able to plug a network reader behind it too.
Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp 2004-06-26 14:20:54 UTC (rev 6885)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp 2004-06-26 16:37:24 UTC (rev 6886)
@@ -0,0 +1,37 @@
+#include "StdAfx.h"
+#include "datasourcefactory.h"
+
+DataSourceFactory::DataSourceFactory(void)
+{
+}
+
+DataSourceFactory::~DataSourceFactory(void)
+{
+}
+
+IFilterDataSource* DataSourceFactory::createDataSource(string inSourceLocation) {
+ string locType = identifySourceType(inSourceLocation);
+
+ if(locType.length() == 1) {
+ //File...
+ return new FilterFileSource;
+ } else if (locType == "http") {
+ //Http stream
+ return NULL;
+ } else {
+ //Something else
+ return NULL;
+ }
+}
+
+string DataSourceFactory::identifySourceType(string inSourceLocation) {
+ size_t locPos = inSourceLocation.find(':');
+ if (locPos == string::npos) {
+ //No colon... not a url or file... failure.
+ return "";
+ } else {
+ string retStr = inSourceLocation.substr(0,locPos);
+ return retStr;
+ }
+
+}
\ No newline at end of file
Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.h 2004-06-26 14:20:54 UTC (rev 6885)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.h 2004-06-26 16:37:24 UTC (rev 6886)
@@ -0,0 +1,12 @@
+#pragma once
+#include "IFilterDataSource.h"
+#include "FilterFileSource.h"
+class DataSourceFactory
+{
+public:
+ DataSourceFactory(void);
+ ~DataSourceFactory(void);
+
+ static IFilterDataSource* createDataSource(string inSourceLocation);
+ static string identifySourceType(string inSourceLocation);
+};
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp 2004-06-26 14:20:54 UTC (rev 6885)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp 2004-06-26 16:37:24 UTC (rev 6886)
@@ -84,6 +84,7 @@
OggDemuxSourceFilter::OggDemuxSourceFilter()
: CBaseFilter(NAME("OggDemuxSourceFilter"), NULL, m_pLock, CLSID_OggDemuxSourceFilter)
, mSeekTable(NULL)
+ , mDataSource(NULL)
{
//LEAK CHECK:::Both get deleted in constructor.
m_pLock = new CCritSec;
@@ -285,7 +286,10 @@
}
//SOURCE ABSTRACTION::: seek
- mSourceFile.seekg(mSeekTable->getStartPos(*pCurrent), ios_base::beg);
+ //mSourceFile.seekg(mSeekTable->getStartPos(*pCurrent), ios_base::beg);
+ //
+ mDataSource->seek(mSeekTable->getStartPos(*pCurrent));
+ //
*pCurrent = mSeekTable->getRealStartPos();
@@ -417,13 +421,27 @@
CAutoLock locDemuxLock(mDemuxLock);
//SOURCE ABSTRACTION::: clear, close, open, seek
- mSourceFile.clear();
- mSourceFile.close();
+ //mSourceFile.clear();
+ //mSourceFile.close();
+ //
+ mDataSource->clear();
+ mDataSource->close();
+ //After closing kill the interface
+ delete mDataSource;
+ mDataSource = NULL;
+ //
mOggBuffer.clearData();
- mSourceFile.open(StringHelper::toNarrowStr(mFileName).c_str(), ios_base::in|ios_base::binary);
- mSourceFile.seekg(mStreamMapper->startOfData(), ios_base::beg);
+ //SOURCE ABSTRACTION::: clear, close, open, seek
+ //mSourceFile.open(StringHelper::toNarrowStr(mFileName).c_str(), ios_base::in|ios_base::binary);
+ //mSourceFile.seekg(mStreamMapper->startOfData(), ios_base::beg);
+ //
+ //Before opening make the interface
+ mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
+ mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
+ mDataSource->seek(mStreamMapper->startOfData());
+ //
}
for (unsigned long i = 0; i < mStreamMapper->numStreams(); i++) {
mStreamMapper->getOggStream(i)->setSendExcess(true);
@@ -487,7 +505,10 @@
{
CAutoLock locSourceLock(mSourceFileLock);
//SOURCE ABSTRACTION::: is EOF
- locIsEOF = mSourceFile.eof();
+ //locIsEOF = mSourceFile.eof();
+ //
+ locIsEOF = mDataSource->isEOF();
+ //
}
while (!locIsEOF && locKeepGoing) {
if(CheckRequest(&locCommand) == TRUE) {
@@ -500,8 +521,11 @@
//debugLog << "DataProcessLoop : Getpointer = "<<mSourceFile.tellg()<<endl;
//SOURCE ABSTRACTION::: read, numbytes read
- mSourceFile.read(locBuff, 4096);
- locBytesRead = mSourceFile.gcount();
+ //mSourceFile.read(locBuff, 4096);
+ //locBytesRead = mSourceFile.gcount();
+ //
+ locBytesRead = mDataSource->read(locBuff, 4096);
+ //
}
//debugLog <<"DataProcessLoop : gcount = "<<locBytesRead<<endl;
{
@@ -514,7 +538,9 @@
{
CAutoLock locSourceLock(mSourceFileLock);
//SOURCE ABSTRACTION::: is EOF
- locIsEOF = mSourceFile.eof();
+ //locIsEOF = mSourceFile.eof();
+ locIsEOF = mDataSource->isEOF();
+ //
}
if (locIsEOF) {
//debugLog << "DataProcessLoop : EOF"<<endl;
@@ -539,7 +565,12 @@
CAutoLock locDemuxLock(mDemuxLock);
//SOURCE ABSTRACTION::: open
- mSourceFile.open(StringHelper::toNarrowStr(mFileName).c_str(), ios_base::in|ios_base::binary);
+ //mSourceFile.open(StringHelper::toNarrowStr(mFileName).c_str(), ios_base::in|ios_base::binary);
+ //
+ //Before openeing create the interface
+ mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
+ mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
+ //
//Error check
@@ -551,7 +582,10 @@
//Feed the data in until we have seen all BOS pages.
while(!mStreamMapper->isReady()) {
//SOURCE ABSTRACTION::: read
- mSourceFile.read(locBuff, RAW_BUFFER_SIZE);
+ //mSourceFile.read(locBuff, RAW_BUFFER_SIZE);
+ //
+ mDataSource->read(locBuff, RAW_BUFFER_SIZE);
+ //
mOggBuffer.feed(locBuff, RAW_BUFFER_SIZE);
}
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h 2004-06-26 14:20:54 UTC (rev 6885)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.h 2004-06-26 16:37:24 UTC (rev 6886)
@@ -35,7 +35,9 @@
#include "OggStreamMapper.h"
#include "AutoOggSeekTable.h"
#include <OggDataBuffer.h>
-#include <fstream>
+#include "IFilterDataSource.h"
+#include "DataSourceFactory.h"
+//#include <fstream>
using namespace std;
@@ -132,7 +134,9 @@
OggDataBuffer mOggBuffer;
//SOURCE ABSTRACTION::: declaration
- fstream mSourceFile;
+ //fstream mSourceFile;
+ //
+ IFilterDataSource* mDataSource;
OggStreamMapper* mStreamMapper;
Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj 2004-06-26 14:20:54 UTC (rev 6885)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj 2004-06-26 16:37:24 UTC (rev 6886)
@@ -129,6 +129,9 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
+ RelativePath="DataSourceFactory.cpp">
+ </File>
+ <File
RelativePath="FFDShowVideoStream.cpp">
</File>
<File
@@ -190,6 +193,9 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
+ RelativePath="DataSourceFactory.h">
+ </File>
+ <File
RelativePath="FFDShowVideoStream.h">
</File>
<File
More information about the commits
mailing list