[PATCH v4 4/5] mfplat: Implement IMFattributes::{SetUINT32,SetUINT64,GetUINT32,GetUINT64}.
Jactry Zeng
jzeng at codeweavers.com
Thu Mar 7 20:43:19 CST 2019
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
dlls/mfplat/Makefile.in | 2 +-
dlls/mfplat/main.c | 60 +++++++++++++++++++++++++++++++++-----
dlls/mfplat/tests/mfplat.c | 28 ++++++++++++++++--
3 files changed, 79 insertions(+), 11 deletions(-)
diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in
index a117ede271..4ec51e300e 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 = \
buffer.c \
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 5ae3b4ff07..1749bd6929 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -33,6 +33,7 @@
#include "wine/list.h"
#include "mfplat_private.h"
+#include "propvarutil.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -649,22 +650,59 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
return E_NOTIMPL;
}
+static HRESULT mfattributes_get_item(mfattributes *object, REFGUID key, PROPVARIANT *value)
+{
+ HRESULT hr;
+ struct mfattribute *attribute = NULL;
+
+ EnterCriticalSection(&object->lock);
+
+ attribute = mfattributes_find_item(object, key, NULL);
+ if (!attribute)
+ hr = MF_E_ATTRIBUTENOTFOUND;
+ else
+ {
+ if (attribute->value.vt != value->vt)
+ hr = MF_E_INVALIDTYPE;
+ else
+ hr = PropVariantCopy(value, &attribute->value);
+ }
+
+ LeaveCriticalSection(&object->lock);
+
+ return hr;
+}
+
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value)
{
mfattributes *This = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
+ HRESULT hr;
- 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;
+ hr = mfattributes_get_item(This, key, &attrval);
+ if (SUCCEEDED(hr))
+ hr = PropVariantToUInt32(&attrval, value);
+ return hr;
}
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value)
{
mfattributes *This = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
+ HRESULT hr;
- 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;
+ hr = mfattributes_get_item(This, key, &attrval);
+ if (SUCCEEDED(hr))
+ hr = PropVariantToUInt64(&attrval, value);
+ return hr;
}
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value)
@@ -855,19 +893,25 @@ 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;
+ attrval.vt = VT_UI4;
+ attrval.ulVal = value;
+ return mfattributes_set_item(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));
+ TRACE("(%p, %s, %s)\n", This, debugstr_guid(key), wine_dbgstr_longlong(value));
- return E_NOTIMPL;
+ attrval.vt = VT_UI8;
+ attrval.uhVal.QuadPart = value;
+ return mfattributes_set_item(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 ea70b4bf5f..55c9f516c3 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -423,6 +423,8 @@ static void test_MFCreateAttributes(void)
UINT32 count;
PROPVARIANT propvar, ret_propvar;
GUID key;
+ UINT32 uint32_value;
+ UINT64 uint64_value;
hr = MFCreateAttributes( &attributes, 3 );
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -432,13 +434,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, "got 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);
hr = MFCreateAttributes(&attributes, 0);
--
2.20.1
More information about the wine-devel
mailing list