From efc683228c67b7d0a8fce1a1ad09d6fe3e6c55ac Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Wed, 19 Jun 2024 14:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DH264/H265=E5=88=9B=E5=BB=BAco?= =?UTF-8?q?nfig=E5=B8=A7=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98(#3643)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ZLMediaKit/ZLMediaKit/pull/3611#issuecomment-2177535917 --- ext-codec/H264.cpp | 4 ++-- ext-codec/H264.h | 4 ++-- ext-codec/H265.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext-codec/H264.cpp b/ext-codec/H264.cpp index 953c11fe..7f796ea0 100644 --- a/ext-codec/H264.cpp +++ b/ext-codec/H264.cpp @@ -236,8 +236,8 @@ void H264Track::setExtraData(const uint8_t *data, size_t bytes) { bool H264Track::update() { _config_frames = std::vector{ - createConfigFrame(_sps), - createConfigFrame(_pps) + createConfigFrame(_sps, 0, getIndex()), + createConfigFrame(_pps, 0, getIndex()) }; return getAVCInfo(_sps, _width, _height, _fps); } diff --git a/ext-codec/H264.h b/ext-codec/H264.h index 9940854c..9d662037 100644 --- a/ext-codec/H264.h +++ b/ext-codec/H264.h @@ -134,8 +134,8 @@ private: }; template -Frame::Ptr createConfigFrame(const std::string &data, uint64_t dts = 0, int index = 0) { - auto frame = FrameType::create(); +Frame::Ptr createConfigFrame(const std::string &data, uint64_t dts, int index) { + auto frame = FrameImp::create(); frame->_prefix_size = 4; frame->_buffer.assign("\x00\x00\x00\x01", 4); frame->_buffer.append(data); diff --git a/ext-codec/H265.cpp b/ext-codec/H265.cpp index cc0831f6..4bf3e2ff 100644 --- a/ext-codec/H265.cpp +++ b/ext-codec/H265.cpp @@ -183,9 +183,9 @@ void H265Track::setExtraData(const uint8_t *data, size_t bytes) { bool H265Track::update() { _config_frames = std::vector{ - createConfigFrame(_vps), - createConfigFrame(_sps), - createConfigFrame(_pps) + createConfigFrame(_vps, 0, getIndex()), + createConfigFrame(_sps, 0, getIndex()), + createConfigFrame(_pps, 0, getIndex()) }; return getHEVCInfo(_vps, _sps, _width, _height, _fps); } @@ -199,13 +199,13 @@ void H265Track::insertConfigFrame(const Frame::Ptr &frame) { return; } if (!_vps.empty()) { - VideoTrack::inputFrame(createConfigFrame(_vps)); + VideoTrack::inputFrame(createConfigFrame(_vps, frame->dts(), frame->getIndex())); } if (!_sps.empty()) { - VideoTrack::inputFrame(createConfigFrame(_sps)); + VideoTrack::inputFrame(createConfigFrame(_sps, frame->dts(), frame->getIndex())); } if (!_pps.empty()) { - VideoTrack::inputFrame(createConfigFrame(_pps)); + VideoTrack::inputFrame(createConfigFrame(_pps, frame->dts(), frame->getIndex())); } }