From 6aa4b741a3595d61e3832979b00af26a6ba06b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Wed, 28 Jun 2023 14:56:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=9A=E7=94=A8rtp?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=E5=99=A8=E8=BE=93=E5=85=A5=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E5=A2=9E=E9=87=8F=E6=B5=81=E5=9C=A8=E4=B8=A2?= =?UTF-8?q?=E5=8C=85=E6=97=B6=E4=B8=8D=E5=86=8D=E8=BE=93=E5=87=BA=E5=B8=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84bug=20(#2589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如果rtp时间戳增量很小,在rtp时间戳在转换单位为毫秒时无变化, 从而被认为是上一帧数据,由于处于丢包状态,此rtp数据将被一直丢弃。 --- src/Extension/CommonRtp.cpp | 7 ++++--- src/Extension/CommonRtp.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Extension/CommonRtp.cpp b/src/Extension/CommonRtp.cpp index 9ba9b682..68767a6f 100644 --- a/src/Extension/CommonRtp.cpp +++ b/src/Extension/CommonRtp.cpp @@ -34,10 +34,10 @@ bool CommonRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool){ return false; } auto payload = rtp->getPayload(); - auto stamp = rtp->getStampMS(); + auto stamp = rtp->getStamp(); auto seq = rtp->getSeq(); - if (_frame->_dts != stamp || _frame->_buffer.size() > _max_frame_size) { + if (_last_stamp != stamp || _frame->_buffer.size() > _max_frame_size) { //时间戳发生变化或者缓存超过MAX_FRAME_SIZE,则清空上帧数据 if (!_frame->_buffer.empty()) { //有有效帧,则输出 @@ -46,7 +46,8 @@ bool CommonRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool){ //新的一帧数据 obtainFrame(); - _frame->_dts = stamp; + _frame->_dts = rtp->getStampMS(); + _last_stamp = stamp; _drop_flag = false; } else if (_last_seq != 0 && (uint16_t)(_last_seq + 1) != seq) { //时间戳未发生变化,但是seq却不连续,说明中间rtp丢包了,那么整帧应该废弃 diff --git a/src/Extension/CommonRtp.h b/src/Extension/CommonRtp.h index 7df29af8..6553207e 100644 --- a/src/Extension/CommonRtp.h +++ b/src/Extension/CommonRtp.h @@ -50,6 +50,7 @@ private: private: bool _drop_flag = false; uint16_t _last_seq = 0; + uint64_t _last_stamp = 0; size_t _max_frame_size; CodecId _codec; FrameImp::Ptr _frame;