Commit ad1ae2ac by 夏楚 Committed by GitHub

修复ntp时间戳计算精度导致的bug:#1086

parent c2bf2928
...@@ -244,7 +244,7 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) { ...@@ -244,7 +244,7 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) {
//rtp时间戳正增长 //rtp时间戳正增长
if (rtp_stamp >= _last_rtp_stamp) { if (rtp_stamp >= _last_rtp_stamp) {
auto diff = (rtp_stamp - _last_rtp_stamp) / (sample_rate / 1000.0f); auto diff = static_cast<int>((rtp_stamp - _last_rtp_stamp) / (sample_rate / 1000.0f));
if (diff < MAX_DELTA_STAMP) { if (diff < MAX_DELTA_STAMP) {
//时间戳正常增长 //时间戳正常增长
update(rtp_stamp, _last_ntp_stamp_ms + diff); update(rtp_stamp, _last_ntp_stamp_ms + diff);
...@@ -264,7 +264,7 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) { ...@@ -264,7 +264,7 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) {
} }
//rtp时间戳负增长 //rtp时间戳负增长
auto diff = (_last_rtp_stamp - rtp_stamp) / (sample_rate / 1000.0f); auto diff = static_cast<int>((_last_rtp_stamp - rtp_stamp) / (sample_rate / 1000.0f));
if (diff < MAX_DELTA_STAMP) { if (diff < MAX_DELTA_STAMP) {
//正常范围的时间戳回退,说明收到rtp乱序了 //正常范围的时间戳回退,说明收到rtp乱序了
return _last_ntp_stamp_ms - diff; return _last_ntp_stamp_ms - diff;
...@@ -283,4 +283,4 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) { ...@@ -283,4 +283,4 @@ uint64_t NtpStamp::getNtpStamp_l(uint32_t rtp_stamp, uint32_t sample_rate) {
return _last_ntp_stamp_ms; return _last_ntp_stamp_ms;
} }
}//namespace mediakit }//namespace mediakit
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论