| OLD | NEW |
| 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 |
| 11 #include "webrtc/call/rampup_tests.h" | 11 #include "webrtc/call/rampup_tests.h" |
| 12 | 12 |
| 13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/platform_thread.h" | 14 #include "webrtc/base/platform_thread.h" |
| 15 #include "webrtc/test/encoder_settings.h" | 15 #include "webrtc/test/encoder_settings.h" |
| 16 #include "webrtc/test/gtest.h" | 16 #include "webrtc/test/gtest.h" |
| 17 #include "webrtc/test/testsupport/perf_test.h" | 17 #include "webrtc/test/testsupport/perf_test.h" |
| 18 | 18 |
| 19 namespace webrtc { | 19 namespace webrtc { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 static const int64_t kPollIntervalMs = 20; | 22 static const int64_t kPollIntervalMs = 20; |
| 23 static const int kHighBandwidthLimitBps = 80000; |
| 24 static const int kExpectedHighVideoBitrateBps = 60000; |
| 25 static const int kExpectedHighAudioBitrateBps = 30000; |
| 26 static const int kLowBandwidthLimitBps = 20000; |
| 27 static const int kExpectedLowBitrateBps = 20000; |
| 23 | 28 |
| 24 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { | 29 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { |
| 25 std::vector<uint32_t> ssrcs; | 30 std::vector<uint32_t> ssrcs; |
| 26 for (size_t i = 0; i != num_streams; ++i) | 31 for (size_t i = 0; i != num_streams; ++i) |
| 27 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); | 32 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); |
| 28 return ssrcs; | 33 return ssrcs; |
| 29 } | 34 } |
| 30 } // namespace | 35 } // namespace |
| 31 | 36 |
| 32 RampUpTester::RampUpTester(size_t num_video_streams, | 37 RampUpTester::RampUpTester(size_t num_video_streams, |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 str += s.str(); | 412 str += s.str(); |
| 408 str += "stream"; | 413 str += "stream"; |
| 409 str += (num_audio_streams_ > 1 ? "s" : ""); | 414 str += (num_audio_streams_ > 1 ? "s" : ""); |
| 410 str += "_"; | 415 str += "_"; |
| 411 } | 416 } |
| 412 str += (rtx_ ? "" : "no"); | 417 str += (rtx_ ? "" : "no"); |
| 413 str += "rtx"; | 418 str += "rtx"; |
| 414 return str; | 419 return str; |
| 415 } | 420 } |
| 416 | 421 |
| 422 int RampUpDownUpTester::GetExpectedHighBitrate() const { |
| 423 if (num_audio_streams_ > 0 && num_video_streams_ == 0) |
| 424 return kExpectedHighAudioBitrateBps; |
| 425 return kExpectedHighVideoBitrateBps; |
| 426 } |
| 427 |
| 417 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { | 428 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { |
| 418 int64_t now = clock_->TimeInMilliseconds(); | 429 int64_t now = clock_->TimeInMilliseconds(); |
| 419 switch (test_state_) { | 430 switch (test_state_) { |
| 420 case kFirstRampup: { | 431 case kFirstRampup: { |
| 421 EXPECT_FALSE(suspended); | 432 EXPECT_FALSE(suspended); |
| 422 if (bitrate_bps >= kExpectedHighBitrateBps) { | 433 if (bitrate_bps >= GetExpectedHighBitrate()) { |
| 423 // The first ramp-up has reached the target bitrate. Change the | 434 // The first ramp-up has reached the target bitrate. Change the |
| 424 // channel limit, and move to the next test state. | 435 // channel limit, and move to the next test state. |
| 425 forward_transport_config_.link_capacity_kbps = | 436 forward_transport_config_.link_capacity_kbps = |
| 426 kLowBandwidthLimitBps / 1000; | 437 kLowBandwidthLimitBps / 1000; |
| 427 send_transport_->SetConfig(forward_transport_config_); | 438 send_transport_->SetConfig(forward_transport_config_); |
| 428 test_state_ = kLowRate; | 439 test_state_ = kLowRate; |
| 429 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), | 440 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 430 "first_rampup", now - state_start_ms_, "ms", | 441 "first_rampup", now - state_start_ms_, "ms", |
| 431 false); | 442 false); |
| 432 state_start_ms_ = now; | 443 state_start_ms_ = now; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 449 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), | 460 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 450 "rampdown", now - state_start_ms_, "ms", | 461 "rampdown", now - state_start_ms_, "ms", |
| 451 false); | 462 false); |
| 452 state_start_ms_ = now; | 463 state_start_ms_ = now; |
| 453 interval_start_ms_ = now; | 464 interval_start_ms_ = now; |
| 454 sent_bytes_ = 0; | 465 sent_bytes_ = 0; |
| 455 } | 466 } |
| 456 break; | 467 break; |
| 457 } | 468 } |
| 458 case kSecondRampup: { | 469 case kSecondRampup: { |
| 459 if (bitrate_bps >= kExpectedHighBitrateBps && !suspended) { | 470 if (bitrate_bps >= GetExpectedHighBitrate() && !suspended) { |
| 460 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), | 471 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
| 461 "second_rampup", now - state_start_ms_, "ms", | 472 "second_rampup", now - state_start_ms_, "ms", |
| 462 false); | 473 false); |
| 463 ReportResult("ramp-up-down-up-average-network-latency", | 474 ReportResult("ramp-up-down-up-average-network-latency", |
| 464 send_transport_->GetAverageDelayMs(), "milliseconds"); | 475 send_transport_->GetAverageDelayMs(), "milliseconds"); |
| 465 observation_complete_.Set(); | 476 observation_complete_.Set(); |
| 466 } | 477 } |
| 467 break; | 478 break; |
| 468 } | 479 } |
| 469 } | 480 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 true); | 635 true); |
| 625 RunBaseTest(&test); | 636 RunBaseTest(&test); |
| 626 } | 637 } |
| 627 | 638 |
| 628 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { | 639 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { |
| 629 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, | 640 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, |
| 630 RtpExtension::kTransportSequenceNumberUri, false, false); | 641 RtpExtension::kTransportSequenceNumberUri, false, false); |
| 631 RunBaseTest(&test); | 642 RunBaseTest(&test); |
| 632 } | 643 } |
| 633 } // namespace webrtc | 644 } // namespace webrtc |
| OLD | NEW |