From c020dab393e3fa8667723b3ebd009fed0a44097c Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Thu, 10 Aug 2023 16:40:41 +0200 Subject: [PATCH] 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: --- subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c b/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c index fbbdc75c88..6c1602acc1 100644 --- a/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c +++ b/subprojects/gst-plugins-bad/sys/uvcgadget/gstuvcsink.c @@ -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;