mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
parent
2bf85eb8ff
commit
824be6cbd5
@ -267,31 +267,32 @@ bool H264Track::inputFrame_l(const Frame::Ptr &frame) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case H264Frame::NAL_SPS: {
|
case H264Frame::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;
|
_latest_is_sps = true;
|
||||||
ret = VideoTrack::inputFrame(frame);
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case H264Frame::NAL_PPS: {
|
case H264Frame::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;
|
_latest_is_pps = true;
|
||||||
ret = VideoTrack::inputFrame(frame);
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// 避免识别不出关键帧 [AUTO-TRANSLATED:8eb84679]
|
// 避免识别不出关键帧 [AUTO-TRANSLATED:8eb84679]
|
||||||
// Avoid not being able to recognize keyframes
|
// Avoid not being able to recognize keyframes
|
||||||
if (_latest_is_config_frame && !frame->dropAble()) {
|
if (latestIsConfigFrame() && !frame->dropAble()) {
|
||||||
if (!frame->keyFrame()) {
|
if (!frame->keyFrame()) {
|
||||||
const_cast<Frame::Ptr &>(frame) = std::make_shared<FrameCacheAble>(frame, true);
|
const_cast<Frame::Ptr &>(frame) = std::make_shared<FrameCacheAble>(frame, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 判断是否是I帧, 并且如果是,那判断前面是否插入过config帧, 如果插入过就不插入了 [AUTO-TRANSLATED:40733cd8]
|
// 判断是否是I帧, 并且如果是,那判断前面是否插入过config帧, 如果插入过就不插入了 [AUTO-TRANSLATED:40733cd8]
|
||||||
// Determine if it is an I frame, and if it is, determine if a config frame has been inserted before, and if it has been inserted, do not insert it
|
// Determine if it is an I frame, and if it is, determine if a config frame has been inserted before, and if it has been inserted, do not insert it
|
||||||
if (frame->keyFrame() && !_latest_is_config_frame) {
|
if (frame->keyFrame() && !latestIsConfigFrame()) {
|
||||||
insertConfigFrame(frame);
|
insertConfigFrame(frame);
|
||||||
}
|
}
|
||||||
if(!frame->dropAble()){
|
if(!frame->dropAble()){
|
||||||
_latest_is_config_frame = false;
|
_latest_is_pps = false;
|
||||||
|
_latest_is_sps = false;
|
||||||
}
|
}
|
||||||
ret = VideoTrack::inputFrame(frame);
|
ret = VideoTrack::inputFrame(frame);
|
||||||
break;
|
break;
|
||||||
@ -313,6 +314,10 @@ void H264Track::insertConfigFrame(const Frame::Ptr &frame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool H264Track::latestIsConfigFrame(){
|
||||||
|
return _latest_is_sps && _latest_is_pps;
|
||||||
|
}
|
||||||
|
|
||||||
class H264Sdp : public Sdp {
|
class H264Sdp : public Sdp {
|
||||||
public:
|
public:
|
||||||
H264Sdp(const string &strSPS, const string &strPPS, int payload_type, int bitrate) : Sdp(90000, payload_type) {
|
H264Sdp(const string &strSPS, const string &strPPS, int payload_type, int bitrate) : Sdp(90000, payload_type) {
|
||||||
|
|||||||
@ -146,8 +146,11 @@ private:
|
|||||||
bool inputFrame_l(const Frame::Ptr &frame);
|
bool inputFrame_l(const Frame::Ptr &frame);
|
||||||
void insertConfigFrame(const Frame::Ptr &frame);
|
void insertConfigFrame(const Frame::Ptr &frame);
|
||||||
|
|
||||||
|
bool latestIsConfigFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _latest_is_config_frame = false;
|
bool _latest_is_pps = false;
|
||||||
|
bool _latest_is_sps = 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