aggregator: fix start time selection first with force-live

When force-live is true, we don't want to wait for a first buffer
to select a start time.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1783

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7778>
This commit is contained in:
Mathieu Duponchelle 2024-10-25 19:12:17 +02:00 committed by GStreamer Marge Bot
parent 8c8cffe080
commit 3efd5a358e

View file

@ -866,6 +866,25 @@ gst_aggregator_wait_and_check (GstAggregator * self, gboolean * timeout)
return FALSE;
}
if (self->priv->force_live && self->priv->first_buffer
&& self->priv->start_time_selection ==
GST_AGGREGATOR_START_TIME_SELECTION_FIRST) {
GstClockTime start_time;
GstAggregatorPad *srcpad = GST_AGGREGATOR_PAD (self->srcpad);
start_time = gst_element_get_current_running_time (GST_ELEMENT (self));
if (GST_CLOCK_TIME_IS_VALID (start_time)) {
if (srcpad->segment.position == -1)
srcpad->segment.position = start_time;
else
srcpad->segment.position = MIN (start_time, srcpad->segment.position);
GST_DEBUG_OBJECT (self, "Selecting start time %" GST_TIME_FORMAT,
GST_TIME_ARGS (start_time));
self->priv->first_buffer = FALSE;
}
}
start = gst_aggregator_get_next_time (self);
/* If we're not live, or if we use the running time