[PATCH v2 1/4] qcap/tests: Test effect of setting stream format on media type enumeration.
Jeff Smith
whydoubt at gmail.com
Mon Sep 7 14:13:11 CDT 2020
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
Supersedes 191583-191585
v2:
- Removed some tests that weren't providing much value
- Added calculation of image size when setting format
- Made use of VIDIOC_TRY_FMT ioctl
- Added get_media_type entry to video_capture_device_ops
dlls/qcap/tests/videocapture.c | 59 ++++++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 9 deletions(-)
diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c
index 326601a398..dcce3a7869 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)
{
@@ -81,8 +87,9 @@ static void test_stream_config(IPin *pin)
AM_MEDIA_TYPE *format, *format2;
VIDEO_STREAM_CONFIG_CAPS vscc;
IAMStreamConfig *stream_config;
+ IEnumMediaTypes *enum_media_types;
LONG depth, compression;
- LONG count, size;
+ LONG count, size, i;
HRESULT hr;
hr = IPin_QueryInterface(pin, &IID_IAMStreamConfig, (void **)&stream_config);
@@ -96,6 +103,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 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 +179,38 @@ 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);
+
+ /* Which media types will match varies in wine depending on the attached webcam */
+ todo_wine_if(compare_media_types(format, format2) == FALSE)
+ 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);
}
--
2.23.0
More information about the wine-devel
mailing list