Commit d215502f by xiongguangjie

rtmp packet must has vlc when flush

parent a28aeb21
...@@ -182,8 +182,8 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { ...@@ -182,8 +182,8 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
break; break;
} }
} }
if((frame->configFrame() || frame->keyFrame()) && _lastPacket){ if(frame->configFrame() && _lastPacket &&_lastPacketHasVCL){
// key frame or sps pps flush frame //sps pps flush frame
RtmpCodec::inputRtmp(_lastPacket); RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr; _lastPacket = nullptr;
_lastPacketHasVCL = false; _lastPacketHasVCL = false;
......
...@@ -169,9 +169,21 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) { ...@@ -169,9 +169,21 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
return;// 防止sei aud 作为一帧 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); RtmpCodec::inputRtmp(_lastPacket);
_lastPacket = nullptr; _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) { if(!_lastPacket) {
......
...@@ -84,6 +84,7 @@ private: ...@@ -84,6 +84,7 @@ private:
string _pps; string _pps;
H265Track::Ptr _track; H265Track::Ptr _track;
RtmpPacket::Ptr _lastPacket; RtmpPacket::Ptr _lastPacket;
bool _lastPacketHasVCL = false;
}; };
}//namespace mediakit }//namespace mediakit
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论