summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorTristan Matthews <tristan@sat.qc.ca>2010-03-01 16:40:27 -0500
committerWim Taymans <wim.taymans@collabora.co.uk>2010-03-08 17:47:55 +0100
commita0a6d4ff3beb4a037474a31e4608c9ce36522734 (patch)
tree746950eb2b54a5ec7eefa7d8a8e97b3c95486178 /gst
parent968c981e745adcf67a824950b2a4627a2dee09b4 (diff)
added bitrate estimation to receiver-side stats, fixes #611213
Diffstat (limited to 'gst')
-rw-r--r--gst/rtpmanager/rtpsource.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index bc5ea1f1d..7abb65adc 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -257,6 +257,7 @@ rtp_source_create_stats (RTPSource * src)
gst_structure_set (s,
"octets-received", G_TYPE_UINT64, src->stats.octets_received,
"packets-received", G_TYPE_UINT64, src->stats.packets_received,
+ "bitrate", G_TYPE_UINT64, src->bitrate,
"have-sr", G_TYPE_BOOLEAN, have_sr,
"sr-ntptime", G_TYPE_UINT64, ntptime,
"sr-rtptime", G_TYPE_UINT, (guint) rtptime,
@@ -902,6 +903,7 @@ rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
guint16 seqnr, udelta;
RTPSourceStats *stats;
guint16 expected;
+ guint64 elapsed;
g_return_val_if_fail (RTP_IS_SOURCE (src), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
@@ -983,6 +985,34 @@ rtp_source_process_rtp (RTPSource * src, GstBuffer * buffer,
src->is_sender = TRUE;
src->validated = TRUE;
+ if (src->prev_rtime) {
+ elapsed = arrival->running_time - src->prev_rtime;
+
+ if (elapsed > (G_GINT64_CONSTANT (1) << 31)) {
+ guint64 rate;
+
+ rate =
+ gst_util_uint64_scale (src->stats.bytes_received, elapsed,
+ (G_GINT64_CONSTANT (1) << 29));
+
+ GST_LOG ("Elapsed %" G_GUINT64_FORMAT ", bytes %" G_GUINT64_FORMAT
+ ", rate %" G_GUINT64_FORMAT, elapsed, src->stats.bytes_received,
+ rate);
+
+ if (src->bitrate == 0)
+ src->bitrate = rate;
+ else
+ src->bitrate = ((src->bitrate * 3) + rate) / 4;
+
+ src->prev_rtime = arrival->running_time;
+ src->stats.bytes_received = 0;
+ }
+ } else {
+ GST_LOG ("Reset bitrate measurement");
+ src->prev_rtime = arrival->running_time;
+ src->bitrate = 0;
+ }
+
GST_LOG ("seq %d, PC: %" G_GUINT64_FORMAT ", OC: %" G_GUINT64_FORMAT,
seqnr, src->stats.packets_received, src->stats.octets_received);