filter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <string>
00028 #include <list>
00029 #include <deque>
00030 using namespace std;
00031
00032 #ifndef _MSC_VER
00033 # include <wtypes.h>
00034 # include <unknwn.h>
00035 # include <ole2.h>
00036 # include <limits.h>
00037 # ifdef _WINGDI_
00038 # undef _WINGDI_
00039 # endif
00040 # define _WINGDI_ 1
00041 # define AM_NOVTABLE
00042 # define _OBJBASE_H_
00043 # undef _X86_
00044 # ifndef _I64_MAX
00045 # define _I64_MAX LONG_LONG_MAX
00046 # endif
00047 # define LONGLONG long long
00048 #endif
00049
00050 #include <dshow.h>
00051
00052 extern const GUID MEDIASUBTYPE_I420;
00053 extern const GUID MEDIASUBTYPE_PREVIEW_VIDEO;
00054
00055 typedef struct VLCMediaSample
00056 {
00057 IMediaSample *p_sample;
00058 mtime_t i_timestamp;
00059
00060 } VLCMediaSample;
00061
00062 class CaptureFilter;
00063
00064 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
00065 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
00066 const AM_MEDIA_TYPE *pmtSource );
00067
00068 int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type);
00069
00070
00071
00072
00073 class CapturePin: public IPin, public IMemInputPin
00074 {
00075 friend class CaptureEnumMediaTypes;
00076
00077 vlc_object_t *p_input;
00078 access_sys_t *p_sys;
00079 CaptureFilter *p_filter;
00080
00081 IPin *p_connected_pin;
00082
00083 AM_MEDIA_TYPE *media_types;
00084 size_t media_type_count;
00085
00086 AM_MEDIA_TYPE cx_media_type;
00087
00088 deque<VLCMediaSample> samples_queue;
00089
00090 long i_ref;
00091
00092 public:
00093 CapturePin( vlc_object_t *_p_input, access_sys_t *p_sys,
00094 CaptureFilter *_p_filter,
00095 AM_MEDIA_TYPE *mt, size_t mt_count );
00096 virtual ~CapturePin();
00097
00098
00099 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
00100 STDMETHODIMP_(ULONG) AddRef();
00101 STDMETHODIMP_(ULONG) Release();
00102
00103
00104 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
00105 STDMETHODIMP ReceiveConnection( IPin * pConnector,
00106 const AM_MEDIA_TYPE *pmt );
00107 STDMETHODIMP Disconnect();
00108 STDMETHODIMP ConnectedTo( IPin **pPin );
00109 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
00110 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
00111 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
00112 STDMETHODIMP QueryId( LPWSTR * Id );
00113 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
00114 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
00115 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
00116 STDMETHODIMP EndOfStream( void );
00117
00118 STDMETHODIMP BeginFlush( void );
00119 STDMETHODIMP EndFlush( void );
00120 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
00121 double dRate );
00122
00123
00124 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
00125 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
00126 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
00127 STDMETHODIMP Receive( IMediaSample *pSample );
00128 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
00129 long *nSamplesProcessed );
00130 STDMETHODIMP ReceiveCanBlock( void );
00131
00132
00133 HRESULT CustomGetSample( VLCMediaSample * );
00134 HRESULT CustomGetSamples( deque<VLCMediaSample> &external_queue );
00135
00136 AM_MEDIA_TYPE &CustomGetMediaType();
00137 };
00138
00139
00140
00141
00142 class CaptureFilter : public IBaseFilter
00143 {
00144 friend class CapturePin;
00145
00146 vlc_object_t *p_input;
00147 CapturePin *p_pin;
00148 IFilterGraph *p_graph;
00149
00150 FILTER_STATE state;
00151
00152 long i_ref;
00153
00154 public:
00155 CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys,
00156 AM_MEDIA_TYPE *mt, size_t mt_count );
00157 virtual ~CaptureFilter();
00158
00159
00160 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
00161 STDMETHODIMP_(ULONG) AddRef();
00162 STDMETHODIMP_(ULONG) Release();
00163
00164
00165 STDMETHODIMP GetClassID(CLSID *pClsID);
00166
00167
00168 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
00169 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
00170 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
00171 STDMETHODIMP Stop();
00172 STDMETHODIMP Pause();
00173 STDMETHODIMP Run(REFERENCE_TIME tStart);
00174
00175
00176 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
00177 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
00178 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
00179 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
00180 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
00181
00182
00183 CapturePin *CustomGetPin();
00184 };
00185
00186
00187
00188
00189 class CaptureEnumPins : public IEnumPins
00190 {
00191 vlc_object_t *p_input;
00192 CaptureFilter *p_filter;
00193
00194 int i_position;
00195 long i_ref;
00196
00197 public:
00198 CaptureEnumPins( vlc_object_t *_p_input, CaptureFilter *_p_filter,
00199 CaptureEnumPins *pEnumPins );
00200 virtual ~CaptureEnumPins();
00201
00202
00203 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
00204 STDMETHODIMP_(ULONG) AddRef();
00205 STDMETHODIMP_(ULONG) Release();
00206
00207
00208 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
00209 STDMETHODIMP Skip( ULONG cPins );
00210 STDMETHODIMP Reset();
00211 STDMETHODIMP Clone( IEnumPins **ppEnum );
00212 };
00213
00214
00215
00216
00217 class CaptureEnumMediaTypes : public IEnumMediaTypes
00218 {
00219 vlc_object_t *p_input;
00220 CapturePin *p_pin;
00221 AM_MEDIA_TYPE cx_media_type;
00222
00223 size_t i_position;
00224 long i_ref;
00225
00226 public:
00227 CaptureEnumMediaTypes( vlc_object_t *_p_input, CapturePin *_p_pin,
00228 CaptureEnumMediaTypes *pEnumMediaTypes );
00229
00230 virtual ~CaptureEnumMediaTypes();
00231
00232
00233 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
00234 STDMETHODIMP_(ULONG) AddRef();
00235 STDMETHODIMP_(ULONG) Release();
00236
00237
00238 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
00239 ULONG * pcFetched );
00240 STDMETHODIMP Skip( ULONG cMediaTypes );
00241 STDMETHODIMP Reset();
00242 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );
00243 };