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; | 23 static const int kExpectedHighVideoBitrateBps = 60000; |
25 static const int kExpectedHighAudioBitrateBps = 30000; | 24 static const int kExpectedHighAudioBitrateBps = 30000; |
26 static const int kLowBandwidthLimitBps = 20000; | 25 static const int kLowBandwidthLimitBps = 20000; |
27 static const int kExpectedLowBitrateBps = 20000; | 26 static const int kExpectedLowBitrateBps = 20000; |
28 | 27 |
29 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { | 28 std::vector<uint32_t> GenerateSsrcs(size_t num_streams, uint32_t ssrc_offset) { |
30 std::vector<uint32_t> ssrcs; | 29 std::vector<uint32_t> ssrcs; |
31 for (size_t i = 0; i != num_streams; ++i) | 30 for (size_t i = 0; i != num_streams; ++i) |
32 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); | 31 ssrcs.push_back(static_cast<uint32_t>(ssrc_offset + i)); |
33 return ssrcs; | 32 return ssrcs; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 : RampUpTester(num_video_streams, | 359 : RampUpTester(num_video_streams, |
361 num_audio_streams, | 360 num_audio_streams, |
362 start_bitrate_bps, | 361 start_bitrate_bps, |
363 extension_type, | 362 extension_type, |
364 rtx, | 363 rtx, |
365 red), | 364 red), |
366 test_state_(kFirstRampup), | 365 test_state_(kFirstRampup), |
367 state_start_ms_(clock_->TimeInMilliseconds()), | 366 state_start_ms_(clock_->TimeInMilliseconds()), |
368 interval_start_ms_(clock_->TimeInMilliseconds()), | 367 interval_start_ms_(clock_->TimeInMilliseconds()), |
369 sent_bytes_(0) { | 368 sent_bytes_(0) { |
370 forward_transport_config_.link_capacity_kbps = kHighBandwidthLimitBps / 1000; | 369 forward_transport_config_.link_capacity_kbps = GetHighLinkCapacity(); |
371 } | 370 } |
372 | 371 |
373 RampUpDownUpTester::~RampUpDownUpTester() {} | 372 RampUpDownUpTester::~RampUpDownUpTester() {} |
374 | 373 |
375 bool RampUpDownUpTester::PollStats() { | 374 bool RampUpDownUpTester::PollStats() { |
376 if (send_stream_) { | 375 if (send_stream_) { |
377 webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); | 376 webrtc::VideoSendStream::Stats stats = send_stream_->GetStats(); |
378 int transmit_bitrate_bps = 0; | 377 int transmit_bitrate_bps = 0; |
379 for (auto it : stats.substreams) { | 378 for (auto it : stats.substreams) { |
380 transmit_bitrate_bps += it.second.total_bitrate_bps; | 379 transmit_bitrate_bps += it.second.total_bitrate_bps; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 str += "stream"; | 412 str += "stream"; |
414 str += (num_audio_streams_ > 1 ? "s" : ""); | 413 str += (num_audio_streams_ > 1 ? "s" : ""); |
415 str += "_"; | 414 str += "_"; |
416 } | 415 } |
417 str += (rtx_ ? "" : "no"); | 416 str += (rtx_ ? "" : "no"); |
418 str += "rtx"; | 417 str += "rtx"; |
419 return str; | 418 return str; |
420 } | 419 } |
421 | 420 |
422 int RampUpDownUpTester::GetExpectedHighBitrate() const { | 421 int RampUpDownUpTester::GetExpectedHighBitrate() const { |
423 if (num_audio_streams_ > 0 && num_video_streams_ == 0) | 422 int expected_bitrate_bps = 0; |
424 return kExpectedHighAudioBitrateBps; | 423 if (num_audio_streams_ > 0) |
425 return kExpectedHighVideoBitrateBps; | 424 expected_bitrate_bps += kExpectedHighAudioBitrateBps; |
| 425 if (num_video_streams_ > 0) |
| 426 expected_bitrate_bps += kExpectedHighVideoBitrateBps; |
| 427 return expected_bitrate_bps; |
| 428 } |
| 429 |
| 430 int RampUpDownUpTester::GetHighLinkCapacity() const { |
| 431 return 4 * GetExpectedHighBitrate() / (3 * 1000); |
426 } | 432 } |
427 | 433 |
428 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { | 434 void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { |
429 int64_t now = clock_->TimeInMilliseconds(); | 435 int64_t now = clock_->TimeInMilliseconds(); |
430 switch (test_state_) { | 436 switch (test_state_) { |
431 case kFirstRampup: { | 437 case kFirstRampup: { |
432 EXPECT_FALSE(suspended); | 438 EXPECT_FALSE(suspended); |
433 if (bitrate_bps >= GetExpectedHighBitrate()) { | 439 if (bitrate_bps >= GetExpectedHighBitrate()) { |
434 // The first ramp-up has reached the target bitrate. Change the | 440 // The first ramp-up has reached the target bitrate. Change the |
435 // channel limit, and move to the next test state. | 441 // channel limit, and move to the next test state. |
(...skipping 10 matching lines...) Expand all Loading... |
446 } | 452 } |
447 break; | 453 break; |
448 } | 454 } |
449 case kLowRate: { | 455 case kLowRate: { |
450 // Audio streams are never suspended. | 456 // Audio streams are never suspended. |
451 bool check_suspend_state = num_video_streams_ > 0; | 457 bool check_suspend_state = num_video_streams_ > 0; |
452 if (bitrate_bps < kExpectedLowBitrateBps && | 458 if (bitrate_bps < kExpectedLowBitrateBps && |
453 suspended == check_suspend_state) { | 459 suspended == check_suspend_state) { |
454 // The ramp-down was successful. Change the channel limit back to a | 460 // The ramp-down was successful. Change the channel limit back to a |
455 // high value, and move to the next test state. | 461 // high value, and move to the next test state. |
456 forward_transport_config_.link_capacity_kbps = | 462 forward_transport_config_.link_capacity_kbps = GetHighLinkCapacity(); |
457 kHighBandwidthLimitBps / 1000; | |
458 send_transport_->SetConfig(forward_transport_config_); | 463 send_transport_->SetConfig(forward_transport_config_); |
459 test_state_ = kSecondRampup; | 464 test_state_ = kSecondRampup; |
460 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), | 465 webrtc::test::PrintResult("ramp_up_down_up", GetModifierString(), |
461 "rampdown", now - state_start_ms_, "ms", | 466 "rampdown", now - state_start_ms_, "ms", |
462 false); | 467 false); |
463 state_start_ms_ = now; | 468 state_start_ms_ = now; |
464 interval_start_ms_ = now; | 469 interval_start_ms_ = now; |
465 sent_bytes_ = 0; | 470 sent_bytes_ = 0; |
466 } | 471 } |
467 break; | 472 break; |
(...skipping 15 matching lines...) Expand all Loading... |
483 class RampUpTest : public test::CallTest { | 488 class RampUpTest : public test::CallTest { |
484 public: | 489 public: |
485 RampUpTest() {} | 490 RampUpTest() {} |
486 | 491 |
487 virtual ~RampUpTest() { | 492 virtual ~RampUpTest() { |
488 EXPECT_EQ(nullptr, video_send_stream_); | 493 EXPECT_EQ(nullptr, video_send_stream_); |
489 EXPECT_TRUE(video_receive_streams_.empty()); | 494 EXPECT_TRUE(video_receive_streams_.empty()); |
490 } | 495 } |
491 }; | 496 }; |
492 | 497 |
493 TEST_F(RampUpTest, SingleStream) { | |
494 RampUpTester test(1, 0, 0, RtpExtension::kTimestampOffsetUri, false, false); | |
495 RunBaseTest(&test); | |
496 } | |
497 | |
498 TEST_F(RampUpTest, Simulcast) { | |
499 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, false, false); | |
500 RunBaseTest(&test); | |
501 } | |
502 | |
503 TEST_F(RampUpTest, SimulcastWithRtx) { | |
504 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, true, false); | |
505 RunBaseTest(&test); | |
506 } | |
507 | |
508 TEST_F(RampUpTest, SimulcastByRedWithRtx) { | |
509 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, true, true); | |
510 RunBaseTest(&test); | |
511 } | |
512 | |
513 TEST_F(RampUpTest, SingleStreamWithHighStartBitrate) { | |
514 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, | |
515 RtpExtension::kTimestampOffsetUri, false, false); | |
516 RunBaseTest(&test); | |
517 } | |
518 | |
519 static const uint32_t kStartBitrateBps = 60000; | 498 static const uint32_t kStartBitrateBps = 60000; |
520 | 499 |
521 // Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576 | 500 TEST_F(RampUpTest, UpDownUpAbsSendTimeSimulcastRedRtx) { |
522 TEST_F(RampUpTest, DISABLED_UpDownUpOneStream) { | |
523 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | |
524 false, false); | |
525 RunBaseTest(&test); | |
526 } | |
527 | |
528 TEST_F(RampUpTest, DISABLED_UpDownUpThreeStreams) { | |
529 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | |
530 false, false); | |
531 RunBaseTest(&test); | |
532 } | |
533 | |
534 // Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576 | |
535 TEST_F(RampUpTest, DISABLED_UpDownUpOneStreamRtx) { | |
536 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | |
537 true, false); | |
538 RunBaseTest(&test); | |
539 } | |
540 | |
541 TEST_F(RampUpTest, UpDownUpThreeStreamsRtx) { | |
542 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | |
543 true, false); | |
544 RunBaseTest(&test); | |
545 } | |
546 | |
547 // Disabled: https://bugs.chromium.org/p/webrtc/issues/detail?id=5576 | |
548 TEST_F(RampUpTest, DISABLED_UpDownUpOneStreamByRedRtx) { | |
549 RampUpDownUpTester test(1, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | |
550 true, true); | |
551 RunBaseTest(&test); | |
552 } | |
553 | |
554 TEST_F(RampUpTest, UpDownUpThreeStreamsByRedRtx) { | |
555 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, | 501 RampUpDownUpTester test(3, 0, kStartBitrateBps, RtpExtension::kAbsSendTimeUri, |
556 true, true); | 502 true, true); |
557 RunBaseTest(&test); | 503 RunBaseTest(&test); |
558 } | 504 } |
559 | 505 |
560 TEST_F(RampUpTest, SendSideVideoUpDownUpRtx) { | 506 TEST_F(RampUpTest, UpDownUpTransportSequenceNumberRtx) { |
561 RampUpDownUpTester test(3, 0, kStartBitrateBps, | 507 RampUpDownUpTester test(3, 0, kStartBitrateBps, |
562 RtpExtension::kTransportSequenceNumberUri, true, | 508 RtpExtension::kTransportSequenceNumberUri, true, |
563 false); | 509 false); |
564 RunBaseTest(&test); | 510 RunBaseTest(&test); |
565 } | 511 } |
566 | 512 |
567 // TODO(holmer): Enable when audio bitrates are included in the bitrate | 513 TEST_F(RampUpTest, UpDownUpAudioVideoTransportSequenceNumberRtx) { |
568 // allocation. | |
569 TEST_F(RampUpTest, DISABLED_SendSideAudioVideoUpDownUpRtx) { | |
570 RampUpDownUpTester test(3, 1, kStartBitrateBps, | 514 RampUpDownUpTester test(3, 1, kStartBitrateBps, |
571 RtpExtension::kTransportSequenceNumberUri, true, | 515 RtpExtension::kTransportSequenceNumberUri, true, |
572 false); | 516 false); |
573 RunBaseTest(&test); | 517 RunBaseTest(&test); |
574 } | 518 } |
575 | 519 |
576 TEST_F(RampUpTest, SendSideAudioOnlyUpDownUpRtx) { | 520 TEST_F(RampUpTest, UpDownUpAudioTransportSequenceNumberRtx) { |
577 RampUpDownUpTester test(0, 1, kStartBitrateBps, | 521 RampUpDownUpTester test(0, 1, kStartBitrateBps, |
578 RtpExtension::kTransportSequenceNumberUri, true, | 522 RtpExtension::kTransportSequenceNumberUri, true, |
579 false); | 523 false); |
580 RunBaseTest(&test); | 524 RunBaseTest(&test); |
581 } | 525 } |
582 | 526 |
583 TEST_F(RampUpTest, AbsSendTimeSingleStream) { | 527 TEST_F(RampUpTest, TOffsetSimulcastRedRtx) { |
| 528 RampUpTester test(3, 0, 0, RtpExtension::kTimestampOffsetUri, true, true); |
| 529 RunBaseTest(&test); |
| 530 } |
| 531 |
| 532 TEST_F(RampUpTest, AbsSendTime) { |
584 RampUpTester test(1, 0, 0, RtpExtension::kAbsSendTimeUri, false, false); | 533 RampUpTester test(1, 0, 0, RtpExtension::kAbsSendTimeUri, false, false); |
585 RunBaseTest(&test); | 534 RunBaseTest(&test); |
586 } | 535 } |
587 | 536 |
588 TEST_F(RampUpTest, AbsSendTimeSimulcast) { | 537 TEST_F(RampUpTest, AbsSendTimeSimulcastRedRtx) { |
589 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, false, false); | |
590 RunBaseTest(&test); | |
591 } | |
592 | |
593 TEST_F(RampUpTest, AbsSendTimeSimulcastWithRtx) { | |
594 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, true, false); | |
595 RunBaseTest(&test); | |
596 } | |
597 | |
598 TEST_F(RampUpTest, AbsSendTimeSimulcastByRedWithRtx) { | |
599 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, true, true); | 538 RampUpTester test(3, 0, 0, RtpExtension::kAbsSendTimeUri, true, true); |
600 RunBaseTest(&test); | 539 RunBaseTest(&test); |
601 } | 540 } |
602 | 541 |
603 TEST_F(RampUpTest, AbsSendTimeSingleStreamWithHighStartBitrate) { | 542 TEST_F(RampUpTest, TransportSequenceNumber) { |
604 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, | |
605 RtpExtension::kAbsSendTimeUri, false, false); | |
606 RunBaseTest(&test); | |
607 } | |
608 | |
609 TEST_F(RampUpTest, TransportSequenceNumberSingleStream) { | |
610 RampUpTester test(1, 0, 0, RtpExtension::kTransportSequenceNumberUri, false, | 543 RampUpTester test(1, 0, 0, RtpExtension::kTransportSequenceNumberUri, false, |
611 false); | 544 false); |
612 RunBaseTest(&test); | 545 RunBaseTest(&test); |
613 } | 546 } |
614 | 547 |
615 TEST_F(RampUpTest, TransportSequenceNumberSimulcast) { | 548 TEST_F(RampUpTest, TransportSequenceNumberSimulcast) { |
616 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, false, | 549 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, false, |
617 false); | 550 false); |
618 RunBaseTest(&test); | 551 RunBaseTest(&test); |
619 } | 552 } |
620 | 553 |
621 TEST_F(RampUpTest, TransportSequenceNumberSimulcastWithRtx) { | 554 TEST_F(RampUpTest, TransportSequenceNumberSimulcastRedRtx) { |
622 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, true, | |
623 false); | |
624 RunBaseTest(&test); | |
625 } | |
626 | |
627 TEST_F(RampUpTest, AudioVideoTransportSequenceNumberSimulcastWithRtx) { | |
628 RampUpTester test(3, 1, 0, RtpExtension::kTransportSequenceNumberUri, true, | |
629 false); | |
630 RunBaseTest(&test); | |
631 } | |
632 | |
633 TEST_F(RampUpTest, TransportSequenceNumberSimulcastByRedWithRtx) { | |
634 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, true, | 555 RampUpTester test(3, 0, 0, RtpExtension::kTransportSequenceNumberUri, true, |
635 true); | 556 true); |
636 RunBaseTest(&test); | 557 RunBaseTest(&test); |
637 } | 558 } |
638 | |
639 TEST_F(RampUpTest, TransportSequenceNumberSingleStreamWithHighStartBitrate) { | |
640 RampUpTester test(1, 0, 0.9 * kSingleStreamTargetBps, | |
641 RtpExtension::kTransportSequenceNumberUri, false, false); | |
642 RunBaseTest(&test); | |
643 } | |
644 } // namespace webrtc | 559 } // namespace webrtc |
OLD | NEW |