mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
性能优化
This commit is contained in:
parent
d76c38ef72
commit
880b9139b0
@ -185,12 +185,12 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ssrc, uint32_t mtu, uint32_t sample_rate
|
|||||||
}
|
}
|
||||||
|
|
||||||
void H264RtpEncoder::insertConfigFrame(uint32_t pts){
|
void H264RtpEncoder::insertConfigFrame(uint32_t pts){
|
||||||
if (_sps.empty() || _pps.empty()) {
|
if (!_sps || !_pps) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//gop缓存从sps开始,sps、pps后面还有时间戳相同的关键帧,所以mark bit为false
|
//gop缓存从sps开始,sps、pps后面还有时间戳相同的关键帧,所以mark bit为false
|
||||||
packRtp(_sps.data(), _sps.size(), pts, false, true);
|
packRtp(_sps->data() + _sps->prefixSize(), _sps->size() - _sps->prefixSize(), pts, false, true);
|
||||||
packRtp(_pps.data(), _pps.size(), pts, false, false);
|
packRtp(_pps->data() + _pps->prefixSize(), _pps->size() - _pps->prefixSize(), pts, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void H264RtpEncoder::packRtp(const char *ptr, size_t len, uint32_t pts, bool is_mark, bool gop_pos){
|
void H264RtpEncoder::packRtp(const char *ptr, size_t len, uint32_t pts, bool is_mark, bool gop_pos){
|
||||||
@ -258,18 +258,17 @@ void H264RtpEncoder::packRtpStapA(const char *ptr, size_t len, uint32_t pts, boo
|
|||||||
|
|
||||||
void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||||
auto ptr = frame->data() + frame->prefixSize();
|
auto ptr = frame->data() + frame->prefixSize();
|
||||||
auto len = frame->size() - frame->prefixSize();
|
|
||||||
switch (H264_TYPE(ptr[0])) {
|
switch (H264_TYPE(ptr[0])) {
|
||||||
case H264Frame::NAL_AUD:
|
case H264Frame::NAL_AUD:
|
||||||
case H264Frame::NAL_SEI : {
|
case H264Frame::NAL_SEI : {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case H264Frame::NAL_SPS: {
|
case H264Frame::NAL_SPS: {
|
||||||
_sps = std::string(ptr, len);
|
_sps = Frame::getCacheAbleFrame(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case H264Frame::NAL_PPS: {
|
case H264Frame::NAL_PPS: {
|
||||||
_pps = std::string(ptr, len);
|
_pps = Frame::getCacheAbleFrame(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
|
@ -89,8 +89,8 @@ private:
|
|||||||
void packRtpStapA(const char *data, size_t len, uint32_t pts, bool is_mark, bool gop_pos);
|
void packRtpStapA(const char *data, size_t len, uint32_t pts, bool is_mark, bool gop_pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string _sps;
|
Frame::Ptr _sps;
|
||||||
string _pps;
|
Frame::Ptr _pps;
|
||||||
Frame::Ptr _last_frame;
|
Frame::Ptr _last_frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user