]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11743: video RTCP counter (fix conflicts)
authorDragos Oancea <dragos@signalwire.com>
Thu, 6 Jun 2019 17:38:04 +0000 (17:38 +0000)
committerDragos Oancea <dragos@signalwire.com>
Thu, 6 Jun 2019 17:38:04 +0000 (17:38 +0000)
src/include/switch_types.h
src/switch_rtp.c

index 1ccc893b1b5cda592d09e7424ccb480ec620d967..53c25c395c25157c50d8903eda20e19ff9c7d55a 100644 (file)
@@ -717,6 +717,21 @@ typedef struct {
        uint32_t init;
 } switch_rtcp_numbers_t;
 
+typedef struct {
+       uint16_t nack_count; 
+       uint16_t fir_count;
+       uint16_t pli_count;
+       uint16_t sr_count;
+       uint16_t rr_count;
+} switch_rtcp_video_counters_t;
+
+typedef struct {
+       /* counters and stats for the incoming video stream and outgoing RTCP*/
+       switch_rtcp_video_counters_t video_in;
+       /* counters and stats for the outgoing video stream and incoming RTCP*/
+       switch_rtcp_video_counters_t video_out;
+} switch_rtcp_video_stats_t;
+
 typedef struct {
        switch_rtp_numbers_t inbound;
        switch_rtp_numbers_t outbound;
index 15adc72a5734cf19e0509d8d55659366aa7908e4..c63c94e8ebdc9d1009dcc163495f48e4102c72f1 100644 (file)
@@ -445,6 +445,7 @@ struct switch_rtp {
        uint32_t cng_count;
        switch_rtp_bug_flag_t rtp_bugs;
        switch_rtp_stats_t stats;
+       switch_rtcp_video_stats_t rtcp_vstats;
        uint32_t clean_stream;
        uint32_t bad_stream;
        uint32_t recovering_stream;
@@ -2195,9 +2196,9 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
 
                                ext_hdr->send_ssrc = htonl(rtp_session->ssrc);
                                ext_hdr->recv_ssrc = htonl(rtp_session->remote_ssrc);
-
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP PLI %u %u\n",
-                                                                 rtp_session->ssrc, rtp_session->remote_ssrc);
+                               rtp_session->rtcp_vstats.video_in.pli_count++;
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP PLI %u %u [%u]\n",
+                                                                 rtp_session->ssrc, rtp_session->remote_ssrc, rtp_session->rtcp_vstats.video_in.pli_count);
 
                                ext_hdr->length = htons((uint8_t)(sizeof(switch_rtcp_ext_hdr_t) / 4) - 1);
                                rtcp_bytes += sizeof(switch_rtcp_ext_hdr_t);
@@ -2207,6 +2208,7 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
                        if (rtp_session->flags[SWITCH_RTP_FLAG_NACK] && nack_ttl > 0) {
                                int n = 0;
 
+                               rtp_session->rtcp_vstats.video_in.nack_count++;
                                for (n = 0; n < nack_ttl; n++) {
                                        switch_rtcp_ext_hdr_t *ext_hdr;
                                        uint32_t *nack;
@@ -2266,7 +2268,8 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
                                fir->seq = rtp_session->fir_seq;
                                fir->r1 = fir->r2 = fir->r3 = 0;
 
-                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP FIR SEQ %d\n", rtp_session->fir_seq);
+                               rtp_session->rtcp_vstats.video_in.fir_count++;
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "Sending RTCP FIR SEQ %d [%u]\n", rtp_session->fir_seq, rtp_session->rtcp_vstats.video_in.fir_count);
 
                                rtp_session->fir_seq++;
 
@@ -6504,7 +6507,6 @@ static void handle_nack(switch_rtp_t *rtp_session, uint32_t nack)
 static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t *msg, switch_size_t bytes)
 {
        switch_status_t status = SWITCH_STATUS_FALSE;
-       int i;
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG3,
                                          "RTCP packet bytes %" SWITCH_SIZE_T_FMT " type %d pad %d\n",