]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9503 #resolve [Add flaws and consecutive_flaws to error_log in rtp]
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 12 Sep 2016 17:21:21 +0000 (12:21 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 12 Sep 2016 17:21:21 +0000 (12:21 -0500)
src/include/switch_types.h
src/switch_ivr.c
src/switch_rtp.c

index 4f5d0d1b7432082590959bf97056fa77772c0fe9..707ede43ac43db3ad6b2f479d5bcf5ee01fd54b7 100644 (file)
@@ -621,6 +621,8 @@ typedef uint32_t switch_vad_flag_t;
 typedef struct error_period {
        int64_t start;
        int64_t stop;
+       uint32_t flaws;
+       uint32_t consecutive_flaws;
        struct error_period *next;
 } switch_error_period_t;
 
index 5f8b9ea2bcd15b682f958d677406b50df30673d0..41b55f4a1d42a7288ca6eed111272b5a5f2c99d8 100644 (file)
@@ -2645,6 +2645,14 @@ SWITCH_DECLARE(int) switch_ivr_set_xml_call_stats(switch_xml_t xml, switch_core_
                        x_tmp = switch_xml_add_child_d(x_err, "stop", 1);
                        switch_xml_set_txt_d(x_tmp, var_val);
 
+                       switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_TIME_T_FMT, ep->flaws);
+                       x_tmp = switch_xml_add_child_d(x_err, "flaws", 1);
+                       switch_xml_set_txt_d(x_tmp, var_val);
+
+                       switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_TIME_T_FMT, ep->consecutive_flaws);
+                       x_tmp = switch_xml_add_child_d(x_err, "consecutive-flaws", 1);
+                       switch_xml_set_txt_d(x_tmp, var_val);
+
                        switch_snprintf(var_val, sizeof(var_val), "%" SWITCH_TIME_T_FMT, (ep->stop - ep->start) / 1000);
                        x_tmp = switch_xml_add_child_d(x_err, "duration-msec", 2);
                        switch_xml_set_txt_d(x_tmp, var_val);
@@ -3127,6 +3135,8 @@ SWITCH_DECLARE(void) switch_ivr_set_json_call_stats(cJSON *json, switch_core_ses
 
                        cJSON_AddItemToObject(j_err, "start", cJSON_CreateNumber(ep->start));
                        cJSON_AddItemToObject(j_err, "stop", cJSON_CreateNumber(ep->stop));
+                       cJSON_AddItemToObject(j_err, "flaws", cJSON_CreateNumber(ep->flaws));
+                       cJSON_AddItemToObject(j_err, "Consecutiveflaws", cJSON_CreateNumber(ep->consecutive_flaws));
                        cJSON_AddItemToObject(j_err, "durationMS", cJSON_CreateNumber((ep->stop - ep->start) / 1000));
                        cJSON_AddItemToArray(j_err_log, j_err);
                }
index 0879ab63aab43c1f62d279b357def49f9b06563d..a0575747fca9143c440f1c75104585fd33b0e52b 100644 (file)
@@ -1544,6 +1544,11 @@ static void do_mos(switch_rtp_t *rtp_session, int force) {
                                                          rtp_session->consecutive_flaws, penalty);
                        rtp_session->bad_stream++;
                        rtp_session->stats.inbound.flaws += penalty;
+                       
+                       if (rtp_session->stats.inbound.error_log) {
+                               rtp_session->stats.inbound.error_log->flaws += penalty;
+                               rtp_session->stats.inbound.error_log->consecutive_flaws++;
+                       }
                }
 
                R = (int)((double)((double)(rtp_session->stats.inbound.recved - rtp_session->stats.inbound.flaws) / (double)rtp_session->stats.inbound.recved) * 100.0);
@@ -1643,6 +1648,11 @@ static void check_jitter(switch_rtp_t *rtp_session)
 
                rtp_session->bad_stream++;
                rtp_session->stats.inbound.flaws += lost;
+
+               if (rtp_session->stats.inbound.error_log) {
+                       rtp_session->stats.inbound.error_log->flaws += lost;
+               }
+
        } else {
                rtp_session->stats.inbound.last_loss = 0;
        }
@@ -6291,6 +6301,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
 
                                                rtp_session->bad_stream++;
                                                rtp_session->stats.inbound.flaws += rtp_session->sync_packets;
+
+                                               if (rtp_session->stats.inbound.error_log) {
+                                                       rtp_session->stats.inbound.error_log->flaws += rtp_session->sync_packets;
+                                               }
                                        }
 
                                        switch_core_timer_sync(&rtp_session->timer);
@@ -6857,6 +6871,9 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s %s timeout\n", 
                                                                          rtp_session_name(rtp_session), rtp_type(rtp_session));
 
+                                       if (rtp_session->stats.inbound.error_log) {
+                                               rtp_session->stats.inbound.error_log->flaws++;
+                                       }
                                        rtp_session->stats.inbound.flaws++;
                                        do_mos(rtp_session, SWITCH_FALSE);
                                }