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

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

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

Powered by Google App Engine
This is Rietveld 408576698