mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
防止时间戳跳变
This commit is contained in:
parent
119d8d824f
commit
b573b5bbac
@ -49,19 +49,25 @@ 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){
|
||||||
_start_dts = dts - _dts_inc;
|
//时间戳回环,保证下次相对时间戳与本次相对合理增长
|
||||||
//本次时间戳强制等于上次时间戳
|
_start_dts = dts - _dts_inc;
|
||||||
dts_out = _dts_inc;
|
//本次时间戳强制等于上次时间戳
|
||||||
}else{
|
dts_out = _dts_inc;
|
||||||
//时间戳变小了?,那么取上次时间戳
|
}else{
|
||||||
|
//时间戳变小了?,那么取上次时间戳
|
||||||
|
dts_out = _dts_inc;
|
||||||
|
}
|
||||||
|
}else if(dts_out - _dts_inc > 1000){
|
||||||
|
//直播时,不允许时间戳跳跃性增加
|
||||||
dts_out = _dts_inc;
|
dts_out = _dts_inc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//保留这次相对时间戳,以便下次对比是否回环或乱序
|
//保留这次相对时间戳,以便下次对比是否回环或乱序
|
||||||
_dts_inc = dts_out;
|
_dts_inc = dts_out;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user