From 77283f39732fde543a874cc1c39e6654573da775 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Tue, 13 Jul 2021 10:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ntp=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E8=8E=B7=E5=8F=96=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Stamp.cpp | 6 ++++++ src/Common/Stamp.h | 1 + 2 files changed, 7 insertions(+) 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;