[xiph-commits] r7398 - in trunk/oggdsf/src: lib/core/ogg/libOOOgg

illiminable at dactyl.lonelymoon.com illiminable
Wed Jul 28 10:54:50 PDT 2004


tools/OOOggValidate
Message-ID: <20040728175450.F31199AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Wed Jul 28 10:54:50 2004
New Revision: 7398

Modified:
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp
trunk/oggdsf/src/tools/OOOggValidate/OggValidationState.cpp
Log:
* Changes to demux dispatching.


Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-07-28 16:27:05 UTC (rev 7397)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-07-28 17:54:47 UTC (rev 7398)
@@ -63,30 +63,26 @@
delete pendingPage;
}

-bool OggDataBuffer::registerPageCallback(OggCallbackRego* inPageCB) {
-	if (inPageCB != NULL) {
-		mAlwaysCallList.push_back(inPageCB);
-		return true;
-	} else {
-		return false;
-	}
+bool OggDataBuffer::registerStaticCallback(fPageCallback inPageCallback) {
+	mStaticCallback = inPageCallback;
+	mVirtualCallback = NULL;
+
+	return true;
}
-bool OggDataBuffer::registerSerialNo(SerialNoRego* inSerialRego) {
-	if (inSerialRego != NULL) {
-		mSerialNoCallList.push_back(inSerialRego);
-		return true;
-	} else {
-		return false;
-	}
-}
+//bool OggDataBuffer::registerSerialNo(SerialNoRego* inSerialRego) {
+//	if (inSerialRego != NULL) {
+//		mSerialNoCallList.push_back(inSerialRego);
+//		return true;
+//	} else {
+//		return false;
+//	}
+//}

-bool OggDataBuffer::registerVirtualCallback(IOggCallback* inCBInterface) {
-	if (inCBInterface != NULL) {
-		mVirtualCallbackList.push_back(inCBInterface);
-		return true;
-	} else {
-		return false;
-	}
+bool OggDataBuffer::registerVirtualCallback(IOggCallback* inPageCallback) {
+	mVirtualCallback = inPageCallback;
+	mStaticCallback = NULL;
+	return true;
+
}


@@ -94,7 +90,7 @@
//Returns how many bytes are available in the buffer

unsigned long locBytesAvail = mBuffer->numBytesAvail();				//mStream.tellp() - mStream.tellg();
-	debugLog<<"Bytes avail = "<<locBytesAvail<<endl;
+	//debugLog<<"Bytes avail = "<<locBytesAvail<<endl;
return locBytesAvail;
}

@@ -102,36 +98,53 @@
//returns the state of the stream
return mState;
}
-bool OggDataBuffer::dispatch(OggPage* inOggPage) {
-	debugLog<<"Dispatching page..."<<endl;
+OggDataBuffer::eDispatchResult OggDataBuffer::dispatch(OggPage* inOggPage) {
+	//TODO::: Who owns this pointer inOggPage ?
+	debugLog<<"Dispatching page..."<<endl<<endl;
bool locIsOK;

//Fire off the oggpage to whoever is registered to get it

-	for (unsigned long i = 0; i < mAlwaysCallList.size(); i++) {
-		mAlwaysCallList[i]->dispatch(inOggPage);
+	if (mVirtualCallback != NULL) {
+		if (mVirtualCallback->acceptOggPage(inOggPage) == true) {
+			return DISPATCH_OK;
+		} else {
+			return DISPATCH_FALSE;
+		}
+	} else if (mStaticCallback != NULL) {
+		if (mStaticCallback(inOggPage) == true) {
+			return DISPATCH_OK;
+		} else {
+			return DISPATCH_FALSE;
+		}
+	} else (
+		return DISPATCH_NO_CALLBACK;
}

-	//Fire off the oggpage to those that registered for a particular seriao number.
-	//CHECK::: Does this actually even check for serial number matches ??
-	for (unsigned long i = 0; i < mSerialNoCallList.size(); i++) {
-		mSerialNoCallList[i]->dispatch(inOggPage);
-	}
+	//for (unsigned long i = 0; i < mAlwaysCallList.size(); i++) {
+	//	mAlwaysCallList[i]->dispatch(inOggPage);
+	//}

-	//The above callbacks will only call back to global functions or static members. They won't match the callback
-	// function specification if they are bound memebr functions
-
-	//Any class that implements the IOggCallback interface can pass a point to themselves into this class
-	// and then a call back can be delivered to a function in a specific instance of an object.
-	for (unsigned long i = 0; i < mVirtualCallbackList.size(); i++) {
-		locIsOK = mVirtualCallbackList[i]->acceptOggPage(inOggPage);
-		if (!locIsOK) {
-			debugLog<<"Dispatch : **************** acceptOggPage returned false."<<endl;
-			//Somethings happened deeper in the stack like we are being asked to stop.
-			return false;
-		}
-	}
+	////Fire off the oggpage to those that registered for a particular seriao number.
+	////CHECK::: Does this actually even check for serial number matches ??
+	//for (unsigned long i = 0; i < mSerialNoCallList.size(); i++) {
+	//	mSerialNoCallList[i]->dispatch(inOggPage);
+	//}

+	////The above callbacks will only call back to global functions or static members. They won't match the callback
+	//// function specification if they are bound memebr functions
+	//
+	////Any class that implements the IOggCallback interface can pass a point to themselves into this class
+	//// and then a call back can be delivered to a function in a specific instance of an object.
+	//for (unsigned long i = 0; i < mVirtualCallbackList.size(); i++) {
+	//	locIsOK = mVirtualCallbackList[i]->acceptOggPage(inOggPage);
+	//	if (!locIsOK) {
+	//		debugLog<<"Dispatch : **************** acceptOggPage returned false."<<endl;
+	//		//Somethings happened deeper in the stack like we are being asked to stop.
+	//		return false;
+	//	}
+	//}
+
//Delete the page... if the called functions wanted a copy they should have taken one for themsselves.
delete inOggPage;
pendingPage = NULL;
@@ -143,7 +156,7 @@
if (inData != NULL) {
//Buffer is not null and there is at least 1 byte of data.

-			debugLog<<"********** Fed "<<inNumBytes<<" bytes..."<<endl;
+			debugLog<<"Fed "<<inNumBytes<<" bytes..."<<endl;

unsigned long locNumWritten = mBuffer->write(inData, inNumBytes);

@@ -171,7 +184,7 @@

}
OggDataBuffer::eProcessResult OggDataBuffer::processBaseHeader() {
-		debugLog<<"ProcessBaseHeader : "<<endl;
+		debugLog<<"Processing base header..."<<endl;

//Delete the previous page
delete pendingPage;
@@ -182,7 +195,7 @@
//Make a local buffer for the header
unsigned char* locBuff = new unsigned char[OggPageHeader::OGG_BASE_HEADER_SIZE];

-		debugLog<<"ProcessBaseHeader : Reading from stream..."<<endl;
+		//debugLog<<"ProcessBaseHeader : Reading from stream..."<<endl;

//STREAM ACCESS::: Read
unsigned long locNumRead = mBuffer->read(locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);
@@ -201,12 +214,12 @@
//Set the number of bytes we want for next time
mNumBytesNeeded = pendingPage->header()->NumPageSegments();

-		debugLog<<"ProcessBaseHeader : Setting state to AWAITING_SEG_TABLE"<<endl;
+		debugLog<<"Setting state to AWAITING_SEG_TABLE"<<endl;
//Change the state.
mState = AWAITING_SEG_TABLE;


-		debugLog<<"ProcessBaseHeader : Bytes needed for seg table = "<<mNumBytesNeeded<<endl;
+		debugLog<<"Bytes needed for seg table = "<<mNumBytesNeeded<<endl;
return PROCESS_OK;
}
OggDataBuffer::eProcessResult OggDataBuffer::processSegTable() {
@@ -214,19 +227,19 @@
//Assumes a valid pending page, with numPagesegments set in the header already.
//creates a chunk of memory size numpagesegments and stores it,.

-	debugLog<<"ProcessSegTable : "<<endl;
+	debugLog<<"Processing Segment Table..."<<endl;

//TODAY::: What happens when numpage segments is zero.

//Save a local copy of the number of page segments - Get this from the already set header.
unsigned char locNumSegs = pendingPage->header()->NumPageSegments();

-	debugLog<<"ProcessSegTable : Num segs = "<<(int)locNumSegs<<endl;
+	debugLog<<"Num segments = "<<(int)locNumSegs<<endl;

//Make a local buffer the size of the segment table. 0 - 255
unsigned char* locBuff = new unsigned char[locNumSegs];

-	debugLog<<"ProcessSegTable : Reading from buffer..."<<endl;
+	//debugLog<<"ProcessSegTable : Reading from buffer..."<<endl;

//Read the segment table from the buffer to locBuff
//mStream.read((char*)locBuff, (std::streamsize)locNumSegs);
@@ -248,9 +261,9 @@

mNumBytesNeeded = pendingPage->header()->calculateDataSize();

-	debugLog<<"ProcessSegTable : Num bytes needed for data = "<< mNumBytesNeeded<<endl;
+	debugLog<<"Num bytes needed for data = "<< mNumBytesNeeded<<endl;

-	debugLog<<"ProcessSegTable : Transition to AWAITING_DATA"<<endl;
+	debugLog<<"Transition to AWAITING_DATA"<<endl;

mState = AWAITING_DATA;
return PROCESS_OK;
@@ -259,7 +272,7 @@

OggDataBuffer::eProcessResult OggDataBuffer::processDataSegment() {

-	debugLog<<"ProcessDataSegment : "<<endl;
+	debugLog<<"Processing Data Segment..."<<endl;
//Make a local buffer

unsigned long locPageDataSize = pendingPage->header()->dataSize();
@@ -318,7 +331,7 @@

//FIX::: check for stream failure.

-			debugLog<<"ProcessDataSegment : Adding packet size = "<<locCurrPackSize<<endl;
+			debugLog<<"Adding packet - size = "<<locCurrPackSize<<endl;

//A packet ends when a lacing value is not 255. So the check for != 255 means the isComplete property of the packet is not set unless the
// lacing value is not equal to 255.
@@ -358,13 +371,13 @@
mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
mState = eState::AWAITING_BASE_HEADER;

-	debugLog<<"ClearData : Num bytes needed = "<<mNumBytesNeeded<<endl;
+	//debugLog<<"ClearData : Num bytes needed = "<<mNumBytesNeeded<<endl;
}

OggDataBuffer::eProcessResult OggDataBuffer::processBuffer() {

while (numBytesAvail() >= mNumBytesNeeded) {
-		debugLog<<"ProcessBuffer : Bytes Needed = "<<mNumBytesNeeded<<" --- "<<"Bytes avail = "<<numBytesAvail()<<endl;
+		//debugLog<<"ProcessBuffer : Bytes Needed = "<<mNumBytesNeeded<<" --- "<<"Bytes avail = "<<numBytesAvail()<<endl;
switch (mState) {

//QUERY:::	Should it be a bug when the if state inside the switch falls through,... potential for infinite loop.

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-07-28 16:27:05 UTC (rev 7397)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-07-28 17:54:47 UTC (rev 7398)
@@ -52,7 +52,7 @@
AWAITING_BASE_HEADER = 32,
AWAITING_SEG_TABLE,
AWAITING_DATA,
-		LOST_PAGE_SYNC = 128
+		LOST_PAGE_SYNC
};

enum eFeedResult {
@@ -61,13 +61,20 @@
FEED_BUFFER_WRITE_ERROR
};

+	enum eDispatchResult {
+		DISPATCH_OK,
+		DISPATCH_NO_CALLBACK = 512,
+		DISPATCH_FALSE
+
+	};
+
enum eProcessResult {
PROCESS_OK,
PROCESS_UNKNOWN_INTERNAL_ERROR = 256,
PROCESS_STREAM_READ_ERROR,
PROCESS_DISPATCH_FAILED,
PROCESS_FAILED_TO_SET_HEADER,
-		PROCESS_LOST_SYNC
+		PROCESS_LOST_SYNC = 4096

};

@@ -82,17 +89,14 @@
//
~OggDataBuffer(void);

-	bool registerPageCallback(OggCallbackRego* inPageCB);
-	bool registerSerialNo(SerialNoRego* inSerialRego);
-	bool registerVirtualCallback(IOggCallback* inCBInterface);
+	bool registerStaticCallback(fPageCallback inPageCallback);
+	bool registerVirtualCallback(IOggCallback* inPageCallback);

+	//bool registerSerialNo(SerialNoRego* inSerialRego);
void clearData();

-	OggDataBuffer::eFeedResult feed(const unsigned char* inData, unsigned long inNumBytes);
+	eFeedResult feed(const unsigned char* inData, unsigned long inNumBytes);

-	//FIX ::: Add later
-	//void unRegisterSerialNo(unsigned long inSerialNo);
-
unsigned long numBytesAvail();

eState state();
@@ -108,21 +112,26 @@
eState mState;

eProcessResult processBuffer();
-	virtual bool dispatch(OggPage* inOggPage);
+	virtual eDispatchResult dispatch(OggPage* inOggPage);

unsigned long mNumBytesNeeded;

OggPage* pendingPage;

-	vector<OggCallbackRego*> mAlwaysCallList;
-	vector<SerialNoRego*> mSerialNoCallList;
-	vector<IOggCallback*> mVirtualCallbackList;
+	IOggCallback* mVirtualCallback;
+	fPageCallback mStaticCallback;

+
+	//vector<OggCallbackRego*> mAlwaysCallList;
+	//vector<SerialNoRego*> mSerialNoCallList;
+	//vector<IOggCallback*> mVirtualCallbackList;
+
//DEBUG
fstream debugLog;
//

private:
+
eProcessResult processBaseHeader();
eProcessResult processSegTable();
eProcessResult processDataSegment();

Modified: trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp	2004-07-28 16:27:05 UTC (rev 7397)
+++ trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp	2004-07-28 17:54:47 UTC (rev 7398)
@@ -4,11 +4,11 @@
#include "stdafx.h"
#include "OggValidationState.h"
#include "libOOOgg.h"
-#include "libOOOgg.h"




+
int __cdecl _tmain(int argc, _TCHAR* argv[])
{
//This program just dumps the pages out of a file in ogg format.

Modified: trunk/oggdsf/src/tools/OOOggValidate/OggValidationState.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggValidate/OggValidationState.cpp	2004-07-28 16:27:05 UTC (rev 7397)
+++ trunk/oggdsf/src/tools/OOOggValidate/OggValidationState.cpp	2004-07-28 17:54:47 UTC (rev 7398)
@@ -78,10 +78,17 @@

if (mNumBOS == mNumEOS) {
//Valid case. Chain.
+				//We are here because we've seen an equal number of EOS and BOS and at least 1 EOS(this one)
+				// This happens whenever a complete chain of streams complete and/or the end of a complete physical bitstream.
+				//
+				//This is the only place it's possible for isValid to become true.
+				// It is true when an equal number of eos and bos pages are seen,
+				//  and all streams are also considered fully valid.
+
//If this EOS balanced the eos = bos then we can accept bos pages again.
mState = FVS_AWAITING_BOS;

-
+
if (mStreams.size() != 0) {
mIsValid = true;
for (int i = 0; i < mStreams.size(); i++) {
@@ -182,8 +189,8 @@
//Verify BOS integrity.

if (locHeader->isBOS()) {
-		//Add a BOS to the tally.

+

if (locStreamState->mState == OggStreamValidationState::VS_SEEN_NOTHING) {
//Valid case.
@@ -210,9 +217,9 @@
//----------------------------------------------------------------------
//Verify EOS integrity
if (locHeader->isEOS()) {
-		//Add a BOS to the tally.


+
if (locStreamState->mState == OggStreamValidationState::VS_SEEN_BOS) {
//Valid case.
locStreamState->mState = OggStreamValidationState::VS_FULLY_VALID;



More information about the commits mailing list