1、修复生成的rtmp无法被flash播放的问题

2、修复RTSP有B帧时,相对时间戳计算异常的问题
This commit is contained in:
xiongziliang
2020-01-13 11:51:29 +08:00
parent db146406c3
commit 66ec67bfb9
4 changed files with 21 additions and 12 deletions

View File

@@ -27,25 +27,27 @@
#include "Stamp.h"
#define MAX_DELTA_STAMP 300
#define ABS(x) ((x) > 0 ? (x) : (-x))
namespace mediakit {
int64_t DeltaStamp::deltaStamp(int64_t stamp) {
if(!_last_stamp){
//第一次计算时间戳增量,时间戳增量为0
_last_stamp = stamp;
if(stamp){
_last_stamp = stamp;
}
return 0;
}
int64_t ret = stamp - _last_stamp;
if(ret >= 0){
//时间戳增量为正,返回之
if(ABS(ret) < MAX_DELTA_STAMP){
//时间戳变化不明显
_last_stamp = stamp;
//在直播情况下时间戳增量不得大于MAX_DELTA_STAMP
return ret < MAX_DELTA_STAMP ? ret : (_playback ? ret : 0);
return ret;
}
//时间戳增量为负,说明时间戳回环了或回退
//时间戳变化太明显可能回环了或者seek
_last_stamp = stamp;
return _playback ? ret : 0;
}