1 /*****************************************************************************
2 * filter.h : DirectShow access module for vlc:
3 * CapturePin, CaptureFilter, CaptureEnumPins implementations
4 *****************************************************************************
5 * Copyright (C) 2002-2004, 2008 the VideoLAN team
8 * Author: Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
45 # define _I64_MAX LONG_LONG_MAX
47 # define LONGLONG long long
51 #include "vlc_dshow.h"
53 typedef struct VLCMediaSample
55 IMediaSample
*p_sample
;
61 void WINAPI
FreeMediaType( AM_MEDIA_TYPE
& mt
);
62 HRESULT WINAPI
CopyMediaType( AM_MEDIA_TYPE
*pmtTarget
,
63 const AM_MEDIA_TYPE
*pmtSource
);
65 int GetFourCCFromMediaType(const AM_MEDIA_TYPE
&media_type
);
67 /****************************************************************************
68 * Declaration of our dummy directshow filter pin class
69 ****************************************************************************/
71 class CapturePin
: public IPin
, public IMemInputPin
73 friend class CaptureEnumMediaTypes
;
75 vlc_object_t
*p_input
;
77 CaptureFilter
*p_filter
;
79 IPin
*p_connected_pin
;
81 AM_MEDIA_TYPE
*media_types
;
82 size_t media_type_count
;
84 AM_MEDIA_TYPE cx_media_type
;
86 deque
<VLCMediaSample
> samples_queue
;
91 CapturePin( vlc_object_t
*_p_input
, access_sys_t
*p_sys
,
92 CaptureFilter
*_p_filter
,
93 AM_MEDIA_TYPE
*mt
, size_t mt_count
);
94 virtual ~CapturePin();
96 /* IUnknown methods */
97 STDMETHODIMP
QueryInterface(REFIID riid
, void **ppv
);
98 STDMETHODIMP_(ULONG
) AddRef();
99 STDMETHODIMP_(ULONG
) Release();
102 STDMETHODIMP
Connect( IPin
* pReceivePin
, const AM_MEDIA_TYPE
*pmt
);
103 STDMETHODIMP
ReceiveConnection( IPin
* pConnector
,
104 const AM_MEDIA_TYPE
*pmt
);
105 STDMETHODIMP
Disconnect();
106 STDMETHODIMP
ConnectedTo( IPin
**pPin
);
107 STDMETHODIMP
ConnectionMediaType( AM_MEDIA_TYPE
*pmt
);
108 STDMETHODIMP
QueryPinInfo( PIN_INFO
* pInfo
);
109 STDMETHODIMP
QueryDirection( PIN_DIRECTION
* pPinDir
);
110 STDMETHODIMP
QueryId( LPWSTR
* Id
);
111 STDMETHODIMP
QueryAccept( const AM_MEDIA_TYPE
*pmt
);
112 STDMETHODIMP
EnumMediaTypes( IEnumMediaTypes
**ppEnum
);
113 STDMETHODIMP
QueryInternalConnections( IPin
* *apPin
, ULONG
*nPin
);
114 STDMETHODIMP
EndOfStream( void );
116 STDMETHODIMP
BeginFlush( void );
117 STDMETHODIMP
EndFlush( void );
118 STDMETHODIMP
NewSegment( REFERENCE_TIME tStart
, REFERENCE_TIME tStop
,
121 /* IMemInputPin methods */
122 STDMETHODIMP
GetAllocator( IMemAllocator
**ppAllocator
);
123 STDMETHODIMP
NotifyAllocator( IMemAllocator
*pAllocator
, BOOL bReadOnly
);
124 STDMETHODIMP
GetAllocatorRequirements( ALLOCATOR_PROPERTIES
*pProps
);
125 STDMETHODIMP
Receive( IMediaSample
*pSample
);
126 STDMETHODIMP
ReceiveMultiple( IMediaSample
**pSamples
, long nSamples
,
127 long *nSamplesProcessed
);
128 STDMETHODIMP
ReceiveCanBlock( void );
131 HRESULT
CustomGetSample( VLCMediaSample
* );
132 HRESULT
CustomGetSamples( deque
<VLCMediaSample
> &external_queue
);
134 AM_MEDIA_TYPE
&CustomGetMediaType();
137 /****************************************************************************
138 * Declaration of our dummy directshow filter class
139 ****************************************************************************/
140 class CaptureFilter
: public IBaseFilter
142 friend class CapturePin
;
144 vlc_object_t
*p_input
;
146 IFilterGraph
*p_graph
;
147 //AM_MEDIA_TYPE media_type;
153 CaptureFilter( vlc_object_t
*_p_input
, access_sys_t
*p_sys
,
154 AM_MEDIA_TYPE
*mt
, size_t mt_count
);
155 virtual ~CaptureFilter();
157 /* IUnknown methods */
158 STDMETHODIMP
QueryInterface(REFIID riid
, void **ppv
);
159 STDMETHODIMP_(ULONG
) AddRef();
160 STDMETHODIMP_(ULONG
) Release();
162 /* IPersist method */
163 STDMETHODIMP
GetClassID(CLSID
*pClsID
);
165 /* IMediaFilter methods */
166 STDMETHODIMP
GetState(DWORD dwMSecs
, FILTER_STATE
*State
);
167 STDMETHODIMP
SetSyncSource(IReferenceClock
*pClock
);
168 STDMETHODIMP
GetSyncSource(IReferenceClock
**pClock
);
170 STDMETHODIMP
Pause();
171 STDMETHODIMP
Run(REFERENCE_TIME tStart
);
173 /* IBaseFilter methods */
174 STDMETHODIMP
EnumPins( IEnumPins
** ppEnum
);
175 STDMETHODIMP
FindPin( LPCWSTR Id
, IPin
** ppPin
);
176 STDMETHODIMP
QueryFilterInfo( FILTER_INFO
* pInfo
);
177 STDMETHODIMP
JoinFilterGraph( IFilterGraph
* pGraph
, LPCWSTR pName
);
178 STDMETHODIMP
QueryVendorInfo( LPWSTR
* pVendorInfo
);
181 CapturePin
*CustomGetPin();
184 /****************************************************************************
185 * Declaration of our dummy directshow enumpins class
186 ****************************************************************************/
187 class CaptureEnumPins
: public IEnumPins
189 vlc_object_t
*p_input
;
190 CaptureFilter
*p_filter
;
196 CaptureEnumPins( vlc_object_t
*_p_input
, CaptureFilter
*_p_filter
,
197 CaptureEnumPins
*pEnumPins
);
198 virtual ~CaptureEnumPins();
201 STDMETHODIMP
QueryInterface( REFIID riid
, void **ppv
);
202 STDMETHODIMP_(ULONG
) AddRef();
203 STDMETHODIMP_(ULONG
) Release();
206 STDMETHODIMP
Next( ULONG cPins
, IPin
** ppPins
, ULONG
* pcFetched
);
207 STDMETHODIMP
Skip( ULONG cPins
);
208 STDMETHODIMP
Reset();
209 STDMETHODIMP
Clone( IEnumPins
**ppEnum
);
212 /****************************************************************************
213 * Declaration of our dummy directshow enummediatypes class
214 ****************************************************************************/
215 class CaptureEnumMediaTypes
: public IEnumMediaTypes
217 vlc_object_t
*p_input
;
219 AM_MEDIA_TYPE cx_media_type
;
225 CaptureEnumMediaTypes( vlc_object_t
*_p_input
, CapturePin
*_p_pin
,
226 CaptureEnumMediaTypes
*pEnumMediaTypes
);
228 virtual ~CaptureEnumMediaTypes();
231 STDMETHODIMP
QueryInterface( REFIID riid
, void **ppv
);
232 STDMETHODIMP_(ULONG
) AddRef();
233 STDMETHODIMP_(ULONG
) Release();
236 STDMETHODIMP
Next( ULONG cMediaTypes
, AM_MEDIA_TYPE
** ppMediaTypes
,
238 STDMETHODIMP
Skip( ULONG cMediaTypes
);
239 STDMETHODIMP
Reset();
240 STDMETHODIMP
Clone( IEnumMediaTypes
**ppEnum
);