session: count internal sources and how many are senders

This commit is contained in:
Wim Taymans 2013-07-26 00:29:41 +02:00
parent 719343c206
commit 7f83927c95
2 changed files with 18 additions and 5 deletions

View file

@ -486,9 +486,8 @@ rtp_session_init (RTPSession * sess)
sess->source->validated = TRUE; sess->source->validated = TRUE;
sess->source->internal = TRUE; sess->source->internal = TRUE;
sess->stats.active_sources++; sess->stats.active_sources++;
sess->stats.internal_sources++;
INIT_AVG (sess->stats.avg_rtcp_packet_size, 100); INIT_AVG (sess->stats.avg_rtcp_packet_size, 100);
sess->source->stats.prev_rtcptime = 0;
sess->source->stats.last_rtcptime = 1;
rtp_stats_set_min_interval (&sess->stats, rtp_stats_set_min_interval (&sess->stats,
(gdouble) DEFAULT_RTCP_MIN_INTERVAL / GST_SECOND); (gdouble) DEFAULT_RTCP_MIN_INTERVAL / GST_SECOND);
@ -2016,6 +2015,8 @@ rtp_session_process_bye (RTPSession * sess, GstRTCPPacket * packet,
} }
if (prevsender && !RTP_SOURCE_IS_SENDER (source)) { if (prevsender && !RTP_SOURCE_IS_SENDER (source)) {
sess->stats.sender_sources--; sess->stats.sender_sources--;
if (source->internal)
sess->stats.internal_sender_sources--;
GST_DEBUG ("source: %08x became non sender, %d sender sources", ssrc, GST_DEBUG ("source: %08x became non sender, %d sender sources", ssrc,
sess->stats.sender_sources); sess->stats.sender_sources);
} }
@ -2434,8 +2435,10 @@ rtp_session_send_rtp (RTPSession * sess, gpointer data, gboolean is_list,
/* we use our own source to send */ /* we use our own source to send */
result = rtp_source_send_rtp (source, data, is_list, running_time); result = rtp_source_send_rtp (source, data, is_list, running_time);
if (RTP_SOURCE_IS_SENDER (source) && !prevsender) if (RTP_SOURCE_IS_SENDER (source) && !prevsender) {
sess->stats.sender_sources++; sess->stats.sender_sources++;
sess->stats.internal_sender_sources++;
}
if (oldrate != source->bitrate) if (oldrate != source->bitrate)
sess->recalc_bandwidth = TRUE; sess->recalc_bandwidth = TRUE;
RTP_SESSION_UNLOCK (sess); RTP_SESSION_UNLOCK (sess);
@ -2483,7 +2486,7 @@ calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
result = rtp_stats_calculate_bye_interval (&sess->stats); result = rtp_stats_calculate_bye_interval (&sess->stats);
} else { } else {
result = rtp_stats_calculate_rtcp_interval (&sess->stats, result = rtp_stats_calculate_rtcp_interval (&sess->stats,
RTP_SOURCE_IS_SENDER (sess->source), first); sess->stats.internal_sender_sources > 0, first);
} }
GST_DEBUG ("next deterministic interval: %" GST_TIME_FORMAT ", first %d", GST_DEBUG ("next deterministic interval: %" GST_TIME_FORMAT ", first %d",
@ -2844,6 +2847,8 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
GST_TIME_FORMAT, source->ssrc, GST_TIME_ARGS (btime)); GST_TIME_FORMAT, source->ssrc, GST_TIME_ARGS (btime));
source->is_sender = FALSE; source->is_sender = FALSE;
sess->stats.sender_sources--; sess->stats.sender_sources--;
if (source->internal)
sess->stats.internal_sender_sources--;
sendertimeout = TRUE; sendertimeout = TRUE;
} }
} }
@ -2851,11 +2856,17 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
if (remove) { if (remove) {
sess->total_sources--; sess->total_sources--;
if (is_sender) if (is_sender) {
sess->stats.sender_sources--; sess->stats.sender_sources--;
if (source->internal)
sess->stats.internal_sender_sources--;
}
if (is_active) if (is_active)
sess->stats.active_sources--; sess->stats.active_sources--;
if (source->internal)
sess->stats.internal_sources--;
if (byetimeout) if (byetimeout)
on_bye_timeout (sess, source); on_bye_timeout (sess, source);
else else

View file

@ -179,7 +179,9 @@ typedef struct {
gdouble receiver_fraction; gdouble receiver_fraction;
gdouble min_interval; gdouble min_interval;
GstClockTime bye_timeout; GstClockTime bye_timeout;
guint internal_sources;
guint sender_sources; guint sender_sources;
guint internal_sender_sources;
guint active_sources; guint active_sources;
guint avg_rtcp_packet_size; guint avg_rtcp_packet_size;
guint bye_members; guint bye_members;