1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.h,v 1.1 2003/08/24 11:17:39 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 *****************************************************************************/
32 typedef struct VLCMediaSample
34 IMediaSample *p_sample;
41 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt );
42 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
43 const AM_MEDIA_TYPE *pmtSource );
45 /****************************************************************************
46 * Declaration of our dummy directshow filter pin class
47 ****************************************************************************/
48 class CapturePin: public IPin, public IMemInputPin
50 input_thread_t * p_input;
52 CaptureFilter *p_filter;
54 IPin *p_connected_pin;
55 AM_MEDIA_TYPE media_type;
57 deque<VLCMediaSample> samples_queue;
62 CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter );
63 virtual ~CapturePin();
65 /* IUnknown methods */
66 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
67 STDMETHODIMP_(ULONG) AddRef();
68 STDMETHODIMP_(ULONG) Release();
71 STDMETHODIMP Connect( IPin * pReceivePin, const AM_MEDIA_TYPE *pmt );
72 STDMETHODIMP ReceiveConnection( IPin * pConnector,
73 const AM_MEDIA_TYPE *pmt );
74 STDMETHODIMP Disconnect();
75 STDMETHODIMP ConnectedTo( IPin **pPin );
76 STDMETHODIMP ConnectionMediaType( AM_MEDIA_TYPE *pmt );
77 STDMETHODIMP QueryPinInfo( PIN_INFO * pInfo );
78 STDMETHODIMP QueryDirection( PIN_DIRECTION * pPinDir );
79 STDMETHODIMP QueryId( LPWSTR * Id );
80 STDMETHODIMP QueryAccept( const AM_MEDIA_TYPE *pmt );
81 STDMETHODIMP EnumMediaTypes( IEnumMediaTypes **ppEnum );
82 STDMETHODIMP QueryInternalConnections( IPin* *apPin, ULONG *nPin );
83 STDMETHODIMP EndOfStream( void );
85 STDMETHODIMP BeginFlush( void );
86 STDMETHODIMP EndFlush( void );
87 STDMETHODIMP NewSegment( REFERENCE_TIME tStart, REFERENCE_TIME tStop,
90 /* IMemInputPin methods */
91 STDMETHODIMP GetAllocator( IMemAllocator **ppAllocator );
92 STDMETHODIMP NotifyAllocator( IMemAllocator *pAllocator, BOOL bReadOnly );
93 STDMETHODIMP GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps );
94 STDMETHODIMP Receive( IMediaSample *pSample );
95 STDMETHODIMP ReceiveMultiple( IMediaSample **pSamples, long nSamples,
96 long *nSamplesProcessed );
97 STDMETHODIMP ReceiveCanBlock( void );
100 HRESULT CustomGetSample( VLCMediaSample * );
101 AM_MEDIA_TYPE CustomGetMediaType();
104 /****************************************************************************
105 * Declaration of our dummy directshow filter class
106 ****************************************************************************/
107 class CaptureFilter : public IBaseFilter
109 input_thread_t * p_input;
111 IFilterGraph * p_graph;
116 CaptureFilter( input_thread_t * _p_input );
117 virtual ~CaptureFilter();
119 /* IUnknown methods */
120 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
121 STDMETHODIMP_(ULONG) AddRef();
122 STDMETHODIMP_(ULONG) Release();
124 /* IPersist method */
125 STDMETHODIMP GetClassID(CLSID *pClsID);
127 /* IMediaFilter methods */
128 STDMETHODIMP GetState(DWORD dwMSecs, FILTER_STATE *State);
129 STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
130 STDMETHODIMP GetSyncSource(IReferenceClock **pClock);
132 STDMETHODIMP Pause();
133 STDMETHODIMP Run(REFERENCE_TIME tStart);
135 /* IBaseFilter methods */
136 STDMETHODIMP EnumPins( IEnumPins ** ppEnum );
137 STDMETHODIMP FindPin( LPCWSTR Id, IPin ** ppPin );
138 STDMETHODIMP QueryFilterInfo( FILTER_INFO * pInfo );
139 STDMETHODIMP JoinFilterGraph( IFilterGraph * pGraph, LPCWSTR pName );
140 STDMETHODIMP QueryVendorInfo( LPWSTR* pVendorInfo );
143 CapturePin *CustomGetPin();
146 /****************************************************************************
147 * Declaration of our dummy directshow enumpins class
148 ****************************************************************************/
149 class CaptureEnumPins : public IEnumPins
151 input_thread_t * p_input;
153 CaptureFilter *p_filter;
158 CaptureEnumPins( input_thread_t * _p_input, CaptureFilter *_p_filter,
159 CaptureEnumPins *pEnumPins );
160 virtual ~CaptureEnumPins();
163 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
164 STDMETHODIMP_(ULONG) AddRef();
165 STDMETHODIMP_(ULONG) Release();
168 STDMETHODIMP Next( ULONG cPins, IPin ** ppPins, ULONG * pcFetched );
169 STDMETHODIMP Skip( ULONG cPins );
170 STDMETHODIMP Reset();
171 STDMETHODIMP Clone( IEnumPins **ppEnum );
174 /****************************************************************************
175 * Declaration of our dummy directshow enummediatypes class
176 ****************************************************************************/
177 class CaptureEnumMediaTypes : public IEnumMediaTypes
179 input_thread_t * p_input;
186 CaptureEnumMediaTypes( input_thread_t * _p_input, CapturePin *_p_pin,
187 CaptureEnumMediaTypes *pEnumMediaTypes );
189 virtual ~CaptureEnumMediaTypes();
192 STDMETHODIMP QueryInterface( REFIID riid, void **ppv );
193 STDMETHODIMP_(ULONG) AddRef();
194 STDMETHODIMP_(ULONG) Release();
197 STDMETHODIMP Next( ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes,
199 STDMETHODIMP Skip( ULONG cMediaTypes );
200 STDMETHODIMP Reset();
201 STDMETHODIMP Clone( IEnumMediaTypes **ppEnum );