2003-07-01 06:30:30 +02:00
|
|
|
/*
|
|
|
|
* ICreateDevEnum implementation for DEVENUM.dll
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Shearman
|
|
|
|
*
|
|
|
|
* 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-07-01 06:30:30 +02:00
|
|
|
*
|
|
|
|
* NOTES ON THIS FILE:
|
|
|
|
* - Implements ICreateDevEnum interface which creates an IEnumMoniker
|
|
|
|
* implementation
|
|
|
|
* - Also creates the special registry keys created at run-time
|
|
|
|
*/
|
|
|
|
|
2003-12-30 22:52:45 +01:00
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
#include "devenum_private.h"
|
2005-04-27 13:07:55 +02:00
|
|
|
#include "vfw.h"
|
2014-01-08 14:12:25 +01:00
|
|
|
#include "aviriff.h"
|
2018-03-11 05:11:52 +01:00
|
|
|
#include "dsound.h"
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2005-05-18 20:25:12 +02:00
|
|
|
#include "wine/unicode.h"
|
2018-03-11 05:11:51 +01:00
|
|
|
#include "wine/heap.h"
|
2003-07-01 06:30:30 +02:00
|
|
|
#include "mmddk.h"
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "fil_data.h"
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
|
|
|
extern HINSTANCE DEVENUM_hInstance;
|
|
|
|
|
2008-06-29 14:07:00 +02:00
|
|
|
static const WCHAR wszFilterKeyName[] = {'F','i','l','t','e','r',0};
|
|
|
|
static const WCHAR wszMeritName[] = {'M','e','r','i','t',0};
|
|
|
|
static const WCHAR wszPins[] = {'P','i','n','s',0};
|
|
|
|
static const WCHAR wszAllowedMany[] = {'A','l','l','o','w','e','d','M','a','n','y',0};
|
|
|
|
static const WCHAR wszAllowedZero[] = {'A','l','l','o','w','e','d','Z','e','r','o',0};
|
|
|
|
static const WCHAR wszDirection[] = {'D','i','r','e','c','t','i','o','n',0};
|
|
|
|
static const WCHAR wszIsRendered[] = {'I','s','R','e','n','d','e','r','e','d',0};
|
|
|
|
static const WCHAR wszTypes[] = {'T','y','p','e','s',0};
|
2013-05-10 10:07:09 +02:00
|
|
|
static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
|
|
|
|
static const WCHAR wszWaveInID[] = {'W','a','v','e','I','n','I','D',0};
|
2018-03-11 05:11:51 +01:00
|
|
|
static const WCHAR wszFilterData[] = {'F','i','l','t','e','r','D','a','t','a',0};
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
static ULONG WINAPI DEVENUM_ICreateDevEnum_AddRef(ICreateDevEnum * iface);
|
2018-03-07 03:57:08 +01:00
|
|
|
static HRESULT register_codecs(void);
|
2018-03-11 05:11:51 +01:00
|
|
|
static HRESULT DEVENUM_CreateAMCategoryKey(const CLSID * clsidCategory);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_ICreateDevEnum_QueryInterface (also IUnknown)
|
|
|
|
*/
|
2012-04-03 00:15:31 +02:00
|
|
|
static HRESULT WINAPI DEVENUM_ICreateDevEnum_QueryInterface(ICreateDevEnum *iface, REFIID riid,
|
|
|
|
void **ppv)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2012-05-07 21:21:24 +02:00
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2012-04-03 00:15:31 +02:00
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_ICreateDevEnum))
|
|
|
|
{
|
2012-04-03 00:15:31 +02:00
|
|
|
*ppv = iface;
|
2003-07-01 06:30:30 +02:00
|
|
|
DEVENUM_ICreateDevEnum_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-01-11 23:47:51 +01:00
|
|
|
FIXME("- no interface IID: %s\n", debugstr_guid(riid));
|
2012-04-03 00:15:31 +02:00
|
|
|
*ppv = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_ICreateDevEnum_AddRef (also IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI DEVENUM_ICreateDevEnum_AddRef(ICreateDevEnum * iface)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_LockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 2; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_ICreateDevEnum_Release (also IUnknown)
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI DEVENUM_ICreateDevEnum_Release(ICreateDevEnum * iface)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
DEVENUM_UnlockModule();
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2004-12-07 15:37:11 +01:00
|
|
|
return 1; /* non-heap based object */
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
2014-01-08 14:12:11 +01:00
|
|
|
static HKEY open_special_category_key(const CLSID *clsid, BOOL create)
|
|
|
|
{
|
|
|
|
WCHAR key_name[sizeof(wszActiveMovieKey)/sizeof(WCHAR) + CHARS_IN_GUID-1];
|
|
|
|
HKEY ret;
|
|
|
|
LONG res;
|
|
|
|
|
|
|
|
strcpyW(key_name, wszActiveMovieKey);
|
|
|
|
if (!StringFromGUID2(clsid, key_name + sizeof(wszActiveMovieKey)/sizeof(WCHAR)-1, CHARS_IN_GUID))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(create)
|
|
|
|
res = RegCreateKeyW(HKEY_CURRENT_USER, key_name, &ret);
|
|
|
|
else
|
|
|
|
res = RegOpenKeyExW(HKEY_CURRENT_USER, key_name, 0, KEY_READ, &ret);
|
|
|
|
if (res != ERROR_SUCCESS) {
|
|
|
|
WARN("Could not open %s\n", debugstr_w(key_name));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
static HRESULT register_codec(const CLSID *class, const WCHAR *name, IMoniker **ret)
|
|
|
|
{
|
|
|
|
static const WCHAR deviceW[] = {'@','d','e','v','i','c','e',':','c','m',':',0};
|
|
|
|
IParseDisplayName *parser;
|
|
|
|
WCHAR *buffer;
|
|
|
|
ULONG eaten;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
buffer = heap_alloc((strlenW(deviceW) + CHARS_IN_GUID + strlenW(name) + 1) * sizeof(WCHAR));
|
|
|
|
if (!buffer)
|
|
|
|
{
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(buffer, deviceW);
|
|
|
|
StringFromGUID2(class, buffer + strlenW(buffer), CHARS_IN_GUID);
|
|
|
|
strcatW(buffer, backslashW);
|
|
|
|
strcatW(buffer, name);
|
|
|
|
|
|
|
|
hr = IParseDisplayName_ParseDisplayName(parser, NULL, buffer, &eaten, ret);
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
heap_free(buffer);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
static void DEVENUM_ReadPinTypes(HKEY hkeyPinKey, REGFILTERPINS2 *rgPin)
|
2008-06-29 14:07:00 +02:00
|
|
|
{
|
|
|
|
HKEY hkeyTypes = NULL;
|
|
|
|
DWORD dwMajorTypes, i;
|
|
|
|
REGPINTYPES *lpMediaType = NULL;
|
|
|
|
DWORD dwMediaTypeSize = 0;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hkeyPinKey, wszTypes, 0, KEY_READ, &hkeyTypes) != ERROR_SUCCESS)
|
|
|
|
return ;
|
|
|
|
|
|
|
|
if (RegQueryInfoKeyW(hkeyTypes, NULL, NULL, NULL, &dwMajorTypes, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyTypes);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < dwMajorTypes; i++)
|
|
|
|
{
|
|
|
|
HKEY hkeyMajorType = NULL;
|
|
|
|
WCHAR wszMajorTypeName[64];
|
|
|
|
DWORD cName = sizeof(wszMajorTypeName) / sizeof(WCHAR);
|
|
|
|
DWORD dwMinorTypes, i1;
|
|
|
|
|
|
|
|
if (RegEnumKeyExW(hkeyTypes, i, wszMajorTypeName, &cName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hkeyTypes, wszMajorTypeName, 0, KEY_READ, &hkeyMajorType) != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
if (RegQueryInfoKeyW(hkeyMajorType, NULL, NULL, NULL, &dwMinorTypes, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyMajorType);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i1 = 0; i1 < dwMinorTypes; i1++)
|
|
|
|
{
|
|
|
|
WCHAR wszMinorTypeName[64];
|
|
|
|
CLSID *clsMajorType = NULL, *clsMinorType = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2012-04-18 00:11:08 +02:00
|
|
|
cName = sizeof(wszMinorTypeName) / sizeof(WCHAR);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (RegEnumKeyExW(hkeyMajorType, i1, wszMinorTypeName, &cName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
clsMinorType = CoTaskMemAlloc(sizeof(CLSID));
|
|
|
|
if (!clsMinorType) continue;
|
|
|
|
|
|
|
|
clsMajorType = CoTaskMemAlloc(sizeof(CLSID));
|
|
|
|
if (!clsMajorType) goto error_cleanup_types;
|
|
|
|
|
|
|
|
hr = CLSIDFromString(wszMinorTypeName, clsMinorType);
|
|
|
|
if (FAILED(hr)) goto error_cleanup_types;
|
|
|
|
|
|
|
|
hr = CLSIDFromString(wszMajorTypeName, clsMajorType);
|
|
|
|
if (FAILED(hr)) goto error_cleanup_types;
|
|
|
|
|
|
|
|
if (rgPin->nMediaTypes == dwMediaTypeSize)
|
|
|
|
{
|
2008-09-10 20:31:50 +02:00
|
|
|
DWORD dwNewSize = dwMediaTypeSize + (dwMediaTypeSize < 2 ? 1 : dwMediaTypeSize / 2);
|
2008-06-29 14:07:00 +02:00
|
|
|
REGPINTYPES *lpNewMediaType;
|
|
|
|
|
|
|
|
lpNewMediaType = CoTaskMemRealloc(lpMediaType, sizeof(REGPINTYPES) * dwNewSize);
|
|
|
|
if (!lpNewMediaType) goto error_cleanup_types;
|
|
|
|
|
|
|
|
lpMediaType = lpNewMediaType;
|
|
|
|
dwMediaTypeSize = dwNewSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpMediaType[rgPin->nMediaTypes].clsMajorType = clsMajorType;
|
|
|
|
lpMediaType[rgPin->nMediaTypes].clsMinorType = clsMinorType;
|
|
|
|
rgPin->nMediaTypes++;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
error_cleanup_types:
|
|
|
|
|
2016-07-08 10:10:57 +02:00
|
|
|
CoTaskMemFree(clsMajorType);
|
|
|
|
CoTaskMemFree(clsMinorType);
|
2008-06-29 14:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkeyMajorType);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkeyTypes);
|
|
|
|
|
|
|
|
if (lpMediaType && !rgPin->nMediaTypes)
|
|
|
|
{
|
|
|
|
CoTaskMemFree(lpMediaType);
|
|
|
|
lpMediaType = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rgPin->lpMediaType = lpMediaType;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DEVENUM_ReadPins(HKEY hkeyFilterClass, REGFILTER2 *rgf2)
|
|
|
|
{
|
|
|
|
HKEY hkeyPins = NULL;
|
|
|
|
DWORD dwPinsSubkeys, i;
|
2018-03-09 06:42:17 +01:00
|
|
|
REGFILTERPINS2 *rgPins = NULL;
|
|
|
|
|
|
|
|
rgf2->dwVersion = 2;
|
|
|
|
rgf2->u.s2.cPins2 = 0;
|
|
|
|
rgf2->u.s2.rgPins2 = NULL;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
|
|
|
if (RegOpenKeyExW(hkeyFilterClass, wszPins, 0, KEY_READ, &hkeyPins) != ERROR_SUCCESS)
|
|
|
|
return ;
|
|
|
|
|
|
|
|
if (RegQueryInfoKeyW(hkeyPins, NULL, NULL, NULL, &dwPinsSubkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
|
|
|
|
!= ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyPins);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dwPinsSubkeys)
|
|
|
|
{
|
2018-03-09 06:42:17 +01:00
|
|
|
rgPins = CoTaskMemAlloc(sizeof(REGFILTERPINS2) * dwPinsSubkeys);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (!rgPins)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkeyPins);
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < dwPinsSubkeys; i++)
|
|
|
|
{
|
|
|
|
HKEY hkeyPinKey = NULL;
|
|
|
|
WCHAR wszPinName[MAX_PATH];
|
|
|
|
DWORD cName = sizeof(wszPinName) / sizeof(WCHAR);
|
2018-03-09 06:42:17 +01:00
|
|
|
REGFILTERPINS2 *rgPin = &rgPins[rgf2->u.s2.cPins2];
|
|
|
|
DWORD value, size, Type;
|
2008-06-29 14:07:00 +02:00
|
|
|
LONG lRet;
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
memset(rgPin, 0, sizeof(*rgPin));
|
2008-06-29 14:07:00 +02:00
|
|
|
|
|
|
|
if (RegEnumKeyExW(hkeyPins, i, wszPinName, &cName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW(hkeyPins, wszPinName, 0, KEY_READ, &hkeyPinKey) != ERROR_SUCCESS) continue;
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
size = sizeof(DWORD);
|
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, wszAllowedMany, NULL, &Type, (BYTE *)&value, &size);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (lRet != ERROR_SUCCESS || Type != REG_DWORD)
|
|
|
|
goto error_cleanup;
|
2018-03-09 06:42:17 +01:00
|
|
|
if (value)
|
|
|
|
rgPin->dwFlags |= REG_PINFLAG_B_MANY;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
size = sizeof(DWORD);
|
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, wszAllowedZero, NULL, &Type, (BYTE *)&value, &size);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (lRet != ERROR_SUCCESS || Type != REG_DWORD)
|
|
|
|
goto error_cleanup;
|
2018-03-09 06:42:17 +01:00
|
|
|
if (value)
|
|
|
|
rgPin->dwFlags |= REG_PINFLAG_B_ZERO;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
size = sizeof(DWORD);
|
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, wszDirection, NULL, &Type, (BYTE *)&value, &size);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (lRet != ERROR_SUCCESS || Type != REG_DWORD)
|
|
|
|
goto error_cleanup;
|
2018-03-09 06:42:17 +01:00
|
|
|
if (value)
|
|
|
|
rgPin->dwFlags |= REG_PINFLAG_B_OUTPUT;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
|
|
|
|
size = sizeof(DWORD);
|
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, wszIsRendered, NULL, &Type, (BYTE *)&value, &size);
|
2008-06-29 14:07:00 +02:00
|
|
|
if (lRet != ERROR_SUCCESS || Type != REG_DWORD)
|
|
|
|
goto error_cleanup;
|
2018-03-09 06:42:17 +01:00
|
|
|
if (value)
|
|
|
|
rgPin->dwFlags |= REG_PINFLAG_B_RENDERER;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
|
|
|
DEVENUM_ReadPinTypes(hkeyPinKey, rgPin);
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
++rgf2->u.s2.cPins2;
|
2008-06-29 14:07:00 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
error_cleanup:
|
|
|
|
|
|
|
|
RegCloseKey(hkeyPinKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkeyPins);
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
if (rgPins && !rgf2->u.s2.cPins2)
|
2008-06-29 14:07:00 +02:00
|
|
|
{
|
|
|
|
CoTaskMemFree(rgPins);
|
|
|
|
rgPins = NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:42:17 +01:00
|
|
|
rgf2->u.s2.rgPins2 = rgPins;
|
2008-06-29 14:07:00 +02:00
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
static void free_regfilter2(REGFILTER2 *rgf)
|
|
|
|
{
|
|
|
|
if (rgf->u.s2.rgPins2)
|
|
|
|
{
|
|
|
|
UINT iPin;
|
|
|
|
|
|
|
|
for (iPin = 0; iPin < rgf->u.s2.cPins2; iPin++)
|
|
|
|
{
|
|
|
|
if (rgf->u.s2.rgPins2[iPin].lpMediaType)
|
|
|
|
{
|
|
|
|
UINT iType;
|
|
|
|
|
|
|
|
for (iType = 0; iType < rgf->u.s2.rgPins2[iPin].nMediaTypes; iType++)
|
|
|
|
{
|
|
|
|
CoTaskMemFree((void *)rgf->u.s2.rgPins2[iPin].lpMediaType[iType].clsMajorType);
|
|
|
|
CoTaskMemFree((void *)rgf->u.s2.rgPins2[iPin].lpMediaType[iType].clsMinorType);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree((void *)rgf->u.s2.rgPins2[iPin].lpMediaType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree((void *)rgf->u.s2.rgPins2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void write_filter_data(IPropertyBag *prop_bag, REGFILTER2 *rgf)
|
|
|
|
{
|
|
|
|
IAMFilterData *fildata;
|
|
|
|
SAFEARRAYBOUND sabound;
|
|
|
|
BYTE *data, *array;
|
|
|
|
VARIANT var = {};
|
|
|
|
ULONG size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IAMFilterData, (void **)&fildata);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IAMFilterData_CreateFilterData(fildata, rgf, &data, &size);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_ARRAY | VT_UI1;
|
|
|
|
sabound.lLbound = 0;
|
|
|
|
sabound.cElements = size;
|
|
|
|
if (!(V_ARRAY(&var) = SafeArrayCreate(VT_UI1, 1, &sabound)))
|
|
|
|
goto cleanup;
|
|
|
|
hr = SafeArrayAccessData(V_ARRAY(&var), (void *)&array);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
memcpy(array, data, size);
|
|
|
|
hr = SafeArrayUnaccessData(V_ARRAY(&var));
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IPropertyBag_Write(prop_bag, wszFilterData, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VariantClear(&var);
|
|
|
|
CoTaskMemFree(data);
|
|
|
|
IAMFilterData_Release(fildata);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void register_legacy_filters(void)
|
2008-06-29 14:07:00 +02:00
|
|
|
{
|
|
|
|
HKEY hkeyFilter = NULL;
|
|
|
|
DWORD dwFilterSubkeys, i;
|
|
|
|
LONG lRet;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszFilterKeyName, 0, KEY_READ, &hkeyFilter);
|
|
|
|
hr = HRESULT_FROM_WIN32(lRet);
|
2008-06-29 14:07:00 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
lRet = RegQueryInfoKeyW(hkeyFilter, NULL, NULL, NULL, &dwFilterSubkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
hr = HRESULT_FROM_WIN32(lRet);
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = DEVENUM_CreateAMCategoryKey(&CLSID_LegacyAmFilterCategory);
|
|
|
|
|
2008-06-29 14:07:00 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
for (i = 0; i < dwFilterSubkeys; i++)
|
|
|
|
{
|
|
|
|
WCHAR wszFilterSubkeyName[64];
|
|
|
|
DWORD cName = sizeof(wszFilterSubkeyName) / sizeof(WCHAR);
|
2018-03-11 05:11:51 +01:00
|
|
|
IPropertyBag *prop_bag = NULL;
|
2008-06-29 14:07:00 +02:00
|
|
|
WCHAR wszRegKey[MAX_PATH];
|
2018-03-11 05:11:51 +01:00
|
|
|
HKEY classkey = NULL;
|
|
|
|
IMoniker *mon = NULL;
|
|
|
|
VARIANT var = {};
|
|
|
|
REGFILTER2 rgf2;
|
|
|
|
DWORD Type, len;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
|
|
|
if (RegEnumKeyExW(hkeyFilter, i, wszFilterSubkeyName, &cName, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) continue;
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
TRACE("Registering %s\n", debugstr_w(wszFilterSubkeyName));
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
strcpyW(wszRegKey, clsidW);
|
2008-06-29 14:07:00 +02:00
|
|
|
strcatW(wszRegKey, wszFilterSubkeyName);
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, wszRegKey, 0, KEY_READ, &classkey) != ERROR_SUCCESS)
|
|
|
|
continue;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
hr = register_codec(&CLSID_LegacyAmFilterCategory, wszFilterSubkeyName, &mon);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
2008-06-29 14:07:00 +02:00
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
/* write friendly name */
|
|
|
|
len = 0;
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
if (!RegQueryValueExW(classkey, NULL, NULL, &Type, NULL, &len))
|
|
|
|
{
|
|
|
|
WCHAR *friendlyname = heap_alloc(len);
|
|
|
|
if (!friendlyname)
|
|
|
|
goto cleanup;
|
|
|
|
RegQueryValueExW(classkey, NULL, NULL, &Type, (BYTE *)friendlyname, &len);
|
|
|
|
V_BSTR(&var) = SysAllocStringLen(friendlyname, len/sizeof(WCHAR));
|
|
|
|
heap_free(friendlyname);
|
2008-06-29 14:07:00 +02:00
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
else
|
|
|
|
V_BSTR(&var) = SysAllocString(wszFilterSubkeyName);
|
|
|
|
|
|
|
|
if (!V_BSTR(&var))
|
|
|
|
goto cleanup;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, wszFriendlyName, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write clsid */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
if (!(V_BSTR(&var) = SysAllocString(wszFilterSubkeyName)))
|
|
|
|
goto cleanup;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, clsid_keyname, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf2.dwMerit = MERIT_NORMAL;
|
|
|
|
|
|
|
|
len = sizeof(rgf2.dwMerit);
|
|
|
|
RegQueryValueExW(classkey, wszMeritName, NULL, &Type, (BYTE *)&rgf2.dwMerit, &len);
|
|
|
|
|
|
|
|
DEVENUM_ReadPins(classkey, &rgf2);
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf2);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (prop_bag) IPropertyBag_Release(prop_bag);
|
|
|
|
if (mon) IMoniker_Release(mon);
|
|
|
|
RegCloseKey(classkey);
|
|
|
|
VariantClear(&var);
|
|
|
|
free_regfilter2(&rgf2);
|
2008-06-29 14:07:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hkeyFilter) RegCloseKey(hkeyFilter);
|
|
|
|
}
|
|
|
|
|
2018-03-11 05:11:52 +01:00
|
|
|
static BOOL CALLBACK register_dsound_devices(GUID *guid, const WCHAR *desc, const WCHAR *module, void *context)
|
|
|
|
{
|
|
|
|
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',' ','D','i','r','e','c','t','S','o','u','n','d',' ','D','e','v','i','c','e',0};
|
|
|
|
static const WCHAR directsoundW[] = {'D','i','r','e','c','t','S','o','u','n','d',':',' ',0};
|
|
|
|
static const WCHAR dsguidW[] = {'D','S','G','u','i','d',0};
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTERPINS2 rgpins = {0};
|
|
|
|
REGPINTYPES rgtypes = {0};
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
WCHAR clsid[CHARS_IN_GUID];
|
|
|
|
IMoniker *mon = NULL;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = DEVENUM_CreateAMCategoryKey(&CLSID_AudioRendererCategory);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
if (guid)
|
|
|
|
{
|
|
|
|
WCHAR *name = heap_alloc(sizeof(defaultW) + strlenW(desc) * sizeof(WCHAR));
|
|
|
|
if (!name)
|
|
|
|
goto cleanup;
|
|
|
|
strcpyW(name, directsoundW);
|
|
|
|
strcatW(name, desc);
|
|
|
|
|
|
|
|
V_BSTR(&var) = SysAllocString(name);
|
|
|
|
heap_free(name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
V_BSTR(&var) = SysAllocString(defaultW);
|
|
|
|
|
|
|
|
if (!V_BSTR(&var))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = register_codec(&CLSID_AudioRendererCategory, V_BSTR(&var), &mon);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
/* write friendly name */
|
|
|
|
hr = IPropertyBag_Write(prop_bag, wszFriendlyName, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write clsid */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
StringFromGUID2(&CLSID_DSoundRender, clsid, CHARS_IN_GUID);
|
|
|
|
if (!(V_BSTR(&var) = SysAllocString(clsid)))
|
|
|
|
goto cleanup;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, clsid_keyname, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = guid ? MERIT_DO_NOT_USE : MERIT_PREFERRED;
|
|
|
|
rgf.u.s2.cPins2 = 1;
|
|
|
|
rgf.u.s2.rgPins2 = &rgpins;
|
|
|
|
rgpins.dwFlags = REG_PINFLAG_B_RENDERER;
|
|
|
|
/* FIXME: native registers many more formats */
|
|
|
|
rgpins.nMediaTypes = 1;
|
|
|
|
rgpins.lpMediaType = &rgtypes;
|
|
|
|
rgtypes.clsMajorType = &MEDIATYPE_Audio;
|
|
|
|
rgtypes.clsMinorType = &MEDIASUBTYPE_PCM;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
|
|
|
/* write DSound guid */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
StringFromGUID2(guid ? guid : &GUID_NULL, clsid, CHARS_IN_GUID);
|
|
|
|
if (!(V_BSTR(&var) = SysAllocString(clsid)))
|
|
|
|
goto cleanup;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, dsguidW, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VariantClear(&var);
|
|
|
|
if (prop_bag) IPropertyBag_Release(prop_bag);
|
|
|
|
if (mon) IMoniker_Release(mon);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:14 +02:00
|
|
|
static void register_waveout_devices(void)
|
|
|
|
{
|
|
|
|
static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',' ','W','a','v','e','O','u','t',' ','D','e','v','i','c','e',0};
|
|
|
|
static const WCHAR waveoutidW[] = {'W','a','v','e','O','u','t','I','d',0};
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTERPINS2 rgpins = {0};
|
|
|
|
REGPINTYPES rgtypes = {0};
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
WCHAR clsid[CHARS_IN_GUID];
|
|
|
|
IMoniker *mon = NULL;
|
|
|
|
WAVEOUTCAPSW caps;
|
|
|
|
int i, count;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = DEVENUM_CreateAMCategoryKey(&CLSID_AudioRendererCategory);
|
|
|
|
if (FAILED(hr)) return;
|
|
|
|
|
|
|
|
count = waveOutGetNumDevs();
|
|
|
|
|
|
|
|
for (i = -1; i < count; i++)
|
|
|
|
{
|
|
|
|
waveOutGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
|
|
|
|
if (i == -1) /* WAVE_MAPPER */
|
|
|
|
V_BSTR(&var) = SysAllocString(defaultW);
|
|
|
|
else
|
|
|
|
V_BSTR(&var) = SysAllocString(caps.szPname);
|
|
|
|
if (!(V_BSTR(&var)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = register_codec(&CLSID_AudioRendererCategory, V_BSTR(&var), &mon);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&prop_bag);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
/* write friendly name */
|
|
|
|
hr = IPropertyBag_Write(prop_bag, wszFriendlyName, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write clsid */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
StringFromGUID2(&CLSID_AudioRender, clsid, CHARS_IN_GUID);
|
|
|
|
if (!(V_BSTR(&var) = SysAllocString(clsid)))
|
|
|
|
goto cleanup;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, clsid_keyname, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
VariantClear(&var);
|
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = MERIT_DO_NOT_USE;
|
|
|
|
rgf.u.s2.cPins2 = 1;
|
|
|
|
rgf.u.s2.rgPins2 = &rgpins;
|
|
|
|
rgpins.dwFlags = REG_PINFLAG_B_RENDERER;
|
|
|
|
rgpins.nMediaTypes = 1;
|
|
|
|
rgpins.lpMediaType = &rgtypes;
|
|
|
|
rgtypes.clsMajorType = &MEDIATYPE_Audio;
|
|
|
|
rgtypes.clsMinorType = &MEDIASUBTYPE_NULL;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
|
|
|
/* write WaveOutId */
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = i;
|
|
|
|
hr = IPropertyBag_Write(prop_bag, waveoutidW, &var);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VariantClear(&var);
|
|
|
|
if (prop_bag) IPropertyBag_Release(prop_bag);
|
|
|
|
if (mon) IMoniker_Release(mon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_ICreateDevEnum_CreateClassEnumerator
|
|
|
|
*/
|
2008-12-02 15:27:15 +01:00
|
|
|
static HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
|
2003-07-01 06:30:30 +02:00
|
|
|
ICreateDevEnum * iface,
|
|
|
|
REFCLSID clsidDeviceClass,
|
|
|
|
IEnumMoniker **ppEnumMoniker,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2018-03-11 05:11:52 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-05-07 21:21:24 +02:00
|
|
|
TRACE("(%p)->(%s, %p, %x)\n", iface, debugstr_guid(clsidDeviceClass), ppEnumMoniker, dwFlags);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
if (!ppEnumMoniker)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*ppEnumMoniker = NULL;
|
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
register_codecs();
|
2018-03-11 05:11:51 +01:00
|
|
|
register_legacy_filters();
|
2018-03-11 05:11:52 +01:00
|
|
|
hr = DirectSoundEnumerateW(®ister_dsound_devices, NULL);
|
|
|
|
if (FAILED(hr)) return hr;
|
2018-03-31 23:25:14 +02:00
|
|
|
register_waveout_devices();
|
2014-01-08 14:12:11 +01:00
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
return create_EnumMoniker(clsidDeviceClass, ppEnumMoniker);
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ICreateDevEnum_Vtbl
|
|
|
|
*/
|
2005-05-30 12:01:08 +02:00
|
|
|
static const ICreateDevEnumVtbl ICreateDevEnum_Vtbl =
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
DEVENUM_ICreateDevEnum_QueryInterface,
|
|
|
|
DEVENUM_ICreateDevEnum_AddRef,
|
|
|
|
DEVENUM_ICreateDevEnum_Release,
|
|
|
|
DEVENUM_ICreateDevEnum_CreateClassEnumerator,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* static CreateDevEnum instance
|
|
|
|
*/
|
2012-04-04 10:43:12 +02:00
|
|
|
ICreateDevEnum DEVENUM_CreateDevEnum = { &ICreateDevEnum_Vtbl };
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2003-12-30 22:52:45 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* DEVENUM_CreateAMCategoryKey (INTERNAL)
|
|
|
|
*
|
|
|
|
* Creates a registry key for a category at HKEY_CURRENT_USER\Software\
|
|
|
|
* Microsoft\ActiveMovie\devenum\{clsid}
|
|
|
|
*/
|
|
|
|
static HRESULT DEVENUM_CreateAMCategoryKey(const CLSID * clsidCategory)
|
|
|
|
{
|
|
|
|
WCHAR wszRegKey[MAX_PATH];
|
|
|
|
HRESULT res = S_OK;
|
|
|
|
HKEY hkeyDummy = NULL;
|
|
|
|
|
|
|
|
strcpyW(wszRegKey, wszActiveMovieKey);
|
|
|
|
|
|
|
|
if (!StringFromGUID2(clsidCategory, wszRegKey + strlenW(wszRegKey), sizeof(wszRegKey)/sizeof(wszRegKey[0]) - strlenW(wszRegKey)))
|
|
|
|
res = E_INVALIDARG;
|
|
|
|
|
|
|
|
if (SUCCEEDED(res))
|
2005-12-05 20:39:47 +01:00
|
|
|
{
|
|
|
|
LONG lRes = RegCreateKeyW(HKEY_CURRENT_USER, wszRegKey, &hkeyDummy);
|
|
|
|
res = HRESULT_FROM_WIN32(lRes);
|
|
|
|
}
|
2003-12-30 22:52:45 +01:00
|
|
|
|
|
|
|
if (hkeyDummy)
|
|
|
|
RegCloseKey(hkeyDummy);
|
|
|
|
|
|
|
|
if (FAILED(res))
|
|
|
|
ERR("Failed to create key HKEY_CURRENT_USER\\%s\n", debugstr_w(wszRegKey));
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2014-01-08 14:12:25 +01:00
|
|
|
static void register_vfw_codecs(void)
|
|
|
|
{
|
|
|
|
WCHAR avico_clsid_str[CHARS_IN_GUID];
|
|
|
|
HKEY basekey, key;
|
|
|
|
ICINFO icinfo;
|
|
|
|
DWORD i, res;
|
|
|
|
|
|
|
|
static const WCHAR CLSIDW[] = {'C','L','S','I','D',0};
|
|
|
|
static const WCHAR FccHandlerW[] = {'F','c','c','H','a','n','d','l','e','r',0};
|
|
|
|
static const WCHAR FriendlyNameW[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
|
|
|
|
|
|
|
|
StringFromGUID2(&CLSID_AVICo, avico_clsid_str, sizeof(avico_clsid_str)/sizeof(WCHAR));
|
|
|
|
|
|
|
|
basekey = open_special_category_key(&CLSID_VideoCompressorCategory, TRUE);
|
|
|
|
if(!basekey) {
|
|
|
|
ERR("Could not create key\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; ICInfo(FCC('v','i','d','c'), i, &icinfo); i++) {
|
|
|
|
WCHAR fcc_str[5] = {LOBYTE(LOWORD(icinfo.fccHandler)), HIBYTE(LOWORD(icinfo.fccHandler)),
|
|
|
|
LOBYTE(HIWORD(icinfo.fccHandler)), HIBYTE(HIWORD(icinfo.fccHandler))};
|
|
|
|
|
|
|
|
res = RegCreateKeyW(basekey, fcc_str, &key);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
RegSetValueExW(key, CLSIDW, 0, REG_SZ, (const BYTE*)avico_clsid_str, sizeof(avico_clsid_str));
|
|
|
|
RegSetValueExW(key, FccHandlerW, 0, REG_SZ, (const BYTE*)fcc_str, sizeof(fcc_str));
|
|
|
|
RegSetValueExW(key, FriendlyNameW, 0, REG_SZ, (const BYTE*)icinfo.szName, (strlenW(icinfo.szName)+1)*sizeof(WCHAR));
|
|
|
|
/* FIXME: Set ClassManagerFlags and FilterData values */
|
|
|
|
|
|
|
|
RegCloseKey(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(basekey);
|
|
|
|
}
|
|
|
|
|
2018-03-07 03:57:08 +01:00
|
|
|
static HRESULT register_codecs(void)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2003-12-30 22:52:45 +01:00
|
|
|
HRESULT res;
|
2018-03-07 03:57:08 +01:00
|
|
|
WCHAR class[CHARS_IN_GUID];
|
2003-07-01 06:30:30 +02:00
|
|
|
DWORD iDefaultDevice = -1;
|
|
|
|
UINT numDevs;
|
|
|
|
IFilterMapper2 * pMapper = NULL;
|
|
|
|
REGFILTER2 rf2;
|
|
|
|
REGFILTERPINS2 rfp2;
|
2010-01-30 16:21:19 +01:00
|
|
|
HKEY basekey;
|
|
|
|
|
|
|
|
/* Since devices can change between session, for example because you just plugged in a webcam
|
|
|
|
* or switched from pulseaudio to alsa, delete all old devices first
|
|
|
|
*/
|
2018-03-07 03:57:08 +01:00
|
|
|
RegOpenKeyW(HKEY_CURRENT_USER, wszActiveMovieKey, &basekey);
|
2018-03-11 05:11:51 +01:00
|
|
|
StringFromGUID2(&CLSID_LegacyAmFilterCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
2018-03-07 03:57:08 +01:00
|
|
|
StringFromGUID2(&CLSID_AudioRendererCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
|
|
|
StringFromGUID2(&CLSID_AudioInputDeviceCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
|
|
|
StringFromGUID2(&CLSID_VideoInputDeviceCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
|
|
|
StringFromGUID2(&CLSID_MidiRendererCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
|
|
|
StringFromGUID2(&CLSID_VideoCompressorCategory, class, CHARS_IN_GUID);
|
|
|
|
RegDeleteTreeW(basekey, class);
|
|
|
|
RegCloseKey(basekey);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
rf2.dwVersion = 2;
|
|
|
|
rf2.dwMerit = MERIT_PREFERRED;
|
2012-05-12 16:14:07 +02:00
|
|
|
rf2.u.s2.cPins2 = 1;
|
|
|
|
rf2.u.s2.rgPins2 = &rfp2;
|
2003-07-01 06:30:30 +02:00
|
|
|
rfp2.cInstances = 1;
|
|
|
|
rfp2.nMediums = 0;
|
|
|
|
rfp2.lpMedium = NULL;
|
|
|
|
rfp2.clsPinCategory = &IID_NULL;
|
|
|
|
|
|
|
|
res = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
|
|
|
|
&IID_IFilterMapper2, (void **) &pMapper);
|
|
|
|
/*
|
2003-12-30 22:52:45 +01:00
|
|
|
* Fill in info for devices
|
2003-07-01 06:30:30 +02:00
|
|
|
*/
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
WAVEINCAPSW wicaps;
|
|
|
|
MIDIOUTCAPSW mocaps;
|
|
|
|
REGPINTYPES * pTypes;
|
2013-05-10 10:07:09 +02:00
|
|
|
IPropertyBag * pPropBag = NULL;
|
2003-12-30 22:52:45 +01:00
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
numDevs = waveInGetNumDevs();
|
|
|
|
|
2003-12-30 22:52:45 +01:00
|
|
|
res = DEVENUM_CreateAMCategoryKey(&CLSID_AudioInputDeviceCategory);
|
|
|
|
if (FAILED(res)) /* can't register any devices in this category */
|
|
|
|
numDevs = 0;
|
|
|
|
|
2005-01-25 11:56:39 +01:00
|
|
|
rfp2.dwFlags = REG_PINFLAG_B_OUTPUT;
|
2003-07-01 06:30:30 +02:00
|
|
|
for (i = 0; i < numDevs; i++)
|
|
|
|
{
|
|
|
|
if (waveInGetDevCapsW(i, &wicaps, sizeof(WAVEINCAPSW))
|
|
|
|
== MMSYSERR_NOERROR)
|
|
|
|
{
|
2003-12-30 22:52:45 +01:00
|
|
|
IMoniker * pMoniker = NULL;
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
rfp2.nMediaTypes = 1;
|
|
|
|
pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES));
|
|
|
|
if (!pTypes)
|
|
|
|
{
|
|
|
|
IFilterMapper2_Release(pMapper);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Not sure if these are correct */
|
|
|
|
pTypes[0].clsMajorType = &MEDIATYPE_Audio;
|
|
|
|
pTypes[0].clsMinorType = &MEDIASUBTYPE_PCM;
|
|
|
|
|
|
|
|
rfp2.lpMediaType = pTypes;
|
|
|
|
|
2013-05-10 10:07:09 +02:00
|
|
|
res = IFilterMapper2_RegisterFilter(pMapper,
|
2003-07-01 06:30:30 +02:00
|
|
|
&CLSID_AudioRecord,
|
|
|
|
wicaps.szPname,
|
|
|
|
&pMoniker,
|
|
|
|
&CLSID_AudioInputDeviceCategory,
|
|
|
|
wicaps.szPname,
|
|
|
|
&rf2);
|
|
|
|
|
|
|
|
|
2013-05-10 10:07:09 +02:00
|
|
|
if (pMoniker) {
|
|
|
|
VARIANT var;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
2014-09-02 23:17:37 +02:00
|
|
|
V_I4(&var) = i;
|
2013-05-10 10:07:09 +02:00
|
|
|
res = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
res = IPropertyBag_Write(pPropBag, wszWaveInID, &var);
|
|
|
|
else
|
|
|
|
pPropBag = NULL;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_LPWSTR;
|
2014-09-02 23:17:37 +02:00
|
|
|
V_BSTR(&var) = wicaps.szPname;
|
2013-05-10 10:07:09 +02:00
|
|
|
if (SUCCEEDED(res))
|
|
|
|
res = IPropertyBag_Write(pPropBag, wszFriendlyName, &var);
|
|
|
|
|
|
|
|
if (pPropBag)
|
|
|
|
IPropertyBag_Release(pPropBag);
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
|
|
|
|
CoTaskMemFree(pTypes);
|
|
|
|
}
|
|
|
|
}
|
2003-12-30 22:52:45 +01:00
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
numDevs = midiOutGetNumDevs();
|
|
|
|
|
2003-12-30 22:52:45 +01:00
|
|
|
res = DEVENUM_CreateAMCategoryKey(&CLSID_MidiRendererCategory);
|
|
|
|
if (FAILED(res)) /* can't register any devices in this category */
|
|
|
|
numDevs = 0;
|
|
|
|
|
2005-01-25 11:56:39 +01:00
|
|
|
rfp2.dwFlags = REG_PINFLAG_B_RENDERER;
|
2003-07-01 06:30:30 +02:00
|
|
|
for (i = 0; i < numDevs; i++)
|
|
|
|
{
|
|
|
|
if (midiOutGetDevCapsW(i, &mocaps, sizeof(MIDIOUTCAPSW))
|
|
|
|
== MMSYSERR_NOERROR)
|
|
|
|
{
|
2003-12-30 22:52:45 +01:00
|
|
|
IMoniker * pMoniker = NULL;
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
rfp2.nMediaTypes = 1;
|
|
|
|
pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES));
|
|
|
|
if (!pTypes)
|
|
|
|
{
|
|
|
|
IFilterMapper2_Release(pMapper);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Not sure if these are correct */
|
|
|
|
pTypes[0].clsMajorType = &MEDIATYPE_Midi;
|
|
|
|
pTypes[0].clsMinorType = &MEDIASUBTYPE_None;
|
|
|
|
|
|
|
|
rfp2.lpMediaType = pTypes;
|
|
|
|
|
2003-12-30 22:52:45 +01:00
|
|
|
res = IFilterMapper2_RegisterFilter(pMapper,
|
2003-07-01 06:30:30 +02:00
|
|
|
&CLSID_AVIMIDIRender,
|
|
|
|
mocaps.szPname,
|
|
|
|
&pMoniker,
|
|
|
|
&CLSID_MidiRendererCategory,
|
|
|
|
mocaps.szPname,
|
|
|
|
&rf2);
|
|
|
|
|
|
|
|
/* FIXME: do additional stuff with IMoniker here, depending on what RegisterFilter does */
|
|
|
|
/* Native version sets MidiOutId */
|
|
|
|
|
|
|
|
if (pMoniker)
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
|
|
|
|
if (i == iDefaultDevice)
|
|
|
|
{
|
|
|
|
FIXME("Default device\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(pTypes);
|
|
|
|
}
|
|
|
|
}
|
2005-04-27 13:07:55 +02:00
|
|
|
res = DEVENUM_CreateAMCategoryKey(&CLSID_VideoInputDeviceCategory);
|
|
|
|
if (SUCCEEDED(res))
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
2005-05-18 20:25:12 +02:00
|
|
|
WCHAR szDeviceName[32], szDeviceVersion[32], szDevicePath[10];
|
2005-04-27 13:07:55 +02:00
|
|
|
|
|
|
|
if (capGetDriverDescriptionW ((WORD) i,
|
|
|
|
szDeviceName, sizeof(szDeviceName)/sizeof(WCHAR),
|
|
|
|
szDeviceVersion, sizeof(szDeviceVersion)/sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
IMoniker * pMoniker = NULL;
|
2005-05-18 20:25:12 +02:00
|
|
|
WCHAR dprintf[] = { 'v','i','d','e','o','%','d',0 };
|
|
|
|
snprintfW(szDevicePath, sizeof(szDevicePath)/sizeof(WCHAR), dprintf, i);
|
|
|
|
/* The above code prevents 1 device with a different ID overwriting another */
|
2005-04-27 13:07:55 +02:00
|
|
|
|
|
|
|
rfp2.nMediaTypes = 1;
|
|
|
|
pTypes = CoTaskMemAlloc(rfp2.nMediaTypes * sizeof(REGPINTYPES));
|
|
|
|
if (!pTypes) {
|
|
|
|
IFilterMapper2_Release(pMapper);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTypes[0].clsMajorType = &MEDIATYPE_Video;
|
2005-05-18 20:25:12 +02:00
|
|
|
pTypes[0].clsMinorType = &MEDIASUBTYPE_None;
|
2005-04-27 13:07:55 +02:00
|
|
|
|
|
|
|
rfp2.lpMediaType = pTypes;
|
|
|
|
|
|
|
|
res = IFilterMapper2_RegisterFilter(pMapper,
|
|
|
|
&CLSID_VfwCapture,
|
|
|
|
szDeviceName,
|
|
|
|
&pMoniker,
|
|
|
|
&CLSID_VideoInputDeviceCategory,
|
2005-05-18 20:25:12 +02:00
|
|
|
szDevicePath,
|
2005-04-27 13:07:55 +02:00
|
|
|
&rf2);
|
|
|
|
|
2005-05-18 20:25:12 +02:00
|
|
|
if (pMoniker) {
|
|
|
|
OLECHAR wszVfwIndex[] = { 'V','F','W','I','n','d','e','x',0 };
|
|
|
|
VARIANT var;
|
|
|
|
V_VT(&var) = VT_I4;
|
2014-09-02 23:17:37 +02:00
|
|
|
V_I4(&var) = i;
|
2005-05-18 20:25:12 +02:00
|
|
|
res = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (LPVOID)&pPropBag);
|
2013-05-10 10:07:09 +02:00
|
|
|
if (SUCCEEDED(res)) {
|
|
|
|
res = IPropertyBag_Write(pPropBag, wszVfwIndex, &var);
|
|
|
|
IPropertyBag_Release(pPropBag);
|
|
|
|
}
|
2005-05-18 20:25:12 +02:00
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
}
|
2005-04-27 13:07:55 +02:00
|
|
|
|
|
|
|
if (i == iDefaultDevice) FIXME("Default device\n");
|
|
|
|
CoTaskMemFree(pTypes);
|
|
|
|
}
|
|
|
|
}
|
2003-07-01 06:30:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pMapper)
|
|
|
|
IFilterMapper2_Release(pMapper);
|
2014-01-08 14:12:25 +01:00
|
|
|
|
|
|
|
register_vfw_codecs();
|
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
return res;
|
|
|
|
}
|