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
This commit is contained in:
Nicolas Dufresne 2017-07-19 22:01:26 -04:00
parent 336c8a7dad
commit 558e9f4e57

View file

@ -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 */