mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
解决多pps问题
解决某些流因为多pps而导致不能播放的问题.
This commit is contained in:
parent
08de795220
commit
f128b35b18
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
@ -48,7 +48,8 @@ static const char *memfind(const char *buf, ssize_t len, const char *subbuf, ssi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void splitH264(const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t , size_t)> &cb) {
|
||||
void splitH264(
|
||||
const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t, size_t)> &cb) {
|
||||
auto start = ptr + prefix;
|
||||
auto end = ptr + len;
|
||||
size_t next_prefix;
|
||||
@ -180,22 +181,28 @@ bool H264Track::inputFrame_l(const Frame::Ptr &frame){
|
||||
switch (type) {
|
||||
case H264Frame::NAL_SPS: {
|
||||
_sps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
||||
_latest_is_config_frame = true;
|
||||
ret = VideoTrack::inputFrame(frame);
|
||||
break;
|
||||
}
|
||||
case H264Frame::NAL_PPS: {
|
||||
_pps = string(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
|
||||
_insert_config_frame = true;
|
||||
_latest_is_config_frame = true;
|
||||
ret = VideoTrack::inputFrame(frame);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (_insert_config_frame && !frame->dropAble()) {
|
||||
// 避免识别不出关键帧
|
||||
if (_latest_is_config_frame && !frame->dropAble()) {
|
||||
if (!frame->keyFrame()) {
|
||||
const_cast<Frame::Ptr &>(frame) = std::make_shared<FrameCacheAble>(frame, true);
|
||||
}
|
||||
insertConfigFrame(frame);
|
||||
_insert_config_frame = false;
|
||||
}
|
||||
// 判断是否是I帧, 并且如果是,那判断前面是否插入过config帧, 如果插入过就不插入了
|
||||
if (frame->keyFrame() && !_latest_is_config_frame) {
|
||||
insertConfigFrame(frame);
|
||||
}
|
||||
_latest_is_config_frame = false;
|
||||
ret = VideoTrack::inputFrame(frame);
|
||||
break;
|
||||
}
|
||||
@ -258,13 +265,9 @@ public:
|
||||
_printer << "a=control:trackID=" << (int)TrackVideo << "\r\n";
|
||||
}
|
||||
|
||||
string getSdp() const {
|
||||
return _printer;
|
||||
}
|
||||
string getSdp() const { return _printer; }
|
||||
|
||||
CodecId getCodecId() const {
|
||||
return CodecH264;
|
||||
}
|
||||
CodecId getCodecId() const { return CodecH264; }
|
||||
|
||||
private:
|
||||
_StrPrinter _printer;
|
||||
@ -279,5 +282,3 @@ Sdp::Ptr H264Track::getSdp() {
|
||||
}
|
||||
|
||||
} // namespace mediakit
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user