uvcsink: use the pad's current caps to update caps_changed

The caps that were sent by the caps event can be retrieved from the sinkpad
using gst_pad_get_current_caps(). This is more reliable than using cur_caps as
we know exactly which caps upstream selected when the UVC host didn't select a
format, yet.

This further allows to simplify the check, if the uvcsink has to wait for the
caps event before switching to the internal v4l2sink.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4994>
This commit is contained in:
Michael Tretter 2023-08-10 16:40:41 +02:00 committed by GStreamer Marge Bot
parent 733b4d9597
commit c020dab393

View file

@ -611,8 +611,6 @@ gst_uvc_sink_task (gpointer data)
GstCaps *configured_caps;
GstCaps *prev_caps;
prev_caps = gst_caps_copy (self->cur_caps);
/* The configured caps are not sufficient for negotiation. Select caps
* from the probed caps that match the configured caps.
*/
@ -625,8 +623,12 @@ gst_uvc_sink_task (gpointer data)
self->cur_caps);
gst_caps_unref (configured_caps);
if (!gst_caps_is_equal (self->probed_caps, prev_caps))
self->caps_changed = !gst_caps_is_equal (self->cur_caps, prev_caps);
prev_caps = gst_pad_get_current_caps (self->sinkpad);
if (!gst_caps_is_subset (prev_caps, self->cur_caps)) {
self->caps_changed = TRUE;
GST_DEBUG_OBJECT (self,
"caps changed from %" GST_PTR_FORMAT, prev_caps);
}
gst_caps_unref (prev_caps);
}
break;