diff options
author | Jakub Adam <jakub.adam@collabora.com> | 2019-09-03 16:57:00 +0200 |
---|---|---|
committer | David King <amigadave@amigadave.com> | 2020-09-21 10:02:02 +0100 |
commit | 1c1e7fa0c4608331fd89683ccb342ed3518acccc (patch) | |
tree | c47a37ce8b9919376ba63a2e821b4773403c1a0e | |
parent | 58de82b3d463b69f4c0bef75667e47020924e28b (diff) | |
download | cheese-1c1e7fa0c4608331fd89683ccb342ed3518acccc.tar.gz |
Preserve video/x-raw over image/jpeg
gst_caps_simplify() doesn't preserve the original order of caps, so when
called on the full set of caps, collected from all supported_formats, it
may end up preferring image/jpeg caps even when video/x-raw with
identical resolution and framerate is available.
Simplify the caps coming from each of supported_formats separately, so
that video/x-raw always comes first in the result GstCaps.
We prefer raw camera output whenever possible in order to avoid decoding
MJPEG.
-rw-r--r-- | libcheese/cheese-camera-device.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c index 34b846a5..efcb0459 100644 --- a/libcheese/cheese-camera-device.c +++ b/libcheese/cheese-camera-device.c @@ -893,10 +893,9 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device, CheeseVideoFormat *format) { CheeseCameraDevicePrivate *priv; - CheeseVideoFormatFull *full_format; - GstCaps *desired_caps; - GstCaps *subset_caps; - gsize i; + CheeseVideoFormatFull *full_format; + GstCaps *result_caps; + gsize i; g_return_val_if_fail (CHEESE_IS_CAMERA_DEVICE (device), NULL); @@ -913,21 +912,26 @@ cheese_camera_device_get_caps_for_format (CheeseCameraDevice *device, full_format->width, full_format->height, full_format->fr_numerator, full_format->fr_denominator); - desired_caps = gst_caps_new_empty (); + priv = cheese_camera_device_get_instance_private (device); - for (i = 0; supported_formats[i] != NULL; i++) - { - gst_caps_append (desired_caps, - cheese_camera_device_format_to_caps (supported_formats[i], - full_format)); - } + result_caps = gst_caps_new_empty (); - priv = cheese_camera_device_get_instance_private (device); - subset_caps = gst_caps_intersect (desired_caps, priv->caps); - subset_caps = gst_caps_simplify (subset_caps); - gst_caps_unref (desired_caps); + for (i = 0; supported_formats[i] != NULL; i++) + { + GstCaps *desired_caps; + GstCaps *subset_caps; + + desired_caps = cheese_camera_device_format_to_caps (supported_formats[i], + full_format); + subset_caps = gst_caps_intersect (desired_caps, priv->caps); + subset_caps = gst_caps_simplify (subset_caps); + + gst_caps_append (result_caps, subset_caps); + + gst_caps_unref (desired_caps); + } - GST_INFO ("Got %" GST_PTR_FORMAT, subset_caps); + GST_INFO ("Got %" GST_PTR_FORMAT, result_caps); - return subset_caps; + return result_caps; } |