From a26a2a9ff535895cb48ae788266e918c13788b81 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 31 Aug 2009 13:02:16 +0200 Subject: jitterbuffer: add slope estimation code and debug Add some code to measure the sender speed vs the receiver speed. This can be used to detect bursts. --- gst/rtpmanager/rtpjitterbuffer.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'gst/rtpmanager') diff --git a/gst/rtpmanager/rtpjitterbuffer.c b/gst/rtpmanager/rtpjitterbuffer.c index 55e084f3..a38c2141 100644 --- a/gst/rtpmanager/rtpjitterbuffer.c +++ b/gst/rtpmanager/rtpjitterbuffer.c @@ -203,6 +203,7 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time, gint64 old; gint pos, i; GstClockTime gstrtptime, out_time; + guint64 slope; ext_rtptime = gst_rtp_buffer_ext_timestamp (&jbuf->ext_rtptime, rtptime); @@ -258,13 +259,21 @@ calculate_skew (RTPJitterBuffer * jbuf, guint32 rtptime, GstClockTime time, /* elapsed time at receiver, includes the jitter */ recv_diff = time - jbuf->base_time; - GST_DEBUG ("time %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT ", recv_diff %" - GST_TIME_FORMAT, GST_TIME_ARGS (time), GST_TIME_ARGS (jbuf->base_time), - GST_TIME_ARGS (recv_diff)); - /* measure the diff */ delta = ((gint64) recv_diff) - ((gint64) send_diff); + /* measure the slope, this gives a rought estimate between the sender speed + * and the receiver speed. This should be approximately 8, higher values + * indicate a burst (especially when the connection starts) */ + if (recv_diff > 0) + slope = (send_diff * 8) / recv_diff; + else + slope = 8; + + GST_DEBUG ("time %" GST_TIME_FORMAT ", base %" GST_TIME_FORMAT ", recv_diff %" + GST_TIME_FORMAT ", slope %" G_GUINT64_FORMAT, GST_TIME_ARGS (time), + GST_TIME_ARGS (jbuf->base_time), GST_TIME_ARGS (recv_diff), slope); + /* if the difference between the sender timeline and the receiver timeline * changed too quickly we have to resync because the server likely restarted * its timestamps. */ -- cgit