flvmux: Don't time out in live mode if no timestamped next buffer is available

But also don't wait for a buffer on both pads, which might take forever in case
of gaps in one of the streams.

The muxer can only advance the time if it has a timestamped buffer that can be
output, otherwise it will just busy-wait and use up a lot of CPU.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7871>
This commit is contained in:
Sebastian Dröge 2024-11-12 11:25:38 +02:00 committed by GStreamer Marge Bot
parent d0543444d8
commit 969b51acb6

View file

@ -2223,21 +2223,20 @@ static GstClockTime
gst_flv_mux_get_next_time (GstAggregator * aggregator) gst_flv_mux_get_next_time (GstAggregator * aggregator)
{ {
GstFlvMux *mux = GST_FLV_MUX (aggregator); GstFlvMux *mux = GST_FLV_MUX (aggregator);
GstAggregatorPad *agg_audio_pad = GST_AGGREGATOR_PAD_CAST (mux->audio_pad); GstFlvMuxPad *best = NULL;
GstAggregatorPad *agg_video_pad = GST_AGGREGATOR_PAD_CAST (mux->video_pad); GstClockTime best_time = GST_CLOCK_TIME_NONE;
GST_OBJECT_LOCK (aggregator); GST_OBJECT_LOCK (aggregator);
if (mux->state == GST_FLV_MUX_STATE_HEADER && if (mux->state == GST_FLV_MUX_STATE_HEADER &&
((mux->audio_pad && mux->audio_pad->codec == G_MAXUINT) || ((mux->audio_pad && mux->audio_pad->codec == G_MAXUINT) ||
(mux->video_pad && mux->video_pad->codec == G_MAXUINT))) (mux->video_pad && mux->video_pad->codec == G_MAXUINT)))
goto wait_for_data; goto wait_for_data;
if (!((agg_audio_pad && gst_aggregator_pad_has_buffer (agg_audio_pad)) ||
(agg_video_pad && gst_aggregator_pad_has_buffer (agg_video_pad))))
goto wait_for_data;
GST_OBJECT_UNLOCK (aggregator); GST_OBJECT_UNLOCK (aggregator);
return gst_aggregator_simple_get_next_time (aggregator); best = gst_flv_mux_find_best_pad (aggregator, &best_time, TRUE);
gst_clear_object (&best);
return best_time;
wait_for_data: wait_for_data:
GST_OBJECT_UNLOCK (aggregator); GST_OBJECT_UNLOCK (aggregator);