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

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