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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/inter_arrival_unittest.cc

Issue 1481003002: Revert of Make overuse estimator one dimensional. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 27 matching lines...) Expand all
38 kRtpTimestampToMs, 38 kRtpTimestampToMs,
39 true)); 39 true));
40 inter_arrival_ast_.reset(new InterArrival( 40 inter_arrival_ast_.reset(new InterArrival(
41 MakeAbsSendTime(kTimestampGroupLengthUs), 41 MakeAbsSendTime(kTimestampGroupLengthUs),
42 kAstToMs, 42 kAstToMs,
43 true)); 43 true));
44 } 44 }
45 45
46 // Test that neither inter_arrival instance complete the timestamp group from 46 // Test that neither inter_arrival instance complete the timestamp group from
47 // the given data. 47 // the given data.
48 void ExpectFalse(int64_t timestamp_us, int64_t arrival_time_ms) { 48 void ExpectFalse(int64_t timestamp_us, int64_t arrival_time_ms,
49 size_t packet_size) {
49 InternalExpectFalse(inter_arrival_rtp_.get(), 50 InternalExpectFalse(inter_arrival_rtp_.get(),
50 MakeRtpTimestamp(timestamp_us), arrival_time_ms); 51 MakeRtpTimestamp(timestamp_us), arrival_time_ms,
52 packet_size);
51 InternalExpectFalse(inter_arrival_ast_.get(), MakeAbsSendTime(timestamp_us), 53 InternalExpectFalse(inter_arrival_ast_.get(), MakeAbsSendTime(timestamp_us),
52 arrival_time_ms); 54 arrival_time_ms, packet_size);
53 } 55 }
54 56
55 // Test that both inter_arrival instances complete the timestamp group from 57 // Test that both inter_arrival instances complete the timestamp group from
56 // the given data and that all returned deltas are as expected (except 58 // the given data and that all returned deltas are as expected (except
57 // timestamp delta, which is rounded from us to different ranges and must 59 // timestamp delta, which is rounded from us to different ranges and must
58 // match within an interval, given in |timestamp_near]. 60 // match within an interval, given in |timestamp_near].
59 void ExpectTrue(int64_t timestamp_us, 61 void ExpectTrue(int64_t timestamp_us, int64_t arrival_time_ms,
60 int64_t arrival_time_ms, 62 size_t packet_size, int64_t expected_timestamp_delta_us,
61 int64_t expected_timestamp_delta_us,
62 int64_t expected_arrival_time_delta_ms, 63 int64_t expected_arrival_time_delta_ms,
64 int expected_packet_size_delta,
63 uint32_t timestamp_near) { 65 uint32_t timestamp_near) {
64 InternalExpectTrue(inter_arrival_rtp_.get(), MakeRtpTimestamp(timestamp_us), 66 InternalExpectTrue(inter_arrival_rtp_.get(), MakeRtpTimestamp(timestamp_us),
65 arrival_time_ms, 67 arrival_time_ms, packet_size,
66 MakeRtpTimestamp(expected_timestamp_delta_us), 68 MakeRtpTimestamp(expected_timestamp_delta_us),
67 expected_arrival_time_delta_ms, timestamp_near); 69 expected_arrival_time_delta_ms,
70 expected_packet_size_delta, timestamp_near);
68 InternalExpectTrue(inter_arrival_ast_.get(), MakeAbsSendTime(timestamp_us), 71 InternalExpectTrue(inter_arrival_ast_.get(), MakeAbsSendTime(timestamp_us),
69 arrival_time_ms, 72 arrival_time_ms, packet_size,
70 MakeAbsSendTime(expected_timestamp_delta_us), 73 MakeAbsSendTime(expected_timestamp_delta_us),
71 expected_arrival_time_delta_ms, timestamp_near << 8); 74 expected_arrival_time_delta_ms,
75 expected_packet_size_delta, timestamp_near << 8);
72 } 76 }
73 77
74 void WrapTestHelper(int64_t wrap_start_us, uint32_t timestamp_near, 78 void WrapTestHelper(int64_t wrap_start_us, uint32_t timestamp_near,
75 bool unorderly_within_group) { 79 bool unorderly_within_group) {
76 // Step through the range of a 32 bit int, 1/4 at a time to not cause 80 // Step through the range of a 32 bit int, 1/4 at a time to not cause
77 // packets close to wraparound to be judged as out of order. 81 // packets close to wraparound to be judged as out of order.
78 82
79 // G1 83 // G1
80 int64_t arrival_time = 17; 84 int64_t arrival_time = 17;
81 ExpectFalse(0, arrival_time); 85 ExpectFalse(0, arrival_time, 1);
82 86
83 // G2 87 // G2
84 arrival_time += kBurstThresholdMs + 1; 88 arrival_time += kBurstThresholdMs + 1;
85 ExpectFalse(wrap_start_us / 4, arrival_time); 89 ExpectFalse(wrap_start_us / 4, arrival_time, 1);
86 90
87 // G3 91 // G3
88 arrival_time += kBurstThresholdMs + 1; 92 arrival_time += kBurstThresholdMs + 1;
89 ExpectTrue(wrap_start_us / 2, arrival_time, wrap_start_us / 4, 93 ExpectTrue(wrap_start_us / 2, arrival_time, 1,
90 6, // Delta G2-G1 94 wrap_start_us / 4, 6, 0, // Delta G2-G1
91 0); 95 0);
92 96
93 // G4 97 // G4
94 arrival_time += kBurstThresholdMs + 1; 98 arrival_time += kBurstThresholdMs + 1;
95 int64_t g4_arrival_time = arrival_time; 99 int64_t g4_arrival_time = arrival_time;
96 ExpectTrue(wrap_start_us / 2 + wrap_start_us / 4, arrival_time, 100 ExpectTrue(wrap_start_us / 2 + wrap_start_us / 4, arrival_time, 1,
97 wrap_start_us / 4, 6, // Delta G3-G2 101 wrap_start_us / 4, 6, 0, // Delta G3-G2
98 timestamp_near); 102 timestamp_near);
99 103
100 // G5 104 // G5
101 arrival_time += kBurstThresholdMs + 1; 105 arrival_time += kBurstThresholdMs + 1;
102 ExpectTrue(wrap_start_us, arrival_time, wrap_start_us / 4, 106 ExpectTrue(wrap_start_us, arrival_time, 2,
103 6, // Delta G4-G3 107 wrap_start_us / 4, 6, 0, // Delta G4-G3
104 timestamp_near); 108 timestamp_near);
105 for (int i = 0; i < 10; ++i) { 109 for (int i = 0; i < 10; ++i) {
106 // Slowly step across the wrap point. 110 // Slowly step across the wrap point.
107 arrival_time += kBurstThresholdMs + 1; 111 arrival_time += kBurstThresholdMs + 1;
108 if (unorderly_within_group) { 112 if (unorderly_within_group) {
109 // These packets arrive with timestamps in decreasing order but are 113 // These packets arrive with timestamps in decreasing order but are
110 // nevertheless accumulated to group because their timestamps are higher 114 // nevertheless accumulated to group because their timestamps are higher
111 // than the initial timestamp of the group. 115 // than the initial timestamp of the group.
112 ExpectFalse(wrap_start_us + kMinStep * (9 - i), arrival_time); 116 ExpectFalse(wrap_start_us + kMinStep * (9 - i), arrival_time, 1);
113 } else { 117 } else {
114 ExpectFalse(wrap_start_us + kMinStep * i, arrival_time); 118 ExpectFalse(wrap_start_us + kMinStep * i, arrival_time, 1);
115 } 119 }
116 } 120 }
117 int64_t g5_arrival_time = arrival_time; 121 int64_t g5_arrival_time = arrival_time;
118 122
119 // This packet is out of order and should be dropped. 123 // This packet is out of order and should be dropped.
120 arrival_time += kBurstThresholdMs + 1; 124 arrival_time += kBurstThresholdMs + 1;
121 ExpectFalse(wrap_start_us - 100, arrival_time); 125 ExpectFalse(wrap_start_us - 100, arrival_time, 100);
122 126
123 // G6 127 // G6
124 arrival_time += kBurstThresholdMs + 1; 128 arrival_time += kBurstThresholdMs + 1;
125 int64_t g6_arrival_time = arrival_time; 129 int64_t g6_arrival_time = arrival_time;
126 ExpectTrue(wrap_start_us + kTriggerNewGroupUs, arrival_time, 130 ExpectTrue(wrap_start_us + kTriggerNewGroupUs, arrival_time, 10,
127 wrap_start_us / 4 + 9 * kMinStep, 131 wrap_start_us / 4 + 9 * kMinStep,
128 g5_arrival_time - g4_arrival_time, timestamp_near); 132 g5_arrival_time - g4_arrival_time,
133 (2 + 10) - 1, // Delta G5-G4
134 timestamp_near);
129 135
130 // This packet is out of order and should be dropped. 136 // This packet is out of order and should be dropped.
131 arrival_time += kBurstThresholdMs + 1; 137 arrival_time += kBurstThresholdMs + 1;
132 ExpectFalse(wrap_start_us + kTimestampGroupLengthUs, arrival_time); 138 ExpectFalse(wrap_start_us + kTimestampGroupLengthUs, arrival_time, 100);
133 139
134 // G7 140 // G7
135 arrival_time += kBurstThresholdMs + 1; 141 arrival_time += kBurstThresholdMs + 1;
136 ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs, arrival_time, 142 ExpectTrue(wrap_start_us + 2 * kTriggerNewGroupUs,
143 arrival_time, 100,
137 // Delta G6-G5 144 // Delta G6-G5
138 kTriggerNewGroupUs - 9 * kMinStep, 145 kTriggerNewGroupUs - 9 * kMinStep,
139 g6_arrival_time - g5_arrival_time, timestamp_near); 146 g6_arrival_time - g5_arrival_time,
147 10 - (2 + 10),
148 timestamp_near);
140 } 149 }
141 150
142 private: 151 private:
143 static uint32_t MakeRtpTimestamp(int64_t us) { 152 static uint32_t MakeRtpTimestamp(int64_t us) {
144 return static_cast<uint32_t>(static_cast<uint64_t>(us * 90 + 500) / 1000); 153 return static_cast<uint32_t>(static_cast<uint64_t>(us * 90 + 500) / 1000);
145 } 154 }
146 155
147 static uint32_t MakeAbsSendTime(int64_t us) { 156 static uint32_t MakeAbsSendTime(int64_t us) {
148 uint32_t absolute_send_time = static_cast<uint32_t>( 157 uint32_t absolute_send_time = static_cast<uint32_t>(
149 ((static_cast<uint64_t>(us) << 18) + 500000) / 1000000) & 0x00FFFFFFul; 158 ((static_cast<uint64_t>(us) << 18) + 500000) / 1000000) & 0x00FFFFFFul;
150 return absolute_send_time << 8; 159 return absolute_send_time << 8;
151 } 160 }
152 161
153 static void InternalExpectFalse(InterArrival* inter_arrival, 162 static void InternalExpectFalse(InterArrival* inter_arrival,
154 uint32_t timestamp, 163 uint32_t timestamp, int64_t arrival_time_ms,
155 int64_t arrival_time_ms) { 164 size_t packet_size) {
156 uint32_t dummy_timestamp = 101; 165 uint32_t dummy_timestamp = 101;
157 int64_t dummy_arrival_time_ms = 303; 166 int64_t dummy_arrival_time_ms = 303;
158 bool computed = inter_arrival->ComputeDeltas( 167 int dummy_packet_size = 909;
159 timestamp, arrival_time_ms, &dummy_timestamp, &dummy_arrival_time_ms); 168 bool computed = inter_arrival->ComputeDeltas(timestamp,
169 arrival_time_ms,
170 packet_size,
171 &dummy_timestamp,
172 &dummy_arrival_time_ms,
173 &dummy_packet_size);
160 EXPECT_EQ(computed, false); 174 EXPECT_EQ(computed, false);
161 EXPECT_EQ(101ul, dummy_timestamp); 175 EXPECT_EQ(101ul, dummy_timestamp);
162 EXPECT_EQ(303, dummy_arrival_time_ms); 176 EXPECT_EQ(303, dummy_arrival_time_ms);
177 EXPECT_EQ(909, dummy_packet_size);
163 } 178 }
164 179
165 static void InternalExpectTrue(InterArrival* inter_arrival, 180 static void InternalExpectTrue(InterArrival* inter_arrival,
166 uint32_t timestamp, int64_t arrival_time_ms, 181 uint32_t timestamp, int64_t arrival_time_ms,
182 size_t packet_size,
167 uint32_t expected_timestamp_delta, 183 uint32_t expected_timestamp_delta,
168 int64_t expected_arrival_time_delta_ms, 184 int64_t expected_arrival_time_delta_ms,
185 int expected_packet_size_delta,
169 uint32_t timestamp_near) { 186 uint32_t timestamp_near) {
170 uint32_t delta_timestamp = 101; 187 uint32_t delta_timestamp = 101;
171 int64_t delta_arrival_time_ms = 303; 188 int64_t delta_arrival_time_ms = 303;
172 bool computed = inter_arrival->ComputeDeltas( 189 int delta_packet_size = 909;
173 timestamp, arrival_time_ms, &delta_timestamp, &delta_arrival_time_ms); 190 bool computed = inter_arrival->ComputeDeltas(timestamp,
191 arrival_time_ms,
192 packet_size,
193 &delta_timestamp,
194 &delta_arrival_time_ms,
195 &delta_packet_size);
174 EXPECT_EQ(true, computed); 196 EXPECT_EQ(true, computed);
175 EXPECT_NEAR(expected_timestamp_delta, delta_timestamp, timestamp_near); 197 EXPECT_NEAR(expected_timestamp_delta, delta_timestamp, timestamp_near);
176 EXPECT_EQ(expected_arrival_time_delta_ms, delta_arrival_time_ms); 198 EXPECT_EQ(expected_arrival_time_delta_ms, delta_arrival_time_ms);
199 EXPECT_EQ(expected_packet_size_delta, delta_packet_size);
177 } 200 }
178 201
179 rtc::scoped_ptr<InterArrival> inter_arrival_rtp_; 202 rtc::scoped_ptr<InterArrival> inter_arrival_rtp_;
180 rtc::scoped_ptr<InterArrival> inter_arrival_ast_; 203 rtc::scoped_ptr<InterArrival> inter_arrival_ast_;
181 }; 204 };
182 205
183 TEST_F(InterArrivalTest, FirstPacket) { 206 TEST_F(InterArrivalTest, FirstPacket) {
184 ExpectFalse(0, 17); 207 ExpectFalse(0, 17, 1);
185 } 208 }
186 209
187 TEST_F(InterArrivalTest, FirstGroup) { 210 TEST_F(InterArrivalTest, FirstGroup) {
188 // G1 211 // G1
189 int64_t arrival_time = 17; 212 int64_t arrival_time = 17;
190 int64_t g1_arrival_time = arrival_time; 213 int64_t g1_arrival_time = arrival_time;
191 ExpectFalse(0, arrival_time); 214 ExpectFalse(0, arrival_time, 1);
192 215
193 // G2 216 // G2
194 arrival_time += kBurstThresholdMs + 1; 217 arrival_time += kBurstThresholdMs + 1;
195 int64_t g2_arrival_time = arrival_time; 218 int64_t g2_arrival_time = arrival_time;
196 ExpectFalse(kTriggerNewGroupUs, arrival_time); 219 ExpectFalse(kTriggerNewGroupUs, arrival_time, 2);
197 220
198 // G3 221 // G3
199 // Only once the first packet of the third group arrives, do we see the deltas 222 // Only once the first packet of the third group arrives, do we see the deltas
200 // between the first two. 223 // between the first two.
201 arrival_time += kBurstThresholdMs + 1; 224 arrival_time += kBurstThresholdMs + 1;
202 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 225 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
203 // Delta G2-G1 226 // Delta G2-G1
204 kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 0); 227 kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
228 0);
205 } 229 }
206 230
207 TEST_F(InterArrivalTest, SecondGroup) { 231 TEST_F(InterArrivalTest, SecondGroup) {
208 // G1 232 // G1
209 int64_t arrival_time = 17; 233 int64_t arrival_time = 17;
210 int64_t g1_arrival_time = arrival_time; 234 int64_t g1_arrival_time = arrival_time;
211 ExpectFalse(0, arrival_time); 235 ExpectFalse(0, arrival_time, 1);
212 236
213 // G2 237 // G2
214 arrival_time += kBurstThresholdMs + 1; 238 arrival_time += kBurstThresholdMs + 1;
215 int64_t g2_arrival_time = arrival_time; 239 int64_t g2_arrival_time = arrival_time;
216 ExpectFalse(kTriggerNewGroupUs, arrival_time); 240 ExpectFalse(kTriggerNewGroupUs, arrival_time, 2);
217 241
218 // G3 242 // G3
219 arrival_time += kBurstThresholdMs + 1; 243 arrival_time += kBurstThresholdMs + 1;
220 int64_t g3_arrival_time = arrival_time; 244 int64_t g3_arrival_time = arrival_time;
221 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 245 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 1,
222 // Delta G2-G1 246 // Delta G2-G1
223 kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 0); 247 kTriggerNewGroupUs, g2_arrival_time - g1_arrival_time, 1,
248 0);
224 249
225 // G4 250 // G4
226 // First packet of 4th group yields deltas between group 2 and 3. 251 // First packet of 4th group yields deltas between group 2 and 3.
227 arrival_time += kBurstThresholdMs + 1; 252 arrival_time += kBurstThresholdMs + 1;
228 ExpectTrue(3 * kTriggerNewGroupUs, arrival_time, 253 ExpectTrue(3 * kTriggerNewGroupUs, arrival_time, 2,
229 // Delta G3-G2 254 // Delta G3-G2
230 kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, 0); 255 kTriggerNewGroupUs, g3_arrival_time - g2_arrival_time, -1,
256 0);
231 } 257 }
232 258
233 TEST_F(InterArrivalTest, AccumulatedGroup) { 259 TEST_F(InterArrivalTest, AccumulatedGroup) {
234 // G1 260 // G1
235 int64_t arrival_time = 17; 261 int64_t arrival_time = 17;
236 int64_t g1_arrival_time = arrival_time; 262 int64_t g1_arrival_time = arrival_time;
237 ExpectFalse(0, arrival_time); 263 ExpectFalse(0, arrival_time, 1);
238 264
239 // G2 265 // G2
240 arrival_time += kBurstThresholdMs + 1; 266 arrival_time += kBurstThresholdMs + 1;
241 ExpectFalse(kTriggerNewGroupUs, 28); 267 ExpectFalse(kTriggerNewGroupUs, 28, 2);
242 int64_t timestamp = kTriggerNewGroupUs; 268 int64_t timestamp = kTriggerNewGroupUs;
243 for (int i = 0; i < 10; ++i) { 269 for (int i = 0; i < 10; ++i) {
244 // A bunch of packets arriving within the same group. 270 // A bunch of packets arriving within the same group.
245 arrival_time += kBurstThresholdMs + 1; 271 arrival_time += kBurstThresholdMs + 1;
246 timestamp += kMinStep; 272 timestamp += kMinStep;
247 ExpectFalse(timestamp, arrival_time); 273 ExpectFalse(timestamp, arrival_time, 1);
248 } 274 }
249 int64_t g2_arrival_time = arrival_time; 275 int64_t g2_arrival_time = arrival_time;
250 int64_t g2_timestamp = timestamp; 276 int64_t g2_timestamp = timestamp;
251 277
252 // G3 278 // G3
253 arrival_time = 500; 279 arrival_time = 500;
254 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, g2_timestamp, 280 ExpectTrue(2 * kTriggerNewGroupUs, arrival_time, 100,
255 g2_arrival_time - g1_arrival_time, 0); 281 g2_timestamp, g2_arrival_time - g1_arrival_time,
282 (2 + 10) - 1, // Delta G2-G1
283 0);
256 } 284 }
257 285
258 TEST_F(InterArrivalTest, OutOfOrderPacket) { 286 TEST_F(InterArrivalTest, OutOfOrderPacket) {
259 // G1 287 // G1
260 int64_t arrival_time = 17; 288 int64_t arrival_time = 17;
261 int64_t timestamp = 0; 289 int64_t timestamp = 0;
262 ExpectFalse(timestamp, arrival_time); 290 ExpectFalse(timestamp, arrival_time, 1);
263 int64_t g1_timestamp = timestamp; 291 int64_t g1_timestamp = timestamp;
264 int64_t g1_arrival_time = arrival_time; 292 int64_t g1_arrival_time = arrival_time;
265 293
266 // G2 294 // G2
267 arrival_time += 11; 295 arrival_time += 11;
268 timestamp += kTriggerNewGroupUs; 296 timestamp += kTriggerNewGroupUs;
269 ExpectFalse(timestamp, 28); 297 ExpectFalse(timestamp, 28, 2);
270 for (int i = 0; i < 10; ++i) { 298 for (int i = 0; i < 10; ++i) {
271 arrival_time += kBurstThresholdMs + 1; 299 arrival_time += kBurstThresholdMs + 1;
272 timestamp += kMinStep; 300 timestamp += kMinStep;
273 ExpectFalse(timestamp, arrival_time); 301 ExpectFalse(timestamp, arrival_time, 1);
274 } 302 }
275 int64_t g2_timestamp = timestamp; 303 int64_t g2_timestamp = timestamp;
276 int64_t g2_arrival_time = arrival_time; 304 int64_t g2_arrival_time = arrival_time;
277 305
278 // This packet is out of order and should be dropped. 306 // This packet is out of order and should be dropped.
279 arrival_time = 281; 307 arrival_time = 281;
280 ExpectFalse(g1_timestamp, arrival_time); 308 ExpectFalse(g1_timestamp, arrival_time, 100);
281 309
282 // G3 310 // G3
283 arrival_time = 500; 311 arrival_time = 500;
284 timestamp = 2 * kTriggerNewGroupUs; 312 timestamp = 2 * kTriggerNewGroupUs;
285 ExpectTrue(timestamp, arrival_time, 313 ExpectTrue(timestamp, arrival_time, 100,
286 // Delta G2-G1 314 // Delta G2-G1
287 g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time, 0); 315 g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
316 (2 + 10) - 1,
317 0);
288 } 318 }
289 319
290 TEST_F(InterArrivalTest, OutOfOrderWithinGroup) { 320 TEST_F(InterArrivalTest, OutOfOrderWithinGroup) {
291 // G1 321 // G1
292 int64_t arrival_time = 17; 322 int64_t arrival_time = 17;
293 int64_t timestamp = 0; 323 int64_t timestamp = 0;
294 ExpectFalse(timestamp, arrival_time); 324 ExpectFalse(timestamp, arrival_time, 1);
295 int64_t g1_timestamp = timestamp; 325 int64_t g1_timestamp = timestamp;
296 int64_t g1_arrival_time = arrival_time; 326 int64_t g1_arrival_time = arrival_time;
297 327
298 // G2 328 // G2
299 timestamp += kTriggerNewGroupUs; 329 timestamp += kTriggerNewGroupUs;
300 arrival_time += 11; 330 arrival_time += 11;
301 ExpectFalse(kTriggerNewGroupUs, 28); 331 ExpectFalse(kTriggerNewGroupUs, 28, 2);
302 timestamp += 10 * kMinStep; 332 timestamp += 10 * kMinStep;
303 int64_t g2_timestamp = timestamp; 333 int64_t g2_timestamp = timestamp;
304 for (int i = 0; i < 10; ++i) { 334 for (int i = 0; i < 10; ++i) {
305 // These packets arrive with timestamps in decreasing order but are 335 // These packets arrive with timestamps in decreasing order but are
306 // nevertheless accumulated to group because their timestamps are higher 336 // nevertheless accumulated to group because their timestamps are higher
307 // than the initial timestamp of the group. 337 // than the initial timestamp of the group.
308 arrival_time += kBurstThresholdMs + 1; 338 arrival_time += kBurstThresholdMs + 1;
309 ExpectFalse(timestamp, arrival_time); 339 ExpectFalse(timestamp, arrival_time, 1);
310 timestamp -= kMinStep; 340 timestamp -= kMinStep;
311 } 341 }
312 int64_t g2_arrival_time = arrival_time; 342 int64_t g2_arrival_time = arrival_time;
313 343
314 // However, this packet is deemed out of order and should be dropped. 344 // However, this packet is deemed out of order and should be dropped.
315 arrival_time = 281; 345 arrival_time = 281;
316 timestamp = g1_timestamp; 346 timestamp = g1_timestamp;
317 ExpectFalse(timestamp, arrival_time); 347 ExpectFalse(timestamp, arrival_time, 100);
318 348
319 // G3 349 // G3
320 timestamp = 2 * kTriggerNewGroupUs; 350 timestamp = 2 * kTriggerNewGroupUs;
321 arrival_time = 500; 351 arrival_time = 500;
322 ExpectTrue(timestamp, arrival_time, g2_timestamp - g1_timestamp, 352 ExpectTrue(timestamp, arrival_time, 100,
323 g2_arrival_time - g1_arrival_time, 0); 353 g2_timestamp - g1_timestamp, g2_arrival_time - g1_arrival_time,
354 (2 + 10) - 1,
355 0);
324 } 356 }
325 357
326 TEST_F(InterArrivalTest, TwoBursts) { 358 TEST_F(InterArrivalTest, TwoBursts) {
327 // G1 359 // G1
328 int64_t g1_arrival_time = 17; 360 int64_t g1_arrival_time = 17;
329 ExpectFalse(0, g1_arrival_time); 361 ExpectFalse(0, g1_arrival_time, 1);
330 362
331 // G2 363 // G2
332 int64_t timestamp = kTriggerNewGroupUs; 364 int64_t timestamp = kTriggerNewGroupUs;
333 int64_t arrival_time = 100; // Simulate no packets arriving for 100 ms. 365 int64_t arrival_time = 100; // Simulate no packets arriving for 100 ms.
334 for (int i = 0; i < 10; ++i) { 366 for (int i = 0; i < 10; ++i) {
335 // A bunch of packets arriving in one burst (within 5 ms apart). 367 // A bunch of packets arriving in one burst (within 5 ms apart).
336 timestamp += 30000; 368 timestamp += 30000;
337 arrival_time += kBurstThresholdMs; 369 arrival_time += kBurstThresholdMs;
338 ExpectFalse(timestamp, arrival_time); 370 ExpectFalse(timestamp, arrival_time, 1);
339 } 371 }
340 int64_t g2_arrival_time = arrival_time; 372 int64_t g2_arrival_time = arrival_time;
341 int64_t g2_timestamp = timestamp; 373 int64_t g2_timestamp = timestamp;
342 374
343 // G3 375 // G3
344 timestamp += 30000; 376 timestamp += 30000;
345 arrival_time += kBurstThresholdMs + 1; 377 arrival_time += kBurstThresholdMs + 1;
346 ExpectTrue(timestamp, arrival_time, g2_timestamp, 378 ExpectTrue(timestamp, arrival_time, 100,
347 g2_arrival_time - g1_arrival_time, 0); 379 g2_timestamp, g2_arrival_time - g1_arrival_time,
380 10 - 1, // Delta G2-G1
381 0);
348 } 382 }
349 383
350 384
351 TEST_F(InterArrivalTest, NoBursts) { 385 TEST_F(InterArrivalTest, NoBursts) {
352 // G1 386 // G1
353 ExpectFalse(0, 17); 387 ExpectFalse(0, 17, 1);
354 388
355 // G2 389 // G2
356 int64_t timestamp = kTriggerNewGroupUs; 390 int64_t timestamp = kTriggerNewGroupUs;
357 int64_t arrival_time = 28; 391 int64_t arrival_time = 28;
358 ExpectFalse(timestamp, arrival_time); 392 ExpectFalse(timestamp, arrival_time, 2);
359 393
360 // G3 394 // G3
361 ExpectTrue(kTriggerNewGroupUs + 30000, arrival_time + kBurstThresholdMs + 1, 395 ExpectTrue(kTriggerNewGroupUs + 30000, arrival_time + kBurstThresholdMs + 1,
362 timestamp - 0, arrival_time - 17, 0); 396 100, timestamp - 0, arrival_time - 17,
397 2 - 1, // Delta G2-G1
398 0);
363 } 399 }
364 400
365 // Yields 0xfffffffe when converted to internal representation in 401 // Yields 0xfffffffe when converted to internal representation in
366 // inter_arrival_rtp_ and inter_arrival_ast_ respectively. 402 // inter_arrival_rtp_ and inter_arrival_ast_ respectively.
367 static const int64_t kStartRtpTimestampWrapUs = 47721858827; 403 static const int64_t kStartRtpTimestampWrapUs = 47721858827;
368 static const int64_t kStartAbsSendTimeWrapUs = 63999995; 404 static const int64_t kStartAbsSendTimeWrapUs = 63999995;
369 405
370 TEST_F(InterArrivalTest, RtpTimestampWrap) { 406 TEST_F(InterArrivalTest, RtpTimestampWrap) {
371 WrapTestHelper(kStartRtpTimestampWrapUs, 1, false); 407 WrapTestHelper(kStartRtpTimestampWrapUs, 1, false);
372 } 408 }
373 409
374 TEST_F(InterArrivalTest, AbsSendTimeWrap) { 410 TEST_F(InterArrivalTest, AbsSendTimeWrap) {
375 WrapTestHelper(kStartAbsSendTimeWrapUs, 1, false); 411 WrapTestHelper(kStartAbsSendTimeWrapUs, 1, false);
376 } 412 }
377 413
378 TEST_F(InterArrivalTest, RtpTimestampWrapOutOfOrderWithinGroup) { 414 TEST_F(InterArrivalTest, RtpTimestampWrapOutOfOrderWithinGroup) {
379 WrapTestHelper(kStartRtpTimestampWrapUs, 1, true); 415 WrapTestHelper(kStartRtpTimestampWrapUs, 1, true);
380 } 416 }
381 417
382 TEST_F(InterArrivalTest, AbsSendTimeWrapOutOfOrderWithinGroup) { 418 TEST_F(InterArrivalTest, AbsSendTimeWrapOutOfOrderWithinGroup) {
383 WrapTestHelper(kStartAbsSendTimeWrapUs, 1, true); 419 WrapTestHelper(kStartAbsSendTimeWrapUs, 1, true);
384 } 420 }
385 } // namespace testing 421 } // namespace testing
386 } // namespace webrtc 422 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/remote_bitrate_estimator/inter_arrival.cc ('k') | webrtc/modules/remote_bitrate_estimator/overuse_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698