防止时间戳跳变

This commit is contained in:
xiongziliang 2019-09-30 16:51:17 +08:00
parent 119d8d824f
commit b573b5bbac

View File

@ -49,7 +49,8 @@ void Stamp::revise(uint32_t dts, uint32_t pts, int64_t &dts_out, int64_t &pts_ou
//相对时间戳 //相对时间戳
dts_out = dts - _start_dts; dts_out = dts - _start_dts;
if(dts_out < _dts_inc && !_playback){ if(!_playback){
if(dts_out < _dts_inc){
//本次相对时间戳竟然小于上次? //本次相对时间戳竟然小于上次?
if(dts_out < 0 || _dts_inc - dts_out > 0xFFFF){ if(dts_out < 0 || _dts_inc - dts_out > 0xFFFF){
//时间戳回环,保证下次相对时间戳与本次相对合理增长 //时间戳回环,保证下次相对时间戳与本次相对合理增长
@ -60,7 +61,12 @@ void Stamp::revise(uint32_t dts, uint32_t pts, int64_t &dts_out, int64_t &pts_ou
//时间戳变小了?,那么取上次时间戳 //时间戳变小了?,那么取上次时间戳
dts_out = _dts_inc; dts_out = _dts_inc;
} }
}else if(dts_out - _dts_inc > 1000){
//直播时,不允许时间戳跳跃性增加
dts_out = _dts_inc;
} }
}
//保留这次相对时间戳,以便下次对比是否回环或乱序 //保留这次相对时间戳,以便下次对比是否回环或乱序
_dts_inc = dts_out; _dts_inc = dts_out;