summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>2010-06-01 21:17:26 -0400
committerWim Taymans <wim.taymans@collabora.co.uk>2010-09-13 15:51:19 +0200
commit6f53a2b240aed4f2230b7b17fb66025cfadcb32a (patch)
treedaba87ae14f3afbd2ba5a69a8ca5b45460a44be9
parentf38e37470afdf49269d22045dc8d434487b1a60b (diff)
rtpsession: Add the option to auto-discover the RTP bandwidth
-rw-r--r--gst/rtpmanager/gstrtpsession.c2
-rw-r--r--gst/rtpmanager/rtpsession.c28
2 files changed, 27 insertions, 3 deletions
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index 8e2077386..d46ceaf53 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -537,7 +537,7 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
g_param_spec_double ("bandwidth", "Bandwidth",
- "The bandwidth of the session in bytes per second",
+ "The bandwidth of the session in bytes per second (0 for auto-discover)",
0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index 7da6a5c6d..457f4d40a 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -250,7 +250,7 @@ rtp_session_class_init (RTPSessionClass * klass)
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
g_param_spec_double ("bandwidth", "Bandwidth",
- "The bandwidth of the session",
+ "The bandwidth of the session (0 for auto-discover)",
0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
@@ -2063,14 +2063,38 @@ invalid_packet:
}
}
+static void
+add_bitrates (gpointer key, gpointer value, gpointer user_data)
+{
+ gdouble *bandwidth = user_data;
+ RTPSource *source = value;
+
+ *bandwidth += source->bitrate;
+}
+
static GstClockTime
calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
gboolean first)
{
GstClockTime result;
- if (sess->recalc_bandwidth) {
+ if (sess->recalc_bandwidth || sess->bandwidth == 0) {
/* recalculate bandwidth when it changed */
+ gdouble bandwidth;
+
+ if (sess->bandwidth > 0)
+ bandwidth = sess->bandwidth;
+ else {
+ /* If it is <= 0, then try to estimate the actual bandwidth */
+ bandwidth = sess->source->bitrate;
+
+ g_hash_table_foreach (sess->cnames, add_bitrates, &bandwidth);
+ bandwidth /= 8.0;
+ }
+
+ if (bandwidth == 0)
+ bandwidth = RTP_STATS_BANDWIDTH;
+
rtp_stats_set_bandwidths (&sess->stats, sess->bandwidth,
sess->rtcp_bandwidth, sess->rtcp_rs_bandwidth, sess->rtcp_rr_bandwidth);
sess->recalc_bandwidth = FALSE;