[PATCH 09/11] mfplat: Add support for string attributes.
Nikolay Sivov
nsivov at codeweavers.com
Thu Mar 14 03:03:14 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 | 63 +++++++++++++++++++++++++++------
dlls/mfplat/tests/mfplat.c | 44 +++++++++++++++++++++--
dlls/mfreadwrite/tests/mfplat.c | 2 +-
3 files changed, 95 insertions(+), 14 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 6fb917e219..d73076bd83 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -785,25 +785,61 @@ static HRESULT WINAPI mfattributes_GetGUID(IMFAttributes *iface, REFGUID key, GU
static HRESULT WINAPI mfattributes_GetStringLength(IMFAttributes *iface, REFGUID key, UINT32 *length)
{
- FIXME("%p, %s, %p.\n", iface, debugstr_attr(key), length);
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("%p, %s, %p.\n", iface, debugstr_attr(key), length);
+
+ PropVariantInit(&attrval);
+ attrval.vt = VT_LPWSTR;
+ hr = attributes_get_item(attributes, key, &attrval);
+ if (SUCCEEDED(hr) && length)
+ *length = lstrlenW(attrval.u.pwszVal);
+ PropVariantClear(&attrval);
+
+ return hr;
}
static HRESULT WINAPI mfattributes_GetString(IMFAttributes *iface, REFGUID key, WCHAR *value,
- UINT32 size, UINT32 *length)
+ UINT32 size, UINT32 *length)
{
- FIXME("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length);
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_attr(key), value, size, length);
+
+ PropVariantInit(&attrval);
+ attrval.vt = VT_LPWSTR;
+ hr = attributes_get_item(attributes, key, &attrval);
+ if (SUCCEEDED(hr))
+ hr = PropVariantToString(&attrval, value, size);
+ if (SUCCEEDED(hr) && length)
+ *length = lstrlenW(value);
+ PropVariantClear(&attrval);
+
+ return hr;
}
-static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key,
- WCHAR **value, UINT32 *length)
+static HRESULT WINAPI mfattributes_GetAllocatedString(IMFAttributes *iface, REFGUID key, WCHAR **value, UINT32 *length)
{
- FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length);
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, length);
+
+ PropVariantInit(&attrval);
+ attrval.vt = VT_LPWSTR;
+ hr = attributes_get_item(attributes, key, &attrval);
+ if (SUCCEEDED(hr))
+ {
+ *value = attrval.u.pwszVal;
+ *length = lstrlenW(*value);
+ }
+
+ return hr;
}
static HRESULT WINAPI mfattributes_GetBlobSize(IMFAttributes *iface, REFGUID key, UINT32 *size)
@@ -968,9 +1004,14 @@ static HRESULT WINAPI mfattributes_SetGUID(IMFAttributes *iface, REFGUID key, RE
static HRESULT WINAPI mfattributes_SetString(IMFAttributes *iface, REFGUID key, const WCHAR *value)
{
- FIXME("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value));
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
+ PROPVARIANT attrval;
- return E_NOTIMPL;
+ TRACE("%p, %s, %s.\n", iface, debugstr_attr(key), debugstr_w(value));
+
+ attrval.vt = VT_LPWSTR;
+ attrval.u.pwszVal = (WCHAR *)value;
+ return attributes_set_item(attributes, key, &attrval);
}
static HRESULT WINAPI mfattributes_SetBlob(IMFAttributes *iface, REFGUID key, const UINT8 *buf, UINT32 size)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index e6a3f4b9d5..3fda11d0c7 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -44,6 +44,7 @@ DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23,
#include "mferror.h"
#include "mfreadwrite.h"
#include "propvarutil.h"
+#include "strsafe.h"
#include "wine/test.h"
@@ -285,7 +286,7 @@ static void test_source_resolver(void)
(void **)&attributes);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, file_type);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "Failed to set string value, hr %#x.\n", hr);
IMFAttributes_Release(attributes);
hr = IMFSourceResolver_CreateObjectFromByteStream(
@@ -505,11 +506,14 @@ static void check_attr_count(IMFAttributes* obj, UINT32 expected, int line)
static void test_MFCreateAttributes(void)
{
+ static const WCHAR stringW[] = {'W','i','n','e',0};
PROPVARIANT propvar, ret_propvar;
+ UINT32 value, string_length;
IMFAttributes *attributes;
double double_value;
+ WCHAR bufferW[256];
UINT64 value64;
- UINT32 value;
+ WCHAR *string;
HRESULT hr;
GUID key;
@@ -649,6 +653,42 @@ static void test_MFCreateAttributes(void)
ok(hr == S_OK, "Failed to get double value, hr %#x.\n", hr);
ok(double_value == 22.0, "Unexpected value: %f, expected: 22.0.\n", double_value);
+ hr = IMFAttributes_SetString(attributes, &DUMMY_GUID1, stringW);
+ ok(hr == S_OK, "Failed to set string attribute, hr %#x.\n", hr);
+ CHECK_ATTR_COUNT(attributes, 3);
+
+ hr = IMFAttributes_GetStringLength(attributes, &DUMMY_GUID1, &string_length);
+ ok(hr == S_OK, "Failed to get string length, hr %#x.\n", hr);
+ ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length);
+
+ string_length = 0xdeadbeef;
+ hr = IMFAttributes_GetAllocatedString(attributes, &DUMMY_GUID1, &string, &string_length);
+ ok(hr == S_OK, "Failed to get allocated string, hr %#x.\n", hr);
+ ok(!lstrcmpW(string, stringW), "Unexpected string %s.\n", wine_dbgstr_w(string));
+ ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length);
+ CoTaskMemFree(string);
+
+ string_length = 0xdeadbeef;
+ hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, ARRAY_SIZE(bufferW), &string_length);
+ ok(hr == S_OK, "Failed to get string value, hr %#x.\n", hr);
+ ok(!lstrcmpW(bufferW, stringW), "Unexpected string %s.\n", wine_dbgstr_w(bufferW));
+ ok(string_length == lstrlenW(stringW), "Unexpected length %u.\n", string_length);
+ memset(bufferW, 0, sizeof(bufferW));
+
+ hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, ARRAY_SIZE(bufferW), NULL);
+ ok(hr == S_OK, "Failed to get string value, hr %#x.\n", hr);
+ ok(!lstrcmpW(bufferW, stringW), "Unexpected string %s.\n", wine_dbgstr_w(bufferW));
+ memset(bufferW, 0, sizeof(bufferW));
+
+ hr = IMFAttributes_GetString(attributes, &DUMMY_GUID1, bufferW, 1, NULL);
+ ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "Unexpected hr %#x.\n", hr);
+ ok(!bufferW[0], "Unexpected string %s.\n", wine_dbgstr_w(bufferW));
+
+ string_length = 0xdeadbeef;
+ hr = IMFAttributes_GetStringLength(attributes, &GUID_NULL, &string_length);
+ ok(hr == MF_E_INVALIDTYPE, "Unexpected hr %#x.\n", hr);
+ ok(string_length == 0xdeadbeef, "Unexpected length %u.\n", string_length);
+
IMFAttributes_Release(attributes);
}
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c
index 1767433e24..609510d427 100644
--- a/dlls/mfreadwrite/tests/mfplat.c
+++ b/dlls/mfreadwrite/tests/mfplat.c
@@ -64,7 +64,7 @@ static void test_MFCreateSourceReaderFromByteStream(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IMFAttributes_SetString(attributes, &MF_READWRITE_MMCSS_CLASS_AUDIO, audio);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "Failed to set string value, hr %#x.\n", hr);
hr = IMFAttributes_SetUINT32(attributes, &MF_READWRITE_MMCSS_PRIORITY_AUDIO, 0);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
--
2.20.1
More information about the wine-devel
mailing list