1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
41 # define _I64_MAX LONG_LONG_MAX
42 # define LONGLONG long long
47 extern const GUID MEDIASUBTYPE_I420;
48 extern const GUID MEDIASUBTYPE_PREVIEW_VIDEO;
50 typedef struct VLCMediaSample
52 IMediaSample *p_sample;
59 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
60 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
61 const AM_MEDIA_TYPE *pmtSource );
63 int GetFourCCFromMediaType(const AM_MEDIA_TYPE &media_type);
65 /****************************************************************************
66 * Declaration of our dummy directshow filter pin class
67 ****************************************************************************/
68 class CapturePin: public IPin, public IMemInputPin
70 friend class CaptureEnumMediaTypes;
73 CaptureFilter *p_filter;
75 IPin *p_connected_pin;
77 AM_MEDIA_TYPE *media_types;
78 size_t media_type_count;
80 AM_MEDIA_TYPE cx_media_type;
82 deque<VLCMediaSample> samples_queue;
87 CapturePin( access_t * _p_input, CaptureFilter *_p_filter,
88 AM_MEDIA_TYPE *mt, size_t mt_count );
89 virtual ~CapturePin();
91 /* IUnknown methods */
92 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
93 STDMETHODIMP_(ULONG) AddRef();
94 STDMETHODIMP_(ULONG) Release();
97 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
98 STDMETHODIMP ReceiveConnection( IPin * pConnector,
99 const AM_MEDIA_TYPE *pmt );
100 STDMETHODIMP Disconnect();
101 STDMETHODIMP ConnectedTo( IPin **pPin );
102 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
103 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
104 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
105 STDMETHODIMP QueryId( LPWSTR * Id );
106 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
107 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
108 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
109 STDMETHODIMP EndOfStream( void );
111 STDMETHODIMP BeginFlush( void );
112 STDMETHODIMP EndFlush( void );
113 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
116 /* IMemInputPin methods */
117 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
118 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
119 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
120 STDMETHODIMP Receive( IMediaSample *pSample );
121 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
122 long *nSamplesProcessed );
123 STDMETHODIMP ReceiveCanBlock( void );
126 HRESULT CustomGetSample( VLCMediaSample * );
127 AM_MEDIA_TYPE &CustomGetMediaType();
130 /****************************************************************************
131 * Declaration of our dummy directshow filter class
132 ****************************************************************************/
133 class CaptureFilter : public IBaseFilter
135 friend class CapturePin;
139 IFilterGraph *p_graph;
140 //AM_MEDIA_TYPE media_type;
146 CaptureFilter( access_t * _p_input, AM_MEDIA_TYPE *mt, size_t mt_count );
147 virtual ~CaptureFilter();
149 /* IUnknown methods */
150 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
151 STDMETHODIMP_(ULONG) AddRef();
152 STDMETHODIMP_(ULONG) Release();
154 /* IPersist method */
155 STDMETHODIMP GetClassID(CLSID *pClsID);
157 /* IMediaFilter methods */
158 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
159 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
160 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
162 STDMETHODIMP Pause();
163 STDMETHODIMP Run(REFERENCE_TIME tStart);
165 /* IBaseFilter methods */
166 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
167 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
168 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
169 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
170 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
173 CapturePin *CustomGetPin();
176 /****************************************************************************
177 * Declaration of our dummy directshow enumpins class
178 ****************************************************************************/
179 class CaptureEnumPins : public IEnumPins
182 CaptureFilter *p_filter;
188 CaptureEnumPins( access_t * _p_input, CaptureFilter *_p_filter,
189 CaptureEnumPins *pEnumPins );
190 virtual ~CaptureEnumPins();
193 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
194 STDMETHODIMP_(ULONG) AddRef();
195 STDMETHODIMP_(ULONG) Release();
198 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
199 STDMETHODIMP Skip( ULONG cPins );
200 STDMETHODIMP Reset();
201 STDMETHODIMP Clone( IEnumPins **ppEnum );
204 /****************************************************************************
205 * Declaration of our dummy directshow enummediatypes class
206 ****************************************************************************/
207 class CaptureEnumMediaTypes : public IEnumMediaTypes
216 CaptureEnumMediaTypes( access_t * _p_input, CapturePin *_p_pin,
217 CaptureEnumMediaTypes *pEnumMediaTypes );
219 virtual ~CaptureEnumMediaTypes();
222 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
223 STDMETHODIMP_(ULONG) AddRef();
224 STDMETHODIMP_(ULONG) Release();
227 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
229 STDMETHODIMP Skip( ULONG cMediaTypes );
230 STDMETHODIMP Reset();
231 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );