提交 4abe5905 authored 作者: Mike Jerris's avatar Mike Jerris

Merge pull request #1771 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:FS-11965 to master

* commit '9e006869':
  FS-11965: RTC: prevent overflow on percent_fraction (patch by Sergey Khripchenko <shripchenko@intermedia.net>)
  FS-11965: NACK log debug when we get a request
  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 <piotr@dataandsignal.com>)
...@@ -1842,7 +1842,7 @@ static void rtcp_generate_report_block(switch_rtp_t *rtp_session, struct switch_ ...@@ -1842,7 +1842,7 @@ static void rtcp_generate_report_block(switch_rtp_t *rtp_session, struct switch_
stats->cum_lost=stats->cum_lost+pkt_lost; stats->cum_lost=stats->cum_lost+pkt_lost;
if (expected_pkt > 0 && pkt_lost > 0) { 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 { } else {
rtcp_report_block->fraction = 0; rtcp_report_block->fraction = 0;
} }
...@@ -2076,6 +2076,11 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session) ...@@ -2076,6 +2076,11 @@ static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
if (!nack) break; 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; cur_nack[nack_ttl++] = nack;
} }
if (nack_ttl) { if (nack_ttl) {
...@@ -6713,12 +6718,12 @@ static switch_status_t process_rtcp_report(switch_rtp_t *rtp_session, rtcp_msg_t ...@@ -6713,12 +6718,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++) { 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; 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) { 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 { } else {
rtp_session->rtcp_frame.reports[i].loss_avg = (uint32_t)(((float)rtp_session->rtcp_frame.reports[i].loss_avg * .7) + 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); rtp_session->rtcp_frame.reports[i].ssrc = ntohl(report->ssrc);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论