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

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sun Oct 23 03:50:00 PDT 2005


Author: illiminable
Date: 2005-10-23 03:49:55 -0700 (Sun, 23 Oct 2005)
New Revision: 10265

Modified:
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
   branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
Log:
* Add demux packetising
* Add demux output dispatching

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2005-10-23 10:39:27 UTC (rev 10264)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.h	2005-10-23 10:49:55 UTC (rev 10265)
@@ -103,6 +103,7 @@
 	vector<OggPage*> getMatchingBufferedPages(unsigned long inSerialNo);
 	void removeMatchingBufferedPages(unsigned long inSerialNo);
 
+	CCritSec* streamLock()			{		return mStreamLock;		}
 protected:
 	static const unsigned long SETUP_BUFFER_SIZE = 24;
 	virtual HRESULT SetUpPins();

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2005-10-23 10:39:27 UTC (rev 10264)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2005-10-23 10:49:55 UTC (rev 10265)
@@ -44,11 +44,14 @@
 	,	mIdentHeader(inIdentHeader)
 	,	mSerialNo(inSerialNo)
 	,	mIsStreamReady(false)
+	,	mAcceptingData(false)
+	,	mNumBuffers(0)
+	,	mDataQueue(NULL)
 {
 
 	
 		//(BYTE*)inBOSPage->createRawPageData();
-	
+	mPacketiser.setPacketSink(this);
 }
 
 OggDemuxPacketSourcePin::~OggDemuxPacketSourcePin(void)
@@ -60,8 +63,11 @@
 
 bool OggDemuxPacketSourcePin::acceptOggPage(OggPage* inOggPage)
 {
-	//TODO:::
-	return true;
+	if (mIsStreamReady) {
+		mAcceptingData = true;
+		return mPacketiser.acceptOggPage(inOggPage);
+	}
+	return false;
 }
 BYTE* OggDemuxPacketSourcePin::getIdentAsFormatBlock()
 {
@@ -144,6 +150,8 @@
 	if (locHR != S_OK) {
 		return locHR;
 	}
+
+	mNumBuffers = locActualAlloc.cBuffers;
 	
 	locHR = inoutAllocator->Commit();
 
@@ -155,6 +163,8 @@
 //Pin Conenction Methods
 HRESULT OggDemuxPacketSourcePin::BreakConnect()
 {
+	delete mDataQueue;
+	mDataQueue = NULL;
 	return CBaseOutputPin::BreakConnect();
 }
 HRESULT OggDemuxPacketSourcePin::CompleteConnect(IPin *inReceivePin)
@@ -167,6 +177,7 @@
 		IOggDecoder::eAcceptHeaderResult locResult = mDecoderInterface->showHeaderPacket(mIdentHeader->clone());
 		if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
 			mIsStreamReady = true;
+
 		} else {
 			OggPacketiser locPacketiser;
 			locPacketiser.setPacketSink(this);
@@ -179,27 +190,88 @@
 
 			locParent->removeMatchingBufferedPages(mSerialNo);
 
-			if (mIsStreamReady) {
-				return CBaseOutputPin::CompleteConnect(inReceivePin);
-			}	
+			
 		}
 
+		if (mIsStreamReady) {
+			mDataQueue = new COutputQueue (inReceivePin, &mFilterHR, FALSE, TRUE,1,TRUE, mNumBuffers);
+			return CBaseOutputPin::CompleteConnect(inReceivePin);
+		}	
+
 		
 	}
 	return E_FAIL;
 	
 }
 
+bool OggDemuxPacketSourcePin::dispatchPacket(StampedOggPacket* inPacket)
+{
+	CAutoLock locStreamLock(((OggDemuxPacketSourceFilter*)m_pFilter)->streamLock());
+
+
+	//Set up the sample info
+	IMediaSample* locSample = NULL;
+	REFERENCE_TIME locStart = inPacket->startTime();
+	REFERENCE_TIME locStop = inPacket->endTime();
+	
+	//Get a delivery buffer
+	HRESULT	locHR = GetDeliveryBuffer(&locSample, &locStart, &locStop, NULL);
+	
+	//Error checks
+	if (locHR != S_OK) {
+		//Stopping, fluching or error
+
+		delete inPacket;
+		return false;
+	}
+
+	//Set time stamps. These are granule pos, and may be -1
+	locSample->SetTime(&locStart, &locStop);
+	
+	locSample->SetMediaTime(&locStart, &locStop);
+	locSample->SetSyncPoint(TRUE);
+	
+
+	// Create a pointer for the samples buffer
+	BYTE* locBuffer = NULL;
+	locSample->GetPointer(&locBuffer);
+
+	if (locSample->GetSize() >= inPacket->packetSize()) {
+
+		memcpy((void*)locBuffer, (const void*)inPacket->packetData(), inPacket->packetSize());
+		locSample->SetActualDataLength(inPacket->packetSize());
+
+		locHR = mDataQueue->Receive(locSample);
+
+		if (locHR != S_OK) {
+			//debugLog << "Failure... Queue rejected sample..."<<endl;
+			//Stopping ??
+
+			delete inPacket;
+			return false;
+		} else {
+			delete inPacket;
+			return true;
+		}
+	} else {
+		//DbgLog((LOG_TRACE, 2, "* BUFFER TOO SMALL... FATALITY !!"));
+		throw 0;
+	}	
+}
 bool OggDemuxPacketSourcePin::acceptStampedOggPacket(StampedOggPacket* inPacket)
 {
-	//This handles callbacks with header packets
-	IOggDecoder::eAcceptHeaderResult locResult;
-	if ((mDecoderInterface != NULL) && (!mIsStreamReady)) {
-		locResult = mDecoderInterface->showHeaderPacket(inPacket);
-		if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
-			mIsStreamReady = true;
+	if (mAcceptingData) {
+		return dispatchPacket(inPacket);
+	} else {
+		//This handles callbacks with header packets
+		IOggDecoder::eAcceptHeaderResult locResult;
+		if ((mDecoderInterface != NULL) && (!mIsStreamReady)) {
+			locResult = mDecoderInterface->showHeaderPacket(inPacket);
+			if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
+				mIsStreamReady = true;
+			}
 		}
+		delete inPacket;
+		return true;
 	}
-	delete inPacket;
-	return true;
 }
\ No newline at end of file

Modified: branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2005-10-23 10:39:27 UTC (rev 10264)
+++ branches/oggdsf_new_demux/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2005-10-23 10:49:55 UTC (rev 10265)
@@ -76,6 +76,7 @@
 protected:
 	//IStampedOggPacketSink
 	virtual bool acceptStampedOggPacket(StampedOggPacket* inPacket);
+	virtual bool dispatchPacket(StampedOggPacket* inPacket);
 
 	//What is this actually for ?
 	HRESULT mFilterHR;
@@ -83,9 +84,15 @@
 	BYTE* getIdentAsFormatBlock();
 	unsigned long getIdentSize();
 	unsigned long mSerialNo;
+
+	unsigned long mNumBuffers;
 	
 	OggPacket* mIdentHeader;
 	IOggDecoder* mDecoderInterface;
+	OggPacketiser mPacketiser;
 
+	COutputQueue* mDataQueue;
+
 	bool mIsStreamReady;
+	bool mAcceptingData;
 };



More information about the commits mailing list