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

Side by Side 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, 5 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 EXPECT_TRUE( 131 EXPECT_TRUE(
132 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); 132 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
133 timestamp -= kTimestampTicksPerMs; 133 timestamp -= kTimestampTicksPerMs;
134 int64_t timestamp_ms = -1; 134 int64_t timestamp_ms = -1;
135 EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms)); 135 EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms));
136 // Constructed at the same time as the first RTCP and should therefore be 136 // Constructed at the same time as the first RTCP and should therefore be
137 // mapped to zero. 137 // mapped to zero.
138 EXPECT_EQ(0, timestamp_ms); 138 EXPECT_EQ(0, timestamp_ms);
139 } 139 }
140 140
141 TEST(WrapAroundTests, GracefullyHandleRtpJump) {
142 RtpToNtpEstimator estimator;
143 bool new_sr;
144 uint32_t ntp_sec = 0;
145 uint32_t ntp_frac = 1;
146 uint32_t timestamp = 0;
147 EXPECT_TRUE(
148 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
149 ntp_frac += kOneMsInNtpFrac;
150 timestamp += kTimestampTicksPerMs;
151 EXPECT_TRUE(
152 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
153 ntp_frac += kOneMsInNtpFrac;
154 timestamp -= kTimestampTicksPerMs;
155 int64_t timestamp_ms = -1;
156 EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms));
157 // Constructed at the same time as the first RTCP and should therefore be
158 // mapped to zero.
159 EXPECT_EQ(0, timestamp_ms);
160
161 timestamp -= 0xFFFFF;
162 for (int i = 0; i < RtpToNtpEstimator::kMaxInvalidSamples - 1; ++i) {
163 EXPECT_FALSE(
164 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
165 ntp_frac += kOneMsInNtpFrac;
166 timestamp += kTimestampTicksPerMs;
167 }
168 EXPECT_TRUE(
169 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
170 ntp_frac += kOneMsInNtpFrac;
171 timestamp += kTimestampTicksPerMs;
172 EXPECT_TRUE(
173 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
174 ntp_frac += kOneMsInNtpFrac;
175 timestamp += kTimestampTicksPerMs;
176
177 timestamp_ms = -1;
178 EXPECT_TRUE(estimator.Estimate(timestamp, &timestamp_ms));
179 // 6 milliseconds has passed since the start of the test.
180 EXPECT_EQ(6, timestamp_ms);
181 }
182
141 TEST(UpdateRtcpMeasurementTests, FailsForZeroNtp) { 183 TEST(UpdateRtcpMeasurementTests, FailsForZeroNtp) {
142 RtpToNtpEstimator estimator; 184 RtpToNtpEstimator estimator;
143 uint32_t ntp_sec = 0; 185 uint32_t ntp_sec = 0;
144 uint32_t ntp_frac = 0; 186 uint32_t ntp_frac = 0;
145 uint32_t timestamp = 0x12345678; 187 uint32_t timestamp = 0x12345678;
146 bool new_sr; 188 bool new_sr;
147 EXPECT_FALSE( 189 EXPECT_FALSE(
148 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); 190 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
149 EXPECT_FALSE(new_sr); 191 EXPECT_FALSE(new_sr);
150 } 192 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 EXPECT_TRUE( 285 EXPECT_TRUE(
244 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); 286 estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr));
245 EXPECT_TRUE(new_sr); 287 EXPECT_TRUE(new_sr);
246 // Parameters are not calculated, conversion of RTP to NTP time should fail. 288 // Parameters are not calculated, conversion of RTP to NTP time should fail.
247 EXPECT_FALSE(estimator.params().calculated); 289 EXPECT_FALSE(estimator.params().calculated);
248 int64_t timestamp_ms = -1; 290 int64_t timestamp_ms = -1;
249 EXPECT_FALSE(estimator.Estimate(timestamp, &timestamp_ms)); 291 EXPECT_FALSE(estimator.Estimate(timestamp, &timestamp_ms));
250 } 292 }
251 293
252 }; // namespace webrtc 294 }; // namespace webrtc
OLDNEW
« 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