[PATCH v2 7/8] mfplat: Implement IMFattributes::{SetUINT32,SetUINT64,GetUINT32,GetUINT64}.

Jactry Zeng jzeng at codeweavers.com
Fri Jan 4 07:28:54 CST 2019


Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
 dlls/mfplat/Makefile.in    |  2 +-
 dlls/mfplat/main.c         | 50 +++++++++++++++++++++++++++++---------
 dlls/mfplat/tests/mfplat.c | 28 +++++++++++++++++++--
 3 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in
index 76843f5f25..9a4e41c430 100644
--- a/dlls/mfplat/Makefile.in
+++ b/dlls/mfplat/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = mfplat.dll
 IMPORTLIB = mfplat
-IMPORTS   = advapi32 ole32
+IMPORTS   = advapi32 ole32 propsys
 
 C_SRCS = \
 	main.c
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 06a49b237f..25c075781b 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -31,6 +31,7 @@
 #include "mfapi.h"
 #include "mfidl.h"
 #include "mferror.h"
+#include "propvarutil.h"
 
 #include "wine/heap.h"
 #include "wine/debug.h"
@@ -536,7 +537,7 @@ static int mfattributes_finditem(mfattributes *object, REFGUID key, struct mfatt
     return index;
 }
 
-static HRESULT mfattributes_getitem(mfattributes *object, REFGUID key, PROPVARIANT *value)
+static HRESULT mfattributes_getitem(mfattributes *object, REFGUID key, PROPVARIANT *value, BOOL verify_type)
 {
     HRESULT hres;
     struct mfattribute *attribute = NULL;
@@ -547,7 +548,12 @@ static HRESULT mfattributes_getitem(mfattributes *object, REFGUID key, PROPVARIA
     if(!attribute)
         hres = MF_E_ATTRIBUTENOTFOUND;
     else
-        hres = PropVariantCopy(value, &attribute->value);
+    {
+        if(verify_type && (attribute->value.vt != value->vt))
+            hres = MF_E_INVALIDTYPE;
+        else
+            hres = PropVariantCopy(value, &attribute->value);
+    }
 
     LeaveCriticalSection(&object->lock);
 
@@ -560,7 +566,7 @@ static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PR
 
     TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
 
-    return mfattributes_getitem(This, key, value);
+    return mfattributes_getitem(This, key, value, FALSE);
 }
 
 static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
@@ -594,19 +600,33 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
 static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value)
 {
     mfattributes *This = impl_from_IMFAttributes(iface);
+    PROPVARIANT attrval;
+    HRESULT hres;
 
-    FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
+    TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
 
-    return E_NOTIMPL;
+    PropVariantInit(&attrval);
+    attrval.vt = VT_UI4;
+    hres = mfattributes_getitem(This, key, &attrval, TRUE);
+    if(SUCCEEDED(hres))
+        hres = PropVariantToUInt32(&attrval, value);
+    return hres;
 }
 
 static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value)
 {
     mfattributes *This = impl_from_IMFAttributes(iface);
+    PROPVARIANT attrval;
+    HRESULT hres;
 
-    FIXME("%p, %s, %p\n", This, debugstr_guid(key), value);
+    TRACE("(%p, %s, %p)\n", This, debugstr_guid(key), value);
 
-    return E_NOTIMPL;
+    PropVariantInit(&attrval);
+    attrval.vt = VT_UI8;
+    hres = mfattributes_getitem(This, key, &attrval, TRUE);
+    if(SUCCEEDED(hres))
+        hres = PropVariantToUInt64(&attrval, value);
+    return hres;
 }
 
 static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value)
@@ -809,19 +829,27 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
 static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value)
 {
     mfattributes *This = impl_from_IMFAttributes(iface);
+    PROPVARIANT attrval;
 
-    FIXME("%p, %s, %d\n", This, debugstr_guid(key), value);
+    TRACE("(%p, %s, %d)\n", This, debugstr_guid(key), value);
 
-    return E_NOTIMPL;
+    PropVariantInit(&attrval);
+    attrval.vt = VT_UI4;
+    attrval.ulVal = value;
+    return mfattributes_setitem(This, key, &attrval);
 }
 
 static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value)
 {
     mfattributes *This = impl_from_IMFAttributes(iface);
+    PROPVARIANT attrval;
 
-    FIXME("%p, %s, %s\n", This, debugstr_guid(key), wine_dbgstr_longlong(value));
+    FIXME("(%p, %s, %s)\n", This, debugstr_guid(key), wine_dbgstr_longlong(value));
 
-    return E_NOTIMPL;
+    PropVariantInit(&attrval);
+    attrval.vt = VT_UI8;
+    attrval.uhVal.QuadPart = value;
+    return mfattributes_setitem(This, key, &attrval);
 }
 
 static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 7f7f413096..4564f410d3 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -414,6 +414,8 @@ static void test_MFCreateAttributes(void)
     IMFAttributes *attributes;
     HRESULT hr;
     UINT32 count;
+    UINT32 uint32_value;
+    UINT64 uint64_value;
 
     hr = MFCreateAttributes( &attributes, 3 );
     ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -423,13 +425,35 @@ static void test_MFCreateAttributes(void)
     todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(count == 0, "got %d\n", count);
 
-    hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 0);
-    todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+    hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 123);
+    ok(hr == S_OK, "IMFAttributes_SetUINT32 failed: 0x%08x.\n", hr);
 
     hr = IMFAttributes_GetCount(attributes, &count);
     todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
     todo_wine ok(count == 1, "got %d\n", count);
 
+    uint32_value = 0xdeadbeef;
+    hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint32_value);
+    ok(hr == S_OK, "IMFAttributes_GetUINT32 failed: 0x%08x.\n", hr);
+    ok(uint32_value == 123, "got wrong value: %d, expected: 123.\n", uint32_value);
+
+    uint64_value = 0xdeadbeef;
+    hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint64_value);
+    ok(hr == MF_E_INVALIDTYPE, "IMFAttributes_GetUINT64 should fail: 0x%08x.\n", hr);
+    ok(uint64_value == 0xdeadbeef, "got wrong value: %lld, expected: 0xdeadbeef.\n", uint64_value);
+
+    hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536);
+    ok(hr == S_OK, "IMFAttributes_SetUINT64 failed: 0x%08x.\n", hr);
+
+    hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint64_value);
+    ok(hr == S_OK, "IMFAttributes_GetUINT64 failed: 0x%08x.\n", hr);
+    ok(uint64_value == 65536, "got wrong value: %lld, expected: 65536.\n", uint64_value);
+
+    uint32_value = 0xdeadbeef;
+    hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &uint32_value);
+    ok(hr == MF_E_INVALIDTYPE, "IMFAttributes_GetUINT32 should fail: 0x%08x.\n", hr);
+    ok(uint32_value == 0xdeadbeef, "got wrong value: %d, expected: 0xdeadbeef.\n", uint32_value);
+
     IMFAttributes_Release(attributes);
 }
 
-- 
2.20.1





More information about the wine-devel mailing list