From 5322a5761b1d35f188ad58c5ead3d56c5834ce2d Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 16 Dec 2019 16:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E6=88=B3?= =?UTF-8?q?=E8=B7=B3=E8=B7=83=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Stamp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Common/Stamp.cpp b/src/Common/Stamp.cpp index f3507869..9d2c2d45 100644 --- a/src/Common/Stamp.cpp +++ b/src/Common/Stamp.cpp @@ -26,6 +26,8 @@ #include "Stamp.h" +#define MAX_DELTA_STAMP 300 + namespace mediakit { int64_t DeltaStamp::deltaStamp(int64_t stamp) { @@ -39,7 +41,8 @@ int64_t DeltaStamp::deltaStamp(int64_t stamp) { if(ret >= 0){ //时间戳增量为正,返回之 _last_stamp = stamp; - return ret; + //在直播情况下,时间戳增量不得大于MAX_DELTA_STAMP + return ret < MAX_DELTA_STAMP ? ret : (_playback ? ret : 0); } //时间戳增量为负,说明时间戳回环了或回退了 @@ -72,8 +75,8 @@ void Stamp::revise(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_out, dts_out = _relativeStamp; //////////////以下是播放时间戳的计算////////////////// - if(pts_dts_diff > 200 || pts_dts_diff < -200){ - //如果差值大于200毫秒,则认为由于回环导致时间戳错乱了 + if(pts_dts_diff > MAX_DELTA_STAMP || pts_dts_diff < -MAX_DELTA_STAMP){ + //如果差值太大,则认为由于回环导致时间戳错乱了 pts_dts_diff = 0; }