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 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 const int kRunTimeMs = 20000; | 470 const int kRunTimeMs = 20000; |
471 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); | 471 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); |
472 } | 472 } |
473 | 473 |
474 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { | 474 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { |
475 class LoadObserver : public test::SendTest, | 475 class LoadObserver : public test::SendTest, |
476 public test::FrameGeneratorCapturer::SinkWantsObserver { | 476 public test::FrameGeneratorCapturer::SinkWantsObserver { |
477 public: | 477 public: |
478 LoadObserver() | 478 LoadObserver() |
479 : SendTest(kLongTimeoutMs), | 479 : SendTest(kLongTimeoutMs), |
480 expect_lower_resolution_wants_(true), | 480 test_phase_(TestPhase::kStart), |
481 encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {} | 481 encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {} |
482 | 482 |
483 void OnFrameGeneratorCapturerCreated( | 483 void OnFrameGeneratorCapturerCreated( |
484 test::FrameGeneratorCapturer* frame_generator_capturer) override { | 484 test::FrameGeneratorCapturer* frame_generator_capturer) override { |
485 frame_generator_capturer->SetSinkWantsObserver(this); | 485 frame_generator_capturer->SetSinkWantsObserver(this); |
486 // Set a high initial resolution to be sure that we can scale down. | 486 // Set a high initial resolution to be sure that we can scale down. |
487 frame_generator_capturer->ChangeResolution(1920, 1080); | 487 frame_generator_capturer->ChangeResolution(1920, 1080); |
488 } | 488 } |
489 | 489 |
490 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink | 490 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink |
491 // is called. | 491 // is called. |
492 // TODO(sprang): Add integration test for maintain-framerate mode? | |
492 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, | 493 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, |
493 const rtc::VideoSinkWants& wants) override { | 494 const rtc::VideoSinkWants& wants) override { |
494 // First expect CPU overuse. Then expect CPU underuse when the encoder | 495 // First expect CPU overuse. Then expect CPU underuse when the encoder |
495 // delay has been decreased. | 496 // delay has been decreased. |
496 if (wants.target_pixel_count && | 497 switch (test_phase_) { |
ilnik
2017/03/27 10:11:10
In some tests there were 2 AdaptDown requests, bef
sprang_webrtc
2017/03/27 11:18:38
I set it to 150%, as that seems to be a common tes
| |
497 *wants.target_pixel_count < | 498 case TestPhase::kStart: |
498 wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) { | 499 if (wants.max_pixel_count < std::numeric_limits<int>::max()) { |
499 // On adapting up, ViEEncoder::VideoSourceProxy will set the target | 500 // On adapting down, ViEEncoder::VideoSourceProxy will set only the |
500 // pixel count to a step up from the current and the max value to | 501 // max pixel count, leaving the target unset. |
501 // something higher than the target. | 502 test_phase_ = TestPhase::kAdaptedDown; |
502 EXPECT_FALSE(expect_lower_resolution_wants_); | 503 encoder_.SetDelay(2); |
503 observation_complete_.Set(); | 504 } else { |
504 } else if (wants.max_pixel_count) { | 505 ADD_FAILURE() << "Got unexpected adaptation request, max res = " |
505 // On adapting down, ViEEncoder::VideoSourceProxy will set only the max | 506 << wants.max_pixel_count << ", target res = " |
506 // pixel count, leaving the target unset. | 507 << wants.target_pixel_count.value_or(-1) |
507 EXPECT_TRUE(expect_lower_resolution_wants_); | 508 << ", max fps = " << wants.max_framerate_fps; |
508 expect_lower_resolution_wants_ = false; | 509 } |
509 encoder_.SetDelay(2); | 510 break; |
511 case TestPhase::kAdaptedDown: | |
512 // On adapting up, the adaptation counter will again be at zero, and | |
513 // so all constraints will be reset. | |
514 if (wants.max_pixel_count == std::numeric_limits<int>::max() && | |
515 !wants.target_pixel_count) { | |
516 test_phase_ = TestPhase::kAdaptedUp; | |
517 observation_complete_.Set(); | |
518 } else { | |
519 ADD_FAILURE() << "Got unexpected adaptation request, max res = " | |
520 << wants.max_pixel_count << ", target res = " | |
521 << wants.target_pixel_count.value_or(-1) | |
522 << ", max fps = " << wants.max_framerate_fps; | |
523 } | |
524 break; | |
525 case TestPhase::kAdaptedUp: | |
526 ADD_FAILURE() << "Got unexpected adaptation request, max res = " | |
527 << wants.max_pixel_count << ", target res = " | |
528 << wants.target_pixel_count.value_or(-1) | |
529 << ", max fps = " << wants.max_framerate_fps; | |
510 } | 530 } |
511 } | 531 } |
512 | 532 |
513 void ModifyVideoConfigs( | 533 void ModifyVideoConfigs( |
514 VideoSendStream::Config* send_config, | 534 VideoSendStream::Config* send_config, |
515 std::vector<VideoReceiveStream::Config>* receive_configs, | 535 std::vector<VideoReceiveStream::Config>* receive_configs, |
516 VideoEncoderConfig* encoder_config) override { | 536 VideoEncoderConfig* encoder_config) override { |
517 send_config->encoder_settings.encoder = &encoder_; | 537 send_config->encoder_settings.encoder = &encoder_; |
518 } | 538 } |
519 | 539 |
520 void PerformTest() override { | 540 void PerformTest() override { |
521 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; | 541 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; |
522 } | 542 } |
523 | 543 |
524 bool expect_lower_resolution_wants_; | 544 enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_; |
525 test::DelayedEncoder encoder_; | 545 test::DelayedEncoder encoder_; |
526 } test; | 546 } test; |
527 | 547 |
528 RunBaseTest(&test); | 548 RunBaseTest(&test); |
529 } | 549 } |
530 | 550 |
531 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { | 551 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { |
532 static const int kMaxEncodeBitrateKbps = 30; | 552 static const int kMaxEncodeBitrateKbps = 30; |
533 static const int kMinTransmitBitrateBps = 150000; | 553 static const int kMinTransmitBitrateBps = 150000; |
534 static const int kMinAcceptableTransmitBitrate = 130; | 554 static const int kMinAcceptableTransmitBitrate = 130; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 uint32_t last_set_bitrate_kbps_; | 758 uint32_t last_set_bitrate_kbps_; |
739 VideoSendStream* send_stream_; | 759 VideoSendStream* send_stream_; |
740 test::FrameGeneratorCapturer* frame_generator_; | 760 test::FrameGeneratorCapturer* frame_generator_; |
741 VideoEncoderConfig encoder_config_; | 761 VideoEncoderConfig encoder_config_; |
742 } test; | 762 } test; |
743 | 763 |
744 RunBaseTest(&test); | 764 RunBaseTest(&test); |
745 } | 765 } |
746 | 766 |
747 } // namespace webrtc | 767 } // namespace webrtc |
OLD | NEW |