1 /*****************************************************************************
2 * filter.c : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.cpp,v 1.9 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 *****************************************************************************/
32 #include <vlc/input.h>
45 /*****************************************************************************
47 * Easier to define them hear as mingw doesn't provide them all.
48 *****************************************************************************/
49 const GUID CLSID_SystemDeviceEnum = {0x62be5d10, 0x60eb, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
50 const GUID CLSID_VideoInputDeviceCategory = {0x860BB310,0x5D01,0x11d0,{0xBD,0x3B,0x00,0xA0,0xC9,0x11,0xCE,0x86}};
51 const GUID CLSID_AudioInputDeviceCategory = {0x33d9a762, 0x90c8, 0x11d0, {0xbd, 0x43, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
52 const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}};
53 const GUID IID_ICreateDevEnum = {0x29840822, 0x5b84, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
54 const GUID IID_IFilterGraph = {0x56a8689f, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
55 const GUID IID_IMediaControl = {0x56a868b1, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
56 const GUID CLSID_FilterGraph = {0xe436ebb3, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
58 const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
59 const GUID IID_IPersist = {0x0000010c, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
60 const GUID IID_IMediaFilter = {0x56a86899, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
61 const GUID IID_IBaseFilter = {0x56a86895, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
62 const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
63 const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
65 const GUID IID_IEnumPins = {0x56a86892, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
66 const GUID IID_IEnumMediaTypes = {0x89c31040, 0x846b, 0x11ce, {0x97,0xd3, 0x00,0xaa,0x00,0x55,0x59,0x5a}};
68 const GUID IID_IAMBufferNegotiation = {0x56ed71a0, 0xaf5f, 0x11d0, {0xb3, 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5}};
70 const GUID IID_ISpecifyPropertyPages = {0xb196b28b, 0xbab4, 0x101a, {0xb6, 0x9c, 0x00, 0xaa, 0x00, 0x34, 0x1d, 0x07}};
73 * MEDIATYPEs and MEDIASUBTYPEs
75 const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
76 const GUID MEDIASUBTYPE_PREVIEW_VIDEO = {0x2859e1da, 0xb81f, 0x4fbd, {0x94, 0x3b, 0xe2, 0x37, 0x24, 0xa1, 0xab, 0xb3}};
77 const GUID MEDIATYPE_Stream = {0xe436eb83, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
79 /* Packed RGB formats */
80 const GUID MEDIASUBTYPE_RGB1 = {0xe436eb78, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
81 const GUID MEDIASUBTYPE_RGB4 = {0xe436eb79, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
82 const GUID MEDIASUBTYPE_RGB8 = {0xe436eb7a, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
83 const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
84 const GUID MEDIASUBTYPE_RGB555 = {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
85 const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
86 const GUID MEDIASUBTYPE_RGB32 = {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
87 const GUID MEDIASUBTYPE_ARGB32 = {0x773c9ac0, 0x3274, 0x11d0, {0xb7, 0x24, 0x0, 0xaa, 0x0, 0x6c, 0x1a, 0x1}};
89 /* Packed YUV formats */
90 const GUID MEDIASUBTYPE_YUYV = {0x56595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
91 const GUID MEDIASUBTYPE_Y411 = {0x31313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
92 const GUID MEDIASUBTYPE_Y211 = {0x31313259, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
93 const GUID MEDIASUBTYPE_YUY2 = {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
94 const GUID MEDIASUBTYPE_YVYU = {0x55595659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
95 const GUID MEDIASUBTYPE_UYVY = {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
97 /* Planar YUV formats */
98 const GUID MEDIASUBTYPE_YVU9 = {0x39555659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
99 const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
100 const GUID MEDIASUBTYPE_IYUV = {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; /* identical to YV12 */
101 const GUID MEDIASUBTYPE_Y41P = {0x50313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
102 const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
104 const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
105 const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
106 const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
107 const GUID MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
110 const GUID MEDIASUBTYPE_dvsd = {0x64737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
111 const GUID MEDIASUBTYPE_dvhd = {0x64687664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
112 const GUID MEDIASUBTYPE_dvsl = {0x6c737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
115 const GUID MEDIASUBTYPE_MPEG2_VIDEO = {0xe06d8026, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
116 const GUID MEDIASUBTYPE_MPEG2_PROGRAM = {0xe06d8022, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
117 const GUID MEDIASUBTYPE_MPEG2_TRANSPORT = {0xe06d8023, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
118 const GUID FORMAT_MPEG2Video = {0xe06d80e3, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
120 const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
122 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt )
124 if( mt.cbFormat != 0 )
126 CoTaskMemFree( (PVOID)mt.pbFormat );
130 if( mt.pUnk != NULL )
137 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
138 const AM_MEDIA_TYPE *pmtSource )
140 *pmtTarget = *pmtSource;
141 if( pmtSource->cbFormat != 0 )
143 pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat );
144 if( pmtTarget->pbFormat == NULL )
146 pmtTarget->cbFormat = 0;
147 return E_OUTOFMEMORY;
151 CopyMemory( (PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
152 pmtTarget->cbFormat );
155 if( pmtTarget->pUnk != NULL )
157 pmtTarget->pUnk->AddRef();
163 /****************************************************************************
164 * Implementation of our dummy directshow filter pin class
165 ****************************************************************************/
167 CapturePin::CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
169 : p_input( _p_input ), p_filter( _p_filter ), p_connected_pin( NULL ),
170 media_type( mt ), i_ref( 1 )
174 CapturePin::~CapturePin()
178 HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample )
180 if( samples_queue.size() )
182 *vlc_sample = samples_queue.back();
183 samples_queue.pop_back();
189 AM_MEDIA_TYPE CapturePin::CustomGetMediaType()
194 /* IUnknown methods */
195 STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
198 msg_Dbg( p_input, "CapturePin::QueryInterface" );
201 if( riid == IID_IUnknown ||
208 if( riid == IID_IMemInputPin )
211 *ppv = (IMemInputPin *)this;
217 return E_NOINTERFACE;
220 STDMETHODIMP_(ULONG) CapturePin::AddRef()
223 msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref );
228 STDMETHODIMP_(ULONG) CapturePin::Release()
231 msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref );
234 if( !InterlockedDecrement(&i_ref) ) delete this;
240 STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
241 const AM_MEDIA_TYPE *pmt )
244 msg_Dbg( p_input, "CapturePin::Connect" );
248 STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
249 const AM_MEDIA_TYPE *pmt )
252 msg_Dbg( p_input, "CapturePin::ReceiveConnection" );
255 if( pmt->majortype == MEDIATYPE_Video )
257 if( media_type.subtype != GUID_NULL &&
258 media_type.subtype != pmt->subtype )
259 return VFW_E_TYPE_NOT_ACCEPTED;
261 if( media_type.pbFormat &&
262 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight &&
263 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight !=
264 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight )
265 return VFW_E_TYPE_NOT_ACCEPTED;
267 if( media_type.pbFormat &&
268 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth &&
269 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth !=
270 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth )
271 return VFW_E_TYPE_NOT_ACCEPTED;
274 p_connected_pin = pConnector;
275 p_connected_pin->AddRef();
277 FreeMediaType( media_type );
278 return CopyMediaType( &media_type, pmt );
280 STDMETHODIMP CapturePin::Disconnect()
283 msg_Dbg( p_input, "CapturePin::Disconnect" );
286 p_connected_pin->Release();
287 p_connected_pin = NULL;
288 FreeMediaType( media_type );
291 STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
294 msg_Dbg( p_input, "CapturePin::ConnectedTo" );
297 if( !p_connected_pin ) return VFW_E_NOT_CONNECTED;
299 p_connected_pin->AddRef();
300 *pPin = p_connected_pin;
304 STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt )
307 msg_Dbg( p_input, "CapturePin::ConnectionMediaType" );
310 return CopyMediaType( pmt, &media_type );
312 STDMETHODIMP CapturePin::QueryPinInfo( PIN_INFO * pInfo )
315 msg_Dbg( p_input, "CapturePin::QueryPinInfo" );
318 pInfo->pFilter = p_filter;
319 if( p_filter ) p_filter->AddRef();
321 pInfo->achName[0] = L'\0';
323 pInfo->dir = PINDIR_INPUT;
327 STDMETHODIMP CapturePin::QueryDirection( PIN_DIRECTION * pPinDir )
330 msg_Dbg( p_input, "CapturePin::QueryDirection" );
333 *pPinDir = PINDIR_INPUT;
336 STDMETHODIMP CapturePin::QueryId( LPWSTR * Id )
339 msg_Dbg( p_input, "CapturePin::QueryId" );
343 STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
346 msg_Dbg( p_input, "CapturePin::QueryAccept" );
350 STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
353 msg_Dbg( p_input, "CapturePin::EnumMediaTypes" );
356 *ppEnum = new CaptureEnumMediaTypes( p_input, this, NULL );
358 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
362 STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin )
365 msg_Dbg( p_input, "CapturePin::QueryInternalConnections" );
369 STDMETHODIMP CapturePin::EndOfStream( void )
372 msg_Dbg( p_input, "CapturePin::EndOfStream" );
376 STDMETHODIMP CapturePin::BeginFlush( void )
379 msg_Dbg( p_input, "CapturePin::BeginFlush" );
383 STDMETHODIMP CapturePin::EndFlush( void )
386 msg_Dbg( p_input, "CapturePin::EndFlush" );
390 STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart,
391 REFERENCE_TIME tStop,
395 msg_Dbg( p_input, "CapturePin::NewSegment" );
400 /* IMemInputPin methods */
401 STDMETHODIMP CapturePin::GetAllocator( IMemAllocator **ppAllocator )
404 msg_Dbg( p_input, "CapturePin::GetAllocator" );
407 return VFW_E_NO_ALLOCATOR;
409 STDMETHODIMP CapturePin::NotifyAllocator( IMemAllocator *pAllocator,
413 msg_Dbg( p_input, "CapturePin::NotifyAllocator" );
418 STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps )
421 msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" );
426 STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
429 //msg_Dbg( p_input, "CapturePin::Receive" );
433 mtime_t i_timestamp = mdate() * 10;
434 VLCMediaSample vlc_sample = {pSample, i_timestamp};
436 access_sys_t *p_sys = p_input->p_access_data;
437 vlc_mutex_lock( &p_sys->lock );
438 samples_queue.push_front( vlc_sample );
440 /* Make sure we don't cache too many samples */
441 if( samples_queue.size() > 10 )
443 vlc_sample = samples_queue.back();
444 samples_queue.pop_back();
445 msg_Dbg( p_input, "CapturePin::Receive trashing late input sample" );
446 vlc_sample.p_sample->Release();
449 vlc_cond_signal( &p_sys->wait );
450 vlc_mutex_unlock( &p_sys->lock );
454 STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples,
456 long *nSamplesProcessed )
459 msg_Dbg( p_input, "CapturePin::ReceiveMultiple" );
464 *nSamplesProcessed = 0;
465 while( nSamples-- > 0 )
467 hr = Receive( pSamples[*nSamplesProcessed] );
468 if( hr != S_OK ) break;
469 (*nSamplesProcessed)++;
473 STDMETHODIMP CapturePin::ReceiveCanBlock( void )
476 msg_Dbg( p_input, "CapturePin::ReceiveCanBlock" );
479 return S_FALSE; /* Thou shalt not block */
482 /****************************************************************************
483 * Implementation of our dummy directshow filter class
484 ****************************************************************************/
486 CaptureFilter::CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt )
487 : p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt ) ),
488 media_type( mt ), i_ref( 1 )
492 CaptureFilter::~CaptureFilter()
497 /* IUnknown methods */
498 STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
501 msg_Dbg( p_input, "CaptureFilter::QueryInterface" );
504 if( riid == IID_IUnknown )
507 *ppv = (IUnknown *)this;
510 if( riid == IID_IPersist )
513 *ppv = (IPersist *)this;
516 if( riid == IID_IMediaFilter )
519 *ppv = (IMediaFilter *)this;
522 if( riid == IID_IBaseFilter )
525 *ppv = (IBaseFilter *)this;
531 return E_NOINTERFACE;
534 STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
537 msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref );
542 STDMETHODIMP_(ULONG) CaptureFilter::Release()
545 msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref );
548 if( !InterlockedDecrement(&i_ref) ) delete this;
553 /* IPersist method */
554 STDMETHODIMP CaptureFilter::GetClassID(CLSID *pClsID)
557 msg_Dbg( p_input, "CaptureFilter::GetClassID" );
562 /* IMediaFilter methods */
563 STDMETHODIMP CaptureFilter::GetState(DWORD dwMSecs, FILTER_STATE *State)
566 msg_Dbg( p_input, "CaptureFilter::GetStat" );
570 STDMETHODIMP CaptureFilter::SetSyncSource(IReferenceClock *pClock)
573 msg_Dbg( p_input, "CaptureFilter::SetSyncSource" );
578 STDMETHODIMP CaptureFilter::GetSyncSource(IReferenceClock **pClock)
581 msg_Dbg( p_input, "CaptureFilter::GetSyncSource" );
587 STDMETHODIMP CaptureFilter::Stop()
590 msg_Dbg( p_input, "CaptureFilter::Stop" );
594 STDMETHODIMP CaptureFilter::Pause()
597 msg_Dbg( p_input, "CaptureFilter::Pause" );
601 STDMETHODIMP CaptureFilter::Run(REFERENCE_TIME tStart)
604 msg_Dbg( p_input, "CaptureFilter::Run" );
609 /* IBaseFilter methods */
610 STDMETHODIMP CaptureFilter::EnumPins( IEnumPins ** ppEnum )
613 msg_Dbg( p_input, "CaptureFilter::EnumPins" );
616 /* Create a new ref counted enumerator */
617 *ppEnum = new CaptureEnumPins( p_input, this, NULL );
618 return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;
620 STDMETHODIMP CaptureFilter::FindPin( LPCWSTR Id, IPin ** ppPin )
623 msg_Dbg( p_input, "CaptureFilter::FindPin" );
627 STDMETHODIMP CaptureFilter::QueryFilterInfo( FILTER_INFO * pInfo )
630 msg_Dbg( p_input, "CaptureFilter::QueryFilterInfo" );
633 pInfo->achName[0] = L'\0';
635 pInfo->pGraph = p_graph;
636 if( p_graph ) p_graph->AddRef();
640 STDMETHODIMP CaptureFilter::JoinFilterGraph( IFilterGraph * pGraph,
644 msg_Dbg( p_input, "CaptureFilter::JoinFilterGraph" );
651 STDMETHODIMP CaptureFilter::QueryVendorInfo( LPWSTR* pVendorInfo )
654 msg_Dbg( p_input, "CaptureFilter::QueryVendorInfo" );
660 CapturePin *CaptureFilter::CustomGetPin()
665 /****************************************************************************
666 * Implementation of our dummy directshow enumpins class
667 ****************************************************************************/
669 CaptureEnumPins::CaptureEnumPins( input_thread_t * _p_input,
670 CaptureFilter *_p_filter,
671 CaptureEnumPins *pEnumPins )
672 : p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
674 /* Hold a reference count on our filter */
677 /* Are we creating a new enumerator */
679 if( pEnumPins == NULL )
685 i_position = pEnumPins->i_position;
689 CaptureEnumPins::~CaptureEnumPins()
694 /* IUnknown methods */
695 STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
698 msg_Dbg( p_input, "CaptureEnumPins::QueryInterface" );
701 if( riid == IID_IUnknown ||
702 riid == IID_IEnumPins )
705 *ppv = (IEnumPins *)this;
711 return E_NOINTERFACE;
714 STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
717 msg_Dbg( p_input, "CaptureEnumPins::AddRef (ref: %i)", i_ref );
722 STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
725 msg_Dbg( p_input, "CaptureEnumPins::Release (ref: %i)", i_ref );
728 if( !InterlockedDecrement(&i_ref) ) delete this;
734 STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
738 msg_Dbg( p_input, "CaptureEnumPins::Next" );
743 if( i_position < 1 && cPins > 0 )
745 IPin *pPin = p_filter->CustomGetPin();
752 return *pcFetched == cPins ? NOERROR : S_FALSE;
754 STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
757 msg_Dbg( p_input, "CaptureEnumPins::Skip" );
768 STDMETHODIMP CaptureEnumPins::Reset()
771 msg_Dbg( p_input, "CaptureEnumPins::Reset" );
777 STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
780 msg_Dbg( p_input, "CaptureEnumPins::Clone" );
783 *ppEnum = new CaptureEnumPins( p_input, p_filter, this );
784 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
789 /****************************************************************************
790 * Implementation of our dummy directshow enummediatypes class
791 ****************************************************************************/
793 CaptureEnumMediaTypes::CaptureEnumMediaTypes( input_thread_t * _p_input,
795 CaptureEnumMediaTypes *pEnumMediaTypes )
796 : p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
798 /* Hold a reference count on our filter */
801 /* Are we creating a new enumerator */
802 if( pEnumMediaTypes == NULL )
808 i_position = pEnumMediaTypes->i_position;
812 CaptureEnumMediaTypes::~CaptureEnumMediaTypes()
817 /* IUnknown methods */
818 STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
821 msg_Dbg( p_input, "CaptureEnumMediaTypes::QueryInterface" );
824 if( riid == IID_IUnknown ||
825 riid == IID_IEnumMediaTypes )
828 *ppv = (IEnumMediaTypes *)this;
834 return E_NOINTERFACE;
837 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
840 msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef (ref: %i)", i_ref );
845 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
848 msg_Dbg( p_input, "CaptureEnumMediaTypes::Release (ref: %i)", i_ref );
851 if( !InterlockedDecrement(&i_ref) ) delete this;
856 /* IEnumMediaTypes */
857 STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
858 AM_MEDIA_TYPE ** ppMediaTypes,
862 msg_Dbg( p_input, "CaptureEnumMediaTypes::Next" );
865 if( pcFetched ) *pcFetched = 0;
868 STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
871 msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
876 STDMETHODIMP CaptureEnumMediaTypes::Reset()
879 msg_Dbg( p_input, "CaptureEnumMediaTypes::Reset" );
885 STDMETHODIMP CaptureEnumMediaTypes::Clone( IEnumMediaTypes **ppEnum )
888 msg_Dbg( p_input, "CaptureEnumMediaTypes::Clone" );
891 *ppEnum = new CaptureEnumMediaTypes( p_input, p_pin, this );
892 if( *ppEnum == NULL ) return E_OUTOFMEMORY;