diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 4d8ca72d91..e410fdad23 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -210,6 +210,7 @@ rtc_static_library("rtp_rtcp") { "../../rtc_base:sequenced_task_checker", "../../rtc_base:stringutils", "../../rtc_base/system:fallthrough", + "../../rtc_base/time:timestamp_extrapolator", "../../system_wrappers", "../../system_wrappers:field_trial_api", "../../system_wrappers:metrics_api", diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index e3a4ed91e5..fc867a491a 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -11,6 +11,7 @@ #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" #include "rtc_base/logging.h" +#include "rtc_base/time/timestamp_extrapolator.h" #include "system_wrappers/include/clock.h" namespace webrtc { diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 0a90141117..ad2d35987b 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -153,6 +153,7 @@ rtc_static_library("video_coding") { "../../rtc_base:sequenced_task_checker", "../../rtc_base/experiments:alr_experiment", "../../rtc_base/system:fallthrough", + "../../rtc_base/time:timestamp_extrapolator", "../../system_wrappers", "../../system_wrappers:field_trial_api", "../../system_wrappers:metrics_api", diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc index 459345a2ce..2ad61524e3 100644 --- a/modules/video_coding/timing.cc +++ b/modules/video_coding/timing.cc @@ -12,9 +12,9 @@ #include +#include "rtc_base/time/timestamp_extrapolator.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/timestamp_extrapolator.h" namespace webrtc { diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn new file mode 100644 index 0000000000..6c6baa97c6 --- /dev/null +++ b/rtc_base/time/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +import("../../webrtc.gni") +if (is_android) { + import("//build/config/android/config.gni") + import("//build/config/android/rules.gni") +} + +rtc_source_set("timestamp_extrapolator") { + sources = [ + "timestamp_extrapolator.cc", + "timestamp_extrapolator.h", + ] + deps = [ + "../..:typedefs", + "../../system_wrappers", + ] +} diff --git a/system_wrappers/source/timestamp_extrapolator.cc b/rtc_base/time/timestamp_extrapolator.cc similarity index 92% rename from system_wrappers/source/timestamp_extrapolator.cc rename to rtc_base/time/timestamp_extrapolator.cc index b8c6ba0934..bf9f726c42 100644 --- a/system_wrappers/source/timestamp_extrapolator.cc +++ b/rtc_base/time/timestamp_extrapolator.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "system_wrappers/include/timestamp_extrapolator.h" +#include "rtc_base/time/timestamp_extrapolator.h" #include @@ -178,12 +178,14 @@ void TimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz) { // Forward wrap around _wrapArounds++; } - } - // This difference will probably be less than -2^31 if we have had a backward - // wrap around. Since it is casted to a Word32, it should be positive. - else if (static_cast(_prevWrapTimestamp - ts90khz) > 0) { - // Backward wrap around - _wrapArounds--; + } else { + // This difference will probably be less than -2^31 if we have had a + // backward wrap around. Since it is casted to a Word32, it should be + // positive. + if (static_cast(_prevWrapTimestamp - ts90khz) > 0) { + // Backward wrap around + _wrapArounds--; + } } _prevWrapTimestamp = ts90khz; } @@ -193,9 +195,9 @@ bool TimestampExtrapolator::DelayChangeDetection(double error) { error = (error > 0) ? std::min(error, _accMaxError) : std::max(error, -_accMaxError); _detectorAccumulatorPos = - std::max(_detectorAccumulatorPos + error - _accDrift, (double)0); + std::max(_detectorAccumulatorPos + error - _accDrift, double{0}); _detectorAccumulatorNeg = - std::min(_detectorAccumulatorNeg + error + _accDrift, (double)0); + std::min(_detectorAccumulatorNeg + error + _accDrift, double{0}); if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -_alarmThreshold) { // Alarm diff --git a/system_wrappers/include/timestamp_extrapolator.h b/rtc_base/time/timestamp_extrapolator.h similarity index 89% rename from system_wrappers/include/timestamp_extrapolator.h rename to rtc_base/time/timestamp_extrapolator.h index 9418100373..cd4f5f422f 100644 --- a/system_wrappers/include/timestamp_extrapolator.h +++ b/rtc_base/time/timestamp_extrapolator.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ -#define SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ +#ifndef RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ +#define RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ #include "system_wrappers/include/rw_lock_wrapper.h" #include "typedefs.h" // NOLINT(build/include) @@ -51,4 +51,4 @@ class TimestampExtrapolator { } // namespace webrtc -#endif // SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ +#endif // RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 9d339bec8c..ca0dff1ddd 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -23,7 +23,6 @@ rtc_static_library("system_wrappers") { "include/rtp_to_ntp_estimator.h", "include/rw_lock_wrapper.h", "include/sleep.h", - "include/timestamp_extrapolator.h", "source/clock.cc", "source/cpu_features.cc", "source/cpu_info.cc", @@ -40,7 +39,6 @@ rtc_static_library("system_wrappers") { "source/rw_lock_win.cc", "source/rw_lock_win.h", "source/sleep.cc", - "source/timestamp_extrapolator.cc", ] defines = [] diff --git a/video/BUILD.gn b/video/BUILD.gn index 32b05f7fa9..50deea8b75 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -94,6 +94,7 @@ rtc_static_library("video") { "../rtc_base:rtc_task_queue", "../rtc_base:sequenced_task_checker", "../rtc_base:weak_ptr", + "../rtc_base/time:timestamp_extrapolator", "../system_wrappers", ] diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index a661bc64df..41b8e9f0e8 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -37,7 +37,6 @@ #include "rtc_base/system/fallthrough.h" #include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" -#include "system_wrappers/include/timestamp_extrapolator.h" #include "video/receive_statistics_proxy.h" namespace webrtc {