flvmux: use the correct timestamp to calculate wait times
authorMichael Olbrich <m.olbrich@pengutronix.de>
Wed, 24 May 2023 14:17:46 +0000 (16:17 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Mon, 29 May 2023 23:52:01 +0000 (00:52 +0100)
commit9f169ffaf93c484c0a58a070439283523cae46bf
tree99b51731c0447a4f8eefd5ae9885211ece749de3
parentc83f24b0388ac3272167f2033008f979c0be8e27
flvmux: use the correct timestamp to calculate wait times

Since c0bf793c05cf793aa18a8548cda702625e388115 ("flvmux: Set PTS based on
running time") the timestamp of the output buffer is already in running
time. So using that for 'srcpad->segment.position' does not work correctly
because gst_aggregator_simple_get_next_time() will convert it again with
gst_segment_to_running_time().
This means that the timestamp returned by
gst_aggregator_simple_get_next_time() may be incorrect. For example, if
flvmux is added to a already runinng pipeline then the timestamp is too
small and gst_aggregator_wait_and_check() returns immediately. As a result,
buffers may be muxed in the wrong order.

To fix this, use the PTS of the incoming buffer instead of the outgoing
buffer. Also add the duration as get_next_time() is supposed to return the
timestamp of the next buffer, not the current one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4734>
subprojects/gst-plugins-good/gst/flv/gstflvmux.c