Jactry Zeng : mfplat: Implement CompareItem() for attributes.

Alexandre Julliard julliard at winehq.org
Fri Mar 15 15:20:01 CDT 2019


Module: wine
Branch: master
Commit: c9027a8d03fda1beaa34f75cd130f46b848db2d9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c9027a8d03fda1beaa34f75cd130f46b848db2d9

Author: Jactry Zeng <jzeng at codeweavers.com>
Date:   Fri Mar 15 13:56:49 2019 +0300

mfplat: Implement CompareItem() for attributes.

Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 2ef4077..88945f6 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 edf3c6e..38151d9 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);




More information about the wine-cvs mailing list