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;
72 vlc_object_t *p_input;
74 CaptureFilter *p_filter;
76 IPin *p_connected_pin;
78 AM_MEDIA_TYPE *media_types;
79 size_t media_type_count;
81 AM_MEDIA_TYPE cx_media_type;
83 deque<VLCMediaSample> samples_queue;
88 CapturePin( vlc_object_t *_p_input, access_sys_t *p_sys,
89 CaptureFilter *_p_filter,
90 AM_MEDIA_TYPE *mt, size_t mt_count );
91 virtual ~CapturePin();
93 /* IUnknown methods */
94 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
95 STDMETHODIMP_(ULONG) AddRef();
96 STDMETHODIMP_(ULONG) Release();
99 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
100 STDMETHODIMP ReceiveConnection( IPin * pConnector,
101 const AM_MEDIA_TYPE *pmt );
102 STDMETHODIMP Disconnect();
103 STDMETHODIMP ConnectedTo( IPin **pPin );
104 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
105 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
106 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
107 STDMETHODIMP QueryId( LPWSTR * Id );
108 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
109 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
110 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
111 STDMETHODIMP EndOfStream( void );
113 STDMETHODIMP BeginFlush( void );
114 STDMETHODIMP EndFlush( void );
115 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
118 /* IMemInputPin methods */
119 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
120 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
121 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
122 STDMETHODIMP Receive( IMediaSample *pSample );
123 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
124 long *nSamplesProcessed );
125 STDMETHODIMP ReceiveCanBlock( void );
128 HRESULT CustomGetSample( VLCMediaSample * );
129 AM_MEDIA_TYPE &CustomGetMediaType();
132 /****************************************************************************
133 * Declaration of our dummy directshow filter class
134 ****************************************************************************/
135 class CaptureFilter : public IBaseFilter
137 friend class CapturePin;
139 vlc_object_t *p_input;
141 IFilterGraph *p_graph;
142 //AM_MEDIA_TYPE media_type;
148 CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys,
149 AM_MEDIA_TYPE *mt, size_t mt_count );
150 virtual ~CaptureFilter();
152 /* IUnknown methods */
153 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
154 STDMETHODIMP_(ULONG) AddRef();
155 STDMETHODIMP_(ULONG) Release();
157 /* IPersist method */
158 STDMETHODIMP GetClassID(CLSID *pClsID);
160 /* IMediaFilter methods */
161 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
162 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
163 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
165 STDMETHODIMP Pause();
166 STDMETHODIMP Run(REFERENCE_TIME tStart);
168 /* IBaseFilter methods */
169 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
170 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
171 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
172 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
173 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
176 CapturePin *CustomGetPin();
179 /****************************************************************************
180 * Declaration of our dummy directshow enumpins class
181 ****************************************************************************/
182 class CaptureEnumPins : public IEnumPins
184 vlc_object_t *p_input;
185 CaptureFilter *p_filter;
191 CaptureEnumPins( vlc_object_t *_p_input, CaptureFilter *_p_filter,
192 CaptureEnumPins *pEnumPins );
193 virtual ~CaptureEnumPins();
196 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
197 STDMETHODIMP_(ULONG) AddRef();
198 STDMETHODIMP_(ULONG) Release();
201 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
202 STDMETHODIMP Skip( ULONG cPins );
203 STDMETHODIMP Reset();
204 STDMETHODIMP Clone( IEnumPins **ppEnum );
207 /****************************************************************************
208 * Declaration of our dummy directshow enummediatypes class
209 ****************************************************************************/
210 class CaptureEnumMediaTypes : public IEnumMediaTypes
212 vlc_object_t *p_input;
214 AM_MEDIA_TYPE cx_media_type;
220 CaptureEnumMediaTypes( vlc_object_t *_p_input, CapturePin *_p_pin,
221 CaptureEnumMediaTypes *pEnumMediaTypes );
223 virtual ~CaptureEnumMediaTypes();
226 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
227 STDMETHODIMP_(ULONG) AddRef();
228 STDMETHODIMP_(ULONG) Release();
231 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
233 STDMETHODIMP Skip( ULONG cMediaTypes );
234 STDMETHODIMP Reset();
235 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );