[v2 PATCH 8/8] mfplat: Implement CompareItem() for attributes.
Nikolay Sivov
nsivov at codeweavers.com
Fri Mar 15 05:56:49 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 | 16 ++++++++++++++--
dlls/mfplat/tests/mfplat.c | 25 +++++++++++++++++++++----
2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c
index 2ef4077921..88945f6724 100644
--- a/dlls/mfplat/main.c
+++ b/dlls/mfplat/main.c
@@ -731,9 +731,21 @@ static HRESULT WINAPI mfattributes_GetItemType(IMFAttributes *iface, REFGUID key
static HRESULT WINAPI mfattributes_CompareItem(IMFAttributes *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
{
- FIXME("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, result);
+ struct attributes *attributes = impl_from_IMFAttributes(iface);
+ struct attribute *attribute;
- return E_NOTIMPL;
+ TRACE("%p, %s, %p, %p.\n", iface, debugstr_attr(key), value, result);
+
+ *result = FALSE;
+
+ EnterCriticalSection(&attributes->cs);
+
+ if ((attribute = attributes_find_item(attributes, key, NULL)))
+ *result = !PropVariantCompareEx(&attribute->value, value, PVCU_DEFAULT, PVCF_DEFAULT);
+
+ LeaveCriticalSection(&attributes->cs);
+
+ return S_OK;
}
static HRESULT WINAPI mfattributes_Compare(IMFAttributes *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index edf3c6e694..38151d9020 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -406,21 +406,19 @@ todo_wine
flags = 0;
hr = IMFMediaType_IsEqual(mediatype, mediatype2, &flags);
-todo_wine {
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(flags == (MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_DATA
| MF_MEDIATYPE_EQUAL_FORMAT_USER_DATA), "Unexpected flags %#x.\n", flags);
-}
+
hr = IMFMediaType_SetGUID(mediatype, &MF_MT_SUBTYPE, &MFVideoFormat_RGB32);
ok(hr == S_OK, "Failed to set subtype, hr %#x.\n", hr);
flags = 0;
hr = IMFMediaType_IsEqual(mediatype, mediatype2, &flags);
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
-todo_wine {
ok(flags == (MF_MEDIATYPE_EQUAL_MAJOR_TYPES | MF_MEDIATYPE_EQUAL_FORMAT_DATA | MF_MEDIATYPE_EQUAL_FORMAT_USER_DATA),
"Unexpected flags %#x.\n", flags);
-}
+
IMFMediaType_Release(mediatype2);
IMFMediaType_Release(mediatype);
}
@@ -511,6 +509,7 @@ static void test_MFCreateAttributes(void)
WCHAR bufferW[256];
UINT64 value64;
WCHAR *string;
+ BOOL result;
HRESULT hr;
GUID key;
@@ -650,6 +649,18 @@ 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);
+ propvar.vt = MF_ATTRIBUTE_UINT64;
+ U(propvar).uhVal.QuadPart = 22;
+ hr = IMFAttributes_CompareItem(attributes, &GUID_NULL, &propvar, &result);
+ ok(hr == S_OK, "Failed to compare items, hr %#x.\n", hr);
+ ok(!result, "Unexpected result.\n");
+
+ propvar.vt = MF_ATTRIBUTE_DOUBLE;
+ U(propvar).dblVal = 22.0;
+ hr = IMFAttributes_CompareItem(attributes, &GUID_NULL, &propvar, &result);
+ ok(hr == S_OK, "Failed to compare items, hr %#x.\n", hr);
+ ok(result, "Unexpected result.\n");
+
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);
@@ -722,6 +733,12 @@ static void test_MFCreateAttributes(void)
ok(hr == S_OK, "Failed to delete items, hr %#x.\n", hr);
CHECK_ATTR_COUNT(attributes1, 0);
+ propvar.vt = MF_ATTRIBUTE_UINT64;
+ U(propvar).uhVal.QuadPart = 22;
+ hr = IMFAttributes_CompareItem(attributes, &GUID_NULL, &propvar, &result);
+ ok(hr == S_OK, "Failed to compare items, hr %#x.\n", hr);
+ ok(!result, "Unexpected result.\n");
+
hr = IMFAttributes_CopyAllItems(attributes1, attributes);
ok(hr == S_OK, "Failed to copy items, hr %#x.\n", hr);
CHECK_ATTR_COUNT(attributes, 0);
--
2.20.1
More information about the wine-devel
mailing list