1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.h,v 1.3 2003/10/18 20:09:23 gbazin Exp $
7 * Author: Gildas Bazin <gbazin@netcourrier.com>
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;
49 typedef struct VLCMediaSample
51 IMediaSample *p_sample;
58 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
59 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
60 const AM_MEDIA_TYPE *pmtSource );
62 /****************************************************************************
63 * Declaration of our dummy directshow filter pin class
64 ****************************************************************************/
65 class CapturePin: public IPin, public IMemInputPin
67 input_thread_t *p_input;
68 CaptureFilter *p_filter;
70 IPin *p_connected_pin;
71 AM_MEDIA_TYPE media_type;
73 deque<VLCMediaSample> samples_queue;
78 CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
80 virtual ~CapturePin();
82 /* IUnknown methods */
83 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
84 STDMETHODIMP_(ULONG) AddRef();
85 STDMETHODIMP_(ULONG) Release();
88 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
89 STDMETHODIMP ReceiveConnection( IPin * pConnector,
90 const AM_MEDIA_TYPE *pmt );
91 STDMETHODIMP Disconnect();
92 STDMETHODIMP ConnectedTo( IPin **pPin );
93 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
94 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
95 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
96 STDMETHODIMP QueryId( LPWSTR * Id );
97 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
98 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
99 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
100 STDMETHODIMP EndOfStream( void );
102 STDMETHODIMP BeginFlush( void );
103 STDMETHODIMP EndFlush( void );
104 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
107 /* IMemInputPin methods */
108 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
109 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
110 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
111 STDMETHODIMP Receive( IMediaSample *pSample );
112 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
113 long *nSamplesProcessed );
114 STDMETHODIMP ReceiveCanBlock( void );
117 HRESULT CustomGetSample( VLCMediaSample * );
118 AM_MEDIA_TYPE CustomGetMediaType();
121 /****************************************************************************
122 * Declaration of our dummy directshow filter class
123 ****************************************************************************/
124 class CaptureFilter : public IBaseFilter
126 input_thread_t *p_input;
128 IFilterGraph *p_graph;
129 AM_MEDIA_TYPE media_type;
134 CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt );
135 virtual ~CaptureFilter();
137 /* IUnknown methods */
138 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
139 STDMETHODIMP_(ULONG) AddRef();
140 STDMETHODIMP_(ULONG) Release();
142 /* IPersist method */
143 STDMETHODIMP GetClassID(CLSID *pClsID);
145 /* IMediaFilter methods */
146 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
147 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
148 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
150 STDMETHODIMP Pause();
151 STDMETHODIMP Run(REFERENCE_TIME tStart);
153 /* IBaseFilter methods */
154 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
155 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
156 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
157 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
158 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
161 CapturePin *CustomGetPin();
164 /****************************************************************************
165 * Declaration of our dummy directshow enumpins class
166 ****************************************************************************/
167 class CaptureEnumPins : public IEnumPins
169 input_thread_t * p_input;
170 CaptureFilter *p_filter;
176 CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
177 CaptureEnumPins *pEnumPins );
178 virtual ~CaptureEnumPins();
181 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
182 STDMETHODIMP_(ULONG) AddRef();
183 STDMETHODIMP_(ULONG) Release();
186 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
187 STDMETHODIMP Skip( ULONG cPins );
188 STDMETHODIMP Reset();
189 STDMETHODIMP Clone( IEnumPins **ppEnum );
192 /****************************************************************************
193 * Declaration of our dummy directshow enummediatypes class
194 ****************************************************************************/
195 class CaptureEnumMediaTypes : public IEnumMediaTypes
197 input_thread_t * p_input;
204 CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
205 CaptureEnumMediaTypes *pEnumMediaTypes );
207 virtual ~CaptureEnumMediaTypes();
210 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
211 STDMETHODIMP_(ULONG) AddRef();
212 STDMETHODIMP_(ULONG) Release();
215 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
217 STDMETHODIMP Skip( ULONG cMediaTypes );
218 STDMETHODIMP Reset();
219 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );