mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-24 18:22:20 +08:00
1、修复生成的rtmp无法被flash播放的问题
2、修复RTSP有B帧时,相对时间戳计算异常的问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user