v4l2src: Simplify format handling

Always initially use try_format(), delaying set_format() to when the
allocation is being negotiated. This avoid having two code paths, and
will be help adding support for properly importing buffers of specific
strides and offsets.

https://bugzilla.gnome.org/show_bug.cgi?id=583890
This commit is contained in:
Nicolas Dufresne 2018-07-09 15:33:02 -04:00
parent fd0afe033b
commit fe3a70fefd

View file

@ -446,33 +446,28 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps, GstStructure * pref_s)
fcaps = gst_caps_copy_nth (caps, i);
if (GST_V4L2_IS_ACTIVE (obj)) {
/* try hard to avoid TRY_FMT since some UVC camera just crash when this
* is called at run-time. */
if (gst_v4l2_object_caps_is_subset (obj, fcaps)) {
gst_caps_unref (fcaps);
fcaps = gst_v4l2_object_get_current_caps (obj);
break;
}
/* try hard to avoid TRY_FMT since some UVC camera just crash when this
* is called at run-time. */
if (gst_v4l2_object_caps_is_subset (obj, fcaps)) {
gst_caps_unref (fcaps);
fcaps = gst_v4l2_object_get_current_caps (obj);
break;
}
/* Just check if the format is acceptable, once we know
* no buffers should be outstanding we try S_FMT.
*
* Basesrc will do an allocation query that
* should indirectly reclaim buffers, after that we can
* set the format and then configure our pool */
if (gst_v4l2_object_try_format (obj, fcaps, &error)) {
/* make sure the caps changed before doing anything */
if (gst_v4l2_object_caps_equal (obj, fcaps))
break;
/* Just check if the format is acceptable, once we know
* no buffers should be outstanding we try S_FMT.
*
* Basesrc will do an allocation query that
* should indirectly reclaim buffers, after that we can
* set the format and then configure our pool */
if (gst_v4l2_object_try_format (obj, fcaps, &error)) {
/* make sure the caps changed before doing anything */
if (gst_v4l2_object_caps_equal (obj, fcaps))
break;
v4l2src->renegotiation_adjust = v4l2src->offset + 1;
v4l2src->pending_set_fmt = TRUE;
break;
}
} else {
if (gst_v4l2src_set_format (v4l2src, fcaps, &error))
break;
v4l2src->renegotiation_adjust = v4l2src->offset + 1;
v4l2src->pending_set_fmt = TRUE;
break;
}
/* Only EIVAL make sense, report any other errors, this way we don't keep