1 /*****************************************************************************
2 * filter.c : DirectShow access module for vlc
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: filter.cpp,v 1.8 2003/11/24 20:45: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}};
106 const GUID MEDIASUBTYPE_dvsd = {0x64737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
107 const GUID MEDIASUBTYPE_dvhd = {0x64687664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
108 const GUID MEDIASUBTYPE_dvsl = {0x6c737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
110 const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
112 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt )
114 if( mt.cbFormat != 0 )
116 CoTaskMemFree( (PVOID)mt.pbFormat );
120 if( mt.pUnk != NULL )
127 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
128 const AM_MEDIA_TYPE *pmtSource )
130 *pmtTarget = *pmtSource;
131 if( pmtSource->cbFormat != 0 )
133 pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat );
134 if( pmtTarget->pbFormat == NULL )
136 pmtTarget->cbFormat = 0;
137 return E_OUTOFMEMORY;
141 CopyMemory( (PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
142 pmtTarget->cbFormat );
145 if( pmtTarget->pUnk != NULL )
147 pmtTarget->pUnk->AddRef();
153 /****************************************************************************
154 * Implementation of our dummy directshow filter pin class
155 ****************************************************************************/
157 CapturePin::CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
159 : p_input( _p_input ), p_filter( _p_filter ), p_connected_pin( NULL ),
160 media_type( mt ), i_ref( 1 )
164 CapturePin::~CapturePin()
168 HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample )
170 if( samples_queue.size() )
172 *vlc_sample = samples_queue.back();
173 samples_queue.pop_back();
179 AM_MEDIA_TYPE CapturePin::CustomGetMediaType()
184 /* IUnknown methods */
185 STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
188 msg_Dbg( p_input, "CapturePin::QueryInterface" );
191 if( riid == IID_IUnknown ||
198 if( riid == IID_IMemInputPin )
201 *ppv = (IMemInputPin *)this;
207 return E_NOINTERFACE;
210 STDMETHODIMP_(ULONG) CapturePin::AddRef()
213 msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref );
218 STDMETHODIMP_(ULONG) CapturePin::Release()
221 msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref );
224 if( !InterlockedDecrement(&i_ref) ) delete this;
230 STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
231 const AM_MEDIA_TYPE *pmt )
234 msg_Dbg( p_input, "CapturePin::Connect" );
238 STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
239 const AM_MEDIA_TYPE *pmt )
242 msg_Dbg( p_input, "CapturePin::ReceiveConnection" );
245 if( pmt->majortype == MEDIATYPE_Video )
247 if( media_type.subtype != GUID_NULL &&
248 media_type.subtype != pmt->subtype )
249 return VFW_E_TYPE_NOT_ACCEPTED;
251 if( media_type.pbFormat &&
252 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight &&
253 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight !=
254 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight )
255 return VFW_E_TYPE_NOT_ACCEPTED;
257 if( media_type.pbFormat &&
258 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth &&
259 ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth !=
260 ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth )
261 return VFW_E_TYPE_NOT_ACCEPTED;
264 p_connected_pin = pConnector;
265 p_connected_pin->AddRef();
267 FreeMediaType( media_type );
268 return CopyMediaType( &media_type, pmt );
270 STDMETHODIMP CapturePin::Disconnect()
273 msg_Dbg( p_input, "CapturePin::Disconnect" );
276 p_connected_pin->Release();
277 p_connected_pin = NULL;
278 FreeMediaType( media_type );
281 STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
284 msg_Dbg( p_input, "CapturePin::ConnectedTo" );
287 if( !p_connected_pin ) return VFW_E_NOT_CONNECTED;
289 p_connected_pin->AddRef();
290 *pPin = p_connected_pin;
294 STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt )
297 msg_Dbg( p_input, "CapturePin::ConnectionMediaType" );
300 return CopyMediaType( pmt, &media_type );
302 STDMETHODIMP CapturePin::QueryPinInfo( PIN_INFO * pInfo )
305 msg_Dbg( p_input, "CapturePin::QueryPinInfo" );
308 pInfo->pFilter = p_filter;
309 if( p_filter ) p_filter->AddRef();
311 pInfo->achName[0] = L'\0';
313 pInfo->dir = PINDIR_INPUT;
317 STDMETHODIMP CapturePin::QueryDirection( PIN_DIRECTION * pPinDir )
320 msg_Dbg( p_input, "CapturePin::QueryDirection" );
323 *pPinDir = PINDIR_INPUT;
326 STDMETHODIMP CapturePin::QueryId( LPWSTR * Id )
329 msg_Dbg( p_input, "CapturePin::QueryId" );
333 STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
336 msg_Dbg( p_input, "CapturePin::QueryAccept" );
340 STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
343 msg_Dbg( p_input, "CapturePin::EnumMediaTypes" );
346 *ppEnum = new CaptureEnumMediaTypes( p_input, this, NULL );
348 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
352 STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin )
355 msg_Dbg( p_input, "CapturePin::QueryInternalConnections" );
359 STDMETHODIMP CapturePin::EndOfStream( void )
362 msg_Dbg( p_input, "CapturePin::EndOfStream" );
366 STDMETHODIMP CapturePin::BeginFlush( void )
369 msg_Dbg( p_input, "CapturePin::BeginFlush" );
373 STDMETHODIMP CapturePin::EndFlush( void )
376 msg_Dbg( p_input, "CapturePin::EndFlush" );
380 STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart,
381 REFERENCE_TIME tStop,
385 msg_Dbg( p_input, "CapturePin::NewSegment" );
390 /* IMemInputPin methods */
391 STDMETHODIMP CapturePin::GetAllocator( IMemAllocator **ppAllocator )
394 msg_Dbg( p_input, "CapturePin::GetAllocator" );
397 return VFW_E_NO_ALLOCATOR;
399 STDMETHODIMP CapturePin::NotifyAllocator( IMemAllocator *pAllocator,
403 msg_Dbg( p_input, "CapturePin::NotifyAllocator" );
408 STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps )
411 msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" );
416 STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
419 //msg_Dbg( p_input, "CapturePin::Receive" );
423 mtime_t i_timestamp = mdate() * 10;
424 VLCMediaSample vlc_sample = {pSample, i_timestamp};
426 access_sys_t *p_sys = p_input->p_access_data;
427 vlc_mutex_lock( &p_sys->lock );
428 samples_queue.push_front( vlc_sample );
430 /* Make sure we don't cache too many samples */
431 if( samples_queue.size() > 10 )
433 vlc_sample = samples_queue.back();
434 samples_queue.pop_back();
435 msg_Dbg( p_input, "CapturePin::Receive trashing late input sample" );
436 vlc_sample.p_sample->Release();
439 vlc_cond_signal( &p_sys->wait );
440 vlc_mutex_unlock( &p_sys->lock );
444 STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples,
446 long *nSamplesProcessed )
449 msg_Dbg( p_input, "CapturePin::ReceiveMultiple" );
454 *nSamplesProcessed = 0;
455 while( nSamples-- > 0 )
457 hr = Receive( pSamples[*nSamplesProcessed] );
458 if( hr != S_OK ) break;
459 (*nSamplesProcessed)++;
463 STDMETHODIMP CapturePin::ReceiveCanBlock( void )
466 msg_Dbg( p_input, "CapturePin::ReceiveCanBlock" );
469 return S_FALSE; /* Thou shalt not block */
472 /****************************************************************************
473 * Implementation of our dummy directshow filter class
474 ****************************************************************************/
476 CaptureFilter::CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt )
477 : p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt ) ),
478 media_type( mt ), i_ref( 1 )
482 CaptureFilter::~CaptureFilter()
487 /* IUnknown methods */
488 STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
491 msg_Dbg( p_input, "CaptureFilter::QueryInterface" );
494 if( riid == IID_IUnknown )
497 *ppv = (IUnknown *)this;
500 if( riid == IID_IPersist )
503 *ppv = (IPersist *)this;
506 if( riid == IID_IMediaFilter )
509 *ppv = (IMediaFilter *)this;
512 if( riid == IID_IBaseFilter )
515 *ppv = (IBaseFilter *)this;
521 return E_NOINTERFACE;
524 STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
527 msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref );
532 STDMETHODIMP_(ULONG) CaptureFilter::Release()
535 msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref );
538 if( !InterlockedDecrement(&i_ref) ) delete this;
543 /* IPersist method */
544 STDMETHODIMP CaptureFilter::GetClassID(CLSID *pClsID)
547 msg_Dbg( p_input, "CaptureFilter::GetClassID" );
552 /* IMediaFilter methods */
553 STDMETHODIMP CaptureFilter::GetState(DWORD dwMSecs, FILTER_STATE *State)
556 msg_Dbg( p_input, "CaptureFilter::GetStat" );
560 STDMETHODIMP CaptureFilter::SetSyncSource(IReferenceClock *pClock)
563 msg_Dbg( p_input, "CaptureFilter::SetSyncSource" );
568 STDMETHODIMP CaptureFilter::GetSyncSource(IReferenceClock **pClock)
571 msg_Dbg( p_input, "CaptureFilter::GetSyncSource" );
577 STDMETHODIMP CaptureFilter::Stop()
580 msg_Dbg( p_input, "CaptureFilter::Stop" );
584 STDMETHODIMP CaptureFilter::Pause()
587 msg_Dbg( p_input, "CaptureFilter::Pause" );
591 STDMETHODIMP CaptureFilter::Run(REFERENCE_TIME tStart)
594 msg_Dbg( p_input, "CaptureFilter::Run" );
599 /* IBaseFilter methods */
600 STDMETHODIMP CaptureFilter::EnumPins( IEnumPins ** ppEnum )
603 msg_Dbg( p_input, "CaptureFilter::EnumPins" );
606 /* Create a new ref counted enumerator */
607 *ppEnum = new CaptureEnumPins( p_input, this, NULL );
608 return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;
610 STDMETHODIMP CaptureFilter::FindPin( LPCWSTR Id, IPin ** ppPin )
613 msg_Dbg( p_input, "CaptureFilter::FindPin" );
617 STDMETHODIMP CaptureFilter::QueryFilterInfo( FILTER_INFO * pInfo )
620 msg_Dbg( p_input, "CaptureFilter::QueryFilterInfo" );
623 pInfo->achName[0] = L'\0';
625 pInfo->pGraph = p_graph;
626 if( p_graph ) p_graph->AddRef();
630 STDMETHODIMP CaptureFilter::JoinFilterGraph( IFilterGraph * pGraph,
634 msg_Dbg( p_input, "CaptureFilter::JoinFilterGraph" );
641 STDMETHODIMP CaptureFilter::QueryVendorInfo( LPWSTR* pVendorInfo )
644 msg_Dbg( p_input, "CaptureFilter::QueryVendorInfo" );
650 CapturePin *CaptureFilter::CustomGetPin()
655 /****************************************************************************
656 * Implementation of our dummy directshow enumpins class
657 ****************************************************************************/
659 CaptureEnumPins::CaptureEnumPins( input_thread_t * _p_input,
660 CaptureFilter *_p_filter,
661 CaptureEnumPins *pEnumPins )
662 : p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
664 /* Hold a reference count on our filter */
667 /* Are we creating a new enumerator */
669 if( pEnumPins == NULL )
675 i_position = pEnumPins->i_position;
679 CaptureEnumPins::~CaptureEnumPins()
684 /* IUnknown methods */
685 STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
688 msg_Dbg( p_input, "CaptureEnumPins::QueryInterface" );
691 if( riid == IID_IUnknown ||
692 riid == IID_IEnumPins )
695 *ppv = (IEnumPins *)this;
701 return E_NOINTERFACE;
704 STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
707 msg_Dbg( p_input, "CaptureEnumPins::AddRef (ref: %i)", i_ref );
712 STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
715 msg_Dbg( p_input, "CaptureEnumPins::Release (ref: %i)", i_ref );
718 if( !InterlockedDecrement(&i_ref) ) delete this;
724 STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
728 msg_Dbg( p_input, "CaptureEnumPins::Next" );
733 if( i_position < 1 && cPins > 0 )
735 IPin *pPin = p_filter->CustomGetPin();
742 return *pcFetched == cPins ? NOERROR : S_FALSE;
744 STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
747 msg_Dbg( p_input, "CaptureEnumPins::Skip" );
758 STDMETHODIMP CaptureEnumPins::Reset()
761 msg_Dbg( p_input, "CaptureEnumPins::Reset" );
767 STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
770 msg_Dbg( p_input, "CaptureEnumPins::Clone" );
773 *ppEnum = new CaptureEnumPins( p_input, p_filter, this );
774 if( *ppEnum == NULL ) return E_OUTOFMEMORY;
779 /****************************************************************************
780 * Implementation of our dummy directshow enummediatypes class
781 ****************************************************************************/
783 CaptureEnumMediaTypes::CaptureEnumMediaTypes( input_thread_t * _p_input,
785 CaptureEnumMediaTypes *pEnumMediaTypes )
786 : p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
788 /* Hold a reference count on our filter */
791 /* Are we creating a new enumerator */
792 if( pEnumMediaTypes == NULL )
798 i_position = pEnumMediaTypes->i_position;
802 CaptureEnumMediaTypes::~CaptureEnumMediaTypes()
807 /* IUnknown methods */
808 STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
811 msg_Dbg( p_input, "CaptureEnumMediaTypes::QueryInterface" );
814 if( riid == IID_IUnknown ||
815 riid == IID_IEnumMediaTypes )
818 *ppv = (IEnumMediaTypes *)this;
824 return E_NOINTERFACE;
827 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
830 msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef (ref: %i)", i_ref );
835 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
838 msg_Dbg( p_input, "CaptureEnumMediaTypes::Release (ref: %i)", i_ref );
841 if( !InterlockedDecrement(&i_ref) ) delete this;
846 /* IEnumMediaTypes */
847 STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
848 AM_MEDIA_TYPE ** ppMediaTypes,
852 msg_Dbg( p_input, "CaptureEnumMediaTypes::Next" );
855 if( pcFetched ) *pcFetched = 0;
858 STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
861 msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
866 STDMETHODIMP CaptureEnumMediaTypes::Reset()
869 msg_Dbg( p_input, "CaptureEnumMediaTypes::Reset" );
875 STDMETHODIMP CaptureEnumMediaTypes::Clone( IEnumMediaTypes **ppEnum )
878 msg_Dbg( p_input, "CaptureEnumMediaTypes::Clone" );
881 *ppEnum = new CaptureEnumMediaTypes( p_input, p_pin, this );
882 if( *ppEnum == NULL ) return E_OUTOFMEMORY;