uvcsink: set cur_caps to upstream selected caps

If the UVC gadget announces multiple formats in the descriptors the uvcsink
doesn't select the actual format but let's the UVC hosts select the format.

If the GStreamer pipeline is started before a UVC host selected the format,
upstream decides on a format until the UVC host has decided. In this case, the
current format needs to be set based on the caps from the caps event to be able
to detect if the format selection by the UVC host requires a format change on
the GStreamer pipeline.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7473>
This commit is contained in:
Michael Tretter 2023-07-18 17:34:54 +02:00 committed by GStreamer Marge Bot
parent f82a716009
commit 76d753f1c5

View file

@ -248,6 +248,22 @@ gst_uvc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
case GST_EVENT_CAPS: case GST_EVENT_CAPS:
GST_DEBUG_OBJECT (self, "Handling %" GST_PTR_FORMAT, event); GST_DEBUG_OBJECT (self, "Handling %" GST_PTR_FORMAT, event);
/* If the UVC host did not yet commit a format, the cur_caps may contain
* all probed caps. In this case, the element is not able to detect, if
* the caps have changed when the stream is enabled. Take the caps from
* upstream to be able to detect a change.
*/
if (!GST_CAPS_IS_SIMPLE (self->cur_caps)) {
GstCaps *caps;
gst_event_parse_caps (event, &caps);
gst_caps_replace (&self->cur_caps, caps);
GST_DEBUG_OBJECT (self,
"UVC host didn't select a format, yet. Using upstream %"
GST_PTR_FORMAT, self->cur_caps);
}
/* EVENT CAPS signals that the buffers after the event will use new caps. /* EVENT CAPS signals that the buffers after the event will use new caps.
* If the UVC host requested a new format, we now must start the stream. * If the UVC host requested a new format, we now must start the stream.
*/ */