diff --git a/src/Common/Stamp.cpp b/src/Common/Stamp.cpp index f9df913e..c915a519 100644 --- a/src/Common/Stamp.cpp +++ b/src/Common/Stamp.cpp @@ -222,9 +222,14 @@ void NtpStamp::setNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate, uint64_t nt } uint64_t NtpStamp::getNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate) { + if (rtp_stamp == _last_rtp_stamp) { + return _last_ret; + } uint64_t rtp_stamp_ms = uint64_t(rtp_stamp) * 1000 / sample_rate; if (!_rtp_stamp_ms && !_ntp_stamp_ms) { //尚未收到sender report rtcp包 + _last_ret = rtp_stamp_ms; + _last_rtp_stamp = rtp_stamp; return rtp_stamp_ms; } uint64_t max_rtp_ms = uint64_t(UINT32_MAX) * 1000 / sample_rate; @@ -233,6 +238,7 @@ uint64_t NtpStamp::getNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate) { if (diff < 10 * 1000) { //时间戳正常增长 _last_ret = _ntp_stamp_ms + diff; + _last_rtp_stamp = rtp_stamp; return _last_ret; } //时间戳大幅跳跃 diff --git a/src/Common/Stamp.h b/src/Common/Stamp.h index 5c0d708c..079eb48b 100644 --- a/src/Common/Stamp.h +++ b/src/Common/Stamp.h @@ -123,6 +123,7 @@ public: uint64_t getNtpStamp(uint32_t rtp_stamp, uint32_t sample_rate); private: + uint32_t _last_rtp_stamp = 0; uint64_t _rtp_stamp_ms = 0; uint64_t _ntp_stamp_ms = 0; uint64_t _last_ret = 0;