[PATCH 10/11] mfplat: Implement IMFAttributes::{SetUnknown, GetUnknown}.

Nikolay Sivov nsivov at codeweavers.com
Thu Mar 14 03:03:15 CDT 2019


From: Jactry Zeng <jzeng at codeweavers.com>

Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/mfplat/main.c         | 25 ++++++++++++++++++++-----
 dlls/mfplat/tests/mfplat.c | 25 +++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index d73076bd83..31bed3340e 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -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)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 3fda11d0c7..5579e02953 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -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);
 }
 
-- 
2.20.1




More information about the wine-devel mailing list