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; }; //该类解决时间戳回环、回退问题