Commit 558e9f4e authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2object: Validate colorimetry in S/TRY_FMT

This is in preparation for removing slow TRY_FMT probes for
colorimetry. As we won't have tried that colorimetry we cannot
assume the driver will accept it.

https://bugzilla.gnome.org/show_bug.cgi?id=785156
parent 336c8a7d
......@@ -3408,6 +3408,14 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|| format.fmt.pix.field != field)
goto invalid_field;
gst_v4l2_object_get_colorspace (&format, &info.colorimetry);
s = gst_caps_get_structure (caps, 0);
if (gst_structure_has_field (s, "colorimetry") &&
!gst_video_colorimetry_matches (&info.colorimetry,
gst_structure_get_string (s, "colorimetry")))
goto invalid_colorimetry;
if (try_only) /* good enough for trying only */
return TRUE;
......@@ -3622,6 +3630,20 @@ invalid_field:
wanted_field == V4L2_FIELD_NONE ? "progressive" : "interleaved"));
return FALSE;
}
invalid_colorimetry:
{
gchar *wanted_colorimetry;
wanted_colorimetry = gst_video_colorimetry_to_string (&info.colorimetry);
GST_V4L2_ERROR (error, RESOURCE, SETTINGS,
(_("Device '%s' does not support %s colorimetry"),
v4l2object->videodev, gst_structure_get_string (s, "colorimetry")),
("Device wants %s colorimetry", wanted_colorimetry));
g_free (wanted_colorimetry);
return FALSE;
}
get_parm_failed:
{
/* it's possible that this call is not supported */
......
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