1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 the VideoLAN team
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
44 # define _I64_MAX LONG_LONG_MAX
45 # define LONGLONG long long
50 extern const GUID MEDIASUBTYPE_I420;
51 extern const GUID MEDIASUBTYPE_PREVIEW_VIDEO;
53 typedef struct VLCMediaSample
55 IMediaSample *p_sample;
62 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
63 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
64 const AM_MEDIA_TYPE *pmtSource );
66 int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type);
68 /****************************************************************************
69 * Declaration of our dummy directshow filter pin class
70 ****************************************************************************/
71 class CapturePin: public IPin, public IMemInputPin
73 friend class CaptureEnumMediaTypes;
75 vlc_object_t *p_input;
77 CaptureFilter *p_filter;
79 IPin *p_connected_pin;
81 AM_MEDIA_TYPE *media_types;
82 size_t media_type_count;
84 AM_MEDIA_TYPE cx_media_type;
86 deque<VLCMediaSample> samples_queue;
91 CapturePin( vlc_object_t *_p_input, access_sys_t *p_sys,
92 CaptureFilter *_p_filter,
93 AM_MEDIA_TYPE *mt, size_t mt_count );
94 virtual ~CapturePin();
96 /* IUnknown methods */
97 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
98 STDMETHODIMP_(ULONG) AddRef();
99 STDMETHODIMP_(ULONG) Release();
102 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
103 STDMETHODIMP ReceiveConnection( IPin * pConnector,
104 const AM_MEDIA_TYPE *pmt );
105 STDMETHODIMP Disconnect();
106 STDMETHODIMP ConnectedTo( IPin **pPin );
107 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
108 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
109 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
110 STDMETHODIMP QueryId( LPWSTR * Id );
111 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
112 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
113 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
114 STDMETHODIMP EndOfStream( void );
116 STDMETHODIMP BeginFlush( void );
117 STDMETHODIMP EndFlush( void );
118 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
121 /* IMemInputPin methods */
122 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
123 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
124 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
125 STDMETHODIMP Receive( IMediaSample *pSample );
126 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
127 long *nSamplesProcessed );
128 STDMETHODIMP ReceiveCanBlock( void );
131 HRESULT CustomGetSample( VLCMediaSample * );
132 AM_MEDIA_TYPE &CustomGetMediaType();
135 /****************************************************************************
136 * Declaration of our dummy directshow filter class
137 ****************************************************************************/
138 class CaptureFilter : public IBaseFilter
140 friend class CapturePin;
142 vlc_object_t *p_input;
144 IFilterGraph *p_graph;
145 //AM_MEDIA_TYPE media_type;
151 CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys,
152 AM_MEDIA_TYPE *mt, size_t mt_count );
153 virtual ~CaptureFilter();
155 /* IUnknown methods */
156 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
157 STDMETHODIMP_(ULONG) AddRef();
158 STDMETHODIMP_(ULONG) Release();
160 /* IPersist method */
161 STDMETHODIMP GetClassID(CLSID *pClsID);
163 /* IMediaFilter methods */
164 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
165 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
166 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
168 STDMETHODIMP Pause();
169 STDMETHODIMP Run(REFERENCE_TIME tStart);
171 /* IBaseFilter methods */
172 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
173 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
174 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
175 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
176 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
179 CapturePin *CustomGetPin();
182 /****************************************************************************
183 * Declaration of our dummy directshow enumpins class
184 ****************************************************************************/
185 class CaptureEnumPins : public IEnumPins
187 vlc_object_t *p_input;
188 CaptureFilter *p_filter;
194 CaptureEnumPins( vlc_object_t *_p_input, CaptureFilter *_p_filter,
195 CaptureEnumPins *pEnumPins );
196 virtual ~CaptureEnumPins();
199 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
200 STDMETHODIMP_(ULONG) AddRef();
201 STDMETHODIMP_(ULONG) Release();
204 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
205 STDMETHODIMP Skip( ULONG cPins );
206 STDMETHODIMP Reset();
207 STDMETHODIMP Clone( IEnumPins **ppEnum );
210 /****************************************************************************
211 * Declaration of our dummy directshow enummediatypes class
212 ****************************************************************************/
213 class CaptureEnumMediaTypes : public IEnumMediaTypes
215 vlc_object_t *p_input;
217 AM_MEDIA_TYPE cx_media_type;
223 CaptureEnumMediaTypes( vlc_object_t *_p_input, CapturePin *_p_pin,
224 CaptureEnumMediaTypes *pEnumMediaTypes );
226 virtual ~CaptureEnumMediaTypes();
229 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
230 STDMETHODIMP_(ULONG) AddRef();
231 STDMETHODIMP_(ULONG) Release();
234 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
236 STDMETHODIMP Skip( ULONG cMediaTypes );
237 STDMETHODIMP Reset();
238 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );