媒体时间戳默认改为相对时间戳,通过时间戳矫正器解决跳跃和回退问题 (#2523)

通过用户反馈发现,遇到较多直播源时间戳混乱问题,包括rtsp流之rtcp ntp时间戳混乱,国标流时间戳混乱问题。
之前默认采用源流绝对时间戳,但是由于时间戳混乱会导致hls切片异常或视频播放不了等问题。
故默认改成相对时间戳(modify_stamp=2),通过时间戳矫正器过滤了时间戳跳跃以及回退问题(强制加1ms),
同时保留了对之前时间戳覆盖(modify_stamp=1)的兼容。
该修改同时兼容点播流,在点播流开启时间戳覆盖时,不起实质作用(采用原始绝对时间戳)。
This commit is contained in:
夏楚
2023-06-03 17:34:34 +08:00
committed by GitHub
parent af57691bc8
commit e4acc59bec
9 changed files with 111 additions and 90 deletions

View File

@@ -13,6 +13,7 @@
#include "H265.h"
#include "Common/Parser.h"
#include "Common/Stamp.h"
#include "Common/MediaSource.h"
using namespace std;
using namespace toolkit;
@@ -31,11 +32,11 @@ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){
return std::make_shared<FrameCacheAble>(frame);
}
FrameStamp::FrameStamp(Frame::Ptr frame, Stamp &stamp, bool modify_stamp)
FrameStamp::FrameStamp(Frame::Ptr frame, Stamp &stamp, int modify_stamp)
{
_frame = std::move(frame);
//覆盖时间戳
stamp.revise(_frame->dts(), _frame->pts(), _dts, _pts, modify_stamp);
// kModifyStampSystem时采用系统时间戳kModifyStampRelative采用相对时间戳
stamp.revise(_frame->dts(), _frame->pts(), _dts, _pts, modify_stamp == ProtocolOption::kModifyStampSystem);
}
TrackType getTrackType(CodecId codecId) {