GStreamer clocks and latency calculation

Bob Barker bobbarker278 at gmail.com
Fri Oct 4 12:41:41 PDT 2013


We’re new to GStreamer and are writing our own elements.  We’re trying to
understand which clocks are used for jitter calculation. From the GStreamer
documentation:

http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-qos.txt

“A buffer with timestamp B1 arrives in the sink at time T1. The buffer

timestamp is then synchronized against the clock which yields a jitter J1

return value from the clock. The jitter J1 is simply calculated as

  J1 = CT - B1

Where CT is the clock time when the entry arrives in the sink. This value

is calculated inside the clock when we perform gst_clock_entry_wait().



If the jitter is negative, the entry arrived in time and can be rendered

after waiting for the clock to reach time B1 (which is also CT - J1).



If the jitter is positive however, the entry arrived too late in the sink

and should therefore be dropped. J1 is the amount of time the entry was
late.”





We assume the clock is the monotonically increasing wall clock, not the
running time nor the stream time shown ins section  14.4 of the GStreamer
application development manual. From the documentation the running time
always starts at zero so the running time and stream time are always less
than the clock time.



In the GStreamer clocks diagram (and the real-world) the clock time is
always greater than stream time and the running time. Given that and the
equation above (  J1 = CT – B1) , jitter will always be positive. According
to GStreamer documentation “If the jitter is positive however, the entry
arrived too late in the sink and should therefore be dropped. “



Questions:

1.       So all buffers will always be late and should be dropped?!  What
are we missing?



2.       Which timestamp is the documentation referring to?    GStreamer
calls out one in the Linux version of  gstbuffer.h:“  GstClockTime
timestamp;” and  two in the windows version: pts and gts.



 * @pts: presentation timestamp of the buffer, can be #GST_CLOCK_TIME_NONE
when the

 *     pts is not known or relevant. The pts contains the timestamp when the

 *     media should be presented to the user.

 * @dts: decoding timestamp of the buffer, can be #GST_CLOCK_TIME_NONE when
the

 *     dts is not known or relevant. The dts contains the timestamp when the

 *     media should be processed

       GstClockTime           pts;

       GstClockTime           dts;



3.       Which of the three clocks (clocktime, running time, stream time)
are the pts and dts referring to?

4.       It seems the correct jitter formula is:



                     Jitter  = buffer_arrival_time - base_time –
buffer_time_stamp



                      Where buffer_arrival_time is read from the system
clock.



Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20131004/2a412bcf/attachment.html>


More information about the gstreamer-devel mailing list