OggDemuxSourceFilter.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 <Dshow.h>
00034 #include <Initguid.h>
00035 #include <Qnetwork.h>
00036 #include "oggdllstuff.h"
00037 #include "OggDemuxSourcePin.h"
00038 #include "OggStreamMapper.h"
00039 #include <libOOOggSeek/AutoOggSeekTable.h>
00040 #include <libOOOgg/OggDataBuffer.h>
00041 #include "IFilterDataSource.h"
00042 #include "DataSourceFactory.h"
00043 #include "PropsAbout.h"
00044 #include <fstream>
00045 using namespace std;
00046 
00047 
00048 class OggStreamMapper;
00049 
00050 class OGG_DEMUX_API OggDemuxSourceFilter 
00051         :       public CBaseFilter,
00052                 public CAMThread,
00053                 public IFileSourceFilter,
00054                 public IOggCallback
00055         ,       public BasicSeekPassThrough
00056         ,       public ISpecifyPropertyPages
00057         ,       public IAMFilterMiscFlags
00058         ,       public IAMMediaContent
00059                 
00060 {
00061 public:
00062         friend class OggStream;
00063         static const unsigned long RAW_BUFFER_SIZE = 24;
00064         //Com Stuff
00065         DECLARE_IUNKNOWN
00066         STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
00067         static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
00068 
00069         enum eThreadCommands {
00070                 THREAD_EXIT = 0,
00071                 THREAD_PAUSE = 1,
00072                 THREAD_RUN = 2
00073         };
00074         //Constructors
00075         OggDemuxSourceFilter();
00076         OggDemuxSourceFilter(REFCLSID inFilterGUID);
00077         virtual ~OggDemuxSourceFilter(void);
00078 
00079         //IAMFilterMiscFlags Interface
00080         ULONG STDMETHODCALLTYPE GetMiscFlags(void);
00081         //
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         //PURE VIRTUALS From CBaseFilter
00088         virtual int GetPinCount();
00089         virtual CBasePin* GetPin(int inPinNo);
00090 
00091         //IOggCallback Interface
00092         virtual bool acceptOggPage(OggPage* inOggPage);
00093 
00094         //ISpecifyPropertyPages
00095         virtual STDMETHODIMP GetPages(CAUUID* outPropPages);
00096 
00097         //Streaming MEthods
00098         STDMETHODIMP Run(REFERENCE_TIME tStart);
00099         STDMETHODIMP Pause(void);
00100         STDMETHODIMP Stop(void);
00101 
00102         //IMediaSeeking
00103         virtual STDMETHODIMP GetDuration(LONGLONG* outDuration);
00104         virtual STDMETHODIMP GetCapabilities(DWORD* inCapabilities);
00105          
00106         virtual STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);
00107         virtual STDMETHODIMP IsFormatSupported(const GUID *pFormat);
00108         virtual STDMETHODIMP QueryPreferredFormat(GUID *pFormat);
00109         virtual STDMETHODIMP SetTimeFormat(const GUID *pFormat);
00110         virtual STDMETHODIMP GetTimeFormat( GUID *pFormat);
00111         
00112         virtual STDMETHODIMP GetStopPosition(LONGLONG *pStop);
00113         virtual STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);
00114         virtual STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat);
00115         virtual STDMETHODIMP SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags);
00116         virtual STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);
00117         virtual STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);
00118         virtual STDMETHODIMP SetRate(double dRate);
00119         virtual STDMETHODIMP GetRate(double *dRate);
00120         virtual STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);
00121         virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
00122         
00123         //IAMMediaContent Interface
00124         virtual STDMETHODIMP get_AuthorName(BSTR* outAuthorName);
00125         virtual STDMETHODIMP get_Title(BSTR* outTitle);
00126         virtual STDMETHODIMP get_Rating(BSTR* outRating);
00127         virtual STDMETHODIMP get_Description(BSTR* outDescription);
00128         virtual STDMETHODIMP get_Copyright(BSTR* outCopyright);
00129         virtual STDMETHODIMP get_BaseURL(BSTR* outBaseURL);
00130         virtual STDMETHODIMP get_LogoURL(BSTR* outLogoURL);
00131         virtual STDMETHODIMP get_LogoIconURL(BSTR* outLogoIconURL);
00132         virtual STDMETHODIMP get_WatermarkURL(BSTR* outWatermarkURL);
00133         virtual STDMETHODIMP get_MoreInfoURL(BSTR* outMoreInfoURL);
00134         virtual STDMETHODIMP get_MoreInfoBannerImage(BSTR* outMoreInfoBannerImage);
00135         virtual STDMETHODIMP get_MoreInfoBannerURL(BSTR* outMoreInfoBannerURL);
00136         virtual STDMETHODIMP get_MoreInfoText(BSTR* outMoreInfoText);
00137 
00138 
00139         //IDispatch Interface (Base interface of IAMMediaContent) - evil evil thing.
00140         // Trying not to implement it ! I'm sure it was all very funny when they came up with it.
00141         virtual STDMETHODIMP GetTypeInfoCount(  unsigned int FAR*  pctinfo );
00142         virtual STDMETHODIMP GetIDsOfNames(             REFIID  riid, 
00143                                                                                         OLECHAR FAR* FAR* rgszNames, 
00144                                                                                         unsigned int cNames, 
00145                                                                                         LCID lcid, 
00146                                                                                         DISPID FAR* rgDispId );
00147         virtual STDMETHODIMP GetTypeInfo(               unsigned int iTInfo, 
00148                                                                                         LCID lcid, 
00149                                                                                         ITypeInfo FAR* FAR*  ppTInfo );
00150         virtual STDMETHODIMP Invoke(                    DISPID  dispIdMember,
00151                                                                                         REFIID  riid,
00152                                                                                         LCID  lcid,
00153                                                                                         WORD  wFlags,
00154                                                                                         DISPPARAMS FAR*  pDispParams,  
00155                                                                                         VARIANT FAR*  pVarResult,  
00156                                                                                         EXCEPINFO FAR*  pExcepInfo,  
00157                                                                                         unsigned int FAR*  puArgErr );
00158 
00159 
00160          CCritSec* theLock();
00161         //CAMThread
00162         virtual DWORD ThreadProc(void);
00163 
00164         
00165         CCritSec* mStreamLock;
00166 
00167         REFERENCE_TIME mSeekTimeBase;  //Don't ask !
00168 
00169 protected:
00170         //Internal helper methods
00171         void resetStream();
00172         void DeliverEOS();
00173         void DeliverBeginFlush();
00174         void DeliverEndFlush();
00175         void DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
00176 
00177         virtual HRESULT DataProcessLoop();
00178         virtual HRESULT SetUpPins();
00179         //virtual bool AddPin(OggDemuxSourcePin* inPin, unsigned long inSerialNo);
00180 
00181 
00182         CCritSec* mSourceFileLock;
00183         CCritSec* mDemuxLock;
00184         AutoOggSeekTable* mSeekTable;
00185         wstring mFileName;
00186 
00187         OggDataBuffer mOggBuffer;
00188 
00189         bool mJustReset;  //This is pretty dodgy !
00190 
00191         bool mSetIgnorePackets;
00192 
00193         //SOURCE ABSTRACTION::: declaration
00194         //fstream mSourceFile;
00195         //
00196         IFilterDataSource* mDataSource;
00197 
00198         OggStreamMapper* mStreamMapper;
00199 
00200         //DEBUG
00201         fstream debugLog;
00202 
00203         
00204 };

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