OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" | 10 #include "webrtc/modules/congestion_controller/delay_based_bwe_unittest_helper.h
" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 stream_generator_->AddStream(new test::RtpStream(30, 3e5)); | 161 stream_generator_->AddStream(new test::RtpStream(30, 3e5)); |
162 } | 162 } |
163 | 163 |
164 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0; | 164 const uint32_t DelayBasedBweTest::kDefaultSsrc = 0; |
165 | 165 |
166 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, | 166 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, |
167 int64_t send_time_ms, | 167 int64_t send_time_ms, |
168 uint16_t sequence_number, | 168 uint16_t sequence_number, |
169 size_t payload_size) { | 169 size_t payload_size) { |
170 IncomingFeedback(arrival_time_ms, send_time_ms, sequence_number, payload_size, | 170 IncomingFeedback(arrival_time_ms, send_time_ms, sequence_number, payload_size, |
171 0); | 171 PacketInfo::kNotAProbe); |
172 } | 172 } |
173 | 173 |
174 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, | 174 void DelayBasedBweTest::IncomingFeedback(int64_t arrival_time_ms, |
175 int64_t send_time_ms, | 175 int64_t send_time_ms, |
176 uint16_t sequence_number, | 176 uint16_t sequence_number, |
177 size_t payload_size, | 177 size_t payload_size, |
178 int probe_cluster_id) { | 178 int probe_cluster_id) { |
179 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); | 179 RTC_CHECK_GE(arrival_time_ms + arrival_time_offset_ms_, 0); |
180 PacketInfo packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, | 180 PacketInfo packet(arrival_time_ms + arrival_time_offset_ms_, send_time_ms, |
181 sequence_number, payload_size, probe_cluster_id); | 181 sequence_number, payload_size, probe_cluster_id); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 clock_.AdvanceTimeMilliseconds(1000); | 268 clock_.AdvanceTimeMilliseconds(1000); |
269 // Inserting packets for 5 seconds to get a valid estimate. | 269 // Inserting packets for 5 seconds to get a valid estimate. |
270 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { | 270 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { |
271 if (i == kNumInitialPackets) { | 271 if (i == kNumInitialPackets) { |
272 bitrate_estimator_->Process(); | 272 bitrate_estimator_->Process(); |
273 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); | 273 EXPECT_FALSE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); |
274 EXPECT_EQ(0u, ssrcs.size()); | 274 EXPECT_EQ(0u, ssrcs.size()); |
275 EXPECT_FALSE(bitrate_observer_->updated()); | 275 EXPECT_FALSE(bitrate_observer_->updated()); |
276 bitrate_observer_->Reset(); | 276 bitrate_observer_->Reset(); |
277 } | 277 } |
278 | 278 int cluster_id = i < 5 ? 0 : PacketInfo::kNotAProbe; |
279 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, | 279 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, |
280 sequence_number++, kMtu); | 280 sequence_number++, kMtu, cluster_id); |
281 clock_.AdvanceTimeMilliseconds(1000 / kFramerate); | 281 clock_.AdvanceTimeMilliseconds(1000 / kFramerate); |
282 send_time_ms += kFrameIntervalMs; | 282 send_time_ms += kFrameIntervalMs; |
283 } | 283 } |
284 bitrate_estimator_->Process(); | 284 bitrate_estimator_->Process(); |
285 EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); | 285 EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); |
286 ASSERT_EQ(1u, ssrcs.size()); | 286 ASSERT_EQ(1u, ssrcs.size()); |
287 EXPECT_EQ(kDefaultSsrc, ssrcs.front()); | 287 EXPECT_EQ(kDefaultSsrc, ssrcs.front()); |
288 EXPECT_NEAR(expected_converge_bitrate, bitrate_bps, kAcceptedBitrateErrorBps); | 288 EXPECT_NEAR(expected_converge_bitrate, bitrate_bps, kAcceptedBitrateErrorBps); |
289 EXPECT_TRUE(bitrate_observer_->updated()); | 289 EXPECT_TRUE(bitrate_observer_->updated()); |
290 bitrate_observer_->Reset(); | 290 bitrate_observer_->Reset(); |
291 EXPECT_EQ(bitrate_observer_->latest_bitrate(), bitrate_bps); | 291 EXPECT_EQ(bitrate_observer_->latest_bitrate(), bitrate_bps); |
292 bitrate_estimator_->RemoveStream(kDefaultSsrc); | |
293 EXPECT_TRUE(bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_bps)); | |
294 ASSERT_EQ(0u, ssrcs.size()); | |
295 EXPECT_EQ(0u, bitrate_bps); | |
296 } | 292 } |
297 | 293 |
298 void DelayBasedBweTest::RateIncreaseReorderingTestHelper( | 294 void DelayBasedBweTest::RateIncreaseReorderingTestHelper( |
299 uint32_t expected_bitrate_bps) { | 295 uint32_t expected_bitrate_bps) { |
300 const int kFramerate = 50; // 50 fps to avoid rounding errors. | 296 const int kFramerate = 50; // 50 fps to avoid rounding errors. |
301 const int kFrameIntervalMs = 1000 / kFramerate; | 297 const int kFrameIntervalMs = 1000 / kFramerate; |
302 int64_t send_time_ms = 0; | 298 int64_t send_time_ms = 0; |
303 uint16_t sequence_number = 0; | 299 uint16_t sequence_number = 0; |
304 // Inserting packets for five seconds to get a valid estimate. | 300 // Inserting packets for five seconds to get a valid estimate. |
305 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { | 301 for (int i = 0; i < 5 * kFramerate + 1 + kNumInitialPackets; ++i) { |
306 // TODO(sprang): Remove this hack once the single stream estimator is gone, | 302 // TODO(sprang): Remove this hack once the single stream estimator is gone, |
307 // as it doesn't do anything in Process(). | 303 // as it doesn't do anything in Process(). |
308 if (i == kNumInitialPackets) { | 304 if (i == kNumInitialPackets) { |
309 // Process after we have enough frames to get a valid input rate estimate. | 305 // Process after we have enough frames to get a valid input rate estimate. |
310 bitrate_estimator_->Process(); | 306 bitrate_estimator_->Process(); |
311 EXPECT_FALSE(bitrate_observer_->updated()); // No valid estimate. | 307 EXPECT_FALSE(bitrate_observer_->updated()); // No valid estimate. |
312 } | 308 } |
313 | 309 int cluster_id = i < 5 ? 0 : PacketInfo::kNotAProbe; |
314 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, | 310 IncomingFeedback(clock_.TimeInMilliseconds(), send_time_ms, |
315 sequence_number++, kMtu); | 311 sequence_number++, kMtu, cluster_id); |
316 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); | 312 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); |
317 send_time_ms += kFrameIntervalMs; | 313 send_time_ms += kFrameIntervalMs; |
318 } | 314 } |
319 bitrate_estimator_->Process(); | 315 bitrate_estimator_->Process(); |
320 EXPECT_TRUE(bitrate_observer_->updated()); | 316 EXPECT_TRUE(bitrate_observer_->updated()); |
321 EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(), | 317 EXPECT_NEAR(expected_bitrate_bps, bitrate_observer_->latest_bitrate(), |
322 kAcceptedBitrateErrorBps); | 318 kAcceptedBitrateErrorBps); |
323 for (int i = 0; i < 10; ++i) { | 319 for (int i = 0; i < 10; ++i) { |
324 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); | 320 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); |
325 send_time_ms += 2 * kFrameIntervalMs; | 321 send_time_ms += 2 * kFrameIntervalMs; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 sequence_number++, 1000); | 487 sequence_number++, 1000); |
492 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); | 488 clock_.AdvanceTimeMilliseconds(2 * kFrameIntervalMs); |
493 send_time_ms += kFrameIntervalMs; | 489 send_time_ms += kFrameIntervalMs; |
494 bitrate_estimator_->Process(); | 490 bitrate_estimator_->Process(); |
495 } | 491 } |
496 uint32_t bitrate_after = 0; | 492 uint32_t bitrate_after = 0; |
497 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); | 493 bitrate_estimator_->LatestEstimate(&ssrcs, &bitrate_after); |
498 EXPECT_LT(bitrate_after, bitrate_before); | 494 EXPECT_LT(bitrate_after, bitrate_before); |
499 } | 495 } |
500 } // namespace webrtc | 496 } // namespace webrtc |
OLD | NEW |