mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复ntp时间戳计算精度导致的bug:#1086
This commit is contained in:
parent
c2bf2928d0
commit
ad1ae2ac66
@ -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) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//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) {
|
|||||||
return _last_ntp_stamp_ms;
|
return _last_ntp_stamp_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
Loading…
Reference in New Issue
Block a user