From b8a316275c86a3f2d83ea47aba32f83003ffda43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 11 Sep 2024 08:28:39 +0300 Subject: [PATCH] splitmuxsink: Override LATENCY query to pretend to downstream that we're not live splitmuxsink can't possibly know how much latency it will introduce as it always keeps one GOP around before outputting something. This breaks the latency configuration of the pipeline and we're better off just pretending that everything downstream of the sinkpads is not live. Especially muxers that are based on aggregator and time out on the latency deadline can easily misbehave otherwise as the deadline will be exceeded usually. Part-of: --- .../gst/multifile/gstsplitmuxsink.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxsink.c b/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxsink.c index b08347e863..4e6181a6ce 100644 --- a/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxsink.c +++ b/subprojects/gst-plugins-good/gst/multifile/gstsplitmuxsink.c @@ -2902,6 +2902,25 @@ handle_mq_input (GstPad * pad, GstPadProbeInfo * info, MqStreamCtx * ctx) default: return GST_PAD_PROBE_PASS; } + } else if (info->type & GST_PAD_PROBE_TYPE_QUERY_UPSTREAM) { + switch (GST_QUERY_TYPE (GST_QUERY (info->data))) { + case GST_QUERY_LATENCY: + // Override the latency query to pretend that everything downstream + // of the sink pads is actually not live. splitmuxsink doesn't know + // how much latency it will possibly introduce. + if (info->type & GST_PAD_PROBE_TYPE_PUSH) { + GST_DEBUG_OBJECT (pad, + "Overriding latency query to pretend we're not live"); + gst_query_set_latency (info->data, FALSE, 0, GST_CLOCK_TIME_NONE); + return GST_PAD_PROBE_HANDLED; + } else { + // Should not happen as we already handled it above. + g_warn_if_reached (); + return GST_PAD_PROBE_PASS; + } + default: + return GST_PAD_PROBE_PASS; + } } buf = gst_pad_probe_info_get_buffer (info); @@ -3559,7 +3578,7 @@ gst_splitmux_sink_request_new_pad (GstElement * element, ctx->sink_pad_block_id = gst_pad_add_probe (q_sink, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH | - GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM, + GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_QUERY_UPSTREAM, (GstPadProbeCallback) handle_mq_input, ctx, NULL); GST_DEBUG_OBJECT (splitmux, "splitmuxsink pad %" GST_PTR_FORMAT