[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 <eshr@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39075}
This commit is contained in:
Evan Shrubsole 2023-01-11 14:14:51 +00:00 committed by WebRTC LUCI CQ
parent e6b4cbe606
commit e4c49e379a
2 changed files with 13 additions and 2 deletions

View file

@ -16,8 +16,8 @@
#include <list>
#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<RtcpMeasurement> measurements_;
absl::optional<Parameters> params_;
mutable TimestampUnwrapper unwrapper_;
mutable RtpTimestampUnwrapper unwrapper_;
};
} // namespace webrtc

View file

@ -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),