From 0a4b59031f99f8f998a4d04a9fb57753e12cfaac Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 14 Jan 2020 19:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8A=E6=97=B6=E6=8E=A8=E6=8B=89=E6=B5=81?= =?UTF-8?q?=E4=B9=9F=E8=83=BD=E7=A1=AE=E4=BF=9D=E7=AC=AC=E4=B8=80=E5=B8=A7?= =?UTF-8?q?=E4=B8=BA=E5=85=B3=E9=94=AE=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- src/Extension/H264Rtp.cpp | 12 +++++++++--- src/Extension/H265Rtp.cpp | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 72013f51..a6b41db9 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 72013f5128d8c04bad8b973370da463c311081c0 +Subproject commit a6b41db987aa2633762fd06e809e0fdb7d60fef0 diff --git a/src/Extension/H264Rtp.cpp b/src/Extension/H264Rtp.cpp index f90f3c56..5df37767 100644 --- a/src/Extension/H264Rtp.cpp +++ b/src/Extension/H264Rtp.cpp @@ -189,9 +189,8 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { //该帧最后一个rtp包 FU-A end _h264frame->_buffer.append((char *)frame + 2, length - 2); _h264frame->_pts = rtppack->timeStamp; - auto key = _h264frame->keyFrame(); onGetH264(_h264frame); - return key; + return false; } default:{ @@ -209,8 +208,15 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { } void H264RtpDecoder::onGetH264(const H264Frame::Ptr &frame) { - //根据pts计算dts auto flag = _dts_generator.getDts(frame->_pts,frame->_dts); + if(!flag){ + if(frame->configFrame() || frame->keyFrame()){ + flag = true; + frame->_dts = frame->_pts; + } + } + + //根据pts计算dts if(flag){ //写入环形缓存 RtpCodec::inputFrame(frame); diff --git a/src/Extension/H265Rtp.cpp b/src/Extension/H265Rtp.cpp index 4b8df94c..8f41ec76 100644 --- a/src/Extension/H265Rtp.cpp +++ b/src/Extension/H265Rtp.cpp @@ -127,9 +127,8 @@ bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { //该帧最后一个rtp包 _h265frame->_buffer.append((char *) frame + 3, length - 3); _h265frame->_pts = rtppack->timeStamp; - auto key = _h265frame->keyFrame(); onGetH265(_h265frame); - return key; + return false; } default: // 4.4.1. Single NAL Unit Packets (p24) @@ -146,6 +145,12 @@ bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { void H265RtpDecoder::onGetH265(const H265Frame::Ptr &frame) { //计算dts auto flag = _dts_generator.getDts(frame->_pts,frame->_dts); + if(!flag){ + if(frame->configFrame() || frame->keyFrame()){ + flag = true; + frame->_dts = frame->_pts; + } + } if(flag){ //写入环形缓存 RtpCodec::inputFrame(frame);