[xiph-commits] r7942 - trunk/oggdsf/src/lib/core/directshow/dsfOggDemux

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Sat Oct 9 01:30:32 PDT 2004


Author: illiminable
Date: 2004-10-09 01:30:32 -0700 (Sat, 09 Oct 2004)
New Revision: 7942

Added:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.h
Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/StreamHeaders.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
Log:
* Start of new FLAC encapsulation.

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.cpp	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.cpp	2004-10-09 08:30:32 UTC (rev 7942)
@@ -0,0 +1,140 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
+#include "StdAfx.h"
+#include "OggFLAC_1_0_Stream.h"
+//#include "FLACMath.h"
+
+OggFLAC_1_0_Stream::OggFLAC_1_0_Stream(OggPage* inBOSPage, OggDemuxSourceFilter* inOwningFilter, bool inAllowSeek)
+	:	OggStream(inBOSPage, inOwningFilter, inAllowSeek)
+	,	mFLACFormatBlock(NULL)
+	//,	mNumHeaderPackets(0)
+{
+	InitCodec(inBOSPage->getStampedPacket(0));
+}
+
+OggFLAC_1_0_Stream::~OggFLAC_1_0_Stream(void)
+{
+	delete mFLACFormatBlock;
+}
+
+bool OggFLAC_1_0_Stream::InitCodec(StampedOggPacket* inOggPacket) {
+	//Can probably abstract this out of here too !
+	mCodecHeaders = new StreamHeaders;
+	mCodecHeaders->mCodecType = StreamHeaders::FLAC;
+	mCodecHeaders->addPacket((StampedOggPacket*)inOggPacket->clone());
+	//What to do with commment fields ??
+	//We set this to 1... and we override the header processor
+	//When we see the last header packet ie starts with 1xxxxxxx then we decrement it.
+	mNumHeadersNeeded = 1;
+	return true;
+}
+
+wstring OggFLAC_1_0_Stream::getPinName() {
+	wstring locName = L"FLAC Out";
+	return locName;
+}
+
+bool OggFLAC_1_0_Stream::createFormatBlock() {
+	const unsigned char FLAC_CHANNEL_MASK = 14;  //00001110
+	const unsigned char FLAC_BPS_START_MASK = 1; //00000001
+	const unsigned char FLAC_BPS_END_MASK = 240;  //11110000
+	mFLACFormatBlock = new sFLACFormatBlock;
+	//Fix the format block data... use header version and other version.
+	//mFLACFormatBlock->FLACVersion = FLACMath::charArrToULong(mCodecHeaders->getPacket(1)->packetData() + 28);
+	mFLACFormatBlock->numChannels = (((mCodecHeaders->getPacket(1)->packetData()[16]) & FLAC_CHANNEL_MASK) >> 1) + 1;
+	mFLACFormatBlock->sampleRate = (iBE_Math::charArrToULong(mCodecHeaders->getPacket(1)->packetData() + 14)) >> 12;
+	
+	mFLACFormatBlock->numBitsPerSample =	(((mCodecHeaders->getPacket(1)->packetData()[16] & FLAC_BPS_START_MASK) << 4)	|
+											((mCodecHeaders->getPacket(1)->packetData()[17] & FLAC_BPS_END_MASK) >> 4)) + 1;	
+	return true;
+}
+BYTE* OggFLAC_1_0_Stream::getFormatBlock() {
+
+	return (BYTE*)mFLACFormatBlock;
+
+
+}
+unsigned long OggFLAC_1_0_Stream::getFormatBlockSize() {
+	//Do something
+	return sizeof(sFLACFormatBlock);
+}
+GUID OggFLAC_1_0_Stream::getFormatGUID() {
+	return FORMAT_FLAC;
+}
+GUID OggFLAC_1_0_Stream::getSubtypeGUID() {
+	return MEDIASUBTYPE_FLAC;
+}
+GUID OggFLAC_1_0_Stream::getMajorTypeGUID() {
+	return MEDIATYPE_Audio;
+}
+
+//Need to override from oggstream because we have variable number of headers
+bool OggFLAC_1_0_Stream::processHeaderPacket(StampedOggPacket* inPacket) {
+	//FIX::: Return values
+	const unsigned char MORE_HEADERS_MASK = 128;   //10000000
+	//We don't delete the packet... the codecheader list will delete when it's done.
+	//StampedOggPacket* locPacket = processPacket(inPacket);
+	if (inPacket != NULL) {
+		//We got a comlpete packet
+		mCodecHeaders->addPacket(inPacket);
+		if ((inPacket->packetData()[0] & MORE_HEADERS_MASK) != 0) {
+			mNumHeadersNeeded--;
+			//mNumHeaderPackets++;
+		}
+	}
+	return true;
+}
+void OggFLAC_1_0_Stream::setLastEndGranPos(__int64 inPos) {
+	mLastEndGranulePos = (inPos * (__int64)mFLACFormatBlock->sampleRate)/ UNITS;
+}
+bool OggFLAC_1_0_Stream::deliverCodecHeaders() {
+	StampedOggPacket* locPacket = NULL;
+	for (unsigned long i = 0; i < mCodecHeaders->numPackets(); i++) {
+		if (i==0) {
+			locPacket = (StampedOggPacket*)mCodecHeaders->getPacket(0)->clone();
+		} else {
+			locPacket->merge(mCodecHeaders->getPacket(i));
+		}
+	}
+	if (mCodecHeaders->numPackets() > 0) {
+		dispatchPacket(locPacket);
+	}
+	return true;
+}
+
+LONGLONG OggFLAC_1_0_Stream::getCurrentPos() {
+	return (mLastEndGranulePos * UNITS) / mFLACFormatBlock->sampleRate;
+}
+
+//unsigned long OggFLAC_1_0_Stream::numCodecHeaders() {
+//	return mNumHeaderPackets;  //is this even needed ?
+//}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.h	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggFLAC_1_0_Stream.h	2004-10-09 08:30:32 UTC (rev 7942)
@@ -0,0 +1,67 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors 
+//  may be used to endorse or promote products derived from this software 
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+#pragma once
+#include "oggdllstuff.h"
+
+#include "OggPage.h"
+#include "OggPacket.h"
+class OggStream;
+class OggFLAC_1_0_Stream
+	:	public OggStream
+{
+public:
+	OggFLAC_1_0_Stream(OggPage* inOggPage, OggDemuxSourceFilter* inOwningFilter, bool inAllowSeek);
+	virtual ~OggFLAC_1_0_Stream(void);
+
+	//Implementing virtuals in OGgStream
+	virtual bool InitCodec(StampedOggPacket* inOggPacket);
+
+	virtual BYTE* getFormatBlock() ;
+	virtual unsigned long getFormatBlockSize();
+	virtual GUID getFormatGUID();
+	virtual GUID getSubtypeGUID();
+	virtual wstring getPinName();
+	virtual bool createFormatBlock();
+	virtual GUID getMajorTypeGUID();
+	virtual LONGLONG getCurrentPos();
+
+	//Override from oggstream to handle dynamic number of headers.
+	virtual bool OggFLAC_1_0_Stream::processHeaderPacket(StampedOggPacket* inPacket);
+	virtual bool deliverCodecHeaders();
+
+//	virtual unsigned long numCodecHeaders();
+
+	virtual void setLastEndGranPos(__int64 inPos);
+
+protected:
+	//unsigned long mNumHeaderPackets;
+	sFLACFormatBlock* mFLACFormatBlock;
+};

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.cpp	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.cpp	2004-10-09 08:30:32 UTC (rev 7942)
@@ -50,6 +50,8 @@
 			return new SpeexStream(inOggPage, inOwningFilter, inAllowSeek);
 		case StreamHeaders::FLAC:
 			return new FLACStream(inOggPage, inOwningFilter, inAllowSeek);
+		case StreamHeaders::OGG_FLAC_1_0:
+			return new OggFLAC_1_0_Stream(inOggPage, inOwningFilter, inAllowSeek);
 		case StreamHeaders::THEORA:
 			return new TheoraStream(inOggPage, inOwningFilter, inAllowSeek);
 		case StreamHeaders::FFDSHOW_VIDEO:
@@ -67,6 +69,8 @@
 		return StreamHeaders::SPEEX;
 	} else if ((strncmp((char*)inOggPacket->packetData(), "fLaC", 4)) == 0) {
 		return StreamHeaders::FLAC;
+	} else if ((strncmp((char*)inOggPacket->packetData(), "\177FLAC", 5)) == 0) {
+		return StreamHeaders::OGG_FLAC_1_0;
 	} else if ((strncmp((char*)inOggPacket->packetData(), "\200theora", 7)) == 0) {
 		return StreamHeaders::THEORA;
 	} else if ((strncmp((char*)inOggPacket->packetData(), "\001video\000\000\000", 9)) == 0) {

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.h	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStreamFactory.h	2004-10-09 08:30:32 UTC (rev 7942)
@@ -35,6 +35,7 @@
 #include "FLACStream.h"
 #include "TheoraStream.h"
 #include "FFDShowVideoStream.h"
+#include "OggFLAC_1_0_Stream.h"
 
 
 #include "OggPage.h"

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/StreamHeaders.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/StreamHeaders.h	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/StreamHeaders.h	2004-10-09 08:30:32 UTC (rev 7942)
@@ -57,6 +57,7 @@
 		SPEEX = 2,
 		FLAC = 3,
 		THEORA = 4,
+		OGG_FLAC_1_0 = 5,
 		CMML = 20,
 		FFDSHOW_VIDEO = 100
 	};

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj	2004-10-09 06:59:48 UTC (rev 7941)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/dsfOggDemux.vcproj	2004-10-09 08:30:32 UTC (rev 7942)
@@ -307,6 +307,9 @@
 				RelativePath="oggdllstuff.cpp">
 			</File>
 			<File
+				RelativePath=".\OggFLAC_1_0_Stream.cpp">
+			</File>
+			<File
 				RelativePath="OggStream.cpp">
 			</File>
 			<File
@@ -398,6 +401,9 @@
 				RelativePath="oggdllstuff.h">
 			</File>
 			<File
+				RelativePath=".\OggFLAC_1_0_Stream.h">
+			</File>
+			<File
 				RelativePath="OggStream.h">
 			</File>
 			<File



More information about the commits mailing list