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