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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 const int kRunTimeMs = 20000; | 464 const int kRunTimeMs = 20000; |
465 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); | 465 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); |
466 } | 466 } |
467 #if defined(WEBRTC_ANDROID) | 467 #if defined(WEBRTC_ANDROID) |
468 // This test is disabled on android as it does not update | 468 // This test is disabled on android as it does not update |
469 // sinkWants below 320x180, the starting resolution for these | 469 // sinkWants below 320x180, the starting resolution for these |
470 // tests. | 470 // tests. |
471 #define ReceivesCpuOveruseAndUnderuse DISABLED_ReceivesCpuOveruseAndUnderuse | 471 #define ReceivesCpuOveruseAndUnderuse DISABLED_ReceivesCpuOveruseAndUnderuse |
472 #endif | 472 #endif |
473 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { | 473 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { |
| 474 static const int kFrameRateFps = 30; |
| 475 |
474 class LoadObserver : public test::SendTest, | 476 class LoadObserver : public test::SendTest, |
475 public test::FrameGeneratorCapturer::SinkWantsObserver { | 477 public test::FrameGeneratorCapturer::SinkWantsObserver { |
476 public: | 478 public: |
477 LoadObserver() | 479 LoadObserver() |
478 : SendTest(kLongTimeoutMs), | 480 : SendTest(kLongTimeoutMs), |
479 expect_lower_resolution_wants_(true), | 481 expect_lower_resolution_wants_(true), |
480 encoder_(Clock::GetRealTimeClock(), 35 /* delay_ms */) {} | 482 encoder_(Clock::GetRealTimeClock(), |
| 483 2 * (1000 / kFrameRateFps) /* delay = 200% utilization */), |
| 484 start_pixel_count_(0) {} |
481 | 485 |
482 void OnFrameGeneratorCapturerCreated( | 486 void OnFrameGeneratorCapturerCreated( |
483 test::FrameGeneratorCapturer* frame_generator_capturer) override { | 487 test::FrameGeneratorCapturer* frame_generator_capturer) override { |
484 frame_generator_capturer->SetSinkWantsObserver(this); | 488 frame_generator_capturer->SetSinkWantsObserver(this); |
485 } | 489 } |
486 | 490 |
487 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink | 491 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink |
488 // is called. | 492 // is called. |
489 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, | 493 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, |
490 const rtc::VideoSinkWants& wants) override { | 494 const rtc::VideoSinkWants& wants) override { |
| 495 RTC_DCHECK_GT(start_pixel_count_, 0); |
491 // First expect CPU overuse. Then expect CPU underuse when the encoder | 496 // First expect CPU overuse. Then expect CPU underuse when the encoder |
492 // delay has been decreased. | 497 // delay has been decreased. |
493 if (wants.target_pixel_count && | 498 if (wants.pixel_count && |
494 *wants.target_pixel_count < | 499 wants.pixel_count->max == |
495 wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) { | 500 static_cast<uint32_t>(start_pixel_count_ - 1)) { |
496 // On adapting up, ViEEncoder::VideoSourceProxy will set the target | 501 // On adapting down, ViEEncoder::VideoSourceProxy will set the max one |
497 // pixel count to a step up from the current and the max value to | 502 // step below the current resolution. |
498 // something higher than the target. | 503 EXPECT_TRUE(expect_lower_resolution_wants_); |
| 504 expect_lower_resolution_wants_ = false; |
| 505 encoder_.SetDelay(2); // Reduce fake high utilization. |
| 506 } else if (wants.pixel_count && |
| 507 wants.pixel_count->min == |
| 508 static_cast<uint32_t>(start_pixel_count_ + 1)) { |
| 509 // On adapting up, ViEEncoder::VideoSourceProxy will set the min pixel |
| 510 // count one step higher than the current. Since this test doesn't |
| 511 // include an adapter to actually scale down the input, this will still |
| 512 // be the start resolution. |
499 EXPECT_FALSE(expect_lower_resolution_wants_); | 513 EXPECT_FALSE(expect_lower_resolution_wants_); |
500 observation_complete_.Set(); | 514 observation_complete_.Set(); |
501 } else if (wants.max_pixel_count) { | |
502 // On adapting down, ViEEncoder::VideoSourceProxy will set only the max | |
503 // pixel count, leaving the target unset. | |
504 EXPECT_TRUE(expect_lower_resolution_wants_); | |
505 expect_lower_resolution_wants_ = false; | |
506 encoder_.SetDelay(2); | |
507 } | 515 } |
508 } | 516 } |
509 | 517 |
510 void ModifyVideoConfigs( | 518 void ModifyVideoConfigs( |
511 VideoSendStream::Config* send_config, | 519 VideoSendStream::Config* send_config, |
512 std::vector<VideoReceiveStream::Config>* receive_configs, | 520 std::vector<VideoReceiveStream::Config>* receive_configs, |
513 VideoEncoderConfig* encoder_config) override { | 521 VideoEncoderConfig* encoder_config) override { |
514 send_config->encoder_settings.encoder = &encoder_; | 522 send_config->encoder_settings.encoder = &encoder_; |
515 } | 523 } |
516 | 524 |
| 525 void ModifyVideoCaptureStartResolution(int* width, |
| 526 int* heigt, |
| 527 int* frame_rate) override { |
| 528 RTC_DCHECK_EQ(0, start_pixel_count_); |
| 529 start_pixel_count_ = *width * *heigt; |
| 530 *frame_rate = kFrameRateFps; |
| 531 } |
| 532 |
517 void PerformTest() override { | 533 void PerformTest() override { |
518 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; | 534 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; |
519 } | 535 } |
520 | 536 |
521 bool expect_lower_resolution_wants_; | 537 bool expect_lower_resolution_wants_; |
522 test::DelayedEncoder encoder_; | 538 test::DelayedEncoder encoder_; |
| 539 int start_pixel_count_; |
523 } test; | 540 } test; |
524 | 541 |
525 RunBaseTest(&test); | 542 RunBaseTest(&test); |
526 } | 543 } |
527 | 544 |
528 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { | 545 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { |
529 static const int kMaxEncodeBitrateKbps = 30; | 546 static const int kMaxEncodeBitrateKbps = 30; |
530 static const int kMinTransmitBitrateBps = 150000; | 547 static const int kMinTransmitBitrateBps = 150000; |
531 static const int kMinAcceptableTransmitBitrate = 130; | 548 static const int kMinAcceptableTransmitBitrate = 130; |
532 static const int kMaxAcceptableTransmitBitrate = 170; | 549 static const int kMaxAcceptableTransmitBitrate = 170; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 uint32_t last_set_bitrate_kbps_; | 752 uint32_t last_set_bitrate_kbps_; |
736 VideoSendStream* send_stream_; | 753 VideoSendStream* send_stream_; |
737 test::FrameGeneratorCapturer* frame_generator_; | 754 test::FrameGeneratorCapturer* frame_generator_; |
738 VideoEncoderConfig encoder_config_; | 755 VideoEncoderConfig encoder_config_; |
739 } test; | 756 } test; |
740 | 757 |
741 RunBaseTest(&test); | 758 RunBaseTest(&test); |
742 } | 759 } |
743 | 760 |
744 } // namespace webrtc | 761 } // namespace webrtc |
OLD | NEW |