Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc

Issue 2963133003: More gracefully handle rtp timestamp jumps in the rtp to ntp estimator. (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/system_wrappers/source/rtp_to_ntp_estimator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
diff --git a/webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc b/webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
index 09b47b4873b3deedf984fca68dfc731c9cb41c11..cfcb13bf8d3a5245cc9ea92457e809dfa603e2cf 100644
--- a/webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
+++ b/webrtc/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc
@@ -138,6 +138,48 @@ TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) {
EXPECT_EQ(0, timestamp_ms);
}
+TEST(WrapAroundTests, GracefullyHandleRtpJump) {
+ RtpToNtpEstimator estimator;
+ bool new_sr;
+ uint32_t ntp_sec = 0;
+ uint32_t ntp_frac = 1;
+ uint32_t timestamp = 0;
+ EXPECT_TRUE(
+ estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
+ ntp_frac += kOneMsInNtpFrac;
+ timestamp += kTimestampTicksPerMs;
+ EXPECT_TRUE(
+ estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
+ ntp_frac += kOneMsInNtpFrac;
+ timestamp -= kTimestampTicksPerMs;
+ int64_t timestamp_ms = -1;
+ EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms));
+ // Constructed at the same time as the first RTCP and should therefore be
+ // mapped to zero.
+ EXPECT_EQ(0, timestamp_ms);
+
+ timestamp -= 0xFFFFF;
+ for (int i = 0; i < RtpToNtpEstimator::kMaxInvalidSamples - 1; ++i) {
+ EXPECT_FALSE(
+ estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
+ ntp_frac += kOneMsInNtpFrac;
+ timestamp += kTimestampTicksPerMs;
+ }
+ EXPECT_TRUE(
+ estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
+ ntp_frac += kOneMsInNtpFrac;
+ timestamp += kTimestampTicksPerMs;
+ EXPECT_TRUE(
+ estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
+ ntp_frac += kOneMsInNtpFrac;
+ timestamp += kTimestampTicksPerMs;
+
+ timestamp_ms = -1;
+ EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms));
+ // 6 milliseconds has passed since the start of the test.
+ EXPECT_EQ(6, timestamp_ms);
+}
+
TEST(UpdateRtcpMeasurementTests, FailsForZeroNtp) {
RtpToNtpEstimator estimator;
uint32_t ntp_sec = 0;
« no previous file with comments | « webrtc/system_wrappers/source/rtp_to_ntp_estimator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698