msdmo: Improve registration and reading of codecs.
This commit is contained in:
parent
c632a7500f
commit
352d29b194
|
@ -32,6 +32,7 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
|
||||
|
||||
#define MSDMO_MAJOR_VERSION 6
|
||||
|
||||
static const WCHAR szDMORootKey[] =
|
||||
{
|
||||
|
@ -96,6 +97,8 @@ typedef struct
|
|||
HKEY hkey;
|
||||
} IEnumDMOImpl;
|
||||
|
||||
static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types);
|
||||
|
||||
static const IEnumDMOVtbl edmovt;
|
||||
|
||||
static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
|
||||
|
@ -119,6 +122,40 @@ static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL
|
|||
IsEqualCLSID(&mt1->subtype, &GUID_NULL));
|
||||
}
|
||||
|
||||
static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* types, DWORD count)
|
||||
{
|
||||
HRESULT hres = S_OK;
|
||||
if (MSDMO_MAJOR_VERSION > 5)
|
||||
{
|
||||
hres = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types,
|
||||
count* sizeof(DMO_PARTIAL_MEDIATYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
HKEY skey1,skey2,skey3;
|
||||
DWORD index = 0;
|
||||
WCHAR szGuidKey[64];
|
||||
|
||||
hres = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE, NULL, &skey1, NULL);
|
||||
while (index < count)
|
||||
{
|
||||
GUIDToString(szGuidKey,&types[index].type);
|
||||
hres = RegCreateKeyExW(skey1, szGuidKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL);
|
||||
GUIDToString(szGuidKey,&types[index].subtype);
|
||||
hres = RegCreateKeyExW(skey2, szGuidKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL);
|
||||
RegCloseKey(skey3);
|
||||
RegCloseKey(skey2);
|
||||
index ++;
|
||||
}
|
||||
RegCloseKey(skey1);
|
||||
}
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* DMORegister
|
||||
*
|
||||
|
@ -144,7 +181,8 @@ HRESULT WINAPI DMORegister(
|
|||
|
||||
TRACE("%s\n", debugstr_w(szName));
|
||||
|
||||
hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey);
|
||||
hres = RegCreateKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hrkey, NULL);
|
||||
if (ERROR_SUCCESS != hres)
|
||||
goto lend;
|
||||
|
||||
|
@ -156,13 +194,13 @@ HRESULT WINAPI DMORegister(
|
|||
|
||||
/* Set default Name value */
|
||||
hres = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName,
|
||||
(strlenW(szName) + 1)) * sizeof(WCHAR);
|
||||
(strlenW(szName) + 1) * sizeof(WCHAR));
|
||||
|
||||
/* Set InputTypes */
|
||||
hres = RegSetValueExW(hkey, szDMOInputType, 0, REG_BINARY,
|
||||
(const BYTE*) pInTypes, cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE));
|
||||
hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes);
|
||||
|
||||
/* Set OutputTypes */
|
||||
hres = RegSetValueExW(hkey, szDMOOutputType, 0, REG_BINARY,
|
||||
(const BYTE*) pOutTypes, cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE));
|
||||
hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes);
|
||||
|
||||
if (dwFlags & DMO_REGISTERF_IS_KEYED)
|
||||
{
|
||||
|
@ -175,13 +213,15 @@ HRESULT WINAPI DMORegister(
|
|||
}
|
||||
|
||||
/* Register the category */
|
||||
hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey);
|
||||
hres = RegCreateKeyExW(hrkey, szDMOCategories, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
|
||||
if (ERROR_SUCCESS != hres)
|
||||
goto lend;
|
||||
|
||||
RegCloseKey(hkey);
|
||||
|
||||
hres = RegOpenKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, KEY_WRITE, &hkey);
|
||||
hres = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
|
||||
if (ERROR_SUCCESS != hres)
|
||||
goto lend;
|
||||
hres = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
|
||||
|
@ -330,19 +370,25 @@ static IEnumDMO * IEnumDMO_Constructor(
|
|||
lpedmo->guidCategory = guidCategory;
|
||||
lpedmo->dwFlags = dwFlags;
|
||||
|
||||
size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
if (!lpedmo->pInTypes)
|
||||
goto lerr;
|
||||
memcpy(lpedmo->pInTypes, pInTypes, size);
|
||||
lpedmo->cInTypes = cInTypes;
|
||||
if (cInTypes > 0)
|
||||
{
|
||||
size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
if (!lpedmo->pInTypes)
|
||||
goto lerr;
|
||||
memcpy(lpedmo->pInTypes, pInTypes, size);
|
||||
lpedmo->cInTypes = cInTypes;
|
||||
}
|
||||
|
||||
size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
if (!lpedmo->pOutTypes)
|
||||
goto lerr;
|
||||
memcpy(lpedmo->pOutTypes, pOutTypes, size);
|
||||
lpedmo->cOutTypes = cOutTypes;
|
||||
if (cOutTypes > 0)
|
||||
{
|
||||
size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
if (!lpedmo->pOutTypes)
|
||||
goto lerr;
|
||||
memcpy(lpedmo->pOutTypes, pOutTypes, size);
|
||||
lpedmo->cOutTypes = cOutTypes;
|
||||
}
|
||||
|
||||
/* If not filtering by category enum from media objects root */
|
||||
if (IsEqualGUID(guidCategory, &GUID_NULL))
|
||||
|
@ -487,15 +533,16 @@ static HRESULT WINAPI IEnumDMO_fnNext(
|
|||
DWORD cInTypes;
|
||||
DMO_PARTIAL_MEDIATYPE* pInTypes;
|
||||
|
||||
len = MAX_PATH * sizeof(WCHAR);
|
||||
hres = RegQueryValueExW(hkey, szDMOInputType, NULL, NULL, (LPBYTE) szValue, &len);
|
||||
if (ERROR_SUCCESS != hres)
|
||||
hres = read_types(hkey, szDMOInputType, &cInTypes,
|
||||
sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
|
||||
(DMO_PARTIAL_MEDIATYPE*)szValue);
|
||||
|
||||
if (ERROR_SUCCESS != hres)
|
||||
{
|
||||
RegCloseKey(hkey);
|
||||
continue;
|
||||
}
|
||||
|
||||
cInTypes = len / sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
|
||||
|
||||
for (i = 0; i < This->cInTypes; i++)
|
||||
|
@ -523,15 +570,16 @@ static HRESULT WINAPI IEnumDMO_fnNext(
|
|||
DWORD cOutTypes;
|
||||
DMO_PARTIAL_MEDIATYPE* pOutTypes;
|
||||
|
||||
len = MAX_PATH * sizeof(WCHAR);
|
||||
hres = RegQueryValueExW(hkey, szDMOOutputType, NULL, NULL, (LPBYTE) szValue, &len);
|
||||
hres = read_types(hkey, szDMOOutputType, &cOutTypes,
|
||||
sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
|
||||
(DMO_PARTIAL_MEDIATYPE*)szValue);
|
||||
|
||||
if (ERROR_SUCCESS != hres)
|
||||
{
|
||||
RegCloseKey(hkey);
|
||||
continue;
|
||||
}
|
||||
|
||||
cOutTypes = len / sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
|
||||
|
||||
for (i = 0; i < This->cOutTypes; i++)
|
||||
|
@ -659,64 +707,73 @@ static const IEnumDMOVtbl edmovt =
|
|||
};
|
||||
|
||||
|
||||
HRESULT build_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types )
|
||||
HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types )
|
||||
{
|
||||
HRESULT ret = S_OK;
|
||||
HKEY hkey;
|
||||
WCHAR szGuidKey[64];
|
||||
|
||||
*supplied = 0;
|
||||
if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
|
||||
if (MSDMO_MAJOR_VERSION > 5)
|
||||
{
|
||||
int index = 0;
|
||||
WCHAR szNextKey[MAX_PATH];
|
||||
DWORD len;
|
||||
LONG rc = ERROR_SUCCESS;
|
||||
DWORD len;
|
||||
len = requested * sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
ret = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len);
|
||||
*supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
HKEY hkey;
|
||||
WCHAR szGuidKey[64];
|
||||
|
||||
len = MAX_PATH;
|
||||
while (rc == ERROR_SUCCESS)
|
||||
{
|
||||
len = MAX_PATH;
|
||||
rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
*supplied = 0;
|
||||
if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
|
||||
{
|
||||
HKEY subk;
|
||||
int sub_index = 0;
|
||||
LONG rcs = ERROR_SUCCESS;
|
||||
WCHAR szSubKey[MAX_PATH];
|
||||
int index = 0;
|
||||
WCHAR szNextKey[MAX_PATH];
|
||||
DWORD len;
|
||||
LONG rc = ERROR_SUCCESS;
|
||||
|
||||
RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
|
||||
while (rcs == ERROR_SUCCESS)
|
||||
while (rc == ERROR_SUCCESS)
|
||||
{
|
||||
len = MAX_PATH;
|
||||
rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
|
||||
if (rcs == ERROR_SUCCESS)
|
||||
len = MAX_PATH * sizeof(WCHAR);
|
||||
rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
if (*supplied >= requested)
|
||||
{
|
||||
/* Bailing */
|
||||
ret = S_FALSE;
|
||||
rc = ERROR_MORE_DATA;
|
||||
rcs = ERROR_MORE_DATA;
|
||||
break;
|
||||
}
|
||||
HKEY subk;
|
||||
int sub_index = 0;
|
||||
LONG rcs = ERROR_SUCCESS;
|
||||
WCHAR szSubKey[MAX_PATH];
|
||||
|
||||
wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
|
||||
CLSIDFromString(szGuidKey, &types[*supplied].type);
|
||||
wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
|
||||
CLSIDFromString(szGuidKey, &types[*supplied].subtype);
|
||||
TRACE("Adding type %s subtype %s at index %i\n",
|
||||
debugstr_guid(&types[*supplied].type),
|
||||
debugstr_guid(&types[*supplied].subtype),
|
||||
*supplied);
|
||||
(*supplied)++;
|
||||
RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
|
||||
while (rcs == ERROR_SUCCESS)
|
||||
{
|
||||
len = MAX_PATH * sizeof(WCHAR);
|
||||
rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
|
||||
if (rcs == ERROR_SUCCESS)
|
||||
{
|
||||
if (*supplied >= requested)
|
||||
{
|
||||
/* Bailing */
|
||||
ret = S_FALSE;
|
||||
rc = ERROR_MORE_DATA;
|
||||
rcs = ERROR_MORE_DATA;
|
||||
break;
|
||||
}
|
||||
|
||||
wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
|
||||
CLSIDFromString(szGuidKey, &types[*supplied].type);
|
||||
wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
|
||||
CLSIDFromString(szGuidKey, &types[*supplied].subtype);
|
||||
TRACE("Adding type %s subtype %s at index %i\n",
|
||||
debugstr_guid(&types[*supplied].type),
|
||||
debugstr_guid(&types[*supplied].subtype),
|
||||
*supplied);
|
||||
(*supplied)++;
|
||||
}
|
||||
sub_index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
sub_index++;
|
||||
}
|
||||
index++;
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -751,7 +808,7 @@ HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
|
|||
|
||||
if (ulInputTypesRequested > 0)
|
||||
{
|
||||
ret = build_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
|
||||
ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
|
||||
}
|
||||
else
|
||||
*pulInputTypesSupplied = 0;
|
||||
|
@ -759,7 +816,7 @@ HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
|
|||
if (ulOutputTypesRequested > 0)
|
||||
{
|
||||
HRESULT ret2;
|
||||
ret2 = build_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
|
||||
ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
|
||||
|
||||
if (ret == S_OK)
|
||||
ret = ret2;
|
||||
|
|
Loading…
Reference in New Issue