Commit f5cdbc21 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

windowscodecs: Store container formats in metadata component info object.

parent 89642d9b
...@@ -1502,6 +1502,8 @@ typedef struct ...@@ -1502,6 +1502,8 @@ typedef struct
{ {
ComponentInfo base; ComponentInfo base;
HKEY classkey; HKEY classkey;
GUID *container_formats;
UINT container_count;
} MetadataReaderInfo; } MetadataReaderInfo;
static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface) static inline MetadataReaderInfo *impl_from_IWICMetadataReaderInfo(IWICMetadataReaderInfo *iface)
...@@ -1554,6 +1556,7 @@ static ULONG WINAPI MetadataReaderInfo_Release(IWICMetadataReaderInfo *iface) ...@@ -1554,6 +1556,7 @@ static ULONG WINAPI MetadataReaderInfo_Release(IWICMetadataReaderInfo *iface)
if (!ref) if (!ref)
{ {
RegCloseKey(This->classkey); RegCloseKey(This->classkey);
heap_free(This->container_formats);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
...@@ -1654,10 +1657,20 @@ static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderI ...@@ -1654,10 +1657,20 @@ static HRESULT WINAPI MetadataReaderInfo_GetContainerFormats(IWICMetadataReaderI
UINT length, GUID *formats, UINT *actual_length) UINT length, GUID *formats, UINT *actual_length)
{ {
MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface); MetadataReaderInfo *This = impl_from_IWICMetadataReaderInfo(iface);
TRACE("(%p,%u,%p,%p)\n", iface, length, formats, actual_length); TRACE("(%p,%u,%p,%p)\n", iface, length, formats, actual_length);
return ComponentInfo_GetGuidList(This->classkey, containers_keyname, length, if (!actual_length)
formats, actual_length); return E_INVALIDARG;
*actual_length = This->container_count;
if (formats)
{
if (This->container_count && length < This->container_count)
return WINCODEC_ERR_INSUFFICIENTBUFFER;
memcpy(formats, This->container_formats, This->container_count);
}
return S_OK;
} }
static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface, static HRESULT WINAPI MetadataReaderInfo_GetDeviceManufacturer(IWICMetadataReaderInfo *iface,
...@@ -1915,11 +1928,36 @@ static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl = { ...@@ -1915,11 +1928,36 @@ static const IWICMetadataReaderInfoVtbl MetadataReaderInfo_Vtbl = {
MetadataReaderInfo_CreateInstance MetadataReaderInfo_CreateInstance
}; };
static BOOL read_metadata_info(MetadataReaderInfo *info)
{
UINT format_count;
GUID *formats;
HRESULT hr;
hr = ComponentInfo_GetGuidList(info->classkey, containers_keyname, 0, NULL, &format_count);
if (FAILED(hr)) return TRUE;
formats = heap_calloc(format_count, sizeof(*formats));
if (!formats) return FALSE;
hr = ComponentInfo_GetGuidList(info->classkey, containers_keyname, format_count, formats,
&format_count);
if (FAILED(hr))
{
heap_free(formats);
return FALSE;
}
info->container_formats = formats;
info->container_count = format_count;
return TRUE;
}
static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **info) static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, ComponentInfo **info)
{ {
MetadataReaderInfo *This; MetadataReaderInfo *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This)); This = heap_alloc_zero(sizeof(*This));
if (!This) if (!This)
{ {
RegCloseKey(classkey); RegCloseKey(classkey);
...@@ -1931,6 +1969,12 @@ static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, Com ...@@ -1931,6 +1969,12 @@ static HRESULT MetadataReaderInfo_Constructor(HKEY classkey, REFCLSID clsid, Com
This->classkey = classkey; This->classkey = classkey;
This->base.clsid = *clsid; This->base.clsid = *clsid;
if (!read_metadata_info(This))
{
IWICComponentInfo_Release(&This->base.IWICComponentInfo_iface);
return WINCODEC_ERR_COMPONENTNOTFOUND;
}
*info = &This->base; *info = &This->base;
return S_OK; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment