mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复通用rtp解码器输入小时间戳增量流在丢包时不再输出帧数据的bug (#2589)
如果rtp时间戳增量很小,在rtp时间戳在转换单位为毫秒时无变化, 从而被认为是上一帧数据,由于处于丢包状态,此rtp数据将被一直丢弃。
This commit is contained in:
parent
d5bf99a27b
commit
6aa4b741a3
@ -34,10 +34,10 @@ bool CommonRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto payload = rtp->getPayload();
|
auto payload = rtp->getPayload();
|
||||||
auto stamp = rtp->getStampMS();
|
auto stamp = rtp->getStamp();
|
||||||
auto seq = rtp->getSeq();
|
auto seq = rtp->getSeq();
|
||||||
|
|
||||||
if (_frame->_dts != stamp || _frame->_buffer.size() > _max_frame_size) {
|
if (_last_stamp != stamp || _frame->_buffer.size() > _max_frame_size) {
|
||||||
//时间戳发生变化或者缓存超过MAX_FRAME_SIZE,则清空上帧数据
|
//时间戳发生变化或者缓存超过MAX_FRAME_SIZE,则清空上帧数据
|
||||||
if (!_frame->_buffer.empty()) {
|
if (!_frame->_buffer.empty()) {
|
||||||
//有有效帧,则输出
|
//有有效帧,则输出
|
||||||
@ -46,7 +46,8 @@ bool CommonRtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool){
|
|||||||
|
|
||||||
//新的一帧数据
|
//新的一帧数据
|
||||||
obtainFrame();
|
obtainFrame();
|
||||||
_frame->_dts = stamp;
|
_frame->_dts = rtp->getStampMS();
|
||||||
|
_last_stamp = stamp;
|
||||||
_drop_flag = false;
|
_drop_flag = false;
|
||||||
} else if (_last_seq != 0 && (uint16_t)(_last_seq + 1) != seq) {
|
} else if (_last_seq != 0 && (uint16_t)(_last_seq + 1) != seq) {
|
||||||
//时间戳未发生变化,但是seq却不连续,说明中间rtp丢包了,那么整帧应该废弃
|
//时间戳未发生变化,但是seq却不连续,说明中间rtp丢包了,那么整帧应该废弃
|
||||||
|
@ -50,6 +50,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool _drop_flag = false;
|
bool _drop_flag = false;
|
||||||
uint16_t _last_seq = 0;
|
uint16_t _last_seq = 0;
|
||||||
|
uint64_t _last_stamp = 0;
|
||||||
size_t _max_frame_size;
|
size_t _max_frame_size;
|
||||||
CodecId _codec;
|
CodecId _codec;
|
||||||
FrameImp::Ptr _frame;
|
FrameImp::Ptr _frame;
|
||||||
|
Loading…
Reference in New Issue
Block a user