From dfd37ff3500d3bad11ffc05389431aa28efa6e78 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Wed, 22 Mar 2023 21:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=88=B3=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=9B=B8=E5=AF=B9=E6=97=B6=E9=97=B4=E6=88=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Stamp.cpp | 9 +++++++++ src/Common/Stamp.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/Common/Stamp.cpp b/src/Common/Stamp.cpp index 75f818be..df7f7368 100644 --- a/src/Common/Stamp.cpp +++ b/src/Common/Stamp.cpp @@ -20,6 +20,15 @@ using namespace toolkit; namespace mediakit { +int64_t DeltaStamp::relativeStamp(int64_t stamp) { + _relative_stamp += deltaStamp(stamp); + return _relative_stamp; +} + +int64_t DeltaStamp::relativeStamp(){ + return _relative_stamp; +} + int64_t DeltaStamp::deltaStamp(int64_t stamp) { if(!_last_stamp){ //第一次计算时间戳增量,时间戳增量为0 diff --git a/src/Common/Stamp.h b/src/Common/Stamp.h index f943fc40..cc2dcae0 100644 --- a/src/Common/Stamp.h +++ b/src/Common/Stamp.h @@ -28,9 +28,12 @@ public: * @return 时间戳增量 */ int64_t deltaStamp(int64_t stamp); + int64_t relativeStamp(int64_t stamp); + int64_t relativeStamp(); private: int64_t _last_stamp = 0; + int64_t _relative_stamp = 0; }; //该类解决时间戳回环、回退问题