From bb63273c73521d07cc2e47308c4a0c5957686667 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Mon, 23 Aug 2021 21:48:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97dts=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=80=E4=BA=9B=E5=A5=87=E6=80=AA=E7=9A=84?= =?UTF-8?q?rtsp=E6=B5=81:#1031?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264Rtp.cpp | 9 +++++++-- src/Extension/H265Rtp.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Extension/H264Rtp.cpp b/src/Extension/H264Rtp.cpp index 73435357..a729a1a3 100644 --- a/src/Extension/H264Rtp.cpp +++ b/src/Extension/H264Rtp.cpp @@ -169,8 +169,13 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtp) { } void H264RtpDecoder::outputFrame(const RtpPacket::Ptr &rtp, const H264Frame::Ptr &frame) { - //rtsp没有dts,那么根据pts排序算法生成dts - _dts_generator.getDts(frame->_pts, frame->_dts); + if (frame->dropAble()) { + //不参与dts生成 + frame->_dts = frame->_pts; + } else { + //rtsp没有dts,那么根据pts排序算法生成dts + _dts_generator.getDts(frame->_pts, frame->_dts); + } if (frame->keyFrame() && _gop_dropped) { _gop_dropped = false; diff --git a/src/Extension/H265Rtp.cpp b/src/Extension/H265Rtp.cpp index f783c709..09247929 100644 --- a/src/Extension/H265Rtp.cpp +++ b/src/Extension/H265Rtp.cpp @@ -222,8 +222,13 @@ bool H265RtpDecoder::singleFrame(const RtpPacket::Ptr &rtp, const uint8_t *ptr, } void H265RtpDecoder::outputFrame(const RtpPacket::Ptr &rtp, const H265Frame::Ptr &frame) { - //rtsp没有dts,那么根据pts排序算法生成dts - _dts_generator.getDts(frame->_pts, frame->_dts); + if (frame->dropAble()) { + //不参与dts生成 + frame->_dts = frame->_pts; + } else { + //rtsp没有dts,那么根据pts排序算法生成dts + _dts_generator.getDts(frame->_pts, frame->_dts); + } if (frame->keyFrame() && _gop_dropped) { _gop_dropped = false;