summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-06-01 21:35:40 -0400
committerWim Taymans <wim.taymans@collabora.co.uk>2010-09-13 15:51:20 +0200
commit1f17b334ff2c31061dbeff0a5b42b77872cdb97e (patch)
treef8442797fb1d85ab6b2c3a3ed3b0827fd980a503
parent8381d9788d4a275926b2ded379f25928b1ae4cde (diff)
rtpsession: Calculate RTCP bandwidth as a fraction of the RTP bandwidth
Calculate the RTCP bandwidth to be a fraction of the RTP bandwidth if it is specified as a value between 0 and 1.
-rw-r--r--gst/rtpmanager/gstrtpsession.c4
-rw-r--r--gst/rtpmanager/rtpsession.c4
-rw-r--r--gst/rtpmanager/rtpsession.h2
-rw-r--r--gst/rtpmanager/rtpstats.c21
-rw-r--r--gst/rtpmanager/rtpstats.h6
5 files changed, 24 insertions, 13 deletions
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index d46ceaf53..63123cdcb 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -192,7 +192,7 @@ enum
#define DEFAULT_NTP_NS_BASE 0
#define DEFAULT_BANDWIDTH RTP_STATS_BANDWIDTH
-#define DEFAULT_RTCP_FRACTION RTP_STATS_RTCP_BANDWIDTH
+#define DEFAULT_RTCP_FRACTION (RTP_STATS_BANDWIDTH * RTP_STATS_RTCP_FRACTION)
#define DEFAULT_RTCP_RR_BANDWIDTH -1
#define DEFAULT_RTCP_RS_BANDWIDTH -1
#define DEFAULT_SDES NULL
@@ -542,7 +542,7 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,
g_param_spec_double ("rtcp-fraction", "RTCP Fraction",
- "The RTCP bandwidth of the session in bytes per second",
+ "The RTCP bandwidth of the session in bytes per second (or as a real fraction of the RTP bandwidth if < 1)",
0.0, G_MAXDOUBLE, DEFAULT_RTCP_FRACTION, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_RTCP_RR_BANDWIDTH,
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 6d4885880..3f0bd3b6c 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -47,7 +47,7 @@ enum
#define DEFAULT_INTERNAL_SOURCE NULL
#define DEFAULT_BANDWIDTH RTP_STATS_BANDWIDTH
-#define DEFAULT_RTCP_FRACTION RTP_STATS_RTCP_BANDWIDTH
+#define DEFAULT_RTCP_FRACTION (RTP_STATS_RTCP_FRACTION * RTP_STATS_BANDWIDTH)
#define DEFAULT_RTCP_RR_BANDWIDTH -1
#define DEFAULT_RTCP_RS_BANDWIDTH -1
#define DEFAULT_RTCP_MTU 1400
@@ -256,7 +256,7 @@ rtp_session_class_init (RTPSessionClass * klass)
g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,
g_param_spec_double ("rtcp-fraction", "RTCP Fraction",
- "The fraction of the bandwidth used for RTCP",
+ "The fraction of the bandwidth used for RTCP (or as a real fraction of the RTP bandwidth if < 1)",
0.0, G_MAXDOUBLE, DEFAULT_RTCP_FRACTION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h
index 8a1fb3e18..3fc987467 100644
--- a/gst/rtpmanager/rtpsession.h
+++ b/gst/rtpmanager/rtpsession.h
@@ -166,7 +166,7 @@ struct _RTPSession {
/* bandwidths */
gboolean recalc_bandwidth;
guint bandwidth;
- guint rtcp_bandwidth;
+ gdouble rtcp_bandwidth;
guint rtcp_rr_bandwidth;
guint rtcp_rs_bandwidth;
diff --git a/gst/rtpmanager/rtpstats.c b/gst/rtpmanager/rtpstats.c
index dc3bb8ee0..8d1f5cfa1 100644
--- a/gst/rtpmanager/rtpstats.c
+++ b/gst/rtpmanager/rtpstats.c
@@ -46,8 +46,8 @@ rtp_stats_init_defaults (RTPSessionStats * stats)
* defaults.
*/
void
-rtp_stats_set_bandwidths (RTPSessionStats * stats, guint rtp_bw, guint rtcp_bw,
- guint rs, guint rr)
+rtp_stats_set_bandwidths (RTPSessionStats * stats, guint rtp_bw,
+ gdouble rtcp_bw, guint rs, guint rr)
{
GST_DEBUG ("recalc bandwidths: RTP %u, RTCP %u, RS %u, RR %u", rtp_bw,
rtcp_bw, rs, rr);
@@ -57,16 +57,25 @@ rtp_stats_set_bandwidths (RTPSessionStats * stats, guint rtp_bw, guint rtcp_bw,
if (rs != -1 && rr != -1)
rtcp_bw = rs + rr;
+ /* If rtcp_bw is between 0 and 1, it is a fraction of rtp_bw */
+ if (rtcp_bw > 0 && rtcp_bw < 1) {
+ if (rtp_bw > 0)
+ rtcp_bw = rtp_bw * rtcp_bw;
+ else
+ rtcp_bw = -1;
+ }
+
/* RTCP is 5% of the RTP bandwidth */
- if (rtp_bw == -1 && rtcp_bw != -1)
+ if (rtp_bw == -1 && rtcp_bw > 0)
rtp_bw = rtcp_bw * 20;
- else if (rtp_bw != -1 && rtcp_bw == -1)
+ else if (rtp_bw != -1 && rtcp_bw < 0)
rtcp_bw = rtp_bw / 20;
- else if (rtp_bw == -1 && rtcp_bw == -1) {
+ else if (rtp_bw == -1 && rtcp_bw < 0) {
/* nothing given, take defaults */
rtp_bw = RTP_STATS_BANDWIDTH;
- rtcp_bw = RTP_STATS_RTCP_BANDWIDTH;
+ rtcp_bw = rtp_bw = RTP_STATS_RTCP_FRACTION;
}
+
stats->bandwidth = rtp_bw;
stats->rtcp_bandwidth = rtcp_bw;
diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h
index d71bac4d7..cb447b80c 100644
--- a/gst/rtpmanager/rtpstats.h
+++ b/gst/rtpmanager/rtpstats.h
@@ -128,7 +128,7 @@ typedef struct {
} RTPSourceStats;
#define RTP_STATS_BANDWIDTH 64000
-#define RTP_STATS_RTCP_BANDWIDTH 3200
+#define RTP_STATS_RTCP_FRACTION 0.05
/*
* Minimum average time between RTCP packets from this site (in
* seconds). This time prevents the reports from `clumping' when
@@ -186,7 +186,9 @@ typedef struct {
void rtp_stats_init_defaults (RTPSessionStats *stats);
-void rtp_stats_set_bandwidths (RTPSessionStats *stats, guint rtp_bw, guint rtcp_bw,
+void rtp_stats_set_bandwidths (RTPSessionStats *stats,
+ guint rtp_bw,
+ gdouble rtcp_bw,
guint rs, guint rr);
GstClockTime rtp_stats_calculate_rtcp_interval (RTPSessionStats *stats, gboolean sender, gboolean first);