提交 5d4ac1cd authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-10284: [core] rtp session variable "ts" can wrap to zero for long running…

FS-10284: [core] rtp session variable "ts" can wrap to zero for long running calls, causing incorrect logic to be executed #resolve
上级 75df6bc4
...@@ -7737,6 +7737,22 @@ static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line) ...@@ -7737,6 +7737,22 @@ static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line)
} }
static int ts_delta(int last_val, int cur_val)
{
int32_t delta;
int64_t x, y;
x = last_val;
y = cur_val;
if (x > UINT32_MAX / 2 && y < UINT32_MAX / 2) {
x -= (int64_t)UINT32_MAX+1;
}
delta = (int32_t)y-x;
return delta;
}
static int rtp_common_write(switch_rtp_t *rtp_session, static int rtp_common_write(switch_rtp_t *rtp_session,
...@@ -7801,8 +7817,10 @@ static int rtp_common_write(switch_rtp_t *rtp_session, ...@@ -7801,8 +7817,10 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
if ((rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) { if ((rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) {
m = 0; m = 0;
} else { } else {
int delta = ts_delta(rtp_session->last_write_ts, rtp_session->ts);
if (!rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] && if (!rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
((!rtp_session->flags[SWITCH_RTP_FLAG_RESET] && (rtp_session->ts - rtp_session->last_write_ts > rtp_session->samples_per_interval * 10)) ((!rtp_session->flags[SWITCH_RTP_FLAG_RESET] && (delta > rtp_session->samples_per_interval * 10))
|| rtp_session->ts == rtp_session->samples_per_interval)) { || rtp_session->ts == rtp_session->samples_per_interval)) {
m++; m++;
} }
...@@ -7878,17 +7896,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, ...@@ -7878,17 +7896,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
rtp_session->ts_norm.last_external = external; rtp_session->ts_norm.last_external = external;
if (ntohl(send_msg->header.ts) != rtp_session->ts_norm.last_frame) { if (ntohl(send_msg->header.ts) != rtp_session->ts_norm.last_frame) {
int32_t delta; int32_t delta = ts_delta(rtp_session->ts_norm.last_frame, ntohl(send_msg->header.ts));
int64_t x, y;
x = rtp_session->ts_norm.last_frame;
y = ntohl(send_msg->header.ts);
if (x > UINT32_MAX / 2 && y < UINT32_MAX / 2) {
x -= (int64_t)UINT32_MAX+1;
}
delta = (int32_t)y-x;
if (delta < 0 || delta > 90000) { if (delta < 0 || delta > 90000) {
switch_core_media_gen_key_frame(rtp_session->session); switch_core_media_gen_key_frame(rtp_session->session);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论