From 09625552917c15c2828128afda7850ab3cd2b067 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 14 Apr 2023 10:42:01 +0200 Subject: [PATCH] gst: implement renegotiation If the stream format changes, set the basesrc caps again before pushing a new buffer. See #3147 --- src/gst/gstpipewiresrc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index 892162aed..5191b079f 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -1134,6 +1134,7 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer) const char *error = NULL; GstBuffer *buf; gboolean update_time = FALSE, timeout = FALSE; + GstCaps *caps = NULL; pwsrc = GST_PIPEWIRE_SRC (psrc); @@ -1157,6 +1158,18 @@ gst_pipewire_src_create (GstPushSrc * psrc, GstBuffer ** buffer) if (state != PW_STREAM_STATE_STREAMING) goto streaming_stopped; + if ((caps = pwsrc->caps) != NULL) { + pwsrc->caps = NULL; + pw_thread_loop_unlock (pwsrc->core->loop); + + GST_DEBUG_OBJECT (pwsrc, "set format %" GST_PTR_FORMAT, caps); + gst_base_src_set_caps (GST_BASE_SRC (pwsrc), caps); + gst_caps_unref (caps); + + pw_thread_loop_lock (pwsrc->core->loop); + continue; + } + if (pwsrc->eos) { if (pwsrc->last_buffer == NULL) goto streaming_eos;