Commit 1c1e7fa0 authored by Jakub Adam's avatar Jakub Adam Committed by David King

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.
parent 58de82b3
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment