[PATCH v2 4/6] qcap/videocapture: Implement IAMStreamConfig_GetNumberOfCapabilities().

Jactry Zeng jzeng at codeweavers.com
Tue Apr 28 09:12:57 CDT 2020


Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
 dlls/qcap/capture.h            |  1 +
 dlls/qcap/tests/videocapture.c | 18 ++++++++++++++++++
 dlls/qcap/v4l.c                | 11 +++++++++++
 dlls/qcap/vfwcapture.c         | 19 +++++++++++++------
 4 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/dlls/qcap/capture.h b/dlls/qcap/capture.h
index fa48324dd6..e34c33fb0f 100644
--- a/dlls/qcap/capture.h
+++ b/dlls/qcap/capture.h
@@ -27,6 +27,7 @@ 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;
+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;
 HRESULT qcap_driver_get_prop(Capture*,VideoProcAmpProperty,LONG*,LONG*) DECLSPEC_HIDDEN;
diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c
index 39535adece..ab9e19b461 100644
--- a/dlls/qcap/tests/videocapture.c
+++ b/dlls/qcap/tests/videocapture.c
@@ -66,6 +66,7 @@ static void test_stream_config(IPin *pin)
     AM_MEDIA_TYPE *format, *format2;
     IAMStreamConfig *stream_config;
     LONG depth, compression;
+    LONG count, size;
     HRESULT hr;
 
     hr = IPin_QueryInterface(pin, &IID_IAMStreamConfig, (void **)&stream_config);
@@ -116,6 +117,23 @@ static void test_stream_config(IPin *pin)
     ok(hr == E_FAIL, "Got hr %#x.\n", hr);
     FreeMediaType(format);
 
+    count = 0xdeadbeef;
+    size = 0xdeadbeef;
+    /* Crash on Windows */
+    if (0)
+    {
+        hr = IAMStreamConfig_GetNumberOfCapabilities(stream_config, &count, NULL);
+        ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+        hr = IAMStreamConfig_GetNumberOfCapabilities(stream_config, NULL, &size);
+        ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+    }
+
+    hr = IAMStreamConfig_GetNumberOfCapabilities(stream_config, &count, &size);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(count != 0xdeadbeef, "Got wrong count: %d.\n", count);
+    ok(size == sizeof(VIDEO_STREAM_CONFIG_CAPS), "Got wrong size: %d.\n", size);
+
     IAMStreamConfig_Release(stream_config);
 }
 
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c
index b065478d3a..33e05dd545 100644
--- a/dlls/qcap/v4l.c
+++ b/dlls/qcap/v4l.c
@@ -625,6 +625,11 @@ error:
     return NULL;
 }
 
+LONG qcap_driver_get_caps_count(Capture *device)
+{
+    return device->caps_count;
+}
+
 #else
 
 Capture *qcap_driver_init(struct strmbase_source *pin, USHORT card)
@@ -699,4 +704,10 @@ void qcap_driver_cleanup_stream(Capture *device)
     ERR("v4l absent: shouldn't be called\n");
 }
 
+LONG qcap_driver_get_caps_count(Capture *device)
+{
+    ERR("v4l absent: shouldn't be called\n");
+    return 0;
+}
+
 #endif /* defined(VIDIOCMCAPTURE) */
diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c
index 6c9cc3ce51..652b213ccc 100644
--- a/dlls/qcap/vfwcapture.c
+++ b/dlls/qcap/vfwcapture.c
@@ -167,7 +167,7 @@ static const struct strmbase_filter_ops filter_ops =
     .filter_cleanup_stream = vfw_capture_cleanup_stream,
 };
 
-/* AMStreamConfig interface, we only need to implement {G,S}etFormat */
+/* AMStreamConfig interface */
 static HRESULT WINAPI AMStreamConfig_QueryInterface(IAMStreamConfig *iface, REFIID iid, void **out)
 {
     VfwCapture *filter = impl_from_IAMStreamConfig(iface);
@@ -243,12 +243,19 @@ AMStreamConfig_GetFormat( IAMStreamConfig *iface, AM_MEDIA_TYPE **pmt )
 }
 
 static HRESULT WINAPI
-AMStreamConfig_GetNumberOfCapabilities( IAMStreamConfig *iface, int *piCount,
-                                        int *piSize )
+AMStreamConfig_GetNumberOfCapabilities(IAMStreamConfig *iface, int *count, int *size)
 {
-    FIXME("%p: %p %p - stub, intentional\n", iface, piCount, piSize);
-    *piCount = 0;
-    return E_NOTIMPL; /* Not implemented for this interface */
+    VfwCapture *This = impl_from_IAMStreamConfig(iface);
+
+    TRACE("(%p, %p, %p).\n", iface, count, size);
+
+    if (!count || !size)
+        return E_POINTER;
+
+    *count = qcap_driver_get_caps_count(This->driver_info);
+    *size = sizeof(VIDEO_STREAM_CONFIG_CAPS);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI
-- 
2.26.2




More information about the wine-devel mailing list