1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc:
3 * CapturePin, CaptureFilter, CaptureEnumPins implementations
4 *****************************************************************************
5 * Copyright (C) 2002-2004, 2008 VLC authors and VideoLAN
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
34 ComPtr
<IMediaSample
> p_sample
;
35 vlc_tick_t i_timestamp
;
39 void WINAPI
FreeMediaType( AM_MEDIA_TYPE
& mt
);
40 HRESULT WINAPI
CopyMediaType( AM_MEDIA_TYPE
*pmtTarget
,
41 const AM_MEDIA_TYPE
*pmtSource
);
43 int GetFourCCFromMediaType(const AM_MEDIA_TYPE
&media_type
);
45 /****************************************************************************
46 * Declaration of our dummy directshow filter pin class
47 ****************************************************************************/
49 class CapturePin
: public IPin
, public IMemInputPin
51 friend class CaptureEnumMediaTypes
;
53 vlc_object_t
*p_input
;
55 // Don't store this filter as a ComPtr to avoid a circular reference.
56 // p_filter is the parent filter, and already has a refcounter pointer to this CapturePin
58 CaptureFilter
* p_filter
;
60 ComPtr
<IPin
> p_connected_pin
;
62 AM_MEDIA_TYPE
*media_types
;
63 size_t media_type_count
;
65 AM_MEDIA_TYPE cx_media_type
;
67 std::deque
<VLCMediaSample
> samples_queue
;
72 CapturePin( vlc_object_t
*_p_input
, access_sys_t
*p_sys
,
73 CaptureFilter
* _p_filter
,
74 AM_MEDIA_TYPE
*mt
, size_t mt_count
);
76 /* IUnknown methods */
77 STDMETHODIMP
QueryInterface(REFIID riid
, void **ppv
);
78 STDMETHODIMP_(ULONG
) AddRef();
79 STDMETHODIMP_(ULONG
) Release();
82 STDMETHODIMP
Connect( IPin
* pReceivePin
, const AM_MEDIA_TYPE
*pmt
);
83 STDMETHODIMP
ReceiveConnection( IPin
* pConnector
,
84 const AM_MEDIA_TYPE
*pmt
);
85 STDMETHODIMP
Disconnect();
86 STDMETHODIMP
ConnectedTo( IPin
**pPin
);
87 STDMETHODIMP
ConnectionMediaType( AM_MEDIA_TYPE
*pmt
);
88 STDMETHODIMP
QueryPinInfo( PIN_INFO
* pInfo
);
89 STDMETHODIMP
QueryDirection( PIN_DIRECTION
* pPinDir
);
90 STDMETHODIMP
QueryId( LPWSTR
* Id
);
91 STDMETHODIMP
QueryAccept( const AM_MEDIA_TYPE
*pmt
);
92 STDMETHODIMP
EnumMediaTypes( IEnumMediaTypes
**ppEnum
);
93 STDMETHODIMP
QueryInternalConnections( IPin
* *apPin
, ULONG
*nPin
);
94 STDMETHODIMP
EndOfStream( void );
96 STDMETHODIMP
BeginFlush( void );
97 STDMETHODIMP
EndFlush( void );
98 STDMETHODIMP
NewSegment( REFERENCE_TIME tStart
, REFERENCE_TIME tStop
,
101 /* IMemInputPin methods */
102 STDMETHODIMP
GetAllocator( IMemAllocator
**ppAllocator
);
103 STDMETHODIMP
NotifyAllocator( IMemAllocator
*pAllocator
, BOOL bReadOnly
);
104 STDMETHODIMP
GetAllocatorRequirements( ALLOCATOR_PROPERTIES
*pProps
);
105 STDMETHODIMP
Receive( IMediaSample
*pSample
);
106 STDMETHODIMP
ReceiveMultiple( IMediaSample
**pSamples
, long nSamples
,
107 long *nSamplesProcessed
);
108 STDMETHODIMP
ReceiveCanBlock( void );
111 HRESULT
CustomGetSample( VLCMediaSample
* );
112 HRESULT
CustomGetSamples( std::deque
<VLCMediaSample
> &external_queue
);
114 AM_MEDIA_TYPE
&CustomGetMediaType();
117 virtual ~CapturePin();
120 /****************************************************************************
121 * Declaration of our dummy directshow filter class
122 ****************************************************************************/
123 class CaptureFilter
: public IBaseFilter
125 friend class CapturePin
;
127 vlc_object_t
*p_input
;
128 ComPtr
<CapturePin
> p_pin
;
129 ComPtr
<IFilterGraph
> p_graph
;
130 //AM_MEDIA_TYPE media_type;
136 CaptureFilter( vlc_object_t
*_p_input
, access_sys_t
*p_sys
,
137 AM_MEDIA_TYPE
*mt
, size_t mt_count
);
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 ComPtr
<CapturePin
>& CustomGetPin();
166 virtual ~CaptureFilter();
169 /****************************************************************************
170 * Declaration of our dummy directshow enumpins class
171 ****************************************************************************/
172 class CaptureEnumPins
: public IEnumPins
174 vlc_object_t
*p_input
;
175 ComPtr
<CaptureFilter
> p_filter
;
181 CaptureEnumPins( vlc_object_t
*_p_input
, ComPtr
<CaptureFilter
> _p_filter
,
182 ComPtr
<CaptureEnumPins
> pEnumPins
);
185 STDMETHODIMP
QueryInterface( REFIID riid
, void **ppv
);
186 STDMETHODIMP_(ULONG
) AddRef();
187 STDMETHODIMP_(ULONG
) Release();
190 STDMETHODIMP
Next( ULONG cPins
, IPin
** ppPins
, ULONG
* pcFetched
);
191 STDMETHODIMP
Skip( ULONG cPins
);
192 STDMETHODIMP
Reset();
193 STDMETHODIMP
Clone( IEnumPins
**ppEnum
);
196 virtual ~CaptureEnumPins();
199 /****************************************************************************
200 * Declaration of our dummy directshow enummediatypes class
201 ****************************************************************************/
202 class CaptureEnumMediaTypes
: public IEnumMediaTypes
204 vlc_object_t
*p_input
;
205 ComPtr
<CapturePin
> p_pin
;
206 AM_MEDIA_TYPE cx_media_type
;
212 CaptureEnumMediaTypes( vlc_object_t
*_p_input
, ComPtr
<CapturePin
> _p_pin
,
213 CaptureEnumMediaTypes
*pEnumMediaTypes
);
216 STDMETHODIMP
QueryInterface( REFIID riid
, void **ppv
);
217 STDMETHODIMP_(ULONG
) AddRef();
218 STDMETHODIMP_(ULONG
) Release();
221 STDMETHODIMP
Next( ULONG cMediaTypes
, AM_MEDIA_TYPE
** ppMediaTypes
,
223 STDMETHODIMP
Skip( ULONG cMediaTypes
);
224 STDMETHODIMP
Reset();
225 STDMETHODIMP
Clone( IEnumMediaTypes
**ppEnum
);
228 virtual ~CaptureEnumMediaTypes();