1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.h,v 1.5 2004/01/26 18:24:17 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;
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 /****************************************************************************
64 * Declaration of our dummy directshow filter pin class
65 ****************************************************************************/
66 class CapturePin: public IPin, public IMemInputPin
68 input_thread_t *p_input;
69 CaptureFilter *p_filter;
71 IPin *p_connected_pin;
72 AM_MEDIA_TYPE media_type;
74 deque<VLCMediaSample> samples_queue;
79 CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
81 virtual ~CapturePin();
83 /* IUnknown methods */
84 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
85 STDMETHODIMP_(ULONG) AddRef();
86 STDMETHODIMP_(ULONG) Release();
89 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
90 STDMETHODIMP ReceiveConnection( IPin * pConnector,
91 const AM_MEDIA_TYPE *pmt );
92 STDMETHODIMP Disconnect();
93 STDMETHODIMP ConnectedTo( IPin **pPin );
94 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
95 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
96 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
97 STDMETHODIMP QueryId( LPWSTR * Id );
98 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
99 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
100 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
101 STDMETHODIMP EndOfStream( void );
103 STDMETHODIMP BeginFlush( void );
104 STDMETHODIMP EndFlush( void );
105 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
108 /* IMemInputPin methods */
109 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
110 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
111 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
112 STDMETHODIMP Receive( IMediaSample *pSample );
113 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
114 long *nSamplesProcessed );
115 STDMETHODIMP ReceiveCanBlock( void );
118 HRESULT CustomGetSample( VLCMediaSample * );
119 AM_MEDIA_TYPE CustomGetMediaType();
122 /****************************************************************************
123 * Declaration of our dummy directshow filter class
124 ****************************************************************************/
125 class CaptureFilter : public IBaseFilter
127 input_thread_t *p_input;
129 IFilterGraph *p_graph;
130 AM_MEDIA_TYPE media_type;
136 CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt );
137 virtual ~CaptureFilter();
139 /* IUnknown methods */
140 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
141 STDMETHODIMP_(ULONG) AddRef();
142 STDMETHODIMP_(ULONG) Release();
144 /* IPersist method */
145 STDMETHODIMP GetClassID(CLSID *pClsID);
147 /* IMediaFilter methods */
148 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
149 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
150 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
152 STDMETHODIMP Pause();
153 STDMETHODIMP Run(REFERENCE_TIME tStart);
155 /* IBaseFilter methods */
156 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
157 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
158 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
159 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
160 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
163 CapturePin *CustomGetPin();
166 /****************************************************************************
167 * Declaration of our dummy directshow enumpins class
168 ****************************************************************************/
169 class CaptureEnumPins : public IEnumPins
171 input_thread_t * p_input;
172 CaptureFilter *p_filter;
178 CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
179 CaptureEnumPins *pEnumPins );
180 virtual ~CaptureEnumPins();
183 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
184 STDMETHODIMP_(ULONG) AddRef();
185 STDMETHODIMP_(ULONG) Release();
188 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
189 STDMETHODIMP Skip( ULONG cPins );
190 STDMETHODIMP Reset();
191 STDMETHODIMP Clone( IEnumPins **ppEnum );
194 /****************************************************************************
195 * Declaration of our dummy directshow enummediatypes class
196 ****************************************************************************/
197 class CaptureEnumMediaTypes : public IEnumMediaTypes
199 input_thread_t * p_input;
206 CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
207 CaptureEnumMediaTypes *pEnumMediaTypes );
209 virtual ~CaptureEnumMediaTypes();
212 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
213 STDMETHODIMP_(ULONG) AddRef();
214 STDMETHODIMP_(ULONG) Release();
217 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
219 STDMETHODIMP Skip( ULONG cMediaTypes );
220 STDMETHODIMP Reset();
221 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );