From 75860702559a433311dabfe780932b27509254ac Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 16 Nov 2018 14:46:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=A7=A3=E5=86=B3=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E8=81=94=E7=B3=BBIDR=E5=B8=A7=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=92=AD=E6=94=BE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/H264.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Extension/H264.h b/src/Extension/H264.h index cde42659..09960787 100644 --- a/src/Extension/H264.h +++ b/src/Extension/H264.h @@ -205,7 +205,6 @@ public: */ void inputFrame(const Frame::Ptr &frame) override{ int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); - switch (type){ case H264Frame::NAL_SPS:{ //sps @@ -220,7 +219,7 @@ public: case H264Frame::NAL_IDR:{ //I - if(!_sps.empty()){ + if(!_sps.empty() && _last_frame_type != H264Frame::NAL_IDR){ if(!_spsFrame) { H264Frame::Ptr insertFrame = std::make_shared(); @@ -235,7 +234,7 @@ public: VideoTrack::inputFrame(_spsFrame); } - if(!_pps.empty()){ + if(!_pps.empty() && _last_frame_type != H264Frame::NAL_IDR){ if(!_ppsFrame) { H264Frame::Ptr insertFrame = std::make_shared(); @@ -250,12 +249,14 @@ public: VideoTrack::inputFrame(_ppsFrame); } VideoTrack::inputFrame(frame); + _last_frame_type = type; } break; case H264Frame::NAL_B_P:{ //B or P VideoTrack::inputFrame(frame); + _last_frame_type = type; } break; } @@ -280,6 +281,7 @@ private: int _width = 0; int _height = 0; float _fps = 0; + int _last_frame_type = -1; H264Frame::Ptr _spsFrame; H264Frame::Ptr _ppsFrame; };