session: count internal sources and how many are senders
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 25 Jul 2013 22:29:41 +0000 (00:29 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 26 Jul 2013 10:17:58 +0000 (12:17 +0200)
gst/rtpmanager/rtpsession.c
gst/rtpmanager/rtpstats.h

index 8318a08..3220715 100644 (file)
@@ -486,9 +486,8 @@ rtp_session_init (RTPSession * sess)
   sess->source->validated = TRUE;
   sess->source->internal = TRUE;
   sess->stats.active_sources++;
+  sess->stats.internal_sources++;
   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,
       (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)) {
       sess->stats.sender_sources--;
+      if (source->internal)
+        sess->stats.internal_sender_sources--;
       GST_DEBUG ("source: %08x became non sender, %d sender sources", ssrc,
           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 */
   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.internal_sender_sources++;
+  }
   if (oldrate != source->bitrate)
     sess->recalc_bandwidth = TRUE;
   RTP_SESSION_UNLOCK (sess);
@@ -2483,7 +2486,7 @@ calculate_rtcp_interval (RTPSession * sess, gboolean deterministic,
     result = rtp_stats_calculate_bye_interval (&sess->stats);
   } else {
     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",
@@ -2844,6 +2847,8 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
             GST_TIME_FORMAT, source->ssrc, GST_TIME_ARGS (btime));
         source->is_sender = FALSE;
         sess->stats.sender_sources--;
+        if (source->internal)
+          sess->stats.internal_sender_sources--;
         sendertimeout = TRUE;
       }
     }
@@ -2851,11 +2856,17 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
 
   if (remove) {
     sess->total_sources--;
-    if (is_sender)
+    if (is_sender) {
       sess->stats.sender_sources--;
+      if (source->internal)
+        sess->stats.internal_sender_sources--;
+    }
     if (is_active)
       sess->stats.active_sources--;
 
+    if (source->internal)
+      sess->stats.internal_sources--;
+
     if (byetimeout)
       on_bye_timeout (sess, source);
     else
index 77cbc71..f27e9e7 100644 (file)
@@ -179,7 +179,9 @@ typedef struct {
   gdouble       receiver_fraction;
   gdouble       min_interval;
   GstClockTime  bye_timeout;
+  guint         internal_sources;
   guint         sender_sources;
+  guint         internal_sender_sources;
   guint         active_sources;
   guint         avg_rtcp_packet_size;
   guint         bye_members;