Jeff Smith : qcap/tests: Test effect of setting stream format on media type enumeration.

Alexandre Julliard julliard at winehq.org
Tue Sep 8 15:36:16 CDT 2020


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

Author: Jeff Smith <whydoubt at gmail.com>
Date:   Tue Sep  8 11:15:08 2020 -0500

qcap/tests: Test effect of setting stream format on media type enumeration.

Signed-off-by: Jeff Smith <whydoubt at gmail.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/qcap/tests/videocapture.c | 61 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 11 deletions(-)

diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c
index 326601a398..8bda036e1d 100644
--- a/dlls/qcap/tests/videocapture.c
+++ b/dlls/qcap/tests/videocapture.c
@@ -23,6 +23,12 @@
 #include "wine/test.h"
 #include "wine/strmbase.h"
 
+static BOOL compare_media_types(const AM_MEDIA_TYPE *a, const AM_MEDIA_TYPE *b)
+{
+    return !memcmp(a, b, offsetof(AM_MEDIA_TYPE, pbFormat))
+            && !memcmp(a->pbFormat, b->pbFormat, a->cbFormat);
+}
+
 #define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
 static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
 {
@@ -78,11 +84,11 @@ static void test_media_types(IPin *pin)
 static void test_stream_config(IPin *pin)
 {
     VIDEOINFOHEADER *video_info, *video_info2;
+    LONG depth, compression, count, size, i;
+    IEnumMediaTypes *enum_media_types;
     AM_MEDIA_TYPE *format, *format2;
-    VIDEO_STREAM_CONFIG_CAPS vscc;
     IAMStreamConfig *stream_config;
-    LONG depth, compression;
-    LONG count, size;
+    VIDEO_STREAM_CONFIG_CAPS vscc;
     HRESULT hr;
 
     hr = IPin_QueryInterface(pin, &IID_IAMStreamConfig, (void **)&stream_config);
@@ -96,6 +102,16 @@ static void test_stream_config(IPin *pin)
     hr = IAMStreamConfig_SetFormat(stream_config, format);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
+    /* After setting the format, a single media type is enumerated.
+     * This persists until the filter is released. */
+    IPin_EnumMediaTypes(pin, &enum_media_types);
+    hr = IEnumMediaTypes_Next(enum_media_types, 1, &format2, NULL);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    DeleteMediaType(format2);
+    hr = IEnumMediaTypes_Next(enum_media_types, 1, &format2, NULL);
+    todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+    IEnumMediaTypes_Release(enum_media_types);
+
     format->majortype = MEDIATYPE_Audio;
     hr = IAMStreamConfig_SetFormat(stream_config, format);
     ok(hr == E_FAIL, "Got hr %#x.\n", hr);
@@ -162,14 +178,37 @@ static void test_stream_config(IPin *pin)
     hr = IAMStreamConfig_GetStreamCaps(stream_config, 100000, &format, (BYTE *)&vscc);
     ok(hr == S_FALSE, "Got hr %#x.\n", hr);
 
-    hr = IAMStreamConfig_GetStreamCaps(stream_config, 0, &format, (BYTE *)&vscc);
-    ok(hr == S_OK, "Got hr %#x.\n", hr);
-    ok(IsEqualGUID(&format->majortype, &MEDIATYPE_Video), "Got wrong majortype: %s.\n",
-            debugstr_guid(&MEDIATYPE_Video));
-    ok(IsEqualGUID(&vscc.guid, &FORMAT_VideoInfo)
-            || IsEqualGUID(&vscc.guid, &FORMAT_VideoInfo2), "Got wrong guid: %s.\n",
-            debugstr_guid(&vscc.guid));
-    FreeMediaType(format);
+    for (i = 0; i < count; ++i)
+    {
+        hr = IAMStreamConfig_GetStreamCaps(stream_config, i, &format, (BYTE *)&vscc);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+        ok(IsEqualGUID(&format->majortype, &MEDIATYPE_Video), "Got wrong majortype: %s.\n",
+                debugstr_guid(&MEDIATYPE_Video));
+        ok(IsEqualGUID(&vscc.guid, &FORMAT_VideoInfo)
+                || IsEqualGUID(&vscc.guid, &FORMAT_VideoInfo2), "Got wrong guid: %s.\n",
+                debugstr_guid(&vscc.guid));
+
+        hr = IAMStreamConfig_SetFormat(stream_config, format);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+        hr = IAMStreamConfig_GetFormat(stream_config, &format2);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+        ok(compare_media_types(format, format2), "Media types didn't match.\n");
+        DeleteMediaType(format2);
+
+        hr = IPin_EnumMediaTypes(pin, &enum_media_types);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+        hr = IEnumMediaTypes_Next(enum_media_types, 1, &format2, NULL);
+        ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+        todo_wine_if (!compare_media_types(format, format2))
+            ok(compare_media_types(format, format2), "Media types didn't match.\n");
+
+        DeleteMediaType(format2);
+        IEnumMediaTypes_Release(enum_media_types);
+
+        DeleteMediaType(format);
+    }
 
     IAMStreamConfig_Release(stream_config);
 }




More information about the wine-cvs mailing list