[xiph-commits] r8239 - in trunk/oggdsf/src: lib/core/directshow/dsfAbstractAudioDecoder lib/core/directshow/dsfAbstractAudioEncoder lib/core/directshow/dsfAbstractVideoDecoder lib/core/directshow/dsfAbstractVideoEncoder lib/core/directshow/dsfOggDemux tools/CLOgg

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Sat Nov 20 22:06:20 PST 2004


Author: illiminable
Date: 2004-11-20 22:06:19 -0800 (Sat, 20 Nov 2004)
New Revision: 8239

Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.h
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioEncoder/AbstractAudioEncodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp
   trunk/oggdsf/src/tools/CLOgg/CLOgg.cpp
Log:
* Fixed windows network share crash.. can now play from network shares.
* Tidied up some code... and added a few more comments.

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -29,55 +29,75 @@
 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 //===========================================================================
 
+//
+// AbstractAudioDecodeFilter.cpp :	Abstract Audio Decoder Filter Class
+//
+
+
 #include "StdAfx.h"
 #include "abstractaudiodecodefilter.h"
 
+//Constructors
 AbstractAudioDecodeFilter::AbstractAudioDecodeFilter(TCHAR* inFilterName, REFCLSID inFilterGUID, unsigned short inAudioFormat )
-	:	CBaseFilter(inFilterName, NULL,m_pLock, inFilterGUID),
-		mAudioFormat(inAudioFormat)
+	//Base Classes
+	:	CBaseFilter(inFilterName, NULL, m_pLock, inFilterGUID)
+
+	//Member initialisations
+	,	mAudioFormat(inAudioFormat)
 	
 {
+	//Create the filter lock.
 	m_pLock = new CCritSec;		//Deleted in destructor... check what is happening in the base class.
 }
 
 AbstractAudioDecodeFilter::~AbstractAudioDecodeFilter(void)
 {
 	DestroyPins();
-	delete m_pLock;
-	
+	delete m_pLock;		//Deleting filter lock
 }
 
-//STDMETHODIMP_(ULONG) AbstractAudioDecodeFilter::NonDelegatingRelease() {
-//	ULONG x = CBaseFilter::NonDelegatingRelease();
-//	return x;
-//}
-void AbstractAudioDecodeFilter::DestroyPins() {
+void AbstractAudioDecodeFilter::DestroyPins() 
+{
 	delete mOutputPin;
 	delete mInputPin;
 }
 
-STDMETHODIMP AbstractAudioDecodeFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv) {
+//If you want to handle an interface, do it here.
+STDMETHODIMP AbstractAudioDecodeFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv) 
+{
 	return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
 }
 
-CBasePin* AbstractAudioDecodeFilter::GetPin(int inPinNo) {
-	//TO DO::: This is buggy, make a switch	
-	if (inPinNo < 0 ) {
-		return NULL;
-	} else if (inPinNo == 0) {
-		return mInputPin;
-	} else if (inPinNo == 1) {
-		return mOutputPin;
-	}
+CBasePin* AbstractAudioDecodeFilter::GetPin(int inPinNo) 
+{
+	//Pin Constants
+	const int INPUT_PIN = 0;
+	const int OUTPUT_PIN = 1;
+	
+	//Return the pin.
+	switch (inPinNo) {
+		case INPUT_PIN:		
+			return mInputPin;
+		case OUTPUT_PIN:
+			return mOutputPin;
+		default:
+			return NULL;
+	};
 }
 
-STDMETHODIMP AbstractAudioDecodeFilter::Stop() {
+STDMETHODIMP AbstractAudioDecodeFilter::Stop() 
+{
+	//Hold the filter lock
 	CAutoLock locLock(m_pLock);
+
+	//Reset the 
 	mInputPin->ResetFrameCount();
 	mInputPin->ResetTimeBases();
+	
 	return CBaseFilter::Stop();
 }
-int AbstractAudioDecodeFilter::GetPinCount(void) {
+int AbstractAudioDecodeFilter::GetPinCount(void) 
+{
 	const long NUM_PINS = 2;
 	return NUM_PINS;
 }	

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.h	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeFilter.h	2004-11-21 06:06:19 UTC (rev 8239)
@@ -29,6 +29,7 @@
 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 //===========================================================================
 
+
 #pragma once
 
 //Local Includes
@@ -39,21 +40,21 @@
 class AbstractAudioDecodeInputPin;
 class AbstractAudioDecodeOutputPin;
 
-//*************************************************************************************************
+
 class ABS_AUDIO_DEC_API AbstractAudioDecodeFilter
 	//Parent Classes
-	:	public CBaseFilter
-	//,	public BasicSeekable
+	:	public CBaseFilter	
+			//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/cbasefilterclass.asp
 {
 public:
-	//Friends
+	//Friend Classes
 	friend class AbstractAudioDecodeInputPin;
 	friend class AbstractAudioDecodeOutputPin;
 
 	//COM Setup
 	DECLARE_IUNKNOWN
 	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
-	//STDMETHODIMP_(ULONG) NonDelegatingRelease();
+	
 	//Constants and Enumerations
 	static const long NUM_PINS = 2;
 	enum eAudioFormat {

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeInputPin.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -33,19 +33,20 @@
 #include "abstractaudiodecodeinputpin.h"
 
 //#include <mtype.h>
-AbstractAudioDecodeInputPin::AbstractAudioDecodeInputPin(AbstractAudioDecodeFilter* inParentFilter, CCritSec* inFilterLock, AbstractAudioDecodeOutputPin* inOutputPin, CHAR* inObjectName, LPCWSTR inPinDisplayName, CMediaType* inAcceptMediaType)
-	:	CBaseInputPin(inObjectName, inParentFilter, inFilterLock, &mHR, inPinDisplayName)
-	,	mOutputPin(inOutputPin)
-	,	mUptoFrame(0)
-	,	mBegun(false)
-	,	mParentFilter(inParentFilter)
-	,	mFrameSize(0)
-	,	mNumChannels(0)
-	,	mSampleRate(0)
+AbstractAudioDecodeInputPin::AbstractAudioDecodeInputPin (AbstractAudioDecodeFilter* inParentFilter, CCritSec* inFilterLock, AbstractAudioDecodeOutputPin* inOutputPin, CHAR* inObjectName, LPCWSTR inPinDisplayName, CMediaType* inAcceptMediaType)
+	:	CBaseInputPin (inObjectName, inParentFilter, inFilterLock, &mHR, inPinDisplayName)
+	,	mOutputPin (inOutputPin)
+	,	mParentFilter (inParentFilter)
+	
+	,	mBegun (false)
+	,	mUptoFrame (0)
+	,	mFrameSize (0)
+	,	mNumChannels (0)
+	,	mSampleRate (0)
 	//,	mFilterLock(inFilterLock)
-	,	mLastSeenStartGranPos(0)
-	,	mSeekTimeBase(0)
-	,	mChainTimeBase(0)
+	,	mLastSeenStartGranPos (0)
+	,	mSeekTimeBase (0)
+	,	mChainTimeBase (0)
 {
 	
 	//ConstructCodec();
@@ -90,13 +91,15 @@
 	return CBaseInputPin::NonDelegatingQueryInterface(riid, ppv); 
 }
 
-HRESULT AbstractAudioDecodeInputPin::BreakConnect() {
+HRESULT AbstractAudioDecodeInputPin::BreakConnect() 
+{
 	CAutoLock locLock(m_pLock);
-	//Need a lock ??
+	//Release the seeking 
 	ReleaseDelegate();
 	return CBaseInputPin::BreakConnect();
 }
-HRESULT AbstractAudioDecodeInputPin::CompleteConnect (IPin *inReceivePin) {
+HRESULT AbstractAudioDecodeInputPin::CompleteConnect (IPin *inReceivePin) 
+{
 	CAutoLock locLock(m_pLock);
 	
 	IMediaSeeking* locSeeker = NULL;
@@ -114,11 +117,13 @@
 }
 
 
-void AbstractAudioDecodeInputPin::ResetFrameCount() {
+void AbstractAudioDecodeInputPin::ResetFrameCount() 
+{
 	mUptoFrame = 0;
 	
 }
-void AbstractAudioDecodeInputPin::ResetTimeBases() {
+void AbstractAudioDecodeInputPin::ResetTimeBases() 
+{
 	mLastSeenStartGranPos = 0;
 }
 bool AbstractAudioDecodeInputPin::SetSampleParams(IMediaSample* outMediaSample, unsigned long inDataSize, REFERENCE_TIME* inStartTime, REFERENCE_TIME* inEndTime) 
@@ -135,19 +140,15 @@
 
 STDMETHODIMP AbstractAudioDecodeInputPin::Receive(IMediaSample* inSample) 
 {
-	//
-	//inSample->AddRef();
-	//debugLog<<"Received Sample with refcount = "<<inSample->Release()<<endl;
-	//
-	//TO DO::: Fix this up...
 	CAutoLock locLock(mStreamLock);
+
 	HRESULT locHR = CheckStreaming();
+
 	if (locHR == S_OK) {
 		BYTE* locBuff = NULL;
 		locHR = inSample->GetPointer(&locBuff);
 
 		if (FAILED(locHR)) {
-			
 			return locHR;
 		} else {
 			//New start time hacks
@@ -213,13 +214,14 @@
 
 STDMETHODIMP AbstractAudioDecodeInputPin::BeginFlush() {
 	CAutoLock locLock(m_pLock);
+
 	CBaseInputPin::BeginFlush();
 	return mParentFilter->mOutputPin->DeliverBeginFlush();
 }
 STDMETHODIMP AbstractAudioDecodeInputPin::EndFlush() {
 	CAutoLock locLock(m_pLock);
+
 	mParentFilter->mOutputPin->DeliverEndFlush();
-	
 	return CBaseInputPin::EndFlush();
 }
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioDecoder/AbstractAudioDecodeOutputPin.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -114,7 +114,9 @@
 	return locHR;
 }
 HRESULT AbstractAudioDecodeOutputPin::CheckMediaType(const CMediaType *inMediaType) {
-	if (inMediaType->majortype == MEDIATYPE_Audio && inMediaType->subtype == MEDIASUBTYPE_PCM && inMediaType->formattype == FORMAT_WaveFormatEx) {
+	if (	(inMediaType->majortype == MEDIATYPE_Audio) && 
+			(inMediaType->subtype == MEDIASUBTYPE_PCM) && 
+			(inMediaType->formattype == FORMAT_WaveFormatEx)) {
 		return S_OK;
 	} else {
 		return S_FALSE;
@@ -152,22 +154,22 @@
 	return S_OK;
 }
 HRESULT AbstractAudioDecodeOutputPin::DeliverEndOfStream(void) {
-	//QUERY::: I think we need a lock here !
+	
 	mDataQueue->EOS();
     return S_OK;
 }
 
 HRESULT AbstractAudioDecodeOutputPin::DeliverEndFlush(void) {
 	CAutoLock locLock(m_pLock);
-	//QUERY::: Locks ??
+	
 	mDataQueue->EndFlush();
     return S_OK;
 }
 
 HRESULT AbstractAudioDecodeOutputPin::DeliverBeginFlush(void) {
 	CAutoLock locLock(m_pLock);
-	//QUERY:: Locks ???
 	
+	
 	mDataQueue->BeginFlush();
     return S_OK;
 	
@@ -185,8 +187,10 @@
 	SetDelegate(locSeeker);
 	//
 	mDataQueue = new COutputQueue (inReceivePin, &locHR, FALSE, FALSE, 1, TRUE, 20);			//Deleted in destructor
+
 	if (FAILED(locHR)) {
-		locHR = locHR;
+		//Handle data Q failure
+		
 	}
 	
 	return CBaseOutputPin::CompleteConnect(inReceivePin);
@@ -194,10 +198,12 @@
 
 HRESULT AbstractAudioDecodeOutputPin::BreakConnect(void) {
 	CAutoLock locLock(m_pLock);
+
 	delete mDataQueue;
 	mDataQueue = NULL;
 
 	HRESULT locHR = CBaseOutputPin::BreakConnect();
 	ReleaseDelegate();
+
 	return locHR;
 }
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioEncoder/AbstractAudioEncodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioEncoder/AbstractAudioEncodeInputPin.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractAudioEncoder/AbstractAudioEncodeInputPin.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -122,7 +122,7 @@
 HRESULT AbstractAudioEncodeInputPin::CheckMediaType(const CMediaType *inMediaType) {
 	//FIX::: Clean this up !
 	
-	if	( (inMediaType->majortype == MEDIATYPE_Audio) &&
+	if	(	(inMediaType->majortype == MEDIATYPE_Audio) &&
 			(inMediaType->subtype == MEDIASUBTYPE_PCM) &&
 			(inMediaType->formattype == FORMAT_WaveFormatEx)
 		)

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoDecoder/AbstractVideoDecodeInputPin.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -33,18 +33,20 @@
 #include "abstractvideodecodeinputpin.h"
 
 //#include <mtype.h>
-AbstractVideoDecodeInputPin::AbstractVideoDecodeInputPin(AbstractVideoDecodeFilter* inParentFilter, CCritSec* inFilterLock, AbstractVideoDecodeOutputPin* inOutputPin, CHAR* inObjectName, LPCWSTR inPinDisplayName, CMediaType* inAcceptMediaType)
-	:	CBaseInputPin(inObjectName, inParentFilter, inFilterLock, &mHR, inPinDisplayName),
-		mOutputPin(inOutputPin),
+AbstractVideoDecodeInputPin::AbstractVideoDecodeInputPin (AbstractVideoDecodeFilter* inParentFilter, CCritSec* inFilterLock, AbstractVideoDecodeOutputPin* inOutputPin, CHAR* inObjectName, LPCWSTR inPinDisplayName, CMediaType* inAcceptMediaType)
+	:	CBaseInputPin(inObjectName, inParentFilter, inFilterLock, &mHR, inPinDisplayName)
+	,	mOutputPin(inOutputPin)
+	,	mParentFilter(inParentFilter)
 	
-		mBegun(false),
-		mParentFilter(inParentFilter),
-		mHeight(0),
-		mWidth(0)
+	,	mBegun(false)
+	
+	,	mHeight(0)
+	,	mWidth(0)
 
 	,	mFrameDuration(0)
 	,	mFrameSize(0)
 	,	mFrameCount(0)
+	
 	,	mStreamLock(NULL)
 	,	mLastSeenStartGranPos(0)
 	,	mSeekTimeBase(0)

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -51,7 +51,9 @@
 	delete mInputPin;
 }
 
-STDMETHODIMP AbstractVideoEncodeFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv) {
+STDMETHODIMP AbstractVideoEncodeFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv) 
+{
+
 	return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);
 }
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.h	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfAbstractVideoEncoder/AbstractVideoEncodeFilter.h	2004-11-21 06:06:19 UTC (rev 8239)
@@ -38,12 +38,15 @@
 
 {
 public:
+	//Friend Classes
 	friend class AbstractVideoEncodeInputPin;
 	friend class AbstractVideoEncodeOutputPin;
 
+	//Constructors
 	AbstractVideoEncodeFilter(TCHAR* inFilterName, REFCLSID inFilterGUID, unsigned short inVideoFormat );
 	virtual ~AbstractVideoEncodeFilter(void);
 
+	//Constants and enumerations
 	static const long NUM_PINS = 2;
 	enum eVideoFormat {
 		NONE = 0,
@@ -52,6 +55,7 @@
 		OTHER_VIDEO = 2000
 	};
 
+	//COM SETUP
 	DECLARE_IUNKNOWN
 	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
 
@@ -59,7 +63,6 @@
 	virtual bool ConstructPins() = 0;
 	virtual void DestroyPins();
 
-
 	//CBaseFilter overrides
 	CBasePin* GetPin(int n);
 	int GetPinCount(void);

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/DataSourceFactory.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -45,6 +45,9 @@
 	if(locType.length() == 1) {
 		//File...
 		return new FilterFileSource;
+	} else if (locType == "\\\\") {
+		//Network share...
+		return new FilterFileSource;
 	} else if (locType == "http") {
 		//Http stream
 		return new HTTPFileSource;
@@ -57,8 +60,22 @@
 string DataSourceFactory::identifySourceType(string inSourceLocation) {
 	size_t locPos = inSourceLocation.find(':');
 	if (locPos == string::npos) {
-		//No colon... not a url or file... failure.
-		return "";
+		//No colon... not a normal file. See if it's a network share...
+
+		//Make sure it's long enough...
+		if (inSourceLocation.length() > 2) {
+			string retStr = inSourceLocation.substr(0,2);
+			if (retStr == "\\\\") {
+				//A "\\" is a network share
+				return retStr;
+			} else {
+				//Not a network share.
+				return "";
+			}
+		} else {
+			//Too short
+			return "";
+		}
 	} else {
 		string retStr = inSourceLocation.substr(0,locPos);
 		return retStr;

Modified: trunk/oggdsf/src/tools/CLOgg/CLOgg.cpp
===================================================================
--- trunk/oggdsf/src/tools/CLOgg/CLOgg.cpp	2004-11-20 23:40:36 UTC (rev 8238)
+++ trunk/oggdsf/src/tools/CLOgg/CLOgg.cpp	2004-11-21 06:06:19 UTC (rev 8239)
@@ -29,6 +29,7 @@
 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 //===========================================================================
 
+//
 // CLOgg.cpp : Command line minimalist audio player.
 //
 
@@ -37,11 +38,13 @@
 #include <windows.h>
 #include <iostream>
 using namespace std;
+
 int __cdecl _tmain(int argc, _TCHAR* argv[])
 {
+	//
 	IGraphBuilder* locGraphBuilder = NULL;
 	IMediaControl* locMediaControl = NULL;
-	HRESULT locHR;
+	HRESULT locHR = S_FALSE;;
 	CoInitialize(NULL);
 	locHR = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&locGraphBuilder);
 	locHR = locGraphBuilder->RenderFile(L"g:\\a.ogg", NULL);



More information about the commits mailing list