From 2410419911d0fcdaa406b5f1021c4a31b13409f3 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 17 Jun 2023 10:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E9=9D=9E=E6=B3=95=E7=9A=84rt?= =?UTF-8?q?cp=20ntp=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 有些设备在发送sender report rtcp时,其rtp和ntp时间戳一直为0,将导致zlmediakit计算出的ntp时间戳异常 --- src/Common/Stamp.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Common/Stamp.cpp b/src/Common/Stamp.cpp index 3cb5ee32..a19b96d6 100644 --- a/src/Common/Stamp.cpp +++ b/src/Common/Stamp.cpp @@ -231,14 +231,15 @@ bool DtsGenerator::getDts_l(uint64_t pts, uint64_t &dts) { } void NtpStamp::setNtpStamp(uint32_t rtp_stamp, uint64_t ntp_stamp_ms) { + if (!ntp_stamp_ms || !rtp_stamp) { + // 实测发现有些rtsp服务器发送的rtp时间戳和ntp时间戳一直为0 + WarnL << "Invalid sender report rtcp, ntp_stamp_ms = " << ntp_stamp_ms << ", rtp_stamp = " << rtp_stamp; + return; + } update(rtp_stamp, ntp_stamp_ms); } void NtpStamp::update(uint32_t rtp_stamp, uint64_t ntp_stamp_ms) { - if (ntp_stamp_ms == 0) { - // 实测发现有些rtsp服务器发送的rtp时间戳和ntp时间戳一直为0 - return; - } _last_rtp_stamp = rtp_stamp; _last_ntp_stamp_ms = ntp_stamp_ms; }