When including 'wine/port.h', include it first.
[wine] / dlls / quartz / fmap.c
1 /*
2  * Implementation of CLSID_FilterMapper and CLSID_FilterMapper2.
3  *
4  * FIXME - stub.
5  *
6  * hidenori@a2.ctktv.ne.jp
7  */
8
9 #include "config.h"
10
11 #include "windef.h"
12 #include "winbase.h"
13 #include "wingdi.h"
14 #include "winuser.h"
15 #include "winreg.h"
16 #include "winerror.h"
17 #include "strmif.h"
18 #include "uuids.h"
19
20 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(quartz);
22
23 #include "quartz_private.h"
24 #include "fmap.h"
25 #include "regsvr.h"
26
27
28 /***************************************************************************
29  *
30  *      new/delete for CLSID_FilterMapper
31  *
32  */
33
34 /* can I use offsetof safely? - FIXME? */
35 static QUARTZ_IFEntry FMapIFEntries[] =
36 {
37   { &IID_IFilterMapper, offsetof(CFilterMapper,fmap)-offsetof(CFilterMapper,unk) },
38 };
39
40
41 static void QUARTZ_DestroyFilterMapper(IUnknown* punk)
42 {
43         CFilterMapper_THIS(punk,unk);
44
45         CFilterMapper_UninitIFilterMapper( This );
46 }
47
48 HRESULT QUARTZ_CreateFilterMapper(IUnknown* punkOuter,void** ppobj)
49 {
50         CFilterMapper*  pfm;
51         HRESULT hr;
52
53         TRACE("(%p,%p)\n",punkOuter,ppobj);
54
55         pfm = (CFilterMapper*)QUARTZ_AllocObj( sizeof(CFilterMapper) );
56         if ( pfm == NULL )
57                 return E_OUTOFMEMORY;
58
59         QUARTZ_IUnkInit( &pfm->unk, punkOuter );
60         hr = CFilterMapper_InitIFilterMapper( pfm );
61         if ( FAILED(hr) )
62         {
63                 QUARTZ_FreeObj( pfm );
64                 return hr;
65         }
66
67         pfm->unk.pEntries = FMapIFEntries;
68         pfm->unk.dwEntries = sizeof(FMapIFEntries)/sizeof(FMapIFEntries[0]);
69         pfm->unk.pOnFinalRelease = QUARTZ_DestroyFilterMapper;
70
71         *ppobj = (void*)(&pfm->unk);
72
73         return S_OK;
74 }
75
76 /***************************************************************************
77  *
78  *      CLSID_FilterMapper::IFilterMapper
79  *
80  */
81
82 static HRESULT WINAPI
83 IFilterMapper_fnQueryInterface(IFilterMapper* iface,REFIID riid,void** ppobj)
84 {
85         CFilterMapper_THIS(iface,fmap);
86
87         TRACE("(%p)->()\n",This);
88
89         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
90 }
91
92 static ULONG WINAPI
93 IFilterMapper_fnAddRef(IFilterMapper* iface)
94 {
95         CFilterMapper_THIS(iface,fmap);
96
97         TRACE("(%p)->()\n",This);
98
99         return IUnknown_AddRef(This->unk.punkControl);
100 }
101
102 static ULONG WINAPI
103 IFilterMapper_fnRelease(IFilterMapper* iface)
104 {
105         CFilterMapper_THIS(iface,fmap);
106
107         TRACE("(%p)->()\n",This);
108
109         return IUnknown_Release(This->unk.punkControl);
110 }
111
112
113 static HRESULT WINAPI
114 IFilterMapper_fnRegisterFilter(IFilterMapper* iface,CLSID clsid,LPCWSTR lpwszName,DWORD dwMerit)
115 {
116         CFilterMapper_THIS(iface,fmap);
117
118         FIXME("(%p)->(%s,%s,%08lx)\n",This,
119                 debugstr_guid(&clsid),debugstr_w(lpwszName),dwMerit);
120
121         /* FIXME */
122         /* FIXME - handle dwMerit! */
123         return QUARTZ_RegisterAMovieFilter(
124                 &CLSID_LegacyAmFilterCategory,
125                 &clsid,
126                 NULL, 0,
127                 lpwszName, NULL, TRUE );
128 }
129
130 static HRESULT WINAPI
131 IFilterMapper_fnRegisterFilterInstance(IFilterMapper* iface,CLSID clsid,LPCWSTR lpwszName,CLSID* pclsidMedia)
132 {
133         CFilterMapper_THIS(iface,fmap);
134         HRESULT hr;
135
136         FIXME("(%p)->()\n",This);
137
138         if ( pclsidMedia == NULL )
139                 return E_POINTER;
140         hr = CoCreateGuid(pclsidMedia);
141         if ( FAILED(hr) )
142                 return hr;
143
144         /* FIXME */
145         /* this doesn't work. */
146         /* return IFilterMapper_RegisterFilter(iface,
147                 *pclsidMedia,lpwszName,0x60000000); */
148
149         return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI
153 IFilterMapper_fnRegisterPin(IFilterMapper* iface,CLSID clsidFilter,LPCWSTR lpwszName,BOOL bRendered,BOOL bOutput,BOOL bZero,BOOL bMany,CLSID clsidReserved,LPCWSTR lpwszReserved)
154 {
155         CFilterMapper_THIS(iface,fmap);
156
157         FIXME("(%p)->() stub!\n",This);
158
159         return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI
163 IFilterMapper_fnRegisterPinType(IFilterMapper* iface,CLSID clsidFilter,LPCWSTR lpwszName,CLSID clsidMajorType,CLSID clsidSubType)
164 {
165         CFilterMapper_THIS(iface,fmap);
166
167         FIXME("(%p)->() stub!\n",This);
168
169         return E_NOTIMPL;
170 }
171
172 static HRESULT WINAPI
173 IFilterMapper_fnUnregisterFilter(IFilterMapper* iface,CLSID clsidFilter)
174 {
175         CFilterMapper_THIS(iface,fmap);
176
177         FIXME("(%p)->(%s)\n",This,debugstr_guid(&clsidFilter));
178
179         /* FIXME */
180         return QUARTZ_RegisterAMovieFilter(
181                 &CLSID_LegacyAmFilterCategory,
182                 &clsidFilter,
183                 NULL, 0, NULL, NULL, FALSE );
184 }
185
186 static HRESULT WINAPI
187 IFilterMapper_fnUnregisterFilterInstance(IFilterMapper* iface,CLSID clsidMedia)
188 {
189         CFilterMapper_THIS(iface,fmap);
190
191         FIXME("(%p)->(%s)\n",This,debugstr_guid(&clsidMedia));
192
193         /* FIXME */
194         /* this doesn't work. */
195         /* return IFilterMapper_UnregisterFilter(iface,clsidMedia); */
196
197         return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI
201 IFilterMapper_fnUnregisterPin(IFilterMapper* iface,CLSID clsidPin,LPCWSTR lpwszName)
202 {
203         CFilterMapper_THIS(iface,fmap);
204
205         FIXME("(%p)->(%s,%s) stub!\n",This,
206                 debugstr_guid(&clsidPin),debugstr_w(lpwszName));
207
208         return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI
212 IFilterMapper_fnEnumMatchingFilters(IFilterMapper* iface,IEnumRegFilters** ppobj,DWORD dwMerit,BOOL bInputNeeded,CLSID clsInMajorType,CLSID clsidSubType,BOOL bRender,BOOL bOutputNeeded,CLSID clsOutMajorType,CLSID clsOutSubType)
213 {
214         CFilterMapper_THIS(iface,fmap);
215
216         FIXME("(%p)->() stub!\n",This);
217
218         return E_NOTIMPL;
219 }
220
221
222
223 static ICOM_VTABLE(IFilterMapper) ifmap =
224 {
225         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
226         /* IUnknown fields */
227         IFilterMapper_fnQueryInterface,
228         IFilterMapper_fnAddRef,
229         IFilterMapper_fnRelease,
230         /* IFilterMapper fields */
231         IFilterMapper_fnRegisterFilter,
232         IFilterMapper_fnRegisterFilterInstance,
233         IFilterMapper_fnRegisterPin,
234         IFilterMapper_fnRegisterPinType,
235         IFilterMapper_fnUnregisterFilter,
236         IFilterMapper_fnUnregisterFilterInstance,
237         IFilterMapper_fnUnregisterPin,
238         IFilterMapper_fnEnumMatchingFilters,
239 };
240
241
242 HRESULT CFilterMapper_InitIFilterMapper( CFilterMapper* pfm )
243 {
244         TRACE("(%p)\n",pfm);
245         ICOM_VTBL(&pfm->fmap) = &ifmap;
246
247         return NOERROR;
248 }
249
250 void CFilterMapper_UninitIFilterMapper( CFilterMapper* pfm )
251 {
252         TRACE("(%p)\n",pfm);
253 }
254
255
256 /***************************************************************************
257  *
258  *      new/delete for CLSID_FilterMapper2
259  *
260  */
261
262 /* can I use offsetof safely? - FIXME? */
263 static QUARTZ_IFEntry FMap2IFEntries[] =
264 {
265   { &IID_IFilterMapper2, offsetof(CFilterMapper2,fmap3)-offsetof(CFilterMapper2,unk) },
266   { &IID_IFilterMapper3, offsetof(CFilterMapper2,fmap3)-offsetof(CFilterMapper2,unk) },
267 };
268
269
270 static void QUARTZ_DestroyFilterMapper2(IUnknown* punk)
271 {
272         CFilterMapper2_THIS(punk,unk);
273
274         CFilterMapper2_UninitIFilterMapper3( This );
275 }
276
277 HRESULT QUARTZ_CreateFilterMapper2(IUnknown* punkOuter,void** ppobj)
278 {
279         CFilterMapper2* pfm;
280         HRESULT hr;
281
282         TRACE("(%p,%p)\n",punkOuter,ppobj);
283
284         pfm = (CFilterMapper2*)QUARTZ_AllocObj( sizeof(CFilterMapper2) );
285         if ( pfm == NULL )
286                 return E_OUTOFMEMORY;
287
288         QUARTZ_IUnkInit( &pfm->unk, punkOuter );
289         hr = CFilterMapper2_InitIFilterMapper3( pfm );
290         if ( FAILED(hr) )
291         {
292                 QUARTZ_FreeObj( pfm );
293                 return hr;
294         }
295
296         pfm->unk.pEntries = FMap2IFEntries;
297         pfm->unk.dwEntries = sizeof(FMap2IFEntries)/sizeof(FMap2IFEntries[0]);
298         pfm->unk.pOnFinalRelease = QUARTZ_DestroyFilterMapper2;
299
300         *ppobj = (void*)(&pfm->unk);
301
302         return S_OK;
303 }
304
305 /***************************************************************************
306  *
307  *      CLSID_FilterMapper2::IFilterMapper3
308  *
309  */
310
311
312 static HRESULT WINAPI
313 IFilterMapper3_fnQueryInterface(IFilterMapper3* iface,REFIID riid,void** ppobj)
314 {
315         CFilterMapper2_THIS(iface,fmap3);
316
317         TRACE("(%p)->()\n",This);
318
319         return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
320 }
321
322 static ULONG WINAPI
323 IFilterMapper3_fnAddRef(IFilterMapper3* iface)
324 {
325         CFilterMapper2_THIS(iface,fmap3);
326
327         TRACE("(%p)->()\n",This);
328
329         return IUnknown_AddRef(This->unk.punkControl);
330 }
331
332 static ULONG WINAPI
333 IFilterMapper3_fnRelease(IFilterMapper3* iface)
334 {
335         CFilterMapper2_THIS(iface,fmap3);
336
337         TRACE("(%p)->()\n",This);
338
339         return IUnknown_Release(This->unk.punkControl);
340 }
341
342 static HRESULT WINAPI
343 IFilterMapper3_fnCreateCategory(IFilterMapper3* iface,REFCLSID rclsidCategory,DWORD dwMerit,LPCWSTR lpwszDesc)
344 {
345         CFilterMapper2_THIS(iface,fmap3);
346
347         FIXME("(%p)->(%s,%lu,%s) stub!\n",This,
348                 debugstr_guid(rclsidCategory),
349                 (unsigned long)dwMerit,debugstr_w(lpwszDesc));
350
351         return E_NOTIMPL;
352 }
353
354
355 static HRESULT WINAPI
356 IFilterMapper3_fnUnregisterFilter(IFilterMapper3* iface,const CLSID* pclsidCategory,const OLECHAR* lpwszInst,REFCLSID rclsidFilter)
357 {
358         CFilterMapper2_THIS(iface,fmap3);
359
360         FIXME("(%p)->(%s,%s,%s) stub!\n",This,
361                 debugstr_guid(pclsidCategory),
362                 debugstr_w(lpwszInst),
363                 debugstr_guid(rclsidFilter));
364
365         if ( pclsidCategory == NULL )
366                 pclsidCategory = &CLSID_LegacyAmFilterCategory;
367
368         /* FIXME */
369         return QUARTZ_RegisterAMovieFilter(
370                 pclsidCategory,
371                 rclsidFilter,
372                 NULL, 0,
373                 NULL, lpwszInst, FALSE );
374 }
375
376
377 static HRESULT WINAPI
378 IFilterMapper3_fnRegisterFilter(IFilterMapper3* iface,REFCLSID rclsidFilter,LPCWSTR lpName,IMoniker** ppMoniker,const CLSID* pclsidCategory,const OLECHAR* lpwszInst,const REGFILTER2* pRF2)
379 {
380         CFilterMapper2_THIS(iface,fmap3);
381
382         FIXME( "(%p)->(%s,%s,%p,%s,%s,%p) stub!\n",This,
383                 debugstr_guid(rclsidFilter),debugstr_w(lpName),
384                 ppMoniker,debugstr_guid(pclsidCategory),
385                 debugstr_w(lpwszInst),pRF2 );
386
387         if ( lpName == NULL || pRF2 == NULL )
388                 return E_POINTER;
389
390         if ( ppMoniker != NULL )
391         {
392                 FIXME( "ppMoniker != NULL - not implemented!\n" );
393                 return E_NOTIMPL;
394         }
395
396         if ( pclsidCategory == NULL )
397                 pclsidCategory = &CLSID_LegacyAmFilterCategory;
398
399         /* FIXME!! - all members in REGFILTER2 are ignored ! */
400
401         return QUARTZ_RegisterAMovieFilter(
402                 pclsidCategory,
403                 rclsidFilter,
404                 NULL, 0,
405                 lpName, lpwszInst, TRUE );
406 }
407
408
409 static HRESULT WINAPI
410 IFilterMapper3_fnEnumMatchingFilters(IFilterMapper3* iface,IEnumMoniker** ppMoniker,DWORD dwFlags,BOOL bExactMatch,DWORD dwMerit,BOOL bInputNeeded,DWORD cInputTypes,const GUID* pguidInputTypes,const REGPINMEDIUM* pPinMediumIn,const CLSID* pPinCategoryIn,BOOL bRender,BOOL bOutputNeeded,DWORD cOutputTypes,const GUID* pguidOutputTypes,const REGPINMEDIUM* pPinMediumOut,const CLSID* pPinCategoryOut)
411 {
412         CFilterMapper2_THIS(iface,fmap3);
413
414         FIXME("(%p)->() stub!\n",This);
415
416         return E_NOTIMPL;
417 }
418
419 static HRESULT WINAPI
420 IFilterMapper3_fnGetICreateDevEnum(IFilterMapper3* iface,ICreateDevEnum** ppDevEnum)
421 {
422         CFilterMapper2_THIS(iface,fmap3);
423
424         /* undocumented */
425         FIXME("(%p)->() stub!\n",This);
426
427         return E_NOTIMPL;
428 }
429
430
431
432
433 static ICOM_VTABLE(IFilterMapper3) ifmap3 =
434 {
435         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
436         /* IUnknown fields */
437         IFilterMapper3_fnQueryInterface,
438         IFilterMapper3_fnAddRef,
439         IFilterMapper3_fnRelease,
440         /* IFilterMapper2 fields */
441         IFilterMapper3_fnCreateCategory,
442         IFilterMapper3_fnUnregisterFilter,
443         IFilterMapper3_fnRegisterFilter,
444         IFilterMapper3_fnEnumMatchingFilters,
445         /* IFilterMapper3 fields */
446         IFilterMapper3_fnGetICreateDevEnum,
447 };
448
449
450 HRESULT CFilterMapper2_InitIFilterMapper3( CFilterMapper2* pfm )
451 {
452         TRACE("(%p)\n",pfm);
453         ICOM_VTBL(&pfm->fmap3) = &ifmap3;
454
455         return NOERROR;
456 }
457
458 void CFilterMapper2_UninitIFilterMapper3( CFilterMapper2* pfm )
459 {
460         TRACE("(%p)\n",pfm);
461 }
462