OggDemuxPacketSourceFilter.h

Go to the documentation of this file.
00001 //===========================================================================
00002 //Copyright (C) 2003, 2004, 2005 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 #include "BasicSeekPassThrough.h"
00033 #include "IFilterDataSource.h"
00034 #include "IOggBaseTime.h"
00035 //#include "OggStreamMapper.h"
00036 #include <libOOOgg/OggDataBuffer.h>
00037 
00038 #include <libOOOggSeek/AutoOggChainGranuleSeekTable.h>
00039 #include "DataSourceFactory.h"
00040 
00041 class OggStreamMapper;
00042 
00043 class OggDemuxPacketSourceFilter
00044         :       public CBaseFilter
00045         ,       public CAMThread
00046         ,       public IFileSourceFilter
00047         ,       public IOggCallback
00048         ,       public IOggBaseTime
00049         ,       public BasicSeekPassThrough
00050         //,     public ISpecifyPropertyPages
00051         ,       public IAMFilterMiscFlags
00052         //,     public IAMMediaContent
00053 {
00054 public:
00055         OggDemuxPacketSourceFilter(void);
00056         virtual ~OggDemuxPacketSourceFilter(void);
00057         enum eThreadCommands {
00058                 THREAD_EXIT = 0,
00059                 THREAD_PAUSE = 1,
00060                 THREAD_RUN = 2
00061         };
00062         //Com Stuff
00063         DECLARE_IUNKNOWN
00064 
00065         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00066         static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
00067 
00068         //Streaming MEthods
00069         STDMETHODIMP Run(REFERENCE_TIME tStart);
00070         STDMETHODIMP Pause(void);
00071         STDMETHODIMP Stop(void);
00072 
00073         //IOggCallback Interface
00074         virtual bool acceptOggPage(OggPage* inOggPage);
00075 
00076         //PURE VIRTUALS From CBaseFilter
00077         virtual int GetPinCount();
00078         virtual CBasePin* GetPin(int inPinNo);
00079 
00080         //PURE VIRTUALS from CAMThread
00081         virtual DWORD ThreadProc(void);
00082 
00083         //IFileSource Interface
00084         virtual STDMETHODIMP GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType);
00085         virtual STDMETHODIMP Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType);
00086 
00087         //IAMFilterMiscFlags Interface
00088         ULONG STDMETHODCALLTYPE GetMiscFlags(void);
00089 
00090         //IMediaSeeking
00091         virtual STDMETHODIMP GetDuration(LONGLONG* outDuration);
00092         virtual STDMETHODIMP GetCapabilities(DWORD* inCapabilities);
00093          
00094         virtual STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);
00095         virtual STDMETHODIMP IsFormatSupported(const GUID *pFormat);
00096         virtual STDMETHODIMP QueryPreferredFormat(GUID *pFormat);
00097         virtual STDMETHODIMP SetTimeFormat(const GUID *pFormat);
00098         virtual STDMETHODIMP GetTimeFormat( GUID *pFormat);
00099         
00100         virtual STDMETHODIMP GetStopPosition(LONGLONG *pStop);
00101         virtual STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);
00102         virtual STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat);
00103         virtual STDMETHODIMP SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags);
00104         virtual STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);
00105         virtual STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);
00106         virtual STDMETHODIMP SetRate(double dRate);
00107         virtual STDMETHODIMP GetRate(double *dRate);
00108         virtual STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);
00109         virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
00110 
00111         vector<OggPage*> getMatchingBufferedPages(unsigned long inSerialNo);
00112         void removeMatchingBufferedPages(unsigned long inSerialNo);
00113 
00114         CCritSec* streamLock()                  {               return mStreamLock;             }
00115 
00116         virtual void notifyPinConnected();
00117 
00118         //HHHH:::
00119         virtual bool notifyStreamBaseTime(__int64 inStreamBaseTime);
00120 
00121         //IOggBaseTime Interface
00122         virtual __int64 getGlobalBaseTime();
00123         //
00124 protected:
00125         static const unsigned long SETUP_BUFFER_SIZE = 24;
00126         virtual HRESULT SetUpPins();
00127 
00128         void resetStream();
00129         HRESULT DataProcessLoop();
00130 
00131         void DeliverEOS();
00132         void DeliverBeginFlush();
00133         void DeliverEndFlush();
00134         void DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
00135 
00136         CCritSec* mSourceFileLock;
00137         CCritSec* mDemuxLock;
00138         CCritSec* mStreamLock;
00139 
00140         wstring mFileName;
00141 
00142         bool mSeenAllBOSPages;
00143         bool mSeenPositiveGranulePos;
00144         OggPage* mPendingPage;
00145         vector<OggPage*> mBufferedPages;
00146 
00147         OggDataBuffer mOggBuffer;
00148         IFilterDataSource* mDataSource;
00149         OggStreamMapper* mStreamMapper;
00150 
00151         AutoOggChainGranuleSeekTable* mSeekTable;
00152 
00153 
00154         bool mJustReset;
00155 
00156         //HHHH:::
00157         __int64 mGlobalBaseTime;
00158 
00159         //double mPlaybackRate;
00160 };

Generated on Thu Feb 16 23:48:14 2006 for oggdsf by  doxygen 1.3.9