return result;
}
+/* should be called with the SESSION lock */
static guint32
rtp_session_create_new_ssrc (RTPSession * sess)
{
RTPArrivalStats arrival;
guint32 csrcs[16];
guint8 i, count;
+ guint64 oldrate;
g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
prevsender = RTP_SOURCE_IS_SENDER (source);
prevactive = RTP_SOURCE_IS_ACTIVE (source);
+ oldrate = source->bitrate;
/* copy available csrc for later */
count = gst_rtp_buffer_get_csrc_count (buffer);
GST_DEBUG ("source: %08x became sender, %d sender sources", ssrc,
sess->stats.sender_sources);
}
+ if (oldrate != source->bitrate)
+ sess->recalc_bandwidth = TRUE;
if (created)
on_new_ssrc (sess, source);
RTPSource *source;
gboolean prevsender;
gboolean valid_packet;
+ guint64 oldrate;
g_return_val_if_fail (RTP_IS_SESSION (sess), GST_FLOW_ERROR);
g_return_val_if_fail (is_list || GST_IS_BUFFER (data), GST_FLOW_ERROR);
source->last_rtp_activity = current_time;
prevsender = RTP_SOURCE_IS_SENDER (source);
+ oldrate = source->bitrate;
/* we use our own source to send */
result = rtp_source_send_rtp (source, data, is_list, running_time);
if (RTP_SOURCE_IS_SENDER (source) && !prevsender)
sess->stats.sender_sources++;
+ if (oldrate != source->bitrate)
+ sess->recalc_bandwidth = TRUE;
RTP_SESSION_UNLOCK (sess);
return result;
}
static void
-add_bitrates (gpointer key, gpointer value, gpointer user_data)
+add_bitrates (gpointer key, RTPSource * source, gdouble * bandwidth)
{
- gdouble *bandwidth = user_data;
- RTPSource *source = value;
-
*bandwidth += source->bitrate;
}
{
GstClockTime result;
- if (sess->recalc_bandwidth || sess->bandwidth == 0) {
- /* recalculate bandwidth when it changed */
+ /* recalculate bandwidth when it changed */
+ if (sess->recalc_bandwidth) {
gdouble bandwidth;
if (sess->bandwidth > 0)
/* If it is <= 0, then try to estimate the actual bandwidth */
bandwidth = sess->source->bitrate;
- g_hash_table_foreach (sess->cnames, add_bitrates, &bandwidth);
+ g_hash_table_foreach (sess->cnames, (GHFunc) 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, bandwidth,
sess->rtcp_bandwidth, sess->rtcp_rs_bandwidth, sess->rtcp_rr_bandwidth);
+
sess->recalc_bandwidth = FALSE;
}