rtpmanager: consider UDP and IP headers in bandwidth calculation
authorAntonio Ospite <antonio.ospite@collabora.com>
Fri, 21 Jun 2019 15:46:36 +0000 (17:46 +0200)
committerAntonio Ospite <antonio.ospite@collabora.com>
Fri, 2 Aug 2019 15:22:51 +0000 (17:22 +0200)
According to RFC3550 lower-level headers should be considered for
bandwidth calculation.

See https://tools.ietf.org/html/rfc3550#section-6.2 paragraph 4:

  Bandwidth calculations for control and data traffic include
  lower-layer transport and network protocols (e.g., UDP and IP) since
  that is what the resource reservation system would need to know.

Fix the source data to accommodate that.

Assume UDPv4 over IP for now, this is a simplification but it's good
enough for now.

While at it define a constant and use that instead of a magic number.

NOTE: this change basically reverts the logic of commit 529f443a6
(rtpsource: use payload size to estimate bitrate, 2010-03-02)

gst/rtpmanager/rtpsession.c
gst/rtpmanager/rtpsource.c
gst/rtpmanager/rtpstats.h

index 081de50..0ddb2b5 100644 (file)
@@ -673,7 +673,7 @@ rtp_session_init (RTPSession * sess)
   sess->rtcp_rs_bandwidth = DEFAULT_RTCP_RS_BANDWIDTH;
 
   /* default UDP header length */
-  sess->header_len = 28;
+  sess->header_len = UDP_IP_HEADER_OVERHEAD;
   sess->mtu = DEFAULT_RTCP_MTU;
 
   sess->probation = DEFAULT_PROBATION;
index 7079e16..78e6746 100644 (file)
@@ -1188,8 +1188,8 @@ update_receiver_stats (RTPSource * src, RTPPacketInfo * pinfo,
   src->stats.octets_received += pinfo->payload_len;
   src->stats.bytes_received += pinfo->bytes;
   src->stats.packets_received += pinfo->packets;
-  /* for the bitrate estimation */
-  src->bytes_received += pinfo->payload_len;
+  /* for the bitrate estimation consider all lower level headers */
+  src->bytes_received += pinfo->bytes;
 
   GST_LOG ("seq %u, PC: %" G_GUINT64_FORMAT ", OC: %" G_GUINT64_FORMAT,
       seqnr, src->stats.packets_received, src->stats.octets_received);
@@ -1319,7 +1319,7 @@ rtp_source_send_rtp (RTPSource * src, RTPPacketInfo * pinfo)
   /* update stats for the SR */
   src->stats.packets_sent += pinfo->packets;
   src->stats.octets_sent += pinfo->payload_len;
-  src->bytes_sent += pinfo->payload_len;
+  src->bytes_sent += pinfo->bytes;
 
   running_time = pinfo->running_time;
 
index b8b26ec..bd3a54e 100644 (file)
@@ -27,6 +27,9 @@
 #include <gst/rtp/rtp.h>
 #include <gio/gio.h>
 
+/* UDP/IP is assumed for bandwidth calculation */
+#define UDP_IP_HEADER_OVERHEAD 28
+
 /**
  * RTPSenderReport:
  *