]> git.sesse.net Git - vlc/blob - modules/access/dshow/filter.cpp
* modules/access/dshow/filter.cpp: removed useless debug messages.
[vlc] / modules / access / dshow / filter.cpp
1 /*****************************************************************************
2  * filter.c : DirectShow access module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id$
6  *
7  * Author: Gildas Bazin <gbazin@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <string.h>
30
31 #include <vlc/vlc.h>
32 #include <vlc/input.h>
33 #include <vlc/vout.h>
34
35 #ifndef _MSC_VER
36     /* Work-around a bug in w32api-2.5 */
37 #   define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE
38 #endif
39
40 #include "filter.h"
41
42 #define DEBUG_DSHOW 1
43
44 struct access_sys_t
45 {
46     vlc_mutex_t lock;
47     vlc_cond_t  wait;
48 };
49
50 /*****************************************************************************
51  * DirectShow GUIDs.
52  * Easier to define them hear as mingw doesn't provide them all.
53  *****************************************************************************/
54 const GUID CLSID_SystemDeviceEnum = {0x62be5d10, 0x60eb, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
55 const GUID CLSID_VideoInputDeviceCategory = {0x860BB310,0x5D01,0x11d0,{0xBD,0x3B,0x00,0xA0,0xC9,0x11,0xCE,0x86}};
56 const GUID CLSID_AudioInputDeviceCategory = {0x33d9a762, 0x90c8, 0x11d0, {0xbd, 0x43, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
57 const GUID IID_IPropertyBag = {0x55272A00, 0x42CB, 0x11CE, {0x81, 0x35, 0x00, 0xAA, 0x00, 0x4B, 0xB8, 0x51}};
58 const GUID IID_ICreateDevEnum = {0x29840822, 0x5b84, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}};
59 const GUID IID_IFilterGraph = {0x56a8689f, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
60 const GUID IID_IMediaControl = {0x56a868b1, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
61 const GUID CLSID_FilterGraph = {0xe436ebb3, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
62
63 const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
64 const GUID IID_IPersist = {0x0000010c, 0x0000, 0x0000, {0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46}};
65 const GUID IID_IMediaFilter = {0x56a86899, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
66 const GUID IID_IBaseFilter = {0x56a86895, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
67 const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
68 const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
69
70 const GUID IID_IEnumPins = {0x56a86892, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}};
71 const GUID IID_IEnumMediaTypes = {0x89c31040, 0x846b, 0x11ce, {0x97,0xd3, 0x00,0xaa,0x00,0x55,0x59,0x5a}};
72
73 const GUID IID_IAMBufferNegotiation = {0x56ed71a0, 0xaf5f, 0x11d0, {0xb3, 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5}};
74
75 const GUID IID_ISpecifyPropertyPages = {0xb196b28b, 0xbab4, 0x101a, {0xb6, 0x9c, 0x00, 0xaa, 0x00, 0x34, 0x1d, 0x07}};
76
77 const GUID IID_IQualityControl = {0x56a868a5, 0x0ad4, 0x11ce, {0xb, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
78
79 const GUID CLSID_CaptureGraphBuilder2 = {0xBF87B6E1, 0x8C27, 0x11d0, {0xB3, 0xF0, 0x0, 0xAA, 0x00, 0x37, 0x61, 0xC5}};
80
81 const GUID IID_IGraphBuilder = {0x56a868a9, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
82
83 const GUID IID_ICaptureGraphBuilder2 = {0x93E5A4E0, 0x2D50, 0x11d2, {0xAB, 0xFA, 0x00, 0xA0, 0xC9, 0xC6, 0xE3, 0x8D}};
84
85 const GUID IID_IAMTVAudio = {0x83EC1C30, 0x23D1, 0x11d1, {0x99, 0xE6, 0x00, 0xA0, 0xC9, 0x56, 0x02, 0x66}};
86 const GUID IID_IAMStreamConfig = {0xC6E13340, 0x30AC, 0x11d0, {0xA1, 0x8C, 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56}};
87 const GUID IID_IAMCrossbar = {0xC6E13380, 0x30AC, 0x11d0, {0xA1, 0x8C, 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56}};
88 const GUID IID_IAMTVTuner = {0x211A8766, 0x03AC, 0x11d1, {0x8D, 0x13, 0x00, 0xAA, 0x00, 0xBD, 0x83, 0x39}};
89
90 const GUID IID_IKsPropertySet = {0x31EFAC30, 0x515C, 0x11d0, {0xA9, 0xAA, 0x00, 0xAA, 0x00, 0x61, 0xBE, 0x93}};
91
92
93 /*
94  * MEDIATYPEs and MEDIASUBTYPEs
95  */
96 const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
97 const GUID MEDIATYPE_Interleaved = {0x73766169, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
98 const GUID MEDIATYPE_Stream = {0xe436eb83, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
99 const GUID MEDIASUBTYPE_PREVIEW_VIDEO = {0x2859e1da, 0xb81f, 0x4fbd, {0x94, 0x3b, 0xe2, 0x37, 0x24, 0xa1, 0xab, 0xb3}};
100
101 /* Packed RGB formats */
102 const GUID MEDIASUBTYPE_RGB1 = {0xe436eb78, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
103 const GUID MEDIASUBTYPE_RGB4 = {0xe436eb79, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
104 const GUID MEDIASUBTYPE_RGB8 = {0xe436eb7a, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
105 const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
106 const GUID MEDIASUBTYPE_RGB555 = {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
107 const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
108 const GUID MEDIASUBTYPE_RGB32 = {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}};
109 const GUID MEDIASUBTYPE_ARGB32 = {0x773c9ac0, 0x3274, 0x11d0, {0xb7, 0x24, 0x0, 0xaa, 0x0, 0x6c, 0x1a, 0x1}};
110
111 /* Packed YUV formats */
112 const GUID MEDIASUBTYPE_YUYV = {0x56595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
113 const GUID MEDIASUBTYPE_Y411 = {0x31313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
114 const GUID MEDIASUBTYPE_Y211 = {0x31313259, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
115 const GUID MEDIASUBTYPE_YUY2 = {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
116 const GUID MEDIASUBTYPE_YVYU = {0x55595659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
117 const GUID MEDIASUBTYPE_UYVY = {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
118
119 /* Planar YUV formats */
120 const GUID MEDIASUBTYPE_YVU9 = {0x39555659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
121 const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
122 const GUID MEDIASUBTYPE_IYUV = {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; /* identical to YV12 */
123 const GUID MEDIASUBTYPE_Y41P = {0x50313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
124 const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
125
126 const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
127 const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}};
128 const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
129 const GUID MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
130
131 /* DV formats */
132 const GUID MEDIASUBTYPE_dvsd = {0x64737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
133 const GUID MEDIASUBTYPE_dvhd = {0x64687664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
134 const GUID MEDIASUBTYPE_dvsl = {0x6c737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
135
136 /* MPEG2 formats */
137 const GUID MEDIASUBTYPE_MPEG2_VIDEO = {0xe06d8026, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
138 const GUID MEDIASUBTYPE_MPEG2_PROGRAM = {0xe06d8022, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
139 const GUID MEDIASUBTYPE_MPEG2_TRANSPORT = {0xe06d8023, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
140 const GUID FORMAT_MPEG2Video = {0xe06d80e3, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}};
141
142 /* Analog Video */
143 const GUID FORMAT_AnalogVideo = {0x482dde0, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
144
145 const GUID MEDIATYPE_AnalogVideo = {0x482dde1, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xab, 0x0, 0x6e, 0xcb, 0x65}};
146
147 const GUID MEDIASUBTYPE_AnalogVideo_NTSC_M = {0x482dde2, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
148 const GUID MEDIASUBTYPE_AnalogVideo_PAL_B = {0x482dde5, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
149 const GUID MEDIASUBTYPE_AnalogVideo_PAL_D = {0x482dde6, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
150 const GUID MEDIASUBTYPE_AnalogVideo_PAL_G = {0x482dde7, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
151 const GUID MEDIASUBTYPE_AnalogVideo_PAL_H = {0x482dde8, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
152 const GUID MEDIASUBTYPE_AnalogVideo_PAL_I = {0x482dde9, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
153 const GUID MEDIASUBTYPE_AnalogVideo_PAL_M = {0x482ddea, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
154 const GUID MEDIASUBTYPE_AnalogVideo_PAL_N = {0x482ddeb, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
155 const GUID MEDIASUBTYPE_AnalogVideo_PAL_N_COMBO = {0x482ddec, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
156 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_B = {0x482ddf0, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
157 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_D = {0x482ddf1, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
158 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_G = {0x482ddf2, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
159 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_H = {0x482ddf3, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
160 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_K = {0x482ddf4, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
161 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_K1 = {0x482ddf5, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
162 const GUID MEDIASUBTYPE_AnalogVideo_SECAM_L = {0x482ddf6, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}};
163
164 const GUID AMPROPSETID_Pin= {0x9b00f101, 0x1567, 0x11d1, {0xb3, 0xf1, 0x0, 0xaa, 0x0, 0x37, 0x61, 0xc5}};
165 const GUID PIN_CATEGORY_ANALOGVIDEOIN= {0xfb6c4283, 0x0353, 0x11d1, {0x90, 0x5f, 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba}};
166 const GUID PIN_CATEGORY_CAPTURE= {0xfb6c4281, 0x0353, 0x11d1, {0x90, 0x5f, 0x0, 0x0, 0xc0, 0xcc, 0x16, 0xba}};
167 const GUID LOOK_UPSTREAM_ONLY= {0xac798be0, 0x98e3, 0x11d1, {0xb3, 0xf1, 0x0, 0xaa, 0x0, 0x37, 0x61, 0xc}};
168
169 const GUID GUID_NULL = {0x0000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
170
171 void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt )
172 {
173     if( mt.cbFormat != 0 )
174     {
175         CoTaskMemFree( (PVOID)mt.pbFormat );
176         mt.cbFormat = 0;
177         mt.pbFormat = NULL;
178     }
179     if( mt.pUnk != NULL )
180     {
181         mt.pUnk->Release();
182         mt.pUnk = NULL;
183     }
184 }
185
186 HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget,
187                               const AM_MEDIA_TYPE *pmtSource )
188 {
189     *pmtTarget = *pmtSource;
190     if( pmtSource->cbFormat != 0 )
191     {
192         pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat );
193         if( pmtTarget->pbFormat == NULL )
194         {
195             pmtTarget->cbFormat = 0;
196             return E_OUTOFMEMORY;
197         }
198         else
199         {
200             CopyMemory( (PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat,
201                         pmtTarget->cbFormat );
202         }
203     }
204     if( pmtTarget->pUnk != NULL )
205     {
206         pmtTarget->pUnk->AddRef();
207     }
208
209     return S_OK;
210 }
211
212 /****************************************************************************
213  * Implementation of our dummy directshow filter pin class
214  ****************************************************************************/
215
216 CapturePin::CapturePin( input_thread_t * _p_input, CaptureFilter *_p_filter,
217                         AM_MEDIA_TYPE mt )
218   : p_input( _p_input ), p_filter( _p_filter ), p_connected_pin( NULL ),
219     media_type( mt ), i_ref( 1 )
220 {
221 }
222
223 CapturePin::~CapturePin()
224 {
225 #ifdef DEBUG_DSHOW
226     msg_Dbg( p_input, "CapturePin::~CapturePin" );
227 #endif
228 }
229
230 HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample )
231 {
232 #if 0 //def DEBUG_DSHOW
233     msg_Dbg( p_input, "CapturePin::CustomGetSample" );
234 #endif
235
236     access_sys_t *p_sys = p_input->p_access_data;
237     vlc_mutex_lock( &p_sys->lock );
238     if( samples_queue.size() )
239     {
240         *vlc_sample = samples_queue.back();
241         samples_queue.pop_back();
242         vlc_mutex_unlock( &p_sys->lock );
243         return S_OK;
244     }
245     vlc_mutex_unlock( &p_sys->lock );
246     return S_FALSE;
247 }
248
249 AM_MEDIA_TYPE CapturePin::CustomGetMediaType()
250 {
251     return media_type;
252 }
253
254 /* IUnknown methods */
255 STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv)
256 {
257 #ifdef DEBUG_DSHOW
258     msg_Dbg( p_input, "CapturePin::QueryInterface" );
259 #endif
260
261     if( riid == IID_IUnknown ||
262         riid == IID_IPin )
263     {
264         AddRef();
265         *ppv = (IPin *)this;
266         return NOERROR;
267     }
268     if( riid == IID_IMemInputPin )
269     {
270         AddRef();
271         *ppv = (IMemInputPin *)this;
272         return NOERROR;
273     }
274     else
275     {
276 #ifdef DEBUG_DSHOW
277         msg_Dbg( p_input, "CapturePin::QueryInterface() failed for: "
278                  "%04X-%02X-%02X-%02X%02X%02X%02X%02X%02X%02X%02X",
279                  (int)riid.Data1, (int)riid.Data2, (int)riid.Data3,
280                  static_cast<int>(riid.Data4[0]), (int)riid.Data4[1],
281                  (int)riid.Data4[2], (int)riid.Data4[3],
282                  (int)riid.Data4[4], (int)riid.Data4[5],
283                  (int)riid.Data4[6], (int)riid.Data4[7] );
284 #endif
285         *ppv = NULL;
286         return E_NOINTERFACE;
287     }
288 }
289
290 STDMETHODIMP_(ULONG) CapturePin::AddRef()
291 {
292 #ifdef DEBUG_DSHOW_L1
293     msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref );
294 #endif
295
296     return i_ref++;
297 };
298 STDMETHODIMP_(ULONG) CapturePin::Release()
299 {
300 #ifdef DEBUG_DSHOW_L1
301     msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref );
302 #endif
303
304     if( !InterlockedDecrement(&i_ref) ) delete this;
305
306     return 0;
307 };
308
309 /* IPin methods */
310 STDMETHODIMP CapturePin::Connect( IPin * pReceivePin,
311                                   const AM_MEDIA_TYPE *pmt )
312 {
313 #ifdef DEBUG_DSHOW
314     msg_Dbg( p_input, "CapturePin::Connect" );
315 #endif
316     return E_NOTIMPL;
317 }
318 STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector,
319                                             const AM_MEDIA_TYPE *pmt )
320 {
321 #ifdef DEBUG_DSHOW
322     msg_Dbg( p_input, "CapturePin::ReceiveConnection" );
323 #endif
324
325     if( pmt->majortype == MEDIATYPE_Video )
326     {
327         if( media_type.subtype != GUID_NULL &&
328             media_type.subtype != pmt->subtype )
329             return VFW_E_TYPE_NOT_ACCEPTED;
330
331         if( media_type.pbFormat &&
332             ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight &&
333             ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biHeight !=
334             ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight )
335             return VFW_E_TYPE_NOT_ACCEPTED;
336
337         if( media_type.pbFormat &&
338             ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth &&
339             ((VIDEOINFOHEADER *)media_type.pbFormat)->bmiHeader.biWidth !=
340             ((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth )
341             return VFW_E_TYPE_NOT_ACCEPTED;
342     }
343
344     p_connected_pin = pConnector;
345     p_connected_pin->AddRef();
346
347     FreeMediaType( media_type );
348     return CopyMediaType( &media_type, pmt );
349 }
350 STDMETHODIMP CapturePin::Disconnect()
351 {
352 #ifdef DEBUG_DSHOW
353     msg_Dbg( p_input, "CapturePin::Disconnect" );
354 #endif
355
356 #if 0 // FIXME: This does seem to create crashes sometimes
357     VLCMediaSample vlc_sample;
358     access_sys_t *p_sys = p_input->p_access_data;
359
360     vlc_mutex_lock( &p_sys->lock );
361     while( samples_queue.size() )
362     {
363         vlc_sample = samples_queue.back();
364         samples_queue.pop_back();
365         vlc_sample.p_sample->Release();
366     }
367     vlc_mutex_unlock( &p_sys->lock );
368 #endif
369
370     if( p_connected_pin ) p_connected_pin->Release();
371     p_connected_pin = NULL;
372     FreeMediaType( media_type );
373     return S_OK;
374 }
375 STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin )
376 {
377 #ifdef DEBUG_DSHOW
378     msg_Dbg( p_input, "CapturePin::ConnectedTo" );
379 #endif
380
381     if( !p_connected_pin ) return VFW_E_NOT_CONNECTED;
382
383     p_connected_pin->AddRef();
384     *pPin = p_connected_pin;
385
386     return S_OK;
387 }
388 STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt )
389 {
390 #ifdef DEBUG_DSHOW
391     msg_Dbg( p_input, "CapturePin::ConnectionMediaType" );
392 #endif
393
394     return CopyMediaType( pmt, &media_type );
395 }
396 STDMETHODIMP CapturePin::QueryPinInfo( PIN_INFO * pInfo )
397 {
398 #ifdef DEBUG_DSHOW
399     msg_Dbg( p_input, "CapturePin::QueryPinInfo" );
400 #endif
401
402     pInfo->pFilter = p_filter;
403     if( p_filter ) p_filter->AddRef();
404
405     pInfo->achName[0] = L'\0';
406
407     pInfo->dir = PINDIR_INPUT;
408
409     return NOERROR;
410 }
411 STDMETHODIMP CapturePin::QueryDirection( PIN_DIRECTION * pPinDir )
412 {
413 #ifdef DEBUG_DSHOW
414     msg_Dbg( p_input, "CapturePin::QueryDirection" );
415 #endif
416
417     *pPinDir = PINDIR_INPUT;
418     return NOERROR;
419 }
420 STDMETHODIMP CapturePin::QueryId( LPWSTR * Id )
421 {
422 #ifdef DEBUG_DSHOW
423     msg_Dbg( p_input, "CapturePin::QueryId" );
424 #endif
425     return E_NOTIMPL;
426 }
427 STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt )
428 {
429 #ifdef DEBUG_DSHOW
430     msg_Dbg( p_input, "CapturePin::QueryAccept" );
431 #endif
432     if( media_type.subtype == pmt->subtype &&
433         media_type.majortype == pmt->majortype ) return S_OK;
434
435     return S_FALSE;
436 }
437 STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum )
438 {
439 #ifdef DEBUG_DSHOW
440     msg_Dbg( p_input, "CapturePin::EnumMediaTypes" );
441 #endif
442
443     *ppEnum = new CaptureEnumMediaTypes( p_input, this, NULL );
444
445     if( *ppEnum == NULL ) return E_OUTOFMEMORY;
446
447     return NOERROR;
448 }
449 STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin )
450 {
451 #ifdef DEBUG_DSHOW
452     msg_Dbg( p_input, "CapturePin::QueryInternalConnections" );
453 #endif
454     return E_NOTIMPL;
455 }
456 STDMETHODIMP CapturePin::EndOfStream( void )
457 {
458 #ifdef DEBUG_DSHOW
459     msg_Dbg( p_input, "CapturePin::EndOfStream" );
460 #endif
461     return S_OK;
462 }
463 STDMETHODIMP CapturePin::BeginFlush( void )
464 {
465 #ifdef DEBUG_DSHOW
466     msg_Dbg( p_input, "CapturePin::BeginFlush" );
467 #endif
468     return S_OK;
469 }
470 STDMETHODIMP CapturePin::EndFlush( void )
471 {
472 #ifdef DEBUG_DSHOW
473     msg_Dbg( p_input, "CapturePin::EndFlush" );
474 #endif
475     return S_OK;
476 }
477 STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart,
478                                      REFERENCE_TIME tStop,
479                                      double dRate )
480 {
481 #ifdef DEBUG_DSHOW
482     msg_Dbg( p_input, "CapturePin::NewSegment" );
483 #endif
484     return S_OK;
485 }
486
487 /* IMemInputPin methods */
488 STDMETHODIMP CapturePin::GetAllocator( IMemAllocator **ppAllocator )
489 {
490 #ifdef DEBUG_DSHOW
491     msg_Dbg( p_input, "CapturePin::GetAllocator" );
492 #endif
493
494     return VFW_E_NO_ALLOCATOR;
495 }
496 STDMETHODIMP CapturePin::NotifyAllocator( IMemAllocator *pAllocator,
497                                           BOOL bReadOnly )
498 {
499 #ifdef DEBUG_DSHOW
500     msg_Dbg( p_input, "CapturePin::NotifyAllocator" );
501 #endif
502
503     return S_OK;
504 }
505 STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps )
506 {
507 #ifdef DEBUG_DSHOW
508     msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" );
509 #endif
510
511     return E_NOTIMPL;
512 }
513 STDMETHODIMP CapturePin::Receive( IMediaSample *pSample )
514 {
515 #if 0 //def DEBUG_DSHOW
516     msg_Dbg( p_input, "CapturePin::Receive" );
517 #endif
518
519     pSample->AddRef();
520     mtime_t i_timestamp = mdate() * 10;
521     VLCMediaSample vlc_sample = {pSample, i_timestamp};
522
523     access_sys_t *p_sys = p_input->p_access_data;
524     vlc_mutex_lock( &p_sys->lock );
525     samples_queue.push_front( vlc_sample );
526
527     /* Make sure we don't cache too many samples */
528     if( samples_queue.size() > 10 )
529     {
530         vlc_sample = samples_queue.back();
531         samples_queue.pop_back();
532         msg_Dbg( p_input, "CapturePin::Receive trashing late input sample" );
533         vlc_sample.p_sample->Release();
534     }
535
536     vlc_cond_signal( &p_sys->wait );
537     vlc_mutex_unlock( &p_sys->lock );
538
539     return S_OK;
540 }
541 STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples,
542                                           long nSamples,
543                                           long *nSamplesProcessed )
544 {
545     HRESULT hr = S_OK;
546
547     *nSamplesProcessed = 0;
548     while( nSamples-- > 0 )
549     {
550          hr = Receive( pSamples[*nSamplesProcessed] );
551          if( hr != S_OK ) break;
552          (*nSamplesProcessed)++;
553     }
554     return hr;
555 }
556 STDMETHODIMP CapturePin::ReceiveCanBlock( void )
557 {
558 #ifdef DEBUG_DSHOW
559     msg_Dbg( p_input, "CapturePin::ReceiveCanBlock" );
560 #endif
561
562     return S_FALSE; /* Thou shalt not block */
563 }
564
565 /****************************************************************************
566  * Implementation of our dummy directshow filter class
567  ****************************************************************************/
568
569 CaptureFilter::CaptureFilter( input_thread_t * _p_input, AM_MEDIA_TYPE mt )
570   : p_input( _p_input ), p_pin( new CapturePin( _p_input, this, mt ) ),
571     media_type( mt ), state( State_Stopped ), i_ref( 1 )
572 {
573 }
574
575 CaptureFilter::~CaptureFilter()
576 {
577 #ifdef DEBUG_DSHOW
578     msg_Dbg( p_input, "CaptureFilter::~CaptureFilter" );
579 #endif
580     p_pin->Release();
581 }
582
583 /* IUnknown methods */
584 STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv )
585 {
586 #ifdef DEBUG_DSHOW
587     msg_Dbg( p_input, "CaptureFilter::QueryInterface" );
588 #endif
589
590     if( riid == IID_IUnknown )
591     {
592         AddRef();
593         *ppv = (IUnknown *)this;
594         return NOERROR;
595     }
596     if( riid == IID_IPersist )
597     {
598         AddRef();
599         *ppv = (IPersist *)this;
600         return NOERROR;
601     }
602     if( riid == IID_IMediaFilter )
603     {
604         AddRef();
605         *ppv = (IMediaFilter *)this;
606         return NOERROR;
607     }
608     if( riid == IID_IBaseFilter )
609     {
610         AddRef();
611         *ppv = (IBaseFilter *)this;
612         return NOERROR;
613     }
614     else
615     {
616         *ppv = NULL;
617         return E_NOINTERFACE;
618     }
619 };
620 STDMETHODIMP_(ULONG) CaptureFilter::AddRef()
621 {
622 #ifdef DEBUG_DSHOW_L1
623     msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref );
624 #endif
625
626     return i_ref++;
627 };
628 STDMETHODIMP_(ULONG) CaptureFilter::Release()
629 {
630 #ifdef DEBUG_DSHOW_L1
631     msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref );
632 #endif
633
634     if( !InterlockedDecrement(&i_ref) ) delete this;
635
636     return 0;
637 };
638
639 /* IPersist method */
640 STDMETHODIMP CaptureFilter::GetClassID(CLSID *pClsID)
641 {
642 #ifdef DEBUG_DSHOW
643     msg_Dbg( p_input, "CaptureFilter::GetClassID" );
644 #endif
645     return E_NOTIMPL;
646 };
647
648 /* IMediaFilter methods */
649 STDMETHODIMP CaptureFilter::GetState(DWORD dwMSecs, FILTER_STATE *State)
650 {
651 #ifdef DEBUG_DSHOW
652     msg_Dbg( p_input, "CaptureFilter::GetState %i", state );
653 #endif
654
655     *State = state;
656     return S_OK;
657 };
658 STDMETHODIMP CaptureFilter::SetSyncSource(IReferenceClock *pClock)
659 {
660 #ifdef DEBUG_DSHOW
661     msg_Dbg( p_input, "CaptureFilter::SetSyncSource" );
662 #endif
663
664     return S_OK;
665 };
666 STDMETHODIMP CaptureFilter::GetSyncSource(IReferenceClock **pClock)
667 {
668 #ifdef DEBUG_DSHOW
669     msg_Dbg( p_input, "CaptureFilter::GetSyncSource" );
670 #endif
671
672     *pClock = NULL;
673     return NOERROR;
674 };
675 STDMETHODIMP CaptureFilter::Stop()
676 {
677 #ifdef DEBUG_DSHOW
678     msg_Dbg( p_input, "CaptureFilter::Stop" );
679 #endif
680
681     state = State_Stopped;
682     return S_OK;
683 };
684 STDMETHODIMP CaptureFilter::Pause()
685 {
686 #ifdef DEBUG_DSHOW
687     msg_Dbg( p_input, "CaptureFilter::Pause" );
688 #endif
689
690     state = State_Paused;
691     return S_OK;
692 };
693 STDMETHODIMP CaptureFilter::Run(REFERENCE_TIME tStart)
694 {
695 #ifdef DEBUG_DSHOW
696     msg_Dbg( p_input, "CaptureFilter::Run" );
697 #endif
698
699     state = State_Running;
700     return S_OK;
701 };
702
703 /* IBaseFilter methods */
704 STDMETHODIMP CaptureFilter::EnumPins( IEnumPins ** ppEnum )
705 {
706 #ifdef DEBUG_DSHOW
707     msg_Dbg( p_input, "CaptureFilter::EnumPins" );
708 #endif
709
710     /* Create a new ref counted enumerator */
711     *ppEnum = new CaptureEnumPins( p_input, this, NULL );
712     return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;
713 };
714 STDMETHODIMP CaptureFilter::FindPin( LPCWSTR Id, IPin ** ppPin )
715 {
716 #ifdef DEBUG_DSHOW
717     msg_Dbg( p_input, "CaptureFilter::FindPin" );
718 #endif
719     return E_NOTIMPL;
720 };
721 STDMETHODIMP CaptureFilter::QueryFilterInfo( FILTER_INFO * pInfo )
722 {
723 #ifdef DEBUG_DSHOW
724     msg_Dbg( p_input, "CaptureFilter::QueryFilterInfo" );
725 #endif
726
727     pInfo->achName[0] = L'\0';
728
729     pInfo->pGraph = p_graph;
730     if( p_graph ) p_graph->AddRef();
731
732     return NOERROR;
733 };
734 STDMETHODIMP CaptureFilter::JoinFilterGraph( IFilterGraph * pGraph,
735                                              LPCWSTR pName )
736 {
737 #ifdef DEBUG_DSHOW
738     msg_Dbg( p_input, "CaptureFilter::JoinFilterGraph" );
739 #endif
740
741     p_graph = pGraph;
742
743     return NOERROR;
744 };
745 STDMETHODIMP CaptureFilter::QueryVendorInfo( LPWSTR* pVendorInfo )
746 {
747 #ifdef DEBUG_DSHOW
748     msg_Dbg( p_input, "CaptureFilter::QueryVendorInfo" );
749 #endif
750     return E_NOTIMPL;
751 };
752
753 /* Custom methods */
754 CapturePin *CaptureFilter::CustomGetPin()
755 {
756     return p_pin;
757 }
758
759 /****************************************************************************
760  * Implementation of our dummy directshow enumpins class
761  ****************************************************************************/
762
763 CaptureEnumPins::CaptureEnumPins( input_thread_t * _p_input,
764                                   CaptureFilter *_p_filter,
765                                   CaptureEnumPins *pEnumPins )
766   : p_input( _p_input ), p_filter( _p_filter ), i_ref( 1 )
767 {
768     /* Hold a reference count on our filter */
769     p_filter->AddRef();
770
771     /* Are we creating a new enumerator */
772
773     if( pEnumPins == NULL )
774     {
775         i_position = 0;
776     }
777     else
778     {
779         i_position = pEnumPins->i_position;
780     }
781 }
782
783 CaptureEnumPins::~CaptureEnumPins()
784 {
785 #ifdef DEBUG_DSHOW
786     msg_Dbg( p_input, "CaptureEnumPins::~CaptureEnumPins" );
787 #endif
788     p_filter->Release();
789 }
790
791 /* IUnknown methods */
792 STDMETHODIMP CaptureEnumPins::QueryInterface( REFIID riid, void **ppv )
793 {
794 #ifdef DEBUG_DSHOW
795     msg_Dbg( p_input, "CaptureEnumPins::QueryInterface" );
796 #endif
797
798     if( riid == IID_IUnknown ||
799         riid == IID_IEnumPins )
800     {
801         AddRef();
802         *ppv = (IEnumPins *)this;
803         return NOERROR;
804     }
805     else
806     {
807         *ppv = NULL;
808         return E_NOINTERFACE;
809     }
810 };
811 STDMETHODIMP_(ULONG) CaptureEnumPins::AddRef()
812 {
813 #ifdef DEBUG_DSHOW_L1
814     msg_Dbg( p_input, "CaptureEnumPins::AddRef (ref: %i)", i_ref );
815 #endif
816
817     return i_ref++;
818 };
819 STDMETHODIMP_(ULONG) CaptureEnumPins::Release()
820 {
821 #ifdef DEBUG_DSHOW_L1
822     msg_Dbg( p_input, "CaptureEnumPins::Release (ref: %i)", i_ref );
823 #endif
824
825     if( !InterlockedDecrement(&i_ref) ) delete this;
826
827     return 0;
828 };
829
830 /* IEnumPins */
831 STDMETHODIMP CaptureEnumPins::Next( ULONG cPins, IPin ** ppPins,
832                                     ULONG * pcFetched )
833 {
834 #ifdef DEBUG_DSHOW
835     msg_Dbg( p_input, "CaptureEnumPins::Next" );
836 #endif
837
838     unsigned int i_fetched = 0;
839
840     if( i_position < 1 && cPins > 0 )
841     {
842         IPin *pPin = p_filter->CustomGetPin();
843         *ppPins = pPin;
844         pPin->AddRef();
845         i_fetched = 1;
846         i_position++;
847     }
848
849     if( pcFetched ) *pcFetched = i_fetched;
850
851     return (i_fetched == cPins) ? S_OK : S_FALSE;
852 };
853 STDMETHODIMP CaptureEnumPins::Skip( ULONG cPins )
854 {
855 #ifdef DEBUG_DSHOW
856     msg_Dbg( p_input, "CaptureEnumPins::Skip" );
857 #endif
858
859     i_position += cPins;
860
861     if( i_position > 1 )
862     {
863         return S_FALSE;
864     }
865
866     return S_OK;
867 };
868 STDMETHODIMP CaptureEnumPins::Reset()
869 {
870 #ifdef DEBUG_DSHOW
871     msg_Dbg( p_input, "CaptureEnumPins::Reset" );
872 #endif
873
874     i_position = 0;
875     return S_OK;
876 };
877 STDMETHODIMP CaptureEnumPins::Clone( IEnumPins **ppEnum )
878 {
879 #ifdef DEBUG_DSHOW
880     msg_Dbg( p_input, "CaptureEnumPins::Clone" );
881 #endif
882
883     *ppEnum = new CaptureEnumPins( p_input, p_filter, this );
884     if( *ppEnum == NULL ) return E_OUTOFMEMORY;
885
886     return NOERROR;
887 };
888
889 /****************************************************************************
890  * Implementation of our dummy directshow enummediatypes class
891  ****************************************************************************/
892
893 CaptureEnumMediaTypes::CaptureEnumMediaTypes( input_thread_t * _p_input,
894                                   CapturePin *_p_pin,
895                                   CaptureEnumMediaTypes *pEnumMediaTypes )
896   : p_input( _p_input ), p_pin( _p_pin ), i_ref( 1 )
897 {
898     /* Hold a reference count on our filter */
899     p_pin->AddRef();
900
901     /* Are we creating a new enumerator */
902     if( pEnumMediaTypes == NULL )
903     {
904         i_position = 0;
905     }
906     else
907     {
908         i_position = pEnumMediaTypes->i_position;
909     }
910 }
911
912 CaptureEnumMediaTypes::~CaptureEnumMediaTypes()
913 {
914 #ifdef DEBUG_DSHOW
915     msg_Dbg( p_input, "CaptureEnumMediaTypes::~CaptureEnumMediaTypes" );
916 #endif
917     p_pin->Release();
918 }
919
920 /* IUnknown methods */
921 STDMETHODIMP CaptureEnumMediaTypes::QueryInterface( REFIID riid, void **ppv )
922 {
923 #ifdef DEBUG_DSHOW
924     msg_Dbg( p_input, "CaptureEnumMediaTypes::QueryInterface" );
925 #endif
926
927     if( riid == IID_IUnknown ||
928         riid == IID_IEnumMediaTypes )
929     {
930         AddRef();
931         *ppv = (IEnumMediaTypes *)this;
932         return NOERROR;
933     }
934     else
935     {
936         *ppv = NULL;
937         return E_NOINTERFACE;
938     }
939 };
940 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::AddRef()
941 {
942 #ifdef DEBUG_DSHOW_L1
943     msg_Dbg( p_input, "CaptureEnumMediaTypes::AddRef (ref: %i)", i_ref );
944 #endif
945
946     return i_ref++;
947 };
948 STDMETHODIMP_(ULONG) CaptureEnumMediaTypes::Release()
949 {
950 #ifdef DEBUG_DSHOW_L1
951     msg_Dbg( p_input, "CaptureEnumMediaTypes::Release (ref: %i)", i_ref );
952 #endif
953
954     if( !InterlockedDecrement(&i_ref) ) delete this;
955
956     return 0;
957 };
958
959 /* IEnumMediaTypes */
960 STDMETHODIMP CaptureEnumMediaTypes::Next( ULONG cMediaTypes,
961                                           AM_MEDIA_TYPE ** ppMediaTypes,
962                                           ULONG * pcFetched )
963 {
964 #ifdef DEBUG_DSHOW
965     msg_Dbg( p_input, "CaptureEnumMediaTypes::Next" );
966 #endif
967
968     if( pcFetched ) *pcFetched = 0;
969
970     if( cMediaTypes > 0 )
971     {
972         if( 0 == i_position++ )
973         {
974             AM_MEDIA_TYPE mediaType = p_pin->CustomGetMediaType();
975             ppMediaTypes[0] = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
976             if( CopyMediaType(ppMediaTypes[0], &mediaType) != S_OK )
977                 return E_OUTOFMEMORY;
978
979             if( pcFetched ) *pcFetched = 1;
980             if( cMediaTypes == 1 ) return S_OK;
981         }
982
983         return S_FALSE;
984     }
985
986     return S_OK;
987 };
988 STDMETHODIMP CaptureEnumMediaTypes::Skip( ULONG cMediaTypes )
989 {
990 #ifdef DEBUG_DSHOW
991     msg_Dbg( p_input, "CaptureEnumMediaTypes::Skip" );
992 #endif
993
994     return S_FALSE;
995 };
996 STDMETHODIMP CaptureEnumMediaTypes::Reset()
997 {
998 #ifdef DEBUG_DSHOW
999     msg_Dbg( p_input, "CaptureEnumMediaTypes::Reset" );
1000 #endif
1001
1002     i_position = 0;
1003     return S_OK;
1004 };
1005 STDMETHODIMP CaptureEnumMediaTypes::Clone( IEnumMediaTypes **ppEnum )
1006 {
1007 #ifdef DEBUG_DSHOW
1008     msg_Dbg( p_input, "CaptureEnumMediaTypes::Clone" );
1009 #endif
1010
1011     *ppEnum = new CaptureEnumMediaTypes( p_input, p_pin, this );
1012     if( *ppEnum == NULL ) return E_OUTOFMEMORY;
1013
1014     return NOERROR;
1015 };