jitterbuffer: take more accurate running-time for NACK
authorWim Taymans <wtaymans@redhat.com>
Fri, 27 Dec 2013 14:57:39 +0000 (15:57 +0100)
committerWim Taymans <wtaymans@redhat.com>
Mon, 30 Dec 2013 10:18:50 +0000 (11:18 +0100)
Don't use the current time calculated from the tmieout loop for when we
last scheduled the NACK because it might be unscheduled because of a max
packet misorder and then we don't accurately calculate the current time.
Instead, take the current element running time using the clock.

gst/rtpmanager/gstrtpjitterbuffer.c

index 464bb09..85dad3b 100644 (file)
@@ -2490,6 +2490,7 @@ do_expected_timeout (GstRtpJitterBuffer * jitterbuffer, TimerData * timer,
   GstRtpJitterBufferPrivate *priv = jitterbuffer->priv;
   GstEvent *event;
   guint delay;
+  GstClock *clock;
 
   GST_DEBUG_OBJECT (jitterbuffer, "expected %d didn't arrive", timer->seqnum);
 
@@ -2507,7 +2508,15 @@ do_expected_timeout (GstRtpJitterBuffer * jitterbuffer, TimerData * timer,
 
   priv->num_rtx_requests++;
   timer->num_rtx_retry++;
-  timer->rtx_last = now;
+
+  GST_OBJECT_LOCK (jitterbuffer);
+  if ((clock = GST_ELEMENT_CLOCK (jitterbuffer))) {
+    timer->rtx_last = gst_clock_get_time (clock);
+    timer->rtx_last -= GST_ELEMENT_CAST (jitterbuffer)->base_time;
+  } else {
+    timer->rtx_last = now;
+  }
+  GST_OBJECT_UNLOCK (jitterbuffer);
 
   /* calculate the timeout for the next retransmission attempt */
   timer->rtx_retry += (priv->rtx_retry_timeout * GST_MSECOND);