OggStream.h

Go to the documentation of this file.
00001 //===========================================================================
00002 //Copyright (C) 2003, 2004 Zentaro Kavanagh
00003 //
00004 //Redistribution and use in source and binary forms, with or without
00005 //modification, are permitted provided that the following conditions
00006 //are met:
00007 //
00008 //- Redistributions of source code must retain the above copyright
00009 //  notice, this list of conditions and the following disclaimer.
00010 //
00011 //- Redistributions in binary form must reproduce the above copyright
00012 //  notice, this list of conditions and the following disclaimer in the
00013 //  documentation and/or other materials provided with the distribution.
00014 //
00015 //- Neither the name of Zentaro Kavanagh nor the names of contributors 
00016 //  may be used to endorse or promote products derived from this software 
00017 //  without specific prior written permission.
00018 //
00019 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 //``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00022 //PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
00023 //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00024 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00025 //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 //===========================================================================
00031 #pragma once
00032 
00033 #include "oggdllstuff.h"
00034 #include "StreamHeaders.h"
00035 #include <libOOOgg/IOggCallback.h>
00036 #include <libOOOgg/IStampedOggPacketSink.h>
00037 #include <libOOOgg/OggPacketiser.h>
00038 
00039 #include <libOOOgg/OggPage.h>
00040 #include <fstream>
00041 using namespace std;
00042 
00043 
00044 class OggDemuxSourceFilter;
00045 class OggDemuxSourcePin;
00046 class StreamHeaders;
00047 
00048 class OGG_DEMUX_API OggStream
00049         :       public IOggCallback
00050         ,       protected IStampedOggPacketSink
00051 
00052 {
00053 public:
00054         OggStream(OggPage* inBOSPage, OggDemuxSourceFilter* inOwningFilter, bool inAllowSeek);
00055         virtual ~OggStream(void);
00056 
00057         //more hacks
00058         virtual void setLastEndGranPos(__int64 inGranPos);
00059         unsigned long serialNo();
00060         void setSerialNo(unsigned long inSerialNo);
00061         //virtual bool IdentifyCodec(OggPacket* inOggPacket) = 0;
00062         
00063         virtual bool InitCodec(StampedOggPacket* inOggPacket) = 0;
00064         virtual BYTE* getFormatBlock() = 0;
00065         virtual unsigned long getFormatBlockSize() = 0;
00066 
00067         virtual GUID getMajorTypeGUID() = 0;
00068         virtual GUID getFormatGUID() = 0;
00069         virtual GUID getSubtypeGUID() = 0;
00070         virtual wstring getPinName() = 0;
00071         virtual bool createFormatBlock() = 0;
00072 
00073         virtual LONGLONG getCurrentPos() = 0;
00074 
00075         virtual unsigned long getNumBuffers() = 0;
00076         virtual unsigned long getBufferSize() = 0;
00077 
00078         virtual unsigned long numCodecHeaders();
00079         void setSendExcess(bool inSendExcess);
00080 
00081         virtual CMediaType* createMediaType(GUID inMajorType, GUID inSubType, GUID inFormatType, unsigned long inFormatSize, BYTE* inFormatBlock);
00082 
00083         virtual bool dispatchPacket(StampedOggPacket* inPacket);
00084         virtual bool deliverCodecHeaders();
00085 
00086         //IOggcalback Interface
00087         virtual bool acceptOggPage(OggPage* inOggPage);   //Beware if you override this further
00088 
00089         virtual OggDemuxSourcePin* getPin();
00090         virtual bool OggStream::AddPin();
00091 
00092         void setAllowDispatch(bool inAllowDispatch);
00093         bool streamReady();
00094         
00095         
00096         void flush();
00097         void flush(unsigned short inNumPacketsToIgnore);
00098 protected:
00099         virtual bool acceptStampedOggPacket(StampedOggPacket* inPacket);
00100         
00101         //virtual bool processPacket(StampedOggPacket* inPacket);
00102         virtual bool processHeaderPacket(StampedOggPacket* inPacket);
00103         virtual bool processDataPacket(StampedOggPacket* inPacket);
00104         //virtual bool processExcessPacket(StampedOggPacket* inPacket);
00105 
00106         OggPacketiser mPacketiser;
00107         //StampedOggPacket* mPartialPacket;
00108         StreamHeaders* mCodecHeaders;
00109         vector<StampedOggPacket*> mExcessPackets;
00110         unsigned long mSerialNo;
00111         signed long mNumHeadersNeeded;
00112         bool mStreamReady;
00113         bool mFirstRun;
00114         bool mSendExcess;
00115         bool mAllowSeek;
00116         bool mAllowDispatch;
00117 
00118         __int64 mLastEndGranulePos;
00119         __int64 mLastStartGranulePos;
00120 
00121         OggDemuxSourcePin* mSourcePin;
00122         OggDemuxSourceFilter* mOwningFilter;
00123         CCritSec* mStreamLock;
00124 
00125         //fstream debugLog;
00126 };

Generated on Tue Feb 15 14:54:19 2005 for oggdsf by  doxygen 1.3.9