mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
Fix H.265 multi-PPS frame compatibility issue (#3902)
This commit is contained in:
parent
7c914666f2
commit
2cc69d1be6
@ -106,30 +106,35 @@ bool H265Track::inputFrame(const Frame::Ptr &frame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool H265Track::inputFrame_l(const Frame::Ptr &frame) {
|
bool H265Track::inputFrame_l(const Frame::Ptr &frame) {
|
||||||
if (frame->keyFrame()) {
|
int type = H265_TYPE(frame->data()[frame->prefixSize()]);
|
||||||
insertConfigFrame(frame);
|
|
||||||
_is_idr = true;
|
|
||||||
return VideoTrack::inputFrame(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
_is_idr = false;
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
switch (type) {
|
||||||
//非idr帧
|
|
||||||
switch (H265_TYPE( frame->data()[frame->prefixSize()])) {
|
|
||||||
case H265Frame::NAL_VPS: {
|
case H265Frame::NAL_VPS: {
|
||||||
_vps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
_vps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
||||||
|
_latest_is_config_frame = true;
|
||||||
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H265Frame::NAL_SPS: {
|
case H265Frame::NAL_SPS: {
|
||||||
_sps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
_sps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
||||||
|
_latest_is_config_frame = true;
|
||||||
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H265Frame::NAL_PPS: {
|
case H265Frame::NAL_PPS: {
|
||||||
_pps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
_pps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
||||||
|
_latest_is_config_frame = true;
|
||||||
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
// 判断是否是I帧, 并且如果是,那判断前面是否插入过config帧, 如果插入过就不插入了
|
||||||
|
if (frame->keyFrame() && !_latest_is_config_frame) {
|
||||||
|
insertConfigFrame(frame);
|
||||||
|
}
|
||||||
|
if (!frame->dropAble()) {
|
||||||
|
_latest_is_config_frame = false;
|
||||||
|
}
|
||||||
ret = VideoTrack::inputFrame(frame);
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -199,9 +204,6 @@ Track::Ptr H265Track::clone() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void H265Track::insertConfigFrame(const Frame::Ptr &frame) {
|
void H265Track::insertConfigFrame(const Frame::Ptr &frame) {
|
||||||
if (_is_idr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_vps.empty()) {
|
if (!_vps.empty()) {
|
||||||
VideoTrack::inputFrame(createConfigFrame<H265Frame>(_vps, frame->dts(), frame->getIndex()));
|
VideoTrack::inputFrame(createConfigFrame<H265Frame>(_vps, frame->dts(), frame->getIndex()));
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ private:
|
|||||||
void insertConfigFrame(const Frame::Ptr &frame);
|
void insertConfigFrame(const Frame::Ptr &frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_idr = false;
|
bool _latest_is_config_frame = false;
|
||||||
int _width = 0;
|
int _width = 0;
|
||||||
int _height = 0;
|
int _height = 0;
|
||||||
float _fps = 0;
|
float _fps = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user