Module: wine Branch: master Commit: c127fab80e2c47d531d29d7e286dd6455450a727 URL: https://source.winehq.org/git/wine.git/?a=commit;h=c127fab80e2c47d531d29d7e2...
Author: Jactry Zeng jzeng@codeweavers.com Date: Thu Mar 14 11:03:11 2019 +0300
mfplat: Add support for integer attribute values.
Signed-off-by: Jactry Zeng jzeng@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mfplat/Makefile.in | 2 +- dlls/mfplat/main.c | 71 +++++++++++++++++++++++++++++++++++------ dlls/mfplat/tests/mfplat.c | 35 +++++++++++++++----- dlls/mfreadwrite/tests/mfplat.c | 2 +- 4 files changed, 91 insertions(+), 19 deletions(-)
diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in index e64e405..eb9b26f 100644 --- a/dlls/mfplat/Makefile.in +++ b/dlls/mfplat/Makefile.in @@ -1,6 +1,6 @@ MODULE = mfplat.dll IMPORTLIB = mfplat -IMPORTS = advapi32 ole32 mfuuid +IMPORTS = advapi32 ole32 mfuuid propsys
C_SRCS = \ buffer.c \ diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index c339f23..4b4f262 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -20,6 +20,7 @@ #include <string.h>
#define COBJMACROS +#define NONAMELESSUNION
#include "windef.h" #include "winbase.h" @@ -35,6 +36,7 @@
#include "mfplat_private.h" #include "mfreadwrite.h" +#include "propvarutil.h"
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
@@ -659,6 +661,29 @@ static struct attribute *attributes_find_item(struct attributes *attributes, REF return NULL; }
+static HRESULT attributes_get_item(struct attributes *attributes, const GUID *key, PROPVARIANT *value) +{ + struct attribute *attribute; + HRESULT hr; + + EnterCriticalSection(&attributes->cs); + + attribute = attributes_find_item(attributes, key, NULL); + if (attribute) + { + if (attribute->value.vt == value->vt) + hr = PropVariantCopy(value, &attribute->value); + else + hr = MF_E_INVALIDTYPE; + } + else + hr = MF_E_ATTRIBUTENOTFOUND; + + LeaveCriticalSection(&attributes->cs); + + return hr; +} + static HRESULT WINAPI mfattributes_GetItem(IMFAttributes *iface, REFGUID key, PROPVARIANT *value) { struct attributes *attributes = impl_from_IMFAttributes(iface); @@ -705,16 +730,34 @@ static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *
static HRESULT WINAPI mfattributes_GetUINT32(IMFAttributes *iface, REFGUID key, UINT32 *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + PropVariantInit(&attrval); + attrval.vt = VT_UI4; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToUInt32(&attrval, value); + return hr; }
static HRESULT WINAPI mfattributes_GetUINT64(IMFAttributes *iface, REFGUID key, UINT64 *value) { - FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), value); + + PropVariantInit(&attrval); + attrval.vt = VT_UI8; + hr = attributes_get_item(attributes, key, &attrval); + if (SUCCEEDED(hr)) + hr = PropVariantToUInt64(&attrval, value); + return hr; }
static HRESULT WINAPI mfattributes_GetDouble(IMFAttributes *iface, REFGUID key, double *value) @@ -873,16 +916,26 @@ static HRESULT WINAPI mfattributes_DeleteAllItems(IMFAttributes *iface)
static HRESULT WINAPI mfattributes_SetUINT32(IMFAttributes *iface, REFGUID key, UINT32 value) { - FIXME("%p, %s, %d.\n", iface, debugstr_attr(key), value); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %d.\n", iface, debugstr_attr(key), value); + + attrval.vt = VT_UI4; + attrval.u.ulVal = value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetUINT64(IMFAttributes *iface, REFGUID key, UINT64 value) { - FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value)); + struct attributes *attributes = impl_from_IMFAttributes(iface); + PROPVARIANT attrval;
- return E_NOTIMPL; + TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), wine_dbgstr_longlong(value)); + + attrval.vt = VT_UI8; + attrval.u.uhVal.QuadPart = value; + return attributes_set_item(attributes, key, &attrval); }
static HRESULT WINAPI mfattributes_SetDouble(IMFAttributes *iface, REFGUID key, double value) @@ -3481,7 +3534,7 @@ static HRESULT WINAPI eventqueue_QueueEventParamUnk(IMFMediaEventQueue *iface, M TRACE("%p, %d, %s, %#x, %p.\n", iface, event_type, debugstr_guid(extended_type), status, unk);
value.vt = VT_UNKNOWN; - value.punkVal = unk; + value.u.punkVal = unk;
if (FAILED(hr = MFCreateMediaEvent(event_type, extended_type, status, &value, &event))) return hr; diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 273aa26..b51e5e2 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -359,25 +359,21 @@ todo_wine ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 0); -todo_wine ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = FALSE; hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); -todo_wine ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(compressed, "Unexpected value %d.\n", compressed);
hr = IMFMediaType_SetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1); -todo_wine ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
compressed = TRUE; hr = IMFMediaType_IsCompressedFormat(mediatype, &compressed); -todo_wine { ok(hr == S_OK, "Failed to get media type property, hr %#x.\n", hr); ok(!compressed, "Unexpected value %d.\n", compressed); -} + hr = IMFMediaType_SetGUID(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -502,7 +498,8 @@ static void test_MFCreateAttributes(void) { PROPVARIANT propvar, ret_propvar; IMFAttributes *attributes; - UINT32 count; + UINT32 count, value; + UINT64 value64; HRESULT hr; GUID key;
@@ -514,13 +511,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, "Failed to set UINT32 value, hr %#x.\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);
+ value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value); + ok(hr == S_OK, "Failed to get UINT32 value, hr %#x.\n", hr); + ok(value == 123, "Unexpected value %u, expected: 123.\n", value); + + value64 = 0xdeadbeef; + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + ok(value64 == 0xdeadbeef, "Unexpected value.\n"); + + hr = IMFAttributes_SetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, 65536); + ok(hr == S_OK, "Failed to set UINT64 value, hr %#x.\n", hr); + + hr = IMFAttributes_GetUINT64(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value64); + ok(hr == S_OK, "Failed to get UINT64 value, hr %#x.\n", hr); + ok(value64 == 65536, "Unexpected value.\n"); + + value = 0xdeadbeef; + hr = IMFAttributes_GetUINT32(attributes, &MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, &value); + ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr); + ok(value == 0xdeadbeef, "Unexpected value.\n"); + IMFAttributes_Release(attributes);
hr = MFCreateAttributes(&attributes, 0); diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 58533cc..1767433 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -67,7 +67,7 @@ static void test_MFCreateSourceReaderFromByteStream(void) todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0); - todo_wine ok(hr == S_OK, "got 0x%08x\n", hr); + ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "got 0x%08x\n", hr);