mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
rtpsession: Add the option to auto-discover the RTP bandwidth
This commit is contained in:
parent
f38e37470a
commit
6f53a2b240
2 changed files with 27 additions and 3 deletions
|
@ -537,7 +537,7 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
||||||
g_param_spec_double ("bandwidth", "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));
|
0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH, G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,
|
g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,
|
||||||
|
|
|
@ -250,7 +250,7 @@ rtp_session_class_init (RTPSessionClass * klass)
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
g_object_class_install_property (gobject_class, PROP_BANDWIDTH,
|
||||||
g_param_spec_double ("bandwidth", "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,
|
0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
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
|
static GstClockTime
|
||||||
calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
|
calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
|
||||||
gboolean first)
|
gboolean first)
|
||||||
{
|
{
|
||||||
GstClockTime result;
|
GstClockTime result;
|
||||||
|
|
||||||
if (sess->recalc_bandwidth) {
|
if (sess->recalc_bandwidth || sess->bandwidth == 0) {
|
||||||
/* recalculate bandwidth when it changed */
|
/* 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,
|
rtp_stats_set_bandwidths (&sess->stats, sess->bandwidth,
|
||||||
sess->rtcp_bandwidth, sess->rtcp_rs_bandwidth, sess->rtcp_rr_bandwidth);
|
sess->rtcp_bandwidth, sess->rtcp_rs_bandwidth, sess->rtcp_rr_bandwidth);
|
||||||
sess->recalc_bandwidth = FALSE;
|
sess->recalc_bandwidth = FALSE;
|
||||||
|
|
Loading…
Reference in a new issue