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
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
43 * Near the bottom of this file are the exported DllRegisterServer and
44 * DllUnregisterServer, which make all this worthwhile.
49 CLSID
const *majortype
; /* NULL for end of list */
56 DWORD flags
; /* 0xFFFFFFFF for end of list */
57 struct mediatype mediatypes
[11];
62 CLSID
const *clsid
; /* NULL for end of list */
63 CLSID
const *category
;
69 /***********************************************************************
72 static HRESULT
register_filters(struct regsvr_filter
const *list
)
75 IFilterMapper2
* pFM2
= NULL
;
78 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IFilterMapper2
, (LPVOID
*)&pFM2
);
81 for (; SUCCEEDED(hr
) && list
->clsid
; ++list
) {
83 REGFILTERPINS2
* prfp2
;
86 for (i
= 0; list
->pins
[i
].flags
!= 0xFFFFFFFF; i
++) ;
88 rf2
.dwMerit
= list
->merit
;
90 rf2
.u
.s2
.rgPins2
= prfp2
= CoTaskMemAlloc(i
*sizeof(REGFILTERPINS2
));
95 for (i
= 0; list
->pins
[i
].flags
!= 0xFFFFFFFF; i
++) {
96 REGPINTYPES
* lpMediatype
;
100 for (nbmt
= 0; list
->pins
[i
].mediatypes
[nbmt
].majortype
; nbmt
++) ;
101 /* Allocate a single buffer for regpintypes struct and clsids */
102 lpMediatype
= CoTaskMemAlloc(nbmt
*(sizeof(REGPINTYPES
) + 2*sizeof(CLSID
)));
107 lpClsid
= (CLSID
*) (lpMediatype
+ nbmt
);
108 for (j
= 0; j
< nbmt
; j
++) {
109 (lpMediatype
+ j
)->clsMajorType
= lpClsid
+ j
*2;
110 memcpy(lpClsid
+ j
*2, list
->pins
[i
].mediatypes
[j
].majortype
, sizeof(CLSID
));
111 (lpMediatype
+ j
)->clsMinorType
= lpClsid
+ j
*2 + 1;
112 if (list
->pins
[i
].mediatypes
[j
].subtype
)
113 memcpy(lpClsid
+ j
*2 + 1, list
->pins
[i
].mediatypes
[j
].subtype
, sizeof(CLSID
));
115 /* Subtypes are often a combination of major type + fourcc/tag */
116 memcpy(lpClsid
+ j
*2 + 1, list
->pins
[i
].mediatypes
[j
].majortype
, sizeof(CLSID
));
117 *(DWORD
*)(lpClsid
+ j
*2 + 1) = list
->pins
[i
].mediatypes
[j
].fourcc
;
120 prfp2
[i
].dwFlags
= list
->pins
[i
].flags
;
121 prfp2
[i
].cInstances
= 0;
122 prfp2
[i
].nMediaTypes
= j
;
123 prfp2
[i
].lpMediaType
= lpMediatype
;
124 prfp2
[i
].nMediums
= 0;
125 prfp2
[i
].lpMedium
= NULL
;
126 prfp2
[i
].clsPinCategory
= NULL
;
130 ERR("failed to register with hresult 0x%x\n", hr
);
131 CoTaskMemFree(prfp2
);
135 hr
= IFilterMapper2_RegisterFilter(pFM2
, list
->clsid
, list
->name
, NULL
, list
->category
, NULL
, &rf2
);
138 CoTaskMemFree((REGPINTYPES
*)prfp2
[i
-1].lpMediaType
);
141 CoTaskMemFree(prfp2
);
146 IFilterMapper2_Release(pFM2
);
153 /***********************************************************************
156 static HRESULT
unregister_filters(struct regsvr_filter
const *list
)
159 IFilterMapper2
* pFM2
;
161 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IFilterMapper2
, (LPVOID
*)&pFM2
);
164 for (; SUCCEEDED(hr
) && list
->clsid
; ++list
)
165 hr
= IFilterMapper2_UnregisterFilter(pFM2
, list
->category
, NULL
, list
->clsid
);
166 IFilterMapper2_Release(pFM2
);
172 /***********************************************************************
176 static struct regsvr_filter
const filter_list
[] = {
177 { &CLSID_VideoRenderer
,
178 &CLSID_LegacyAmFilterCategory
,
181 { { REG_PINFLAG_B_RENDERER
,
182 { { &MEDIATYPE_Video
, &GUID_NULL
},
189 { &CLSID_VideoRendererDefault
,
190 &CLSID_LegacyAmFilterCategory
,
193 { { REG_PINFLAG_B_RENDERER
,
194 { { &MEDIATYPE_Video
, &GUID_NULL
},
201 { &CLSID_VideoMixingRenderer9
,
202 &CLSID_LegacyAmFilterCategory
,
203 L
"Video Mixing Renderer 9",
205 { { REG_PINFLAG_B_RENDERER
,
206 { { &MEDIATYPE_Video
, &GUID_NULL
},
214 &CLSID_LegacyAmFilterCategory
,
218 { { &MEDIATYPE_Video
, &GUID_NULL
},
222 { REG_PINFLAG_B_OUTPUT
,
223 { { &MEDIATYPE_Video
, &GUID_NULL
},
230 { &CLSID_AsyncReader
,
231 &CLSID_LegacyAmFilterCategory
,
232 L
"File Source (Async.)",
234 { { REG_PINFLAG_B_OUTPUT
,
235 { { &MEDIATYPE_Stream
, &GUID_NULL
},
243 &CLSID_LegacyAmFilterCategory
,
247 { { &MEDIATYPE_Audio
, &GUID_NULL
},
251 { REG_PINFLAG_B_OUTPUT
,
252 { { &MEDIATYPE_Audio
, &GUID_NULL
},
259 { NULL
} /* list terminator */
262 extern HRESULT WINAPI
QUARTZ_DllRegisterServer(void) DECLSPEC_HIDDEN
;
263 extern HRESULT WINAPI
QUARTZ_DllUnregisterServer(void) DECLSPEC_HIDDEN
;
265 /***********************************************************************
266 * DllRegisterServer (QUARTZ.@)
268 HRESULT WINAPI
DllRegisterServer(void)
274 hr
= QUARTZ_DllRegisterServer();
276 hr
= register_filters(filter_list
);
280 /***********************************************************************
281 * DllUnregisterServer (QUARTZ.@)
283 HRESULT WINAPI
DllUnregisterServer(void)
289 hr
= unregister_filters(filter_list
);
291 hr
= QUARTZ_DllUnregisterServer();