From e4c49e379a25fa580ea56e2ecc4d80ea9ec50897 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Wed, 11 Jan 2023 14:14:51 +0000 Subject: [PATCH] [Unwrap] Migrate RtpToNtpEstimator to use RtpTimestampUnwrapper Bug: webrtc:13982 Change-Id: Ib32b374237e19d10b3d36fe981939289c34dd6e8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288965 Commit-Queue: Evan Shrubsole Auto-Submit: Evan Shrubsole Commit-Queue: Harald Alvestrand Reviewed-by: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#39075} --- system_wrappers/include/rtp_to_ntp_estimator.h | 4 ++-- .../source/rtp_to_ntp_estimator_unittest.cc | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/system_wrappers/include/rtp_to_ntp_estimator.h b/system_wrappers/include/rtp_to_ntp_estimator.h index 3b62b78608..a5c7a157b6 100644 --- a/system_wrappers/include/rtp_to_ntp_estimator.h +++ b/system_wrappers/include/rtp_to_ntp_estimator.h @@ -16,8 +16,8 @@ #include #include "absl/types/optional.h" -#include "modules/include/module_common_types_public.h" #include "rtc_base/checks.h" +#include "rtc_base/numerics/sequence_number_unwrapper.h" #include "system_wrappers/include/ntp_time.h" namespace webrtc { @@ -65,7 +65,7 @@ class RtpToNtpEstimator { int consecutive_invalid_samples_ = 0; std::list measurements_; absl::optional params_; - mutable TimestampUnwrapper unwrapper_; + mutable RtpTimestampUnwrapper unwrapper_; }; } // namespace webrtc diff --git a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc index 29de76178b..81effd9452 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc +++ b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc @@ -48,6 +48,17 @@ TEST(WrapAroundTests, OldRtcpWrapped_OldRtpTimestamp_Wraparound_Detected) { RtpToNtpEstimator::kInvalidMeasurement); } +TEST(WrapAroundTests, OldRtcpWrapped_OldRtpTimestamp_NegativeWraparound) { + RtpToNtpEstimator estimator; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0), + RtpToNtpEstimator::kNewMeasurement); + // Expected to fail since the older RTCP has a smaller RTP timestamp than the + // newer (old:0, new:-180). + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + 2 * kOneMsInNtp), + 0xFFFFFFFF - 2 * kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); +} + TEST(WrapAroundTests, NewRtcpWrapped) { RtpToNtpEstimator estimator; EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFF),