rtmp packet must has vlc when flush

This commit is contained in:
xiongguangjie 2021-06-19 01:54:57 +08:00
parent a28aeb2148
commit d215502ff5
3 changed files with 16 additions and 3 deletions

View File

@ -182,8 +182,8 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
break;
}
}
if((frame->configFrame() || frame->keyFrame()) && _lastPacket){
// key frame or sps pps flush frame
if(frame->configFrame() && _lastPacket &&_lastPacketHasVCL){
//sps pps flush frame
RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr;
_lastPacketHasVCL = false;

View File

@ -169,9 +169,21 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
return;// 防止sei aud 作为一帧
}
if (_lastPacket && (_lastPacket->time_stamp != frame->dts() || (type >=H264Frame::NAL_B_P && type<=H264Frame::NAL_IDR && (pcData[2]>>7 &0x01) !=0))) {
if(frame->configFrame() && _lastPacket &&_lastPacketHasVCL){
// sps pps flush frame
RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr;
_lastPacketHasVCL = false;
}
if (_lastPacket && (_lastPacket->time_stamp != frame->dts() || (_lastPacketHasVCL &&type>=H265Frame::NAL_TRAIL_R &&type<= H265Frame::NAL_RSV_IRAP_VCL23 && (pcData[2]>>7 &0x01) !=0))) {
RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr;
_lastPacketHasVCL = false;
}
if(type>=H265Frame::NAL_TRAIL_R &&type<= H265Frame::NAL_RSV_IRAP_VCL23){
_lastPacketHasVCL = true;
}
if(!_lastPacket) {

View File

@ -84,6 +84,7 @@ private:
string _pps;
H265Track::Ptr _track;
RtmpPacket::Ptr _lastPacket;
bool _lastPacketHasVCL = false;
};
}//namespace mediakit