From 40982338a0ab921e3cd0f8739ac4bf5eee2e801a Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 25 Jul 2019 22:48:17 +0000 Subject: [PATCH 1/3] FS-11965: RTCP: fix on rtcp_report_block->fraction - "if X packets were expected and X was lost, we want 0xff to be reported, not 0" (patch by Piotr Gregor ) --- src/switch_rtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index c2e7e0f6fb..142b107469 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -1840,7 +1840,7 @@ static void rtcp_generate_report_block(switch_rtp_t *rtp_session, struct switch_ pkt_lost = expected_pkt - stats->period_pkt_count; stats->cum_lost=stats->cum_lost+pkt_lost; if (expected_pkt > 0 && pkt_lost > 0) { - rtcp_report_block->fraction = (uint8_t) (pkt_lost * 256 / expected_pkt); + rtcp_report_block->fraction = (pkt_lost == expected_pkt ? 255 : (uint8_t) (pkt_lost * 256 / expected_pkt)); /* if X packets were expected and X was lost, we want 0xff to be reported, not 0 */ } else { rtcp_report_block->fraction = 0; } From 2e450cd3dcc267a662d3be407c0aff8e471b5919 Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 25 Jul 2019 22:56:24 +0000 Subject: [PATCH 2/3] FS-11965: NACK log debug when we get a request --- src/switch_rtp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 142b107469..cd39093e7c 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -2074,6 +2074,11 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) if (!nack) break; + seq = ntohs(nack & 0xFFFF); + + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG1, "%s Got NACK [%u][0x%x] for seq %u\n", + switch_core_session_get_name(rtp_session->session), nack, nack, seq); + cur_nack[nack_ttl++] = nack; } if (nack_ttl) { From 9e006869e47bf60706da14c54f81c38ccaf790ca Mon Sep 17 00:00:00 2001 From: Dragos Oancea Date: Thu, 25 Jul 2019 23:07:15 +0000 Subject: [PATCH 3/3] FS-11965: RTC: prevent overflow on percent_fraction (patch by Sergey Khripchenko ) --- src/switch_rtp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index cd39093e7c..795f41207d 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -6716,12 +6716,12 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t for (i = 0; i < (int)msg->header.count && i < MAX_REPORT_BLOCKS ; i++) { uint32_t old_avg = rtp_session->rtcp_frame.reports[i].loss_avg; - uint8_t percent_fraction = (uint8_t)report->fraction * 100 / 256 ; + uint8_t percent_fraction = (uint8_t)((uint16_t/* prevent overflow when '* 100' */)(uint8_t)report->fraction * 100 / 255); if (!rtp_session->rtcp_frame.reports[i].loss_avg) { - rtp_session->rtcp_frame.reports[i].loss_avg = (uint8_t)percent_fraction; + rtp_session->rtcp_frame.reports[i].loss_avg = percent_fraction; } else { rtp_session->rtcp_frame.reports[i].loss_avg = (uint32_t)(((float)rtp_session->rtcp_frame.reports[i].loss_avg * .7) + - ((float)(uint8_t)percent_fraction * .3)); + ((float)percent_fraction * .3)); } rtp_session->rtcp_frame.reports[i].ssrc = ntohl(report->ssrc);