<div dir="ltr"><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font face="Calibri"><font size="3"><font color="#000000">We’re new to GStreamer and are writing our own
elements.<span> </span>We’re trying to understand
which clocks are used for jitter calculation. From the GStreamer documentation:</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><a href="http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-qos.txt"><span style="color:windowtext;text-decoration:none"><font size="3" face="Calibri">http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-qos.txt</font></span></a></p>
<font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font size="3"><font color="#000000"><font face="Calibri">“A buffer with timestamp B1 arrives in the sink at time T1.
The buffer</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font size="3"><font color="#000000"><font face="Calibri">timestamp is then synchronized against the clock which
yields a jitter J1</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font size="3"><font color="#000000"><font face="Calibri">return value from the clock. The jitter J1 is simply
calculated as</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>J1 = CT - B1</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">Where
CT is the clock time when the entry arrives in the sink. This value</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">is
calculated inside the clock when we perform gst_clock_entry_wait().</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">If
the jitter is negative, the entry arrived in time and can be rendered</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">after
waiting for the clock to reach time B1 (which is also CT - J1).</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">If
the jitter is positive however, the entry arrived too late in the sink </font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">and
should therefore be dropped. J1 is the amount of time the entry was late.”</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font face="Calibri"><font size="3"><font color="#000000">We assume the clock is the monotonically increasing wall
clock, not the running time nor the stream time shown ins section<span> </span>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.</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">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 (<span> </span>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. “<span> </span></font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">Questions:</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.5in;line-height:normal"><font color="#000000"><span><span><font size="3" face="Calibri">1.</font><span style="font:7pt/normal "Times New Roman";font-size-adjust:none;font-stretch:normal">
</span></span></span><font face="Calibri"><font size="3">So all buffers will always be late and should be
dropped?! <span> </span></font></font><font face="Calibri"><font size="3">What are we missing?</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.5in;line-height:normal"><font color="#000000"><span><span><font size="3" face="Calibri">2.</font><span style="font:7pt/normal "Times New Roman";font-size-adjust:none;font-stretch:normal">
</span></span></span><font face="Calibri"><font size="3">Which timestamp is the documentation referring
to?<span> </span>GStreamer calls out one in the Linux
version of <span> </span>gstbuffer.h:“<span> </span>GstClockTime<span> </span>timestamp;” and <span> </span></font></font><font face="Calibri"><font size="3">two in the windows version: pts and gts. </font></font></font></p>
<font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 10pt 0.5in"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>* @pts: presentation timestamp of the buffer,
can be #GST_CLOCK_TIME_NONE when the</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>*<span>
</span>pts is not known or relevant. The pts contains the timestamp when the</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>*<span>
</span>media should be presented to the user.</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>* @dts: decoding timestamp of the buffer, can
be #GST_CLOCK_TIME_NONE when the</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>*<span>
</span>dts is not known or relevant. The dts contains the timestamp when the</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.25in;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>*<span>
</span>media should be processed</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span><span> </span>GstClockTime<span> </span>pts;</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span><span> </span>GstClockTime<span> </span>dts;</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.5in;line-height:normal"><font color="#000000"><span><span><font size="3" face="Calibri">3.</font><span style="font:7pt/normal "Times New Roman";font-size-adjust:none;font-stretch:normal">
</span></span></span><font face="Calibri"><font size="3">Which of the three clocks (clocktime, running time,
stream time) are the pts and dts referring to?</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt 0.5in;line-height:normal"><font color="#000000"><span><span><font size="3" face="Calibri">4.</font><span style="font:7pt/normal "Times New Roman";font-size-adjust:none;font-stretch:normal">
</span></span></span><font face="Calibri"><font size="3">It seems the correct jitter formula is:</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri"><span> </span><span> </span>Jitter <span> </span>= buffer_arrival_time - base_time – buffer_time_stamp<span> </span></font></font></font></p>
<font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font face="Calibri"><font size="3"><font color="#000000"><span> </span>Where buffer_arrival_time
is read from the system clock.</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font color="#000000" size="3" face="Calibri"> </font></p><font color="#000000" size="3" face="Times New Roman">
</font><p style="margin:0in 0in 0pt;line-height:normal"><font size="3"><font color="#000000"><font face="Calibri">Thanks.</font></font></font></p><font color="#000000" size="3" face="Times New Roman">
</font></div>