[xiph-commits] r6912 - in trunk/oggdsf/src/lib/core:

illiminable at dactyl.lonelymoon.com illiminable
Mon Jun 28 08:38:19 PDT 2004


directshow/dsfOggDemux ogg/libOOOgg
Message-ID: <20040628153819.B9FA89AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Mon Jun 28 08:38:19 2004
New Revision: 6912

Modified:
trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
Log:
* Something that made it work ! I think it just needed a rebuild.
* Streaming is go... except seeking, or duration etc.
* Haven't tested any unusual network conditions yet, nor made any allowance for pre-buffer as a relation to available bandwidth vs bitrate.
* Probably needs to use a disk cache rather than just memory cache.
* Added a ton of debug code to the main demuxing class, for more through inspection.

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp	2004-06-28 11:30:32 UTC (rev 6911)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggDemuxSourceFilter.cpp	2004-06-28 15:38:15 UTC (rev 6912)
@@ -589,7 +589,7 @@
//
//BUG::: Need to actually see how many bytes were read !
if (locNumRead > 0) {
-			mOggBuffer.feed(locBuff, RAW_BUFFER_SIZE);
+			mOggBuffer.feed(locBuff, locNumRead);
}

}

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-06-28 11:30:32 UTC (rev 6911)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-06-28 15:38:15 UTC (rev 6912)
@@ -34,6 +34,7 @@

OggDataBuffer::OggDataBuffer(void)
{
+	debugLog.open("G:\\logs\\OggDataBuffer.log", ios_base::out);
pendingPage = NULL;
mState = AWAITING_BASE_HEADER;
mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
@@ -41,6 +42,7 @@

OggDataBuffer::~OggDataBuffer(void)
{
+	debugLog.close();
delete pendingPage;
}

@@ -73,7 +75,9 @@

unsigned long OggDataBuffer::numBytesAvail() {
//Returns how many bytes are available in the buffer
-	return mStream.tellp() - mStream.tellg();
+	unsigned long locBytesAvail = mStream.tellp() - mStream.tellg();
+	debugLog<<"Bytes avail = "<<locBytesAvail<<endl;
+	return locBytesAvail;
}

OggDataBuffer::eState OggDataBuffer::state() {
@@ -81,6 +85,7 @@
return mState;
}
bool OggDataBuffer::dispatch(OggPage* inOggPage) {
+	debugLog<<"Dispatching page..."<<endl;
bool locIsOK;

//Fire off the oggpage to whoever is registered to get it
@@ -115,17 +120,20 @@

bool OggDataBuffer::feed(const char* inData, unsigned long inNumBytes) {
if (inNumBytes != 0) {
+		debugLog<<"Fed "<<inNumBytes<<" bytes..."<<endl;
mStream.write(inData, inNumBytes);
//FIX ::: Need error checking.

return processBuffer();
} else {
+		debugLog<<"Fed *zero* bytes..."<<endl;
return true;
}


}
void OggDataBuffer::processBaseHeader() {
+		debugLog<<"ProcessBaseHeader : "<<endl;
//Delete the previous page
delete pendingPage;
//make a fresh one
@@ -133,43 +141,73 @@

//Make a local buffer
unsigned char* locBuff = new unsigned char[OggPageHeader::OGG_BASE_HEADER_SIZE];
+
+		debugLog<<"ProcessBaseHeader : Reading from stream..."<<endl;
//Read from the stream buffer to it
mStream.read((char*)locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);
+
+		if(mStream.fail()) {
+			debugLog<<"ProcessBaseHeader : Read FAILED"<<endl;
+		}
//Set the base header into the pending page
pendingPage->header()->setBaseHeader((unsigned char*)locBuff);
//NOTE ::: The page will delete the buffer when it's done. Don't delete it here

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

//Set the number of bytes we want for next time
mNumBytesNeeded = pendingPage->header()->NumPageSegments();
+
+		debugLog<<"ProcessBaseHeader : Bytes needed for seg table = "<<mNumBytesNeeded<<endl;
}
void OggDataBuffer::processSegTable() {
-		//Make a local buffer
-		unsigned char* locBuff = new unsigned char[pendingPage->header()->NumPageSegments()];
-		//Read from the stream buffer to it
-		mStream.read((char*)locBuff, pendingPage->header()->NumPageSegments());
-		//Set the data into the pending pages segtable
-		pendingPage->header()->setSegmentTable(locBuff);
-		//NOTE ::: The seg table will delete the buffer itself. Don't delete here.

-		mState = AWAITING_DATA;
+	debugLog<<"ProcessSegTable : "<<endl;

-		//Set the number of bytes we want for next time
-		mNumBytesNeeded = pendingPage->header()->dataSize();
+	unsigned long locNumSegs = pendingPage->header()->NumPageSegments();
+
+	debugLog<<"ProcessSegTable : Num segs = "<<locNumSegs<<endl;
+
+	//Make a local buffer
+	unsigned char* locBuff = new unsigned char[locNumSegs];
+
+	debugLog<<"ProcessSegTable : Reading from buffer..."<<endl;
+	//Read from the stream buffer to it
+	mStream.read((char*)locBuff, locNumSegs);
+	if(mStream.fail()) {
+		debugLog<<"ProcessSegTable : Read FAILED"<<endl;
+	}
+
+	//Set the data into the pending pages segtable
+	pendingPage->header()->setSegmentTable(locBuff);
+	//NOTE ::: The seg table will delete the buffer itself. Don't delete here.
+
+	debugLog<<"ProcessSegTable : Transition to AWAITING_DATA"<<endl;
+	mState = AWAITING_DATA;
+
+
+	//Set the number of bytes we want for next time
+	mNumBytesNeeded = pendingPage->header()->dataSize();
+	debugLog<<"ProcessSegTable : Num bytes needed for data = "<< mNumBytesNeeded<<endl;
}

bool OggDataBuffer::processDataSegment() {
+
+	debugLog<<"ProcessDataSegment : "<<endl;
//Make a local buffer

unsigned long locPageDataSize = pendingPage->header()->dataSize();
+
+	debugLog<<"ProcessDataSegment : Page data size = "<<locPageDataSize<<endl;
unsigned char* locBuff = NULL;// = new unsigned char[locPageDataSize];
//unsigned long locPacketOffset = 0;

unsigned char* locSegTable = pendingPage->header()->SegmentTable()->segmentTable();
unsigned int locNumSegs = pendingPage->header()->SegmentTable()->numSegments();

+	debugLog<<"ProcessDataSegment : Num segs = "<<locNumSegs<<endl;
unsigned long locCurrPackSize = 0;

bool locIsLastSeg = false;
@@ -181,10 +219,10 @@
locIsLastSeg = (locNumSegs - 1 == i);
if ( (locSegTable[i] != 255) || locIsLastSeg ) {

-			//MEMORY LEAK
+			//This pointer is given to the packet... it deletes it.
locBuff = new unsigned char[locCurrPackSize];
mStream.read((char*)(locBuff), locCurrPackSize);
-
+			debugLog<<"ProcessDataSegment : Adding packet size = "<<locCurrPackSize<<endl;
pendingPage->addPacket( new StampedOggPacket(locBuff, locCurrPackSize, (locSegTable[i] != 255), 0, pendingPage->header()->GranulePos()->value(), StampedOggPacket::OGG_END_ONLY ) );

//locPacketOffset += locCurrPackSize;
@@ -192,10 +230,11 @@
}
}

+	debugLog<<"ProcessDataSegment : Transition to AWAITING_BASE_HEADER"<<endl;
mState = AWAITING_BASE_HEADER;

mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
-
+	debugLog<<"ProcessDataSegment : num bytes needed = "<<mNumBytesNeeded<<endl;
return dispatch(pendingPage);

}
@@ -205,33 +244,44 @@
mStream.seekg(0, ios_base::beg);
mStream.seekp(0, ios_base::beg);

-	if (numBytesAvail() != 0) {
-		int i = i;
-	}
+	//if (numBytesAvail() != 0) {
+	//	int i = i;
+	//}
+
+	debugLog<<"ClearData : Transition back to AWAITING_BASE_HEADER"<<endl;
mState = eState::AWAITING_BASE_HEADER;
mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
+	debugLog<<"ClearData : Num bytes needed = "<<mNumBytesNeeded<<endl;
}
bool OggDataBuffer::processBuffer() {
+	debugLog<<"ProcessBuffer :"<<endl;
bool locErr;
while (numBytesAvail() >= mNumBytesNeeded) {
+		debugLog<<"ProcessBuffer : Bytes Needed = "<<mNumBytesNeeded<<" --- "<<"Bytes avail = "<<numBytesAvail()<<endl;
switch (mState) {
case eState::AWAITING_BASE_HEADER:
+				debugLog<<"ProcessBuffer : State = AWAITING_BASE_HEADER"<<endl;
//If theres enough data to form the base header
if (numBytesAvail() >= OggPageHeader::OGG_BASE_HEADER_SIZE) {
+					debugLog<<"ProcessBuffer : Enough to process..."<<endl;
processBaseHeader();
}
break;

case eState::AWAITING_SEG_TABLE:
+				debugLog<<"ProcessBuffer : State = AWAITING_SEG_TABLE"<<endl;
//If there is enough data to get the segt table
if (numBytesAvail() >= pendingPage->header()->NumPageSegments()) {
+					debugLog<<"ProcessBuffer : Enough to process..."<<endl;
processSegTable();
}
break;

case eState::AWAITING_DATA:
+				debugLog<<"ProcessBuffer : State = AWAITING_DATA"<<endl;
//If all the data segment is available
if (numBytesAvail() >= pendingPage->header()->dataSize()) {
+					debugLog<<"ProcessBuffer : Enough to process..."<<endl;
locErr = processDataSegment();
if (!locErr) {
return false;
@@ -240,7 +290,7 @@
break;
default:
//Do sometyhing ??
-				cerr<<"Ogg Buffer Error"<<endl;
+				debugLog<<"ProcessBuffer : Ogg Buffer Error"<<endl;
break;
}
}

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-06-28 11:30:32 UTC (rev 6911)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-06-28 15:38:15 UTC (rev 6912)
@@ -34,11 +34,16 @@
#include "OggPage.h"
#include "SerialNoRego.h"
#include "IOggCallback.h"
+
+//Only needed for debugging
+#include <fstream>
+//
using namespace std;




+
class LIBOOOGG_API OggDataBuffer


@@ -83,6 +88,10 @@
vector<SerialNoRego*> mSerialNoCallList;
vector<IOggCallback*> mVirtualCallbackList;

+	//DEBUG
+	fstream debugLog;
+	//
+
private:
void processBaseHeader();
void processSegTable();



More information about the commits mailing list