rtpjitterbuffer: Actually calculate the packet rate for max-dropout and max-misorder...
authorThomas Bluemel <tbluemel@control4.com>
Wed, 10 Aug 2016 17:45:13 +0000 (11:45 -0600)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 10 Aug 2016 17:49:27 +0000 (19:49 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=751311

gst/rtpmanager/gstrtpjitterbuffer.c
gst/rtpmanager/rtpstats.c

index 7b72deb..1fc313b 100644 (file)
@@ -1299,6 +1299,8 @@ gst_jitter_buffer_sink_parse_caps (GstRtpJitterBuffer * jitterbuffer,
 
   rtp_jitter_buffer_set_clock_rate (priv->jbuf, priv->clock_rate);
 
+  gst_rtp_packet_rate_ctx_reset (&priv->packet_rate_ctx, priv->clock_rate);
+
   /* The clock base is the RTP timestamp corrsponding to the npt-start value. We
    * can use this to track the amount of time elapsed on the sender. */
   if (gst_structure_get_uint (caps_struct, "clock-base", &val))
@@ -2632,6 +2634,8 @@ gst_rtp_jitter_buffer_chain (GstPad * pad, GstObject * parent,
 
     if (G_UNLIKELY (priv->clock_rate == -1))
       goto no_clock_rate;
+
+    gst_rtp_packet_rate_ctx_reset (&priv->packet_rate_ctx, priv->clock_rate);
   }
 
   /* don't accept more data on EOS */
index 984bc9f..cc25dbf 100644 (file)
@@ -27,6 +27,7 @@ gst_rtp_packet_rate_ctx_reset (RTPPacketRateCtx * ctx, guint32 clock_rate)
   ctx->clock_rate = clock_rate;
   ctx->probed = FALSE;
   ctx->avg_packet_rate = -1;
+  ctx->last_ts = -1;
 }
 
 guint32
@@ -41,15 +42,16 @@ gst_rtp_packet_rate_ctx_update (RTPPacketRateCtx * ctx, guint16 seqnum,
     return ctx->avg_packet_rate;
   }
 
+  new_ts = ctx->last_ts;
+  gst_rtp_buffer_ext_timestamp (&new_ts, ts);
+
   if (!ctx->probed) {
     ctx->last_seqnum = seqnum;
-    ctx->last_ts = ts;
+    ctx->last_ts = new_ts;
     ctx->probed = TRUE;
     return ctx->avg_packet_rate;
   }
 
-  new_ts = ctx->last_ts;
-  gst_rtp_buffer_ext_timestamp (&new_ts, ts);
   diff_seqnum = gst_rtp_buffer_compare_seqnum (ctx->last_seqnum, seqnum);
   if (diff_seqnum <= 0 || new_ts <= ctx->last_ts) {
     return ctx->avg_packet_rate;
@@ -64,6 +66,7 @@ gst_rtp_packet_rate_ctx_update (RTPPacketRateCtx * ctx, guint16 seqnum,
    * but it will go down again slowly.
    * This is useful for bursty cases, where a lot of packets are close
    * to each other and should allow a higher reorder/dropout there.
+   * Round up the new average.
    */
   if (ctx->avg_packet_rate > new_packet_rate) {
     ctx->avg_packet_rate = (7 * ctx->avg_packet_rate + new_packet_rate + 7) / 8;