2003-08-24 00:56:43 +02:00
|
|
|
/*
|
|
|
|
* self-registerable dll functions for quartz.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 John K. Hohm
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-24 00:56:43 +02:00
|
|
|
*/
|
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define COBJMACROS
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-08-24 00:56:43 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2008-07-10 19:38:47 +02:00
|
|
|
#include "wingdi.h"
|
2003-08-24 00:56:43 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "uuids.h"
|
2005-01-09 18:28:07 +01:00
|
|
|
#include "strmif.h"
|
2003-08-24 00:56:43 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Near the bottom of this file are the exported DllRegisterServer and
|
|
|
|
* DllUnregisterServer, which make all this worthwhile.
|
|
|
|
*/
|
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
struct mediatype
|
|
|
|
{
|
|
|
|
CLSID const *majortype; /* NULL for end of list */
|
|
|
|
CLSID const *subtype;
|
|
|
|
DWORD fourcc;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pin
|
|
|
|
{
|
|
|
|
DWORD flags; /* 0xFFFFFFFF for end of list */
|
|
|
|
struct mediatype mediatypes[11];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct regsvr_filter
|
|
|
|
{
|
|
|
|
CLSID const *clsid; /* NULL for end of list */
|
|
|
|
CLSID const *category;
|
|
|
|
WCHAR name[50];
|
|
|
|
DWORD merit;
|
|
|
|
struct pin pins[11];
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* register_filters
|
|
|
|
*/
|
|
|
|
static HRESULT register_filters(struct regsvr_filter const *list)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IFilterMapper2* pFM2 = NULL;
|
|
|
|
|
|
|
|
CoInitialize(NULL);
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pFM2);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
for (; SUCCEEDED(hr) && list->clsid; ++list) {
|
|
|
|
REGFILTER2 rf2;
|
|
|
|
REGFILTERPINS2* prfp2;
|
|
|
|
int i;
|
2005-01-21 11:14:45 +01:00
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
for (i = 0; list->pins[i].flags != 0xFFFFFFFF; i++) ;
|
|
|
|
rf2.dwVersion = 2;
|
|
|
|
rf2.dwMerit = list->merit;
|
2012-05-12 16:14:07 +02:00
|
|
|
rf2.u.s2.cPins2 = i;
|
|
|
|
rf2.u.s2.rgPins2 = prfp2 = CoTaskMemAlloc(i*sizeof(REGFILTERPINS2));
|
2005-01-09 18:28:07 +01:00
|
|
|
if (!prfp2) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (i = 0; list->pins[i].flags != 0xFFFFFFFF; i++) {
|
|
|
|
REGPINTYPES* lpMediatype;
|
|
|
|
CLSID* lpClsid;
|
|
|
|
int j, nbmt;
|
2005-01-21 11:14:45 +01:00
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
for (nbmt = 0; list->pins[i].mediatypes[nbmt].majortype; nbmt++) ;
|
|
|
|
/* Allocate a single buffer for regpintypes struct and clsids */
|
2007-06-27 00:12:07 +02:00
|
|
|
lpMediatype = CoTaskMemAlloc(nbmt*(sizeof(REGPINTYPES) + 2*sizeof(CLSID)));
|
2005-01-09 18:28:07 +01:00
|
|
|
if (!lpMediatype) {
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lpClsid = (CLSID*) (lpMediatype + nbmt);
|
|
|
|
for (j = 0; j < nbmt; j++) {
|
|
|
|
(lpMediatype + j)->clsMajorType = lpClsid + j*2;
|
|
|
|
memcpy(lpClsid + j*2, list->pins[i].mediatypes[j].majortype, sizeof(CLSID));
|
|
|
|
(lpMediatype + j)->clsMinorType = lpClsid + j*2 + 1;
|
|
|
|
if (list->pins[i].mediatypes[j].subtype)
|
|
|
|
memcpy(lpClsid + j*2 + 1, list->pins[i].mediatypes[j].subtype, sizeof(CLSID));
|
|
|
|
else {
|
2014-04-30 15:42:10 +02:00
|
|
|
/* Subtypes are often a combination of major type + fourcc/tag */
|
2005-01-09 18:28:07 +01:00
|
|
|
memcpy(lpClsid + j*2 + 1, list->pins[i].mediatypes[j].majortype, sizeof(CLSID));
|
|
|
|
*(DWORD*)(lpClsid + j*2 + 1) = list->pins[i].mediatypes[j].fourcc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
prfp2[i].dwFlags = list->pins[i].flags;
|
|
|
|
prfp2[i].cInstances = 0;
|
|
|
|
prfp2[i].nMediaTypes = j;
|
|
|
|
prfp2[i].lpMediaType = lpMediatype;
|
|
|
|
prfp2[i].nMediums = 0;
|
|
|
|
prfp2[i].lpMedium = NULL;
|
|
|
|
prfp2[i].clsPinCategory = NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-21 11:14:45 +01:00
|
|
|
if (FAILED(hr)) {
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("failed to register with hresult 0x%x\n", hr);
|
2005-01-31 17:24:00 +01:00
|
|
|
CoTaskMemFree(prfp2);
|
2005-01-21 11:14:45 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
hr = IFilterMapper2_RegisterFilter(pFM2, list->clsid, list->name, NULL, list->category, NULL, &rf2);
|
|
|
|
|
2005-01-21 11:14:45 +01:00
|
|
|
while (i) {
|
2005-01-09 18:28:07 +01:00
|
|
|
CoTaskMemFree((REGPINTYPES*)prfp2[i-1].lpMediaType);
|
2005-01-21 11:14:45 +01:00
|
|
|
i--;
|
|
|
|
}
|
2005-01-09 18:28:07 +01:00
|
|
|
CoTaskMemFree(prfp2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pFM2)
|
|
|
|
IFilterMapper2_Release(pFM2);
|
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* unregister_filters
|
|
|
|
*/
|
|
|
|
static HRESULT unregister_filters(struct regsvr_filter const *list)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IFilterMapper2* pFM2;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterMapper2, (LPVOID*)&pFM2);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
for (; SUCCEEDED(hr) && list->clsid; ++list)
|
|
|
|
hr = IFilterMapper2_UnregisterFilter(pFM2, list->category, NULL, list->clsid);
|
|
|
|
IFilterMapper2_Release(pFM2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* filter list
|
|
|
|
*/
|
|
|
|
|
|
|
|
static struct regsvr_filter const filter_list[] = {
|
|
|
|
{ &CLSID_VideoRenderer,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"Video Renderer",
|
2005-01-09 18:28:07 +01:00
|
|
|
0x800000,
|
|
|
|
{ { REG_PINFLAG_B_RENDERER,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
2008-02-02 10:47:34 +01:00
|
|
|
{ &CLSID_VideoRendererDefault,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"Video Renderer",
|
2008-02-02 10:47:34 +01:00
|
|
|
0x800000,
|
|
|
|
{ { REG_PINFLAG_B_RENDERER,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
2013-11-05 23:59:54 +01:00
|
|
|
{ &CLSID_VideoMixingRenderer,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"Video Mixing Renderer",
|
2013-11-05 23:59:54 +01:00
|
|
|
0x200000,
|
|
|
|
{ { REG_PINFLAG_B_RENDERER,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
2012-04-03 21:37:55 +02:00
|
|
|
{ &CLSID_VideoMixingRenderer9,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"Video Mixing Renderer 9",
|
2012-04-03 21:37:55 +02:00
|
|
|
0x200000,
|
|
|
|
{ { REG_PINFLAG_B_RENDERER,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
2008-07-03 01:48:13 +02:00
|
|
|
}
|
|
|
|
},
|
2005-01-09 18:28:07 +01:00
|
|
|
{ &CLSID_AVIDec,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"AVI Decompressor",
|
2012-01-17 16:02:25 +01:00
|
|
|
0x5ffff0,
|
2005-01-09 18:28:07 +01:00
|
|
|
{ { 0,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ REG_PINFLAG_B_OUTPUT,
|
|
|
|
{ { &MEDIATYPE_Video, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ &CLSID_AsyncReader,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"File Source (Async.)",
|
2005-01-09 18:28:07 +01:00
|
|
|
0x400000,
|
|
|
|
{ { REG_PINFLAG_B_OUTPUT,
|
|
|
|
{ { &MEDIATYPE_Stream, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
2005-02-01 15:22:00 +01:00
|
|
|
{ &CLSID_ACMWrapper,
|
|
|
|
&CLSID_LegacyAmFilterCategory,
|
2020-01-22 23:30:53 +01:00
|
|
|
L"ACM Wrapper",
|
2012-01-17 16:02:25 +01:00
|
|
|
0x5ffff0,
|
2005-02-01 15:22:00 +01:00
|
|
|
{ { 0,
|
|
|
|
{ { &MEDIATYPE_Audio, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ REG_PINFLAG_B_OUTPUT,
|
|
|
|
{ { &MEDIATYPE_Audio, &GUID_NULL },
|
|
|
|
{ NULL }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ 0xFFFFFFFF },
|
|
|
|
}
|
|
|
|
},
|
2005-01-09 18:28:07 +01:00
|
|
|
{ NULL } /* list terminator */
|
|
|
|
};
|
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
extern HRESULT WINAPI QUARTZ_DllRegisterServer(void) DECLSPEC_HIDDEN;
|
|
|
|
extern HRESULT WINAPI QUARTZ_DllUnregisterServer(void) DECLSPEC_HIDDEN;
|
|
|
|
|
2003-08-24 00:56:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (QUARTZ.@)
|
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
2003-08-24 00:56:43 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2009-09-11 13:40:17 +02:00
|
|
|
hr = QUARTZ_DllRegisterServer();
|
2005-01-09 18:28:07 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = register_filters(filter_list);
|
2003-08-24 00:56:43 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (QUARTZ.@)
|
|
|
|
*/
|
2005-05-17 16:41:37 +02:00
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
2003-08-24 00:56:43 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2005-01-09 18:28:07 +01:00
|
|
|
hr = unregister_filters(filter_list);
|
2009-09-11 13:40:17 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = QUARTZ_DllUnregisterServer();
|
2003-08-24 00:56:43 +02:00
|
|
|
return hr;
|
|
|
|
}
|