From 7edaeb3fae66450759c293e411b630c6fbdfd0ba Mon Sep 17 00:00:00 2001 From: Ederson de Souza Date: Fri, 3 Apr 2020 10:41:04 -0700 Subject: [PATCH] avtpcvfpay: Warn about timestamp issues on non-flushing seek Seek events will cause new segments to be sent to avtpcvfpay, and for flushing seeks, a pipeline running time reset. This running time reset, which effectively changes pipeline base time, will cause avtpcvfpay element to generate incorrect DTS for the initial set of buffers sent after FLUSH_STOP. This happens due the fact that base time change happens only when the sink gets the first buffer after the FLUSH_STOP - so avtpcvfpay used the wrong base time to do its calculations. However, if the pipeline is paused before the seek, sink will update base time when pipeline state goes to PLAYING again, before avtpcvfpay gets the first buffers after the flush. Then avtpcvfpay element will be able to normally calculate DTS for the outgoing packets. This patch simply adds a warning message in case a flushing seek is performed on a playing pipeline. Part-of: --- ext/avtp/gstavtpcvfpay.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ext/avtp/gstavtpcvfpay.c b/ext/avtp/gstavtpcvfpay.c index 4137bb3c5c..76b46121b5 100644 --- a/ext/avtp/gstavtpcvfpay.c +++ b/ext/avtp/gstavtpcvfpay.c @@ -744,6 +744,20 @@ gst_avtp_cvf_pay_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) ret = gst_avtp_cvf_pay_new_caps (avtpcvfpay, caps); gst_event_unref (event); return ret; + case GST_EVENT_FLUSH_STOP: + if (GST_ELEMENT (avtpcvfpay)->current_state == GST_STATE_PLAYING) { + /* After a flush, the sink will reset pipeline base_time, but only + * after it gets the first buffer. So, here, we used the wrong + * base_time to calculate DTS. We'll just notice base_time changed + * when we get the next buffer. So, we'll basically mess with + * timestamps of two frames, which is bad. Known workaround is + * to pause the pipeline before a flushing seek - so that we'll + * be up to date to new pipeline base_time */ + GST_WARNING_OBJECT (avtpcvfpay, + "Flushing seek performed while pipeline is PLAYING, " + "AVTP timestamps will be incorrect!"); + } + break; default: break; }