1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.h,v 1.4 2003/12/02 23:03:31 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;
135 CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt );
136 virtual ~CaptureFilter();
138 /* IUnknown methods */
139 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
140 STDMETHODIMP_(ULONG) AddRef();
141 STDMETHODIMP_(ULONG) Release();
143 /* IPersist method */
144 STDMETHODIMP GetClassID(CLSID *pClsID);
146 /* IMediaFilter methods */
147 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
148 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
149 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
151 STDMETHODIMP Pause();
152 STDMETHODIMP Run(REFERENCE_TIME tStart);
154 /* IBaseFilter methods */
155 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
156 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
157 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
158 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
159 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
162 CapturePin *CustomGetPin();
165 /****************************************************************************
166 * Declaration of our dummy directshow enumpins class
167 ****************************************************************************/
168 class CaptureEnumPins : public IEnumPins
170 input_thread_t * p_input;
171 CaptureFilter *p_filter;
177 CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
178 CaptureEnumPins *pEnumPins );
179 virtual ~CaptureEnumPins();
182 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
183 STDMETHODIMP_(ULONG) AddRef();
184 STDMETHODIMP_(ULONG) Release();
187 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
188 STDMETHODIMP Skip( ULONG cPins );
189 STDMETHODIMP Reset();
190 STDMETHODIMP Clone( IEnumPins **ppEnum );
193 /****************************************************************************
194 * Declaration of our dummy directshow enummediatypes class
195 ****************************************************************************/
196 class CaptureEnumMediaTypes : public IEnumMediaTypes
198 input_thread_t * p_input;
205 CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
206 CaptureEnumMediaTypes *pEnumMediaTypes );
208 virtual ~CaptureEnumMediaTypes();
211 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
212 STDMETHODIMP_(ULONG) AddRef();
213 STDMETHODIMP_(ULONG) Release();
216 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
218 STDMETHODIMP Skip( ULONG cMediaTypes );
219 STDMETHODIMP Reset();
220 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );