Commit 57ac2649 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

mfplat: Implement IMFAttributes::{SetUnknown, GetUnknown}.

parent e00bfc4c
......@@ -671,7 +671,7 @@ static HRESULT attributes_get_item(struct attributes *attributes, const GUID *ke
attribute = attributes_find_item(attributes, key, NULL);
if (attribute)
{
if (attribute->value.vt == value->vt)
if (attribute->value.vt == value->vt && !(value->vt == VT_UNKNOWN && !attribute->value.u.punkVal))
hr = PropVariantCopy(value, &attribute->value);
else
hr = MF_E_INVALIDTYPE;
......@@ -866,9 +866,19 @@ static HRESULT WINAPI mfattributes_GetAllocatedBlob(IMFAttributes *iface, REFGUI
static HRESULT WINAPI mfattributes_GetUnknown(IMFAttributes *iface, REFGUID key, REFIID riid, void **ppv)
{
FIXME("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv);
struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
HRESULT hr;
return E_NOTIMPL;
TRACE("%p, %s, %s, %p.\n", iface, debugstr_attr(key), debugstr_guid(riid), ppv);
PropVariantInit(&attrval);
attrval.vt = VT_UNKNOWN;
hr = attributes_get_item(attributes, key, &attrval);
if (SUCCEEDED(hr))
hr = IUnknown_QueryInterface(attrval.u.punkVal, riid, ppv);
PropVariantClear(&attrval);
return hr;
}
static HRESULT attributes_set_item(struct attributes *attributes, REFGUID key, REFPROPVARIANT value)
......@@ -1023,9 +1033,14 @@ static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, co
static HRESULT WINAPI mfattributes_SetUnknown(IMFAttributes *iface, REFGUID key, IUnknown *unknown)
{
FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), unknown);
struct attributes *attributes = impl_from_IMFAttributes(iface);
PROPVARIANT attrval;
return E_NOTIMPL;
TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), unknown);
attrval.vt = VT_UNKNOWN;
attrval.u.punkVal = unknown;
return attributes_set_item(attributes, key, &attrval);
}
static HRESULT WINAPI mfattributes_LockStore(IMFAttributes *iface)
......
......@@ -511,6 +511,7 @@ static void test_MFCreateAttributes(void)
UINT32 value, string_length;
IMFAttributes *attributes;
double double_value;
IUnknown *unk_value;
WCHAR bufferW[256];
UINT64 value64;
WCHAR *string;
......@@ -689,6 +690,30 @@ static void test_MFCreateAttributes(void)
ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr);
ok(string_length == 0xdeadbeef, "Unexpected length %u.\n", string_length);
/* VT_UNKNOWN */
hr = IMFAttributes_SetUnknown(attributes, &DUMMY_GUID2, (IUnknown *)attributes);
ok(hr == S_OK, "Failed to set value, hr %#x.\n", hr);
CHECK_ATTR_COUNT(attributes, 4);
hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IUnknown, (void **)&unk_value);
ok(hr == S_OK, "Failed to get value, hr %#x.\n", hr);
IUnknown_Release(unk_value);
hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IMFAttributes, (void **)&unk_value);
ok(hr == S_OK, "Failed to get value, hr %#x.\n", hr);
IUnknown_Release(unk_value);
hr = IMFAttributes_GetUnknown(attributes, &DUMMY_GUID2, &IID_IStream, (void **)&unk_value);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFAttributes_SetUnknown(attributes, &DUMMY_CLSID, NULL);
ok(hr == S_OK, "Failed to set value, hr %#x.\n", hr);
CHECK_ATTR_COUNT(attributes, 5);
unk_value = NULL;
hr = IMFAttributes_GetUnknown(attributes, &DUMMY_CLSID, &IID_IUnknown, (void **)&unk_value);
ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr);
IMFAttributes_Release(attributes);
}
......
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