Updated project files to VS2008 SP1. Removed deprecated features (and warning message...
[xiph/unicode.git] / oggdsf / src / lib / core / directshow / dsfOggDemux / OggDemuxSourceFilter.h
blob3247855affd148e6d8dcec4f743c30109107b1b0
1 //===========================================================================
2 //Copyright (C) 2003, 2004 Zentaro Kavanagh
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions
6 //are met:
7 //
8 //- Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
11 //- Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
15 //- Neither the name of Zentaro Kavanagh nor the names of contributors
16 // may be used to endorse or promote products derived from this software
17 // without specific prior written permission.
19 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 //``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 //LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 //PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
23 //CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 //PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 //LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 //NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 //===========================================================================
31 #pragma once
33 #include <Dshow.h>
34 #include <Initguid.h>
35 #include <Qnetwork.h>
36 #include "oggdllstuff.h"
37 #include "OggDemuxSourcePin.h"
38 #include "OggStreamMapper.h"
39 #include <libOOOggSeek/AutoOggSeekTable.h>
40 #include <libOOOgg/OggDataBuffer.h>
41 #include "IFilterDataSource.h"
42 #include "DataSourceFactory.h"
43 #include "PropsAbout.h"
44 #include <fstream>
45 using namespace std;
48 class OggStreamMapper;
50 class OGG_DEMUX_API OggDemuxSourceFilter
51 : public CBaseFilter,
52 public CAMThread,
53 public IFileSourceFilter,
54 public IOggCallback
55 , public BasicSeekPassThrough
56 , public ISpecifyPropertyPages
57 , public IAMFilterMiscFlags
58 , public IAMMediaContent
61 public:
62 friend class OggStream;
63 static const unsigned long RAW_BUFFER_SIZE = 24;
64 //Com Stuff
65 DECLARE_IUNKNOWN
66 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
67 static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
69 enum eThreadCommands {
70 THREAD_EXIT = 0,
71 THREAD_PAUSE = 1,
72 THREAD_RUN = 2
74 //Constructors
75 OggDemuxSourceFilter();
76 OggDemuxSourceFilter(REFCLSID inFilterGUID);
77 virtual ~OggDemuxSourceFilter(void);
79 //IAMFilterMiscFlags Interface
80 ULONG STDMETHODCALLTYPE GetMiscFlags(void);
83 //IFileSource Interface
84 virtual STDMETHODIMP GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType);
85 virtual STDMETHODIMP Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType);
87 //PURE VIRTUALS From CBaseFilter
88 virtual int GetPinCount();
89 virtual CBasePin* GetPin(int inPinNo);
91 //IOggCallback Interface
92 virtual bool acceptOggPage(OggPage* inOggPage);
94 //ISpecifyPropertyPages
95 virtual STDMETHODIMP GetPages(CAUUID* outPropPages);
97 //Streaming MEthods
98 STDMETHODIMP Run(REFERENCE_TIME tStart);
99 STDMETHODIMP Pause(void);
100 STDMETHODIMP Stop(void);
102 //IMediaSeeking
103 virtual STDMETHODIMP GetDuration(LONGLONG* outDuration);
104 virtual STDMETHODIMP GetCapabilities(DWORD* inCapabilities);
106 virtual STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);
107 virtual STDMETHODIMP IsFormatSupported(const GUID *pFormat);
108 virtual STDMETHODIMP QueryPreferredFormat(GUID *pFormat);
109 virtual STDMETHODIMP SetTimeFormat(const GUID *pFormat);
110 virtual STDMETHODIMP GetTimeFormat( GUID *pFormat);
112 virtual STDMETHODIMP GetStopPosition(LONGLONG *pStop);
113 virtual STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);
114 virtual STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source, const GUID *pSourceFormat);
115 virtual STDMETHODIMP SetPositions(LONGLONG *pCurrent,DWORD dwCurrentFlags,LONGLONG *pStop,DWORD dwStopFlags);
116 virtual STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);
117 virtual STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);
118 virtual STDMETHODIMP SetRate(double dRate);
119 virtual STDMETHODIMP GetRate(double *dRate);
120 virtual STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);
121 virtual STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);
123 //IAMMediaContent Interface
124 virtual STDMETHODIMP get_AuthorName(BSTR* outAuthorName);
125 virtual STDMETHODIMP get_Title(BSTR* outTitle);
126 virtual STDMETHODIMP get_Rating(BSTR* outRating);
127 virtual STDMETHODIMP get_Description(BSTR* outDescription);
128 virtual STDMETHODIMP get_Copyright(BSTR* outCopyright);
129 virtual STDMETHODIMP get_BaseURL(BSTR* outBaseURL);
130 virtual STDMETHODIMP get_LogoURL(BSTR* outLogoURL);
131 virtual STDMETHODIMP get_LogoIconURL(BSTR* outLogoIconURL);
132 virtual STDMETHODIMP get_WatermarkURL(BSTR* outWatermarkURL);
133 virtual STDMETHODIMP get_MoreInfoURL(BSTR* outMoreInfoURL);
134 virtual STDMETHODIMP get_MoreInfoBannerImage(BSTR* outMoreInfoBannerImage);
135 virtual STDMETHODIMP get_MoreInfoBannerURL(BSTR* outMoreInfoBannerURL);
136 virtual STDMETHODIMP get_MoreInfoText(BSTR* outMoreInfoText);
139 //IDispatch Interface (Base interface of IAMMediaContent) - evil evil thing.
140 // Trying not to implement it ! I'm sure it was all very funny when they came up with it.
141 virtual STDMETHODIMP GetTypeInfoCount( unsigned int FAR* pctinfo );
142 virtual STDMETHODIMP GetIDsOfNames( REFIID riid,
143 OLECHAR FAR* FAR* rgszNames,
144 unsigned int cNames,
145 LCID lcid,
146 DISPID FAR* rgDispId );
147 virtual STDMETHODIMP GetTypeInfo( unsigned int iTInfo,
148 LCID lcid,
149 ITypeInfo FAR* FAR* ppTInfo );
150 virtual STDMETHODIMP Invoke( DISPID dispIdMember,
151 REFIID riid,
152 LCID lcid,
153 WORD wFlags,
154 DISPPARAMS FAR* pDispParams,
155 VARIANT FAR* pVarResult,
156 EXCEPINFO FAR* pExcepInfo,
157 unsigned int FAR* puArgErr );
160 CCritSec* theLock();
161 //CAMThread
162 virtual DWORD ThreadProc(void);
165 CCritSec* mStreamLock;
167 REFERENCE_TIME mSeekTimeBase; //Don't ask !
169 protected:
170 //Internal helper methods
171 void resetStream();
172 void DeliverEOS();
173 void DeliverBeginFlush();
174 void DeliverEndFlush();
175 void DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
177 virtual HRESULT DataProcessLoop();
178 virtual HRESULT SetUpPins();
179 //virtual bool AddPin(OggDemuxSourcePin* inPin, unsigned long inSerialNo);
182 CCritSec* mSourceFileLock;
183 CCritSec* mDemuxLock;
184 AutoOggSeekTable* mSeekTable;
185 wstring mFileName;
187 OggDataBuffer mOggBuffer;
189 bool mJustReset; //This is pretty dodgy !
191 bool mSetIgnorePackets;
193 //SOURCE ABSTRACTION::: declaration
194 //fstream mSourceFile;
196 IFilterDataSource* mDataSource;
198 OggStreamMapper* mStreamMapper;
200 //DEBUG
201 fstream debugLog;