修复H264/H265创建config帧异常问题(#3643)

https://github.com/ZLMediaKit/ZLMediaKit/pull/3611#issuecomment-2177535917
This commit is contained in:
Xiaofeng Wang 2024-06-19 14:05:23 +08:00 committed by GitHub
parent 84dbe4b076
commit efc683228c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 10 deletions

View File

@ -236,8 +236,8 @@ void H264Track::setExtraData(const uint8_t *data, size_t bytes) {
bool H264Track::update() { bool H264Track::update() {
_config_frames = std::vector<Frame::Ptr>{ _config_frames = std::vector<Frame::Ptr>{
createConfigFrame<H264Frame>(_sps), createConfigFrame<H264Frame>(_sps, 0, getIndex()),
createConfigFrame<H264Frame>(_pps) createConfigFrame<H264Frame>(_pps, 0, getIndex())
}; };
return getAVCInfo(_sps, _width, _height, _fps); return getAVCInfo(_sps, _width, _height, _fps);
} }

View File

@ -134,8 +134,8 @@ private:
}; };
template <typename FrameType> template <typename FrameType>
Frame::Ptr createConfigFrame(const std::string &data, uint64_t dts = 0, int index = 0) { Frame::Ptr createConfigFrame(const std::string &data, uint64_t dts, int index) {
auto frame = FrameType::create(); auto frame = FrameImp::create<FrameType>();
frame->_prefix_size = 4; frame->_prefix_size = 4;
frame->_buffer.assign("\x00\x00\x00\x01", 4); frame->_buffer.assign("\x00\x00\x00\x01", 4);
frame->_buffer.append(data); frame->_buffer.append(data);

View File

@ -183,9 +183,9 @@ void H265Track::setExtraData(const uint8_t *data, size_t bytes) {
bool H265Track::update() { bool H265Track::update() {
_config_frames = std::vector<Frame::Ptr>{ _config_frames = std::vector<Frame::Ptr>{
createConfigFrame<H265Frame>(_vps), createConfigFrame<H265Frame>(_vps, 0, getIndex()),
createConfigFrame<H265Frame>(_sps), createConfigFrame<H265Frame>(_sps, 0, getIndex()),
createConfigFrame<H265Frame>(_pps) createConfigFrame<H265Frame>(_pps, 0, getIndex())
}; };
return getHEVCInfo(_vps, _sps, _width, _height, _fps); return getHEVCInfo(_vps, _sps, _width, _height, _fps);
} }
@ -199,13 +199,13 @@ void H265Track::insertConfigFrame(const Frame::Ptr &frame) {
return; return;
} }
if (!_vps.empty()) { if (!_vps.empty()) {
VideoTrack::inputFrame(createConfigFrame<H265Frame>(_vps)); VideoTrack::inputFrame(createConfigFrame<H265Frame>(_vps, frame->dts(), frame->getIndex()));
} }
if (!_sps.empty()) { if (!_sps.empty()) {
VideoTrack::inputFrame(createConfigFrame<H265Frame>(_sps)); VideoTrack::inputFrame(createConfigFrame<H265Frame>(_sps, frame->dts(), frame->getIndex()));
} }
if (!_pps.empty()) { if (!_pps.empty()) {
VideoTrack::inputFrame(createConfigFrame<H265Frame>(_pps)); VideoTrack::inputFrame(createConfigFrame<H265Frame>(_pps, frame->dts(), frame->getIndex()));
} }
} }