[xiph-commits] r10253 - branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sat Oct 22 11:00:10 PDT 2005


Author: illiminable
Date: 2005-10-22 11:00:03 -0700 (Sat, 22 Oct 2005)
New Revision: 10253

Modified:
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.cpp
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.h
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/stdafx.h
Log:
* Implement load and setupPins methods

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.cpp	2005-10-22 16:44:58 UTC (rev 10252)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.cpp	2005-10-22 18:00:03 UTC (rev 10253)
@@ -30,8 +30,8 @@
 //===========================================================================
 #include "StdAfx.h"
 #include "OggDemuxPageSourceFilter.h"
+#include "OggStreamMapper.h"
 
-
 // This template lets the Object factory create us properly and work with COM infrastructure.
 CFactoryTemplate g_Templates[] = 
 {
@@ -98,6 +98,7 @@
 }
 OggDemuxPageSourceFilter::OggDemuxPageSourceFilter(void)
 	:	CBaseFilter(NAME("OggDemuxPageSourceFilter"), NULL, m_pLock, CLSID_OggDemuxPageSourceFilter)
+	,	mDataSource(NULL)
 {
 	//Why do we do this, should the base class do it ?
 	m_pLock = new CCritSec;
@@ -105,10 +106,13 @@
 	mSourceFileLock = new CCritSec;
 	mDemuxLock = new CCritSec;
 	mStreamLock = new CCritSec;
+
+	mStreamMapper = new OggStreamMapper(this, m_pLock);
 }
 
 OggDemuxPageSourceFilter::~OggDemuxPageSourceFilter(void)
 {
+	delete mStreamMapper;
 	//TODO::: Delete the locks
 }
 //IMEdiaStreaming
@@ -163,8 +167,81 @@
 	return E_NOTIMPL;
 
 }
+
+bool OggDemuxPageSourceFilter::acceptOggPage(OggPage* inOggPage)
+{
+	return mStreamMapper->acceptOggPage(inOggPage);
+}
 HRESULT OggDemuxPageSourceFilter::SetUpPins()
 {
+	CAutoLock locDemuxLock(mDemuxLock);
+	CAutoLock locSourceLock(mSourceFileLock);
+	
+	unsigned short locRetryCount = 0;
+	const unsigned short RETRY_THRESHOLD = 3;
+
+	//Create and open a data source
+	mDataSource = DataSourceFactory::createDataSource(StringHelper::toNarrowStr(mFileName).c_str());
+	mDataSource->open(StringHelper::toNarrowStr(mFileName).c_str());
+	
+	//Error check
+	
+	//Register a callback
+	mOggBuffer.registerVirtualCallback(this);
+
+	char* locBuff = new char[SETUP_BUFFER_SIZE];
+	unsigned long locNumRead = 0;
+
+	//Feed the data in until we have seen all BOS pages.
+	while(!mStreamMapper->allStreamsReady()) {
+	
+		locNumRead = mDataSource->read(locBuff, SETUP_BUFFER_SIZE);
+	
+		if (locNumRead > 0) {
+			mOggBuffer.feed((const unsigned char*)locBuff, locNumRead);
+		}
+
+		if (mDataSource->isEOF() || mDataSource->isError()) {
+			if (mDataSource->isError() && (mDataSource->shouldRetryAt() != "") && (locRetryCount < RETRY_THRESHOLD)) {
+				mOggBuffer.clearData();
+				string locNewLocation = mDataSource->shouldRetryAt();
+				//debugLog<<"Retrying at : "<<locNewLocation<<endl;
+				delete mDataSource;
+				mDataSource = DataSourceFactory::createDataSource(locNewLocation.c_str());
+				mDataSource->open(locNewLocation.c_str());
+				locRetryCount++;
+			} else {
+				//debugLog<<"Bailing out"<<endl;
+				return VFW_E_CANNOT_RENDER;
+			}
+		}
+	}
+	
+	//mStreamMapper->setAllowDispatch(true);
+	//mStreamMapper->toStartOfData();			//Flushes all streams and sets them to ignore the right number of headers.
+	//mOggBuffer.clearData();
+	//mDataSource->seek(0);			//TODO::: This is bad for streams.
+
+	//debugLog<<"COMPLETED SETUP"<<endl;
+	delete[] locBuff;
+	return S_OK;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 	//TODO:::
 	return S_OK;
 }

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.h	2005-10-22 16:44:58 UTC (rev 10252)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPageSourceFilter.h	2005-10-22 18:00:03 UTC (rev 10253)
@@ -30,11 +30,18 @@
 //===========================================================================
 #pragma once
 #include "BasicSeekPassThrough.h"
+#include "IFilterDataSource.h"
+//#include "OggStreamMapper.h"
+#include <libOOOgg/OggDataBuffer.h>
+#include "DataSourceFactory.h"
+
+class OggStreamMapper;
+
 class OggDemuxPageSourceFilter
 	:	public CBaseFilter
 	,	public CAMThread
 	,	public IFileSourceFilter
-	//,	public IOggCallback
+	,	public IOggCallback
 	,	public BasicSeekPassThrough
 	//,	public ISpecifyPropertyPages
 	,	public IAMFilterMiscFlags
@@ -55,6 +62,9 @@
 	STDMETHODIMP Pause(void);
 	STDMETHODIMP Stop(void);
 
+	//IOggCallback Interface
+	virtual bool acceptOggPage(OggPage* inOggPage);
+
 	//PURE VIRTUALS From CBaseFilter
 	virtual int GetPinCount();
 	virtual CBasePin* GetPin(int inPinNo);
@@ -91,9 +101,16 @@
 	virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
 
 protected:
+	static const unsigned long SETUP_BUFFER_SIZE = 24;
 	virtual HRESULT SetUpPins();
 
 	CCritSec* mSourceFileLock;
 	CCritSec* mDemuxLock;
 	CCritSec* mStreamLock;
+
+	wstring mFileName;
+
+	OggDataBuffer mOggBuffer;
+	IFilterDataSource* mDataSource;
+	OggStreamMapper* mStreamMapper;
 };

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj	2005-10-22 16:44:58 UTC (rev 10252)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/dsfOggDemux2.vcproj	2005-10-22 18:00:03 UTC (rev 10253)
@@ -24,7 +24,7 @@
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
-				UsePrecompiledHeader="3"
+				UsePrecompiledHeader="0"
 				WarningLevel="3"
 				Detect64BitPortabilityProblems="TRUE"
 				DebugInformationFormat="4"

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/stdafx.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/stdafx.h	2005-10-22 16:44:58 UTC (rev 10252)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/stdafx.h	2005-10-22 18:00:03 UTC (rev 10253)
@@ -60,7 +60,7 @@
 #include "OggDemuxPageSourcePin.h"
 
 
-
+//#include "OggStreamMapper.h"
 //#include "OggStream.h"
 //#include "StreamHeaders.h"
 



More information about the commits mailing list