2 * self-registerable dll functions for quartz.dll
4 * Copyright (C) 2003 John K. Hohm
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
41 * Near the bottom of this file are the exported DllRegisterServer and
42 * DllUnregisterServer, which make all this worthwhile.
47 CLSID
const *majortype
; /* NULL for end of list */
54 DWORD flags
; /* 0xFFFFFFFF for end of list */
55 struct mediatype mediatypes
[11];
60 CLSID
const *clsid
; /* NULL for end of list */
61 CLSID
const *category
;
67 /***********************************************************************
70 static HRESULT
register_filters(struct regsvr_filter
const *list
)
73 IFilterMapper2
* pFM2
= NULL
;
76 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IFilterMapper2
, (LPVOID
*)&pFM2
);
79 for (; SUCCEEDED(hr
) && list
->clsid
; ++list
) {
81 REGFILTERPINS2
* prfp2
;
84 for (i
= 0; list
->pins
[i
].flags
!= 0xFFFFFFFF; i
++) ;
86 rf2
.dwMerit
= list
->merit
;
88 rf2
.rgPins2
= prfp2
= CoTaskMemAlloc(i
*sizeof(REGFILTERPINS2
));
93 for (i
= 0; list
->pins
[i
].flags
!= 0xFFFFFFFF; i
++) {
94 REGPINTYPES
* lpMediatype
;
98 for (nbmt
= 0; list
->pins
[i
].mediatypes
[nbmt
].majortype
; nbmt
++) ;
99 /* Allocate a single buffer for regpintypes struct and clsids */
100 lpMediatype
= CoTaskMemAlloc(nbmt
*(sizeof(REGPINTYPES
) + 2*sizeof(CLSID
)));
105 lpClsid
= (CLSID
*) (lpMediatype
+ nbmt
);
106 for (j
= 0; j
< nbmt
; j
++) {
107 (lpMediatype
+ j
)->clsMajorType
= lpClsid
+ j
*2;
108 memcpy(lpClsid
+ j
*2, list
->pins
[i
].mediatypes
[j
].majortype
, sizeof(CLSID
));
109 (lpMediatype
+ j
)->clsMinorType
= lpClsid
+ j
*2 + 1;
110 if (list
->pins
[i
].mediatypes
[j
].subtype
)
111 memcpy(lpClsid
+ j
*2 + 1, list
->pins
[i
].mediatypes
[j
].subtype
, sizeof(CLSID
));
113 /* Subtypes are often a combination of major type + fourcc/tag */
114 memcpy(lpClsid
+ j
*2 + 1, list
->pins
[i
].mediatypes
[j
].majortype
, sizeof(CLSID
));
115 *(DWORD
*)(lpClsid
+ j
*2 + 1) = list
->pins
[i
].mediatypes
[j
].fourcc
;
118 prfp2
[i
].dwFlags
= list
->pins
[i
].flags
;
119 prfp2
[i
].cInstances
= 0;
120 prfp2
[i
].nMediaTypes
= j
;
121 prfp2
[i
].lpMediaType
= lpMediatype
;
122 prfp2
[i
].nMediums
= 0;
123 prfp2
[i
].lpMedium
= NULL
;
124 prfp2
[i
].clsPinCategory
= NULL
;
128 ERR("failed to register with hresult %#lx\n", hr
);
129 CoTaskMemFree(prfp2
);
133 hr
= IFilterMapper2_RegisterFilter(pFM2
, list
->clsid
, list
->name
, NULL
, list
->category
, NULL
, &rf2
);
136 CoTaskMemFree((REGPINTYPES
*)prfp2
[i
-1].lpMediaType
);
139 CoTaskMemFree(prfp2
);
144 IFilterMapper2_Release(pFM2
);
151 /***********************************************************************
154 static HRESULT
unregister_filters(struct regsvr_filter
const *list
)
157 IFilterMapper2
* pFM2
;
159 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IFilterMapper2
, (LPVOID
*)&pFM2
);
162 for (; SUCCEEDED(hr
) && list
->clsid
; ++list
)
163 hr
= IFilterMapper2_UnregisterFilter(pFM2
, list
->category
, NULL
, list
->clsid
);
164 IFilterMapper2_Release(pFM2
);
170 /***********************************************************************
174 static struct regsvr_filter
const filter_list
[] = {
175 { &CLSID_VideoRenderer
,
176 &CLSID_LegacyAmFilterCategory
,
179 { { REG_PINFLAG_B_RENDERER
,
180 { { &MEDIATYPE_Video
, &GUID_NULL
},
187 { &CLSID_VideoRendererDefault
,
188 &CLSID_LegacyAmFilterCategory
,
191 { { REG_PINFLAG_B_RENDERER
,
192 { { &MEDIATYPE_Video
, &GUID_NULL
},
199 { &CLSID_VideoMixingRenderer9
,
200 &CLSID_LegacyAmFilterCategory
,
201 L
"Video Mixing Renderer 9",
203 { { REG_PINFLAG_B_RENDERER
,
204 { { &MEDIATYPE_Video
, &GUID_NULL
},
212 &CLSID_LegacyAmFilterCategory
,
216 { { &MEDIATYPE_Video
, &GUID_NULL
},
220 { REG_PINFLAG_B_OUTPUT
,
221 { { &MEDIATYPE_Video
, &GUID_NULL
},
228 { &CLSID_AsyncReader
,
229 &CLSID_LegacyAmFilterCategory
,
230 L
"File Source (Async.)",
232 { { REG_PINFLAG_B_OUTPUT
,
233 { { &MEDIATYPE_Stream
, &GUID_NULL
},
241 &CLSID_LegacyAmFilterCategory
,
245 { { &MEDIATYPE_Audio
, &GUID_NULL
},
249 { REG_PINFLAG_B_OUTPUT
,
250 { { &MEDIATYPE_Audio
, &GUID_NULL
},
257 { NULL
} /* list terminator */
260 extern HRESULT WINAPI
QUARTZ_DllRegisterServer(void);
261 extern HRESULT WINAPI
QUARTZ_DllUnregisterServer(void);
263 /***********************************************************************
264 * DllRegisterServer (QUARTZ.@)
266 HRESULT WINAPI
DllRegisterServer(void)
272 hr
= QUARTZ_DllRegisterServer();
274 hr
= register_filters(filter_list
);
278 /***********************************************************************
279 * DllUnregisterServer (QUARTZ.@)
281 HRESULT WINAPI
DllUnregisterServer(void)
287 hr
= unregister_filters(filter_list
);
289 hr
= QUARTZ_DllUnregisterServer();