1 /*****************************************************************************
2 * filter.c : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.cpp,v 1.6 2003/10/18 20:09:23 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}};
71 * MEDIATYPEs and MEDIASUBTYPEs
73 const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
75 /* Packed RGB formats */
76 const GUID MEDIASUBTYPE_RGB1 = {0xe436eb78, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
77 const GUID MEDIASUBTYPE_RGB4 = {0xe436eb79, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
78 const GUID MEDIASUBTYPE_RGB8 = {0xe436eb7a, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
79 const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
80 const GUID MEDIASUBTYPE_RGB555 = {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
81 const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
82 const GUID MEDIASUBTYPE_RGB32 = {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
83 const GUID MEDIASUBTYPE_ARGB32 = {0x773c9ac0, 0x3274, 0x11d0, {0xb7, 0x24, 0x0, 0xaa, 0x0, 0x6c, 0x1a, 0x1}};
85 /* Packed YUV formats */
86 const GUID MEDIASUBTYPE_YUYV = {0x56595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
87 const GUID MEDIASUBTYPE_Y411 = {0x31313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
88 const GUID MEDIASUBTYPE_Y211 = {0x31313259, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
89 const GUID MEDIASUBTYPE_YUY2 = {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
90 const GUID MEDIASUBTYPE_YVYU = {0x55595659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
91 const GUID MEDIASUBTYPE_UYVY = {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
93 /* Planar YUV formats */
94 const GUID MEDIASUBTYPE_YVU9 = {0x39555659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
95 const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
96 const GUID MEDIASUBTYPE_IYUV = {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; /* identical to YV12 */
97 const GUID MEDIASUBTYPE_Y41P = {0x50313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
98 const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
100 const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
101 const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
102 const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
103 const GUID MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
105 const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
107 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt )
109 if( mt.cbFormat != 0 )
111 CoTaskMemFree( (PVOID)mt.pbFormat );
115 if( mt.pUnk != NULL )
122 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
123 const AM_MEDIA_TYPE *pmtSource )
125 *pmtTarget = *pmtSource;
126 if( pmtSource->cbFormat != 0 )
128 pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat );
129 if( pmtTarget->pbFormat == NULL )
131 pmtTarget->cbFormat = 0;
132 return E_OUTOFMEMORY;
136 CopyMemory( (PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
137 pmtTarget->cbFormat );
140 if( pmtTarget->pUnk != NULL )
142 pmtTarget->pUnk->AddRef();
148 /****************************************************************************
149 * Implementation of our dummy directshow filter pin class
150 ****************************************************************************/
152 CapturePin::CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
154 : p_input( _p_input ), p_filter( _p_filter ), p_connected_pin( NULL ),
155 media_type( mt ), i_ref( 1 )
159 CapturePin::~CapturePin()
163 HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample )
165 if( samples_queue.size() )
167 *vlc_sample = samples_queue.back();
168 samples_queue.pop_back();
174 AM_MEDIA_TYPE CapturePin::CustomGetMediaType()
179 /* IUnknown methods */
180 STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
183 msg_Dbg( p_input, "CapturePin::QueryInterface" );
186 if( riid == IID_IUnknown ||
193 if( riid == IID_IMemInputPin )
196 *ppv = (IMemInputPin *)this;
202 return E_NOINTERFACE;
205 STDMETHODIMP_(ULONG) CapturePin::AddRef()
208 msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref );
213 STDMETHODIMP_(ULONG) CapturePin::Release()
216 msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref );
219 if( !InterlockedDecrement(&i_ref) ) delete this;
225 STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
226 const AM_MEDIA_TYPE *pmt )
229 msg_Dbg( p_input, "CapturePin::Connect" );
233 STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
234 const AM_MEDIA_TYPE *pmt )
237 msg_Dbg( p_input, "CapturePin::ReceiveConnection" );
240 if( pmt->majortype == MEDIATYPE_Video )
242 if( media_type.subtype != GUID_NULL &&
243 media_type.subtype != pmt->subtype )
244 return VFW_E_TYPE_NOT_ACCEPTED;
246 if( media_type.pbFormat &&
247 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight &&
248 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight !=
249 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight )
250 return VFW_E_TYPE_NOT_ACCEPTED;
252 if( media_type.pbFormat &&
253 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth &&
254 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth !=
255 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth )
256 return VFW_E_TYPE_NOT_ACCEPTED;
259 p_connected_pin = pConnector;
260 p_connected_pin->AddRef();
262 FreeMediaType( media_type );
263 return CopyMediaType( &media_type, pmt );
265 STDMETHODIMP CapturePin::Disconnect()
268 msg_Dbg( p_input, "CapturePin::Disconnect" );
271 p_connected_pin->Release();
272 p_connected_pin = NULL;
273 FreeMediaType( media_type );
276 STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
279 msg_Dbg( p_input, "CapturePin::ConnectedTo" );
282 if( !p_connected_pin ) return VFW_E_NOT_CONNECTED;
284 p_connected_pin->AddRef();
285 *pPin = p_connected_pin;
289 STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt )
292 msg_Dbg( p_input, "CapturePin::ConnectionMediaType" );
295 return CopyMediaType( pmt, &media_type );
297 STDMETHODIMP CapturePin::QueryPinInfo( PIN_INFO * pInfo )
300 msg_Dbg( p_input, "CapturePin::QueryPinInfo" );
303 pInfo->pFilter = p_filter;
304 if( p_filter ) p_filter->AddRef();
306 pInfo->achName[0] = L'\0';
308 pInfo->dir = PINDIR_INPUT;
312 STDMETHODIMP CapturePin::QueryDirection( PIN_DIRECTION * pPinDir )
315 msg_Dbg( p_input, "CapturePin::QueryDirection" );
318 *pPinDir = PINDIR_INPUT;
321 STDMETHODIMP CapturePin::QueryId( LPWSTR * Id )
324 msg_Dbg( p_input, "CapturePin::QueryId" );
328 STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
331 msg_Dbg( p_input, "CapturePin::QueryAccept" );
335 STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
338 msg_Dbg( p_input, "CapturePin::EnumMediaTypes" );
341 *ppEnum = new CaptureEnumMediaTypes( p_input, this, NULL );
343 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
347 STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin )
350 msg_Dbg( p_input, "CapturePin::QueryInternalConnections" );
354 STDMETHODIMP CapturePin::EndOfStream( void )
357 msg_Dbg( p_input, "CapturePin::EndOfStream" );
361 STDMETHODIMP CapturePin::BeginFlush( void )
364 msg_Dbg( p_input, "CapturePin::BeginFlush" );
368 STDMETHODIMP CapturePin::EndFlush( void )
371 msg_Dbg( p_input, "CapturePin::EndFlush" );
375 STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart,
376 REFERENCE_TIME tStop,
380 msg_Dbg( p_input, "CapturePin::NewSegment" );
385 /* IMemInputPin methods */
386 STDMETHODIMP CapturePin::GetAllocator( IMemAllocator **ppAllocator )
389 msg_Dbg( p_input, "CapturePin::GetAllocator" );
392 return VFW_E_NO_ALLOCATOR;
394 STDMETHODIMP CapturePin::NotifyAllocator( IMemAllocator *pAllocator,
398 msg_Dbg( p_input, "CapturePin::NotifyAllocator" );
403 STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps )
406 msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" );
411 STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
414 //msg_Dbg( p_input, "CapturePin::Receive" );
418 mtime_t i_timestamp = mdate() * 10;
419 VLCMediaSample vlc_sample = {pSample, i_timestamp};
421 access_sys_t *p_sys = p_input->p_access_data;
422 vlc_mutex_lock( &p_sys->lock );
423 samples_queue.push_front( vlc_sample );
425 /* Make sure we don't cache too many samples */
426 if( samples_queue.size() > 10 )
428 vlc_sample = samples_queue.back();
429 samples_queue.pop_back();
430 msg_Dbg( p_input, "CapturePin::Receive trashing late input sample" );
431 vlc_sample.p_sample->Release();
434 vlc_cond_signal( &p_sys->wait );
435 vlc_mutex_unlock( &p_sys->lock );
439 STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples,
441 long *nSamplesProcessed )
444 msg_Dbg( p_input, "CapturePin::ReceiveMultiple" );
449 *nSamplesProcessed = 0;
450 while( nSamples-- > 0 )
452 hr = Receive( pSamples[*nSamplesProcessed] );
453 if( hr != S_OK ) break;
454 (*nSamplesProcessed)++;
458 STDMETHODIMP CapturePin::ReceiveCanBlock( void )
461 msg_Dbg( p_input, "CapturePin::ReceiveCanBlock" );
464 return S_FALSE; /* Thou shalt not block */
467 /****************************************************************************
468 * Implementation of our dummy directshow filter class
469 ****************************************************************************/
471 CaptureFilter::CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt )
472 : p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt ) ),
473 media_type( mt ), i_ref( 1 )
477 CaptureFilter::~CaptureFilter()
482 /* IUnknown methods */
483 STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
486 msg_Dbg( p_input, "CaptureFilter::QueryInterface" );
489 if( riid == IID_IUnknown )
492 *ppv = (IUnknown *)this;
495 if( riid == IID_IPersist )
498 *ppv = (IPersist *)this;
501 if( riid == IID_IMediaFilter )
504 *ppv = (IMediaFilter *)this;
507 if( riid == IID_IBaseFilter )
510 *ppv = (IBaseFilter *)this;
516 return E_NOINTERFACE;
519 STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
522 msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref );
527 STDMETHODIMP_(ULONG) CaptureFilter::Release()
530 msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref );
533 if( !InterlockedDecrement(&i_ref) ) delete this;
538 /* IPersist method */
539 STDMETHODIMP CaptureFilter::GetClassID(CLSID *pClsID)
542 msg_Dbg( p_input, "CaptureFilter::GetClassID" );
547 /* IMediaFilter methods */
548 STDMETHODIMP CaptureFilter::GetState(DWORD dwMSecs, FILTER_STATE *State)
551 msg_Dbg( p_input, "CaptureFilter::GetStat" );
555 STDMETHODIMP CaptureFilter::SetSyncSource(IReferenceClock *pClock)
558 msg_Dbg( p_input, "CaptureFilter::SetSyncSource" );
563 STDMETHODIMP CaptureFilter::GetSyncSource(IReferenceClock **pClock)
566 msg_Dbg( p_input, "CaptureFilter::GetSyncSource" );
570 STDMETHODIMP CaptureFilter::Stop()
573 msg_Dbg( p_input, "CaptureFilter::Stop" );
577 STDMETHODIMP CaptureFilter::Pause()
580 msg_Dbg( p_input, "CaptureFilter::Pause" );
584 STDMETHODIMP CaptureFilter::Run(REFERENCE_TIME tStart)
587 msg_Dbg( p_input, "CaptureFilter::Run" );
592 /* IBaseFilter methods */
593 STDMETHODIMP CaptureFilter::EnumPins( IEnumPins ** ppEnum )
596 msg_Dbg( p_input, "CaptureFilter::EnumPins" );
599 /* Create a new ref counted enumerator */
600 *ppEnum = new CaptureEnumPins( p_input, this, NULL );
601 return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;
603 STDMETHODIMP CaptureFilter::FindPin( LPCWSTR Id, IPin ** ppPin )
606 msg_Dbg( p_input, "CaptureFilter::FindPin" );
610 STDMETHODIMP CaptureFilter::QueryFilterInfo( FILTER_INFO * pInfo )
613 msg_Dbg( p_input, "CaptureFilter::QueryFilterInfo" );
616 pInfo->achName[0] = L'\0';
618 pInfo->pGraph = p_graph;
619 if( p_graph ) p_graph->AddRef();
623 STDMETHODIMP CaptureFilter::JoinFilterGraph( IFilterGraph * pGraph,
627 msg_Dbg( p_input, "CaptureFilter::JoinFilterGraph" );
634 STDMETHODIMP CaptureFilter::QueryVendorInfo( LPWSTR* pVendorInfo )
637 msg_Dbg( p_input, "CaptureFilter::QueryVendorInfo" );
643 CapturePin *CaptureFilter::CustomGetPin()
648 /****************************************************************************
649 * Implementation of our dummy directshow enumpins class
650 ****************************************************************************/
652 CaptureEnumPins::CaptureEnumPins( input_thread_t * _p_input,
653 CaptureFilter *_p_filter,
654 CaptureEnumPins *pEnumPins )
655 : p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
657 /* Hold a reference count on our filter */
660 /* Are we creating a new enumerator */
662 if( pEnumPins == NULL )
668 i_position = pEnumPins->i_position;
672 CaptureEnumPins::~CaptureEnumPins()
677 /* IUnknown methods */
678 STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
681 msg_Dbg( p_input, "CaptureEnumPins::QueryInterface" );
684 if( riid == IID_IUnknown ||
685 riid == IID_IEnumPins )
688 *ppv = (IEnumPins *)this;
694 return E_NOINTERFACE;
697 STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
700 msg_Dbg( p_input, "CaptureEnumPins::AddRef (ref: %i)", i_ref );
705 STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
708 msg_Dbg( p_input, "CaptureEnumPins::Release (ref: %i)", i_ref );
711 if( !InterlockedDecrement(&i_ref) ) delete this;
717 STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
721 msg_Dbg( p_input, "CaptureEnumPins::Next" );
726 if( i_position < 1 && cPins > 0 )
728 IPin *pPin = p_filter->CustomGetPin();
735 return *pcFetched == cPins ? NOERROR : S_FALSE;
737 STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
740 msg_Dbg( p_input, "CaptureEnumPins::Skip" );
751 STDMETHODIMP CaptureEnumPins::Reset()
754 msg_Dbg( p_input, "CaptureEnumPins::Reset" );
760 STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
763 msg_Dbg( p_input, "CaptureEnumPins::Clone" );
766 *ppEnum = new CaptureEnumPins( p_input, p_filter, this );
767 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
772 /****************************************************************************
773 * Implementation of our dummy directshow enummediatypes class
774 ****************************************************************************/
776 CaptureEnumMediaTypes::CaptureEnumMediaTypes( input_thread_t * _p_input,
778 CaptureEnumMediaTypes *pEnumMediaTypes )
779 : p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
781 /* Hold a reference count on our filter */
784 /* Are we creating a new enumerator */
785 if( pEnumMediaTypes == NULL )
791 i_position = pEnumMediaTypes->i_position;
795 CaptureEnumMediaTypes::~CaptureEnumMediaTypes()
800 /* IUnknown methods */
801 STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
804 msg_Dbg( p_input, "CaptureEnumMediaTypes::QueryInterface" );
807 if( riid == IID_IUnknown ||
808 riid == IID_IEnumMediaTypes )
811 *ppv = (IEnumMediaTypes *)this;
817 return E_NOINTERFACE;
820 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
823 msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef (ref: %i)", i_ref );
828 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
831 msg_Dbg( p_input, "CaptureEnumMediaTypes::Release (ref: %i)", i_ref );
834 if( !InterlockedDecrement(&i_ref) ) delete this;
839 /* IEnumMediaTypes */
840 STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
841 AM_MEDIA_TYPE ** ppMediaTypes,
845 msg_Dbg( p_input, "CaptureEnumMediaTypes::Next" );
848 if( pcFetched ) *pcFetched = 0;
851 STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
854 msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
859 STDMETHODIMP CaptureEnumMediaTypes::Reset()
862 msg_Dbg( p_input, "CaptureEnumMediaTypes::Reset" );
868 STDMETHODIMP CaptureEnumMediaTypes::Clone( IEnumMediaTypes **ppEnum )
871 msg_Dbg( p_input, "CaptureEnumMediaTypes::Clone" );
874 *ppEnum = new CaptureEnumMediaTypes( p_input, p_pin, this );
875 if( *ppEnum == NULL ) return E_OUTOFMEMORY;