From c8b1b993adf992d71c0a88e8908c6ad1dd81a70d Mon Sep 17 00:00:00 2001 From: Jactry Zeng Date: Tue, 28 Apr 2020 11:55:20 -0500 Subject: [PATCH] qcap/videocapture: Implement IAMStreamConfig::GetStreamCaps(). Signed-off-by: Jactry Zeng Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qcap/capture.h | 2 ++ dlls/qcap/tests/videocapture.c | 22 ++++++++++++++++++++++ dlls/qcap/v4l.c | 21 +++++++++++++++++++++ dlls/qcap/vfwcapture.c | 12 +++++++----- 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/dlls/qcap/capture.h b/dlls/qcap/capture.h index e34c33fb0f1..615988bda37 100644 --- a/dlls/qcap/capture.h +++ b/dlls/qcap/capture.h @@ -27,6 +27,8 @@ Capture *qcap_driver_init(struct strmbase_source *,USHORT) DECLSPEC_HIDDEN; HRESULT qcap_driver_destroy(Capture*) DECLSPEC_HIDDEN; HRESULT qcap_driver_check_format(Capture*,const AM_MEDIA_TYPE*) DECLSPEC_HIDDEN; HRESULT qcap_driver_set_format(Capture*,AM_MEDIA_TYPE*) DECLSPEC_HIDDEN; +HRESULT qcap_driver_get_caps(Capture *device, LONG index, AM_MEDIA_TYPE **pmt, + VIDEO_STREAM_CONFIG_CAPS *vscc) DECLSPEC_HIDDEN; LONG qcap_driver_get_caps_count(Capture *device) DECLSPEC_HIDDEN; HRESULT qcap_driver_get_format(const Capture*,AM_MEDIA_TYPE**) DECLSPEC_HIDDEN; HRESULT qcap_driver_get_prop_range(Capture*,VideoProcAmpProperty,LONG*,LONG*,LONG*,LONG*,LONG*) DECLSPEC_HIDDEN; diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c index ab9e19b4615..448136791b4 100644 --- a/dlls/qcap/tests/videocapture.c +++ b/dlls/qcap/tests/videocapture.c @@ -64,6 +64,7 @@ static void test_stream_config(IPin *pin) { VIDEOINFOHEADER *video_info, *video_info2; AM_MEDIA_TYPE *format, *format2; + VIDEO_STREAM_CONFIG_CAPS vscc; IAMStreamConfig *stream_config; LONG depth, compression; LONG count, size; @@ -127,6 +128,12 @@ static void test_stream_config(IPin *pin) hr = IAMStreamConfig_GetNumberOfCapabilities(stream_config, NULL, &size); ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IAMStreamConfig_GetStreamCaps(stream_config, 0, NULL, (BYTE *)&vscc); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IAMStreamConfig_GetStreamCaps(stream_config, 0, &format, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); } hr = IAMStreamConfig_GetNumberOfCapabilities(stream_config, &count, &size); @@ -134,6 +141,21 @@ static void test_stream_config(IPin *pin) ok(count != 0xdeadbeef, "Got wrong count: %d.\n", count); ok(size == sizeof(VIDEO_STREAM_CONFIG_CAPS), "Got wrong size: %d.\n", size); + hr = IAMStreamConfig_GetStreamCaps(stream_config, 100000, NULL, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + 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); + IAMStreamConfig_Release(stream_config); } diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 112c57e89b2..afc9bf2c931 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -624,6 +624,21 @@ error: return NULL; } +HRESULT qcap_driver_get_caps(Capture *device, LONG index, AM_MEDIA_TYPE **type, + VIDEO_STREAM_CONFIG_CAPS *vscc) +{ + if (index >= device->caps_count) + return S_FALSE; + + *type = CreateMediaType(&device->caps[index].media_type); + if (!*type) + return E_OUTOFMEMORY; + + if (vscc) + memcpy(vscc, &device->caps[index].config, sizeof(VIDEO_STREAM_CONFIG_CAPS)); + return S_OK; +} + LONG qcap_driver_get_caps_count(Capture *device) { return device->caps_count; @@ -703,6 +718,12 @@ void qcap_driver_cleanup_stream(Capture *device) ERR("v4l absent: shouldn't be called\n"); } +HRESULT qcap_driver_get_caps(Capture *device, LONG index, AM_MEDIA_TYPE **type, + VIDEO_STREAM_CONFIG_CAPS *vscc) +{ + FAIL_WITH_ERR; +} + LONG qcap_driver_get_caps_count(Capture *device) { ERR("v4l absent: shouldn't be called\n"); diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index 8fb0c0d7bdf..71ca4502b90 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -257,12 +257,14 @@ static HRESULT WINAPI AMStreamConfig_GetNumberOfCapabilities(IAMStreamConfig *if return S_OK; } -static HRESULT WINAPI -AMStreamConfig_GetStreamCaps( IAMStreamConfig *iface, int iIndex, - AM_MEDIA_TYPE **pmt, BYTE *pSCC ) +static HRESULT WINAPI AMStreamConfig_GetStreamCaps(IAMStreamConfig *iface, + int index, AM_MEDIA_TYPE **pmt, BYTE *vscc) { - FIXME("%p: %d %p %p - stub, intentional\n", iface, iIndex, pmt, pSCC); - return E_NOTIMPL; /* Not implemented for this interface */ + VfwCapture *filter = impl_from_IAMStreamConfig(iface); + + TRACE("filter %p, index %d, pmt %p, vscc %p.\n", filter, index, pmt, vscc); + + return qcap_driver_get_caps(filter->driver_info, index, pmt, (VIDEO_STREAM_CONFIG_CAPS *)vscc); } static const IAMStreamConfigVtbl IAMStreamConfig_VTable =