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"
|
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"
|
2018-06-26 16:05:33 +02:00
|
|
|
#include "wine/fil_data.h"
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2003-07-01 06:30:30 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI devenum_factory_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;
|
2020-04-11 17:49:40 +02:00
|
|
|
ICreateDevEnum_AddRef(iface);
|
2003-07-01 06:30:30 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI devenum_factory_AddRef(ICreateDevEnum *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static ULONG WINAPI devenum_factory_Release(ICreateDevEnum *iface)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
static HRESULT register_codec(const GUID *class, const WCHAR *name,
|
|
|
|
const GUID *clsid, const WCHAR *friendly_name, IPropertyBag **ret)
|
2018-03-11 05:11:51 +01:00
|
|
|
{
|
2018-09-23 03:31:55 +02:00
|
|
|
WCHAR guidstr[CHARS_IN_GUID];
|
2018-03-11 05:11:51 +01:00
|
|
|
IParseDisplayName *parser;
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag *propbag;
|
|
|
|
IMoniker *mon;
|
2018-03-11 05:11:51 +01:00
|
|
|
WCHAR *buffer;
|
2018-09-23 03:31:55 +02:00
|
|
|
VARIANT var;
|
2018-03-11 05:11:51 +01:00
|
|
|
ULONG eaten;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_CDeviceMoniker, NULL, CLSCTX_INPROC, &IID_IParseDisplayName, (void **)&parser);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
if (!(buffer = heap_alloc((wcslen(L"@device:cm:") + CHARS_IN_GUID + wcslen(name) + 1) * sizeof(WCHAR))))
|
2018-03-11 05:11:51 +01:00
|
|
|
{
|
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
wcscpy(buffer, L"@device:cm:");
|
|
|
|
StringFromGUID2(class, buffer + wcslen(buffer), CHARS_IN_GUID);
|
|
|
|
wcscat(buffer, L"\\");
|
|
|
|
wcscat(buffer, name);
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
IParseDisplayName_ParseDisplayName(parser, NULL, buffer, &eaten, &mon);
|
2018-03-11 05:11:51 +01:00
|
|
|
IParseDisplayName_Release(parser);
|
|
|
|
heap_free(buffer);
|
2018-09-23 03:31:55 +02:00
|
|
|
|
|
|
|
IMoniker_BindToStorage(mon, NULL, NULL, &IID_IPropertyBag, (void **)&propbag);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(friendly_name);
|
2020-05-14 00:03:09 +02:00
|
|
|
hr = IPropertyBag_Write(propbag, L"FriendlyName", &var);
|
2018-09-23 03:31:55 +02:00
|
|
|
VariantClear(&var);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IPropertyBag_Release(propbag);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
StringFromGUID2(clsid, guidstr, ARRAY_SIZE(guidstr));
|
|
|
|
V_BSTR(&var) = SysAllocString(guidstr);
|
2020-05-14 00:03:09 +02:00
|
|
|
hr = IPropertyBag_Write(propbag, L"CLSID", &var);
|
2018-09-23 03:31:55 +02:00
|
|
|
VariantClear(&var);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IPropertyBag_Release(propbag);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = propbag;
|
|
|
|
return S_OK;
|
2018-03-11 05:11:51 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
if (RegOpenKeyExW(hkeyPinKey, L"Types", 0, KEY_READ, &hkeyTypes) != ERROR_SUCCESS)
|
2008-06-29 14:07:00 +02:00
|
|
|
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];
|
2018-08-04 22:45:40 +02:00
|
|
|
DWORD cName = ARRAY_SIZE(wszMajorTypeName);
|
2008-06-29 14:07:00 +02:00
|
|
|
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;
|
|
|
|
|
2018-08-04 22:45:40 +02:00
|
|
|
cName = ARRAY_SIZE(wszMinorTypeName);
|
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
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
if (RegOpenKeyExW(hkeyFilterClass, L"Pins", 0, KEY_READ, &hkeyPins) != ERROR_SUCCESS)
|
2008-06-29 14:07:00 +02:00
|
|
|
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];
|
2018-08-04 22:45:40 +02:00
|
|
|
DWORD cName = ARRAY_SIZE(wszPinName);
|
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);
|
2020-05-14 00:03:09 +02:00
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, L"AllowedMany", 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);
|
2020-05-14 00:03:09 +02:00
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, L"AllowedZero", 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);
|
2020-05-14 00:03:09 +02:00
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, L"Direction", 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);
|
2020-05-14 00:03:09 +02:00
|
|
|
lRet = RegQueryValueExW(hkeyPinKey, L"IsRendered", 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 23:09:19 +02:00
|
|
|
HRESULT create_filter_data(VARIANT *var, REGFILTER2 *rgf)
|
2018-03-11 05:11:51 +01:00
|
|
|
{
|
|
|
|
IAMFilterData *fildata;
|
2020-05-15 23:09:19 +02:00
|
|
|
BYTE *data = NULL;
|
2018-03-11 05:11:51 +01:00
|
|
|
ULONG size;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IAMFilterData, (void **)&fildata);
|
2020-05-15 23:09:19 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2018-03-11 05:11:51 +01:00
|
|
|
|
|
|
|
hr = IAMFilterData_CreateFilterData(fildata, rgf, &data, &size);
|
2020-05-15 23:09:19 +02:00
|
|
|
IAMFilterData_Release(fildata);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2020-05-15 23:09:19 +02:00
|
|
|
V_VT(var) = VT_ARRAY | VT_UI1;
|
|
|
|
if (!(V_ARRAY(var) = SafeArrayCreateVector(VT_UI1, 1, size)))
|
|
|
|
{
|
|
|
|
VariantClear(var);
|
|
|
|
CoTaskMemFree(data);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2020-05-15 23:09:19 +02:00
|
|
|
memcpy(V_ARRAY(var)->pvData, data, size);
|
|
|
|
CoTaskMemFree(data);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2020-05-15 23:09:19 +02:00
|
|
|
static void write_filter_data(IPropertyBag *prop_bag, REGFILTER2 *rgf)
|
|
|
|
{
|
|
|
|
VARIANT var;
|
2018-03-11 05:11:51 +01:00
|
|
|
|
2020-05-15 23:09:19 +02:00
|
|
|
if (SUCCEEDED(create_filter_data(&var, rgf)))
|
|
|
|
{
|
|
|
|
IPropertyBag_Write(prop_bag, L"FilterData", &var);
|
|
|
|
VariantClear(&var);
|
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void register_legacy_filters(void)
|
2008-06-29 14:07:00 +02:00
|
|
|
{
|
|
|
|
HKEY hkeyFilter = NULL;
|
|
|
|
DWORD dwFilterSubkeys, i;
|
|
|
|
LONG lRet;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
lRet = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Filter", 0, KEY_READ, &hkeyFilter);
|
2018-03-11 05:11:51 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
for (i = 0; i < dwFilterSubkeys; i++)
|
|
|
|
{
|
|
|
|
WCHAR wszFilterSubkeyName[64];
|
2018-08-04 22:45:40 +02:00
|
|
|
DWORD cName = ARRAY_SIZE(wszFilterSubkeyName);
|
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;
|
|
|
|
REGFILTER2 rgf2;
|
|
|
|
DWORD Type, len;
|
2018-09-23 03:31:55 +02:00
|
|
|
GUID clsid;
|
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-09-23 03:31:55 +02:00
|
|
|
hr = CLSIDFromString(wszFilterSubkeyName, &clsid);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
swprintf(wszRegKey, ARRAY_SIZE(wszRegKey), L"CLSID\\%s", 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
|
|
|
len = 0;
|
|
|
|
if (!RegQueryValueExW(classkey, NULL, NULL, &Type, NULL, &len))
|
|
|
|
{
|
|
|
|
WCHAR *friendlyname = heap_alloc(len);
|
|
|
|
if (!friendlyname)
|
2018-09-23 03:31:55 +02:00
|
|
|
{
|
|
|
|
RegCloseKey(classkey);
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
RegQueryValueExW(classkey, NULL, NULL, &Type, (BYTE *)friendlyname, &len);
|
2018-09-23 03:31:55 +02:00
|
|
|
|
|
|
|
hr = register_codec(&CLSID_LegacyAmFilterCategory, wszFilterSubkeyName,
|
|
|
|
&clsid, friendlyname, &prop_bag);
|
|
|
|
|
2018-03-11 05:11:51 +01:00
|
|
|
heap_free(friendlyname);
|
2008-06-29 14:07:00 +02:00
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
else
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_LegacyAmFilterCategory, wszFilterSubkeyName,
|
|
|
|
&clsid, wszFilterSubkeyName, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
RegCloseKey(classkey);
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-11 05:11:51 +01:00
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf2.dwMerit = MERIT_NORMAL;
|
|
|
|
|
|
|
|
len = sizeof(rgf2.dwMerit);
|
2020-05-14 00:03:09 +02:00
|
|
|
RegQueryValueExW(classkey, L"Merit", NULL, &Type, (BYTE *)&rgf2.dwMerit, &len);
|
2018-03-11 05:11:51 +01:00
|
|
|
|
|
|
|
DEVENUM_ReadPins(classkey, &rgf2);
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf2);
|
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2018-03-11 05:11:51 +01:00
|
|
|
RegCloseKey(classkey);
|
|
|
|
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)
|
|
|
|
{
|
2020-05-14 00:03:09 +02:00
|
|
|
static const WCHAR defaultW[] = L"Default DirectSound Device";
|
2018-03-11 05:11:52 +01:00
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTERPINS2 rgpins = {0};
|
|
|
|
REGPINTYPES rgtypes = {0};
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
WCHAR clsid[CHARS_IN_GUID];
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (guid)
|
|
|
|
{
|
2020-05-14 00:03:09 +02:00
|
|
|
WCHAR *name = heap_alloc(sizeof(defaultW) + wcslen(desc) * sizeof(WCHAR));
|
2018-03-11 05:11:52 +01:00
|
|
|
if (!name)
|
2018-09-23 03:31:55 +02:00
|
|
|
return FALSE;
|
2020-05-14 00:03:09 +02:00
|
|
|
wcscpy(name, L"DirectSound: ");
|
|
|
|
wcscat(name, desc);
|
2018-03-11 05:11:52 +01:00
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_AudioRendererCategory, name,
|
|
|
|
&CLSID_DSoundRender, name, &prop_bag);
|
2018-03-11 05:11:52 +01:00
|
|
|
heap_free(name);
|
|
|
|
}
|
|
|
|
else
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_AudioRendererCategory, defaultW,
|
|
|
|
&CLSID_DSoundRender, defaultW, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
2018-03-11 05:11:52 +01:00
|
|
|
|
|
|
|
/* 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);
|
2018-09-23 03:31:55 +02:00
|
|
|
if ((V_BSTR(&var) = SysAllocString(clsid)))
|
2020-05-14 00:03:09 +02:00
|
|
|
hr = IPropertyBag_Write(prop_bag, L"DSGuid", &var);
|
2018-03-11 05:11:52 +01:00
|
|
|
|
|
|
|
VariantClear(&var);
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2018-03-11 05:11:52 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:14 +02:00
|
|
|
static void register_waveout_devices(void)
|
|
|
|
{
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTERPINS2 rgpins = {0};
|
|
|
|
REGPINTYPES rgtypes = {0};
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
WAVEOUTCAPSW caps;
|
2018-09-23 03:31:55 +02:00
|
|
|
const WCHAR *name;
|
2018-03-31 23:25:14 +02:00
|
|
|
int i, count;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
count = waveOutGetNumDevs();
|
|
|
|
|
|
|
|
for (i = -1; i < count; i++)
|
|
|
|
{
|
|
|
|
waveOutGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
name = (i == -1) ? L"Default WaveOut Device" : caps.szPname;
|
2018-03-31 23:25:14 +02:00
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_AudioRendererCategory, name,
|
|
|
|
&CLSID_AudioRender, name, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
2018-03-31 23:25:14 +02:00
|
|
|
|
|
|
|
/* 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;
|
2020-05-14 00:03:09 +02:00
|
|
|
IPropertyBag_Write(prop_bag, L"WaveOutId", &var);
|
2018-03-31 23:25:14 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
if (prop_bag) IPropertyBag_Release(prop_bag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:16 +02:00
|
|
|
static void register_wavein_devices(void)
|
|
|
|
{
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
WAVEINCAPSW caps;
|
|
|
|
int i, count;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
count = waveInGetNumDevs();
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
waveInGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_AudioInputDeviceCategory, caps.szPname,
|
|
|
|
&CLSID_AudioRecord, caps.szPname, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
2018-03-31 23:25:16 +02:00
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = MERIT_DO_NOT_USE;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
|
|
|
/* write WaveInId */
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = i;
|
2020-05-14 00:03:09 +02:00
|
|
|
IPropertyBag_Write(prop_bag, L"WaveInId", &var);
|
2018-03-31 23:25:16 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2018-03-31 23:25:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:17 +02:00
|
|
|
static void register_midiout_devices(void)
|
|
|
|
{
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGFILTERPINS2 rgpins = {0};
|
|
|
|
REGPINTYPES rgtypes = {0};
|
|
|
|
REGFILTER2 rgf = {0};
|
|
|
|
MIDIOUTCAPSW caps;
|
2018-09-23 03:31:55 +02:00
|
|
|
const WCHAR *name;
|
2018-03-31 23:25:17 +02:00
|
|
|
int i, count;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
count = midiOutGetNumDevs();
|
|
|
|
|
|
|
|
for (i = -1; i < count; i++)
|
|
|
|
{
|
|
|
|
midiOutGetDevCapsW(i, &caps, sizeof(caps));
|
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
name = (i == -1) ? L"Default MidiOut Device" : caps.szPname;
|
2018-03-31 23:25:17 +02:00
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_MidiRendererCategory, name,
|
|
|
|
&CLSID_AVIMIDIRender, name, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
2018-03-31 23:25:17 +02:00
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = (i == -1) ? MERIT_PREFERRED : 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_Midi;
|
|
|
|
rgtypes.clsMinorType = &MEDIASUBTYPE_NULL;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
|
|
|
/* write MidiOutId */
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = i;
|
2020-05-14 00:03:09 +02:00
|
|
|
IPropertyBag_Write(prop_bag, L"MidiOutId", &var);
|
2018-03-31 23:25:17 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2018-03-31 23:25:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-31 23:25:18 +02:00
|
|
|
static void register_vfw_codecs(void)
|
|
|
|
{
|
|
|
|
REGFILTERPINS2 rgpins[2] = {};
|
|
|
|
IPropertyBag *prop_bag = NULL;
|
|
|
|
REGPINTYPES rgtypes[2];
|
|
|
|
REGFILTER2 rgf;
|
|
|
|
GUID typeguid;
|
|
|
|
ICINFO info;
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
int i = 0;
|
|
|
|
HIC hic;
|
|
|
|
|
|
|
|
while (ICInfo(ICTYPE_VIDEO, i++, &info))
|
|
|
|
{
|
|
|
|
WCHAR name[5] = {LOBYTE(LOWORD(info.fccHandler)), HIBYTE(LOWORD(info.fccHandler)),
|
|
|
|
LOBYTE(HIWORD(info.fccHandler)), HIBYTE(HIWORD(info.fccHandler))};
|
|
|
|
|
|
|
|
hic = ICOpen(ICTYPE_VIDEO, info.fccHandler, ICMODE_QUERY);
|
|
|
|
ICGetInfo(hic, &info, sizeof(info));
|
|
|
|
ICClose(hic);
|
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
hr = register_codec(&CLSID_VideoCompressorCategory, name,
|
|
|
|
&CLSID_AVICo, info.szDescription, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
2018-03-31 23:25:18 +02:00
|
|
|
|
|
|
|
/* write filter data */
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = MERIT_DO_NOT_USE;
|
|
|
|
rgf.u.s2.cPins2 = 2;
|
|
|
|
rgf.u.s2.rgPins2 = rgpins;
|
|
|
|
rgpins[0].dwFlags = 0;
|
|
|
|
rgpins[0].nMediaTypes = 1;
|
|
|
|
rgpins[0].lpMediaType = &rgtypes[0];
|
|
|
|
rgtypes[0].clsMajorType = &MEDIATYPE_Video;
|
|
|
|
typeguid = MEDIASUBTYPE_PCM;
|
|
|
|
typeguid.Data1 = info.fccHandler;
|
|
|
|
rgtypes[0].clsMinorType = &typeguid;
|
|
|
|
rgpins[1].dwFlags = REG_PINFLAG_B_OUTPUT;
|
|
|
|
rgpins[1].nMediaTypes = 1;
|
|
|
|
rgpins[1].lpMediaType = &rgtypes[1];
|
|
|
|
rgtypes[1].clsMajorType = &MEDIATYPE_Video;
|
|
|
|
rgtypes[1].clsMinorType = &GUID_NULL;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
2018-09-23 03:31:55 +02:00
|
|
|
/* write WaveInId */
|
|
|
|
V_VT(&var) = VT_BSTR;
|
|
|
|
V_BSTR(&var) = SysAllocString(name);
|
2020-05-14 00:03:09 +02:00
|
|
|
IPropertyBag_Write(prop_bag, L"FccHandler", &var);
|
2018-09-23 03:31:55 +02:00
|
|
|
|
2018-03-31 23:25:18 +02:00
|
|
|
VariantClear(&var);
|
2018-09-23 03:31:55 +02:00
|
|
|
IPropertyBag_Release(prop_bag);
|
2018-03-31 23:25:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-23 03:31:56 +02:00
|
|
|
static void register_avicap_devices(void)
|
|
|
|
{
|
2019-04-20 20:19:34 +02:00
|
|
|
WCHAR friendlyname[32], version[32];
|
2018-09-23 03:31:56 +02:00
|
|
|
IPropertyBag *prop_bag = NULL;
|
2018-10-04 05:41:02 +02:00
|
|
|
REGFILTERPINS2 rgpins = {0};
|
2018-09-23 03:31:56 +02:00
|
|
|
REGPINTYPES rgtypes;
|
|
|
|
REGFILTER2 rgf;
|
2020-05-14 00:03:09 +02:00
|
|
|
WCHAR name[6];
|
2018-09-23 03:31:56 +02:00
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; ++i)
|
|
|
|
{
|
2019-04-20 20:19:34 +02:00
|
|
|
if (!capGetDriverDescriptionW(i, friendlyname, ARRAY_SIZE(friendlyname),
|
|
|
|
version, ARRAY_SIZE(version)))
|
2019-04-23 03:15:23 +02:00
|
|
|
continue;
|
2018-09-23 03:31:56 +02:00
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
swprintf(name, ARRAY_SIZE(name), L"video%d", i);
|
2018-09-23 03:31:56 +02:00
|
|
|
|
|
|
|
hr = register_codec(&CLSID_VideoInputDeviceCategory, name,
|
|
|
|
&CLSID_VfwCapture, friendlyname, &prop_bag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rgf.dwVersion = 2;
|
|
|
|
rgf.dwMerit = MERIT_DO_NOT_USE;
|
|
|
|
rgf.u.s2.cPins2 = 1;
|
|
|
|
rgf.u.s2.rgPins2 = &rgpins;
|
|
|
|
rgpins.dwFlags = 0;
|
|
|
|
rgpins.nMediaTypes = 1;
|
|
|
|
rgpins.lpMediaType = &rgtypes;
|
|
|
|
rgtypes.clsMajorType = &MEDIATYPE_Video;
|
|
|
|
rgtypes.clsMinorType = &MEDIASUBTYPE_None;
|
|
|
|
|
|
|
|
write_filter_data(prop_bag, &rgf);
|
|
|
|
|
|
|
|
/* write VFWIndex */
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = i;
|
2020-05-14 00:03:09 +02:00
|
|
|
IPropertyBag_Write(prop_bag, L"VFWIndex", &var);
|
2018-09-23 03:31:56 +02:00
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
IPropertyBag_Release(prop_bag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
static HRESULT WINAPI devenum_factory_CreateClassEnumerator(ICreateDevEnum *iface,
|
|
|
|
REFCLSID class, IEnumMoniker **out, DWORD flags)
|
2003-07-01 06:30:30 +02:00
|
|
|
{
|
2018-09-23 03:31:57 +02:00
|
|
|
WCHAR guidstr[CHARS_IN_GUID];
|
2018-03-11 05:11:52 +01:00
|
|
|
HRESULT hr;
|
2018-09-23 03:31:57 +02:00
|
|
|
HKEY key;
|
2018-03-11 05:11:52 +01:00
|
|
|
|
2018-09-23 03:31:57 +02:00
|
|
|
TRACE("iface %p, class %s, out %p, flags %#x.\n", iface, debugstr_guid(class), out, flags);
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2018-09-23 03:31:57 +02:00
|
|
|
if (!out)
|
2003-07-01 06:30:30 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2018-09-23 03:31:57 +02:00
|
|
|
*out = NULL;
|
2003-07-01 06:30:30 +02:00
|
|
|
|
2020-05-14 00:03:09 +02:00
|
|
|
if (!RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\ActiveMovie\\devenum", &key))
|
2018-09-23 03:31:57 +02:00
|
|
|
{
|
|
|
|
StringFromGUID2(class, guidstr, ARRAY_SIZE(guidstr));
|
|
|
|
RegDeleteTreeW(key, guidstr);
|
|
|
|
}
|
2014-01-08 14:12:11 +01:00
|
|
|
|
2018-09-23 03:31:57 +02:00
|
|
|
if (IsEqualGUID(class, &CLSID_LegacyAmFilterCategory))
|
|
|
|
register_legacy_filters();
|
|
|
|
else if (IsEqualGUID(class, &CLSID_AudioRendererCategory))
|
|
|
|
{
|
|
|
|
hr = DirectSoundEnumerateW(®ister_dsound_devices, NULL);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
register_waveout_devices();
|
|
|
|
register_midiout_devices();
|
|
|
|
}
|
|
|
|
else if (IsEqualGUID(class, &CLSID_AudioInputDeviceCategory))
|
|
|
|
register_wavein_devices();
|
|
|
|
else if (IsEqualGUID(class, &CLSID_VideoCompressorCategory))
|
|
|
|
register_vfw_codecs();
|
|
|
|
else if (IsEqualGUID(class, &CLSID_VideoInputDeviceCategory))
|
|
|
|
register_avicap_devices();
|
|
|
|
|
2020-04-11 17:49:40 +02:00
|
|
|
if (SUCCEEDED(hr = enum_moniker_create(class, out)))
|
2019-04-06 02:41:13 +02:00
|
|
|
{
|
|
|
|
IMoniker *mon;
|
|
|
|
hr = IEnumMoniker_Next(*out, 1, &mon, NULL);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
IEnumMoniker_Reset(*out);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IEnumMoniker_Release(*out);
|
|
|
|
*out = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
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
|
|
|
{
|
2020-04-11 17:49:40 +02:00
|
|
|
devenum_factory_QueryInterface,
|
|
|
|
devenum_factory_AddRef,
|
|
|
|
devenum_factory_Release,
|
|
|
|
devenum_factory_CreateClassEnumerator,
|
2003-07-01 06:30:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* static CreateDevEnum instance
|
|
|
|
*/
|
2020-04-11 17:49:40 +02:00
|
|
|
ICreateDevEnum devenum_factory = { &ICreateDevEnum_Vtbl };
|