From 6de7c227ed2da671ee9a08af7c81084959af7ffb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 25 Nov 2020 17:43:39 -0600 Subject: [PATCH] qcap: Directly pass a VIDEOINFOHEADER pointer to the get_media_type() operation. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/qcap/qcap_private.h | 3 ++- dlls/qcap/v4l.c | 15 +++++++++++---- dlls/qcap/vfwcapture.c | 15 ++++++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/dlls/qcap/qcap_private.h b/dlls/qcap/qcap_private.h index 50bc2525f0e..379d9908637 100644 --- a/dlls/qcap/qcap_private.h +++ b/dlls/qcap/qcap_private.h @@ -47,7 +47,8 @@ struct video_capture_funcs HRESULT (*check_format)(struct video_capture_device *device, const AM_MEDIA_TYPE *mt); HRESULT (*set_format)(struct video_capture_device *device, const AM_MEDIA_TYPE *mt); void (*get_format)(struct video_capture_device *device, AM_MEDIA_TYPE *mt, VIDEOINFOHEADER *format); - HRESULT (*get_media_type)(struct video_capture_device *device, unsigned int index, AM_MEDIA_TYPE *mt); + HRESULT (*get_media_type)(struct video_capture_device *device, + unsigned int index, AM_MEDIA_TYPE *mt, VIDEOINFOHEADER *format); void (*get_caps)(struct video_capture_device *device, LONG index, AM_MEDIA_TYPE *mt, VIDEOINFOHEADER *format, VIDEO_STREAM_CONFIG_CAPS *caps); LONG (*get_caps_count)(struct video_capture_device *device); diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index dd002f7b3ea..b5a599eb0bc 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -216,7 +216,7 @@ static void v4l_device_get_format(struct video_capture_device *device, AM_MEDIA_ } static HRESULT v4l_device_get_media_type(struct video_capture_device *device, - unsigned int index, AM_MEDIA_TYPE *mt) + unsigned int index, AM_MEDIA_TYPE *mt, VIDEOINFOHEADER *format) { unsigned int caps_count = (device->current_caps) ? 1 : device->caps_count; @@ -224,9 +224,16 @@ static HRESULT v4l_device_get_media_type(struct video_capture_device *device, return VFW_S_NO_MORE_ITEMS; if (device->current_caps) - return CopyMediaType(mt, &device->current_caps->media_type); - - return CopyMediaType(mt, &device->caps[index].media_type); + { + *mt = device->current_caps->media_type; + *format = device->current_caps->video_info; + } + else + { + *mt = device->caps[index].media_type; + *format = device->caps[index].video_info; + } + return S_OK; } static __u32 v4l2_cid_from_qcap_property(VideoProcAmpProperty property) diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index e98e97b7816..8123dc4f6f7 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -658,7 +658,20 @@ static HRESULT source_get_media_type(struct strmbase_pin *pin, unsigned int index, AM_MEDIA_TYPE *mt) { struct vfw_capture *filter = impl_from_strmbase_pin(pin); - return capture_funcs->get_media_type(filter->device, index, mt); + VIDEOINFOHEADER *format; + HRESULT hr; + + if (!(format = CoTaskMemAlloc(sizeof(*format)))) + return E_OUTOFMEMORY; + + if ((hr = capture_funcs->get_media_type(filter->device, index, mt, format)) != S_OK) + { + CoTaskMemFree(format); + return hr; + } + mt->cbFormat = sizeof(VIDEOINFOHEADER); + mt->pbFormat = (BYTE *)format; + return S_OK; } static HRESULT source_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)