After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763630 - appsrc: If do-timestamp=true should take the timestamp when queueing the buffer
appsrc: If do-timestamp=true should take the timestamp when queueing the buffer
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 1.9.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-14 17:32 UTC by Sebastian Dröge (slomo)
Modified: 2016-07-01 12:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
appsrc: If do-timestamp=TRUE, capture the time when the buffer was pushed to the source (1.64 KB, patch)
2016-03-16 22:21 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2016-03-14 17:32:33 UTC
Otherwise the timestamping will happen once the buffer is taken out of the queue by basesrc. Which might be later and also depends on how fast downstream consumes buffers.
Comment 1 Tim-Philipp Müller 2016-03-14 18:40:22 UTC
Agreed (I thought we fixed that ages ago..)
Comment 2 Sebastian Dröge (slomo) 2016-03-16 22:21:51 UTC
Created attachment 324147 [details] [review]
appsrc: If do-timestamp=TRUE, capture the time when the buffer was pushed to the source

... instead of the time when it was pushed further downstream.
Comment 3 Sebastian Dröge (slomo) 2016-03-16 22:23:20 UTC
This has the main problem that a buffer might be pushed to the source when it is not PLAYING yet (-> no clock). In that case, basesrc will timestamp the buffer just before pushing. But future buffers that are pushed to appsrc by the application might be timestamp by appsrc before basesrc timestamps the previous buffer, causing timestamps to be misordered.
Comment 4 Nicolas Dufresne (ndufresne) 2016-03-17 00:13:12 UTC
Review of attachment 324147 [details] [review]:

::: gst-libs/gst/app/gstappsrc.c
@@ +1620,3 @@
+  if (GST_BUFFER_DTS (buffer) == GST_CLOCK_TIME_NONE &&
+      GST_BUFFER_PTS (buffer) == GST_CLOCK_TIME_NONE &&
+      gst_base_src_get_do_timestamp (GST_BASE_SRC_CAST (appsrc))) {

That makes do-timestamp conditional to not having timestamp on the buffers, is this consistent with other do-timestamp implementation ?
Comment 5 Nicolas Dufresne (ndufresne) 2016-03-17 00:14:34 UTC
I also wonder if the behaviour should not vary depending if we are live or not. Being media agnostic does not help of course.
Comment 6 Sebastian Dröge (slomo) 2016-03-17 07:40:03 UTC
(In reply to Nicolas Dufresne (stormer) from comment #4)
> Review of attachment 324147 [details] [review] [review]:
> 
> ::: gst-libs/gst/app/gstappsrc.c
> @@ +1620,3 @@
> +  if (GST_BUFFER_DTS (buffer) == GST_CLOCK_TIME_NONE &&
> +      GST_BUFFER_PTS (buffer) == GST_CLOCK_TIME_NONE &&
> +      gst_base_src_get_do_timestamp (GST_BASE_SRC_CAST (appsrc))) {
> 
> That makes do-timestamp conditional to not having timestamp on the buffers,
> is this consistent with other do-timestamp implementation ?

https://cgit.freedesktop.org/gstreamer/gstreamer/tree/libs/gst/base/gstbasesrc.c#n2243
Comment 7 Sebastian Dröge (slomo) 2016-03-25 10:53:22 UTC
Any other comments, ideas?
Comment 8 Nicolas Dufresne (ndufresne) 2016-03-25 12:58:36 UTC
Ok then, as it was like this before.
Comment 9 Sebastian Dröge (slomo) 2016-03-25 14:10:47 UTC
I was mostkyy wondering about what I wrote in comment 3 :)
Comment 10 Tim-Philipp Müller 2016-03-26 14:01:35 UTC
Maybe we should only do this if the appsrc is configured to be live, and also warn if someone asks us to timestamp without having configured the source to be live (is there a good use case for that?)
Comment 11 Sebastian Dröge (slomo) 2016-03-26 18:17:49 UTC
Even if the source is live, nothing is preventing the application from providing buffers before the pipeline is actually PLAYING.
Comment 12 Tim-Philipp Müller 2016-03-26 18:44:28 UTC
That is true, but would be a bug in the application imho :)
Comment 13 Tim-Philipp Müller 2016-03-26 18:45:21 UTC
(Meaning: we can warn, and then do the timestamp when outputting as now)
Comment 14 Sebastian Dröge (slomo) 2016-03-27 08:51:07 UTC
That sounds like an acceptable approach, yes. I don't think there's any point in do-timestamp on non-live streams and I would even consider a warning about that inside basesrc. What do you think?
Comment 15 Olivier Crête 2016-03-29 23:50:27 UTC
Can't we just put "0" or GST_CLOCK_TIME_NONE on buffers that are pushed before starting? It could be used to push headers or maybe the first "not really preroll" frame.
Comment 16 Sebastian Dröge (slomo) 2016-03-30 12:35:48 UTC
NONE would make it use the basesrc timestamping mechanism, which leads to the problem mentioned above (newer buffer gets timestamped by appsrc, older buffer gets timestamped by basesrc => newer < older).

0 could lead to big gaps. Running time does not start at 0 always.


I think I prefer using NONE and warn about it.
Comment 17 Olivier Crête 2016-04-04 09:15:31 UTC
Override the property, keep the value, gst_base_src_set_do_timestamp(FALSE), then the base class won't bother you. 

You should also do like GstBaseSrc and overwrite timestamps even if they are not NONE, no?

And it always starts at 0 as you're timestamping with the running time.
Comment 18 Sebastian Dröge (slomo) 2016-04-04 09:35:28 UTC
(In reply to Olivier Crête from comment #17)
> Override the property, keep the value, gst_base_src_set_do_timestamp(FALSE),
> then the base class won't bother you. 

But then we would push the first buffers possibly without any timestamp. Generally our code is very unhappy about first buffers having no timestamp

> You should also do like GstBaseSrc and overwrite timestamps even if they are
> not NONE, no?

Yes

> And it always starts at 0 as you're timestamping with the running time.

Not really, e.g. consider the case of the source being added to an already running pipeline or manual managing of the base time
Comment 19 Sebastian Dröge (slomo) 2016-07-01 12:32:59 UTC
Attachment 324147 [details] pushed as 1032f5c - appsrc: If do-timestamp=TRUE, capture the time when the buffer was pushed to the source
Comment 20 Sebastian Dröge (slomo) 2016-07-01 12:34:02 UTC
Pushed with the warning, as that seemed to be the result of the above discussion and all alternatives would have fundamental problems.