| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 }; | 53 }; |
| 54 enum class CreateOrder { | 54 enum class CreateOrder { |
| 55 kAudioFirst, kVideoFirst | 55 kAudioFirst, kVideoFirst |
| 56 }; | 56 }; |
| 57 void TestAudioVideoSync(FecMode fec, | 57 void TestAudioVideoSync(FecMode fec, |
| 58 CreateOrder create_first, | 58 CreateOrder create_first, |
| 59 float video_ntp_speed, | 59 float video_ntp_speed, |
| 60 float video_rtp_speed, | 60 float video_rtp_speed, |
| 61 float audio_rtp_speed); | 61 float audio_rtp_speed); |
| 62 | 62 |
| 63 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); | |
| 64 | |
| 65 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 63 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
| 66 | 64 |
| 67 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 65 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 68 int threshold_ms, | 66 int threshold_ms, |
| 69 int start_time_ms, | 67 int start_time_ms, |
| 70 int run_time_ms); | 68 int run_time_ms); |
| 71 }; | 69 }; |
| 72 | 70 |
| 73 class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver, | 71 class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver, |
| 74 public rtc::VideoSinkInterface<VideoFrame> { | 72 public rtc::VideoSinkInterface<VideoFrame> { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 net_config.queue_delay_ms = 100; | 466 net_config.queue_delay_ms = 100; |
| 469 net_config.delay_standard_deviation_ms = 10; | 467 net_config.delay_standard_deviation_ms = 10; |
| 470 // TODO(wu): lower the threshold as the calculation/estimatation becomes more | 468 // TODO(wu): lower the threshold as the calculation/estimatation becomes more |
| 471 // accurate. | 469 // accurate. |
| 472 const int kThresholdMs = 100; | 470 const int kThresholdMs = 100; |
| 473 const int kStartTimeMs = 10000; | 471 const int kStartTimeMs = 10000; |
| 474 const int kRunTimeMs = 20000; | 472 const int kRunTimeMs = 20000; |
| 475 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); | 473 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); |
| 476 } | 474 } |
| 477 | 475 |
| 478 void CallPerfTest::TestCpuOveruse(LoadObserver::Load tested_load, | 476 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { |
| 479 int encode_delay_ms) { | 477 class LoadObserver : public test::SendTest, |
| 480 class LoadObserver : public test::SendTest, public webrtc::LoadObserver { | 478 public test::FrameGeneratorCapturer::SinkWantsObserver { |
| 481 public: | 479 public: |
| 482 LoadObserver(LoadObserver::Load tested_load, int encode_delay_ms) | 480 LoadObserver() |
| 483 : SendTest(kLongTimeoutMs), | 481 : SendTest(kLongTimeoutMs), |
| 484 tested_load_(tested_load), | 482 expect_lower_resolution_wants_(true), |
| 485 encoder_(Clock::GetRealTimeClock(), encode_delay_ms) {} | 483 encoder_(Clock::GetRealTimeClock(), 35 /* delay_ms */) {} |
| 486 | 484 |
| 487 void OnLoadUpdate(Load load) override { | 485 void OnFrameGeneratorCapturerCreated( |
| 488 if (load == tested_load_) | 486 test::FrameGeneratorCapturer* frame_generator_capturer) override { |
| 487 frame_generator_capturer->SetSinkWantsObserver(this); |
| 488 } |
| 489 |
| 490 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink |
| 491 // is called. |
| 492 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, |
| 493 const rtc::VideoSinkWants& wants) override { |
| 494 // First expect CPU overuse. Then expect CPU underuse when the encoder |
| 495 // delay has been decreased. |
| 496 if (wants.max_pixel_count) { |
| 497 EXPECT_TRUE(expect_lower_resolution_wants_); |
| 498 expect_lower_resolution_wants_ = false; |
| 499 encoder_.SetDelay(2); |
| 500 } else if (wants.max_pixel_count_step_up) { |
| 501 EXPECT_FALSE(expect_lower_resolution_wants_); |
| 489 observation_complete_.Set(); | 502 observation_complete_.Set(); |
| 503 } |
| 490 } | 504 } |
| 491 | 505 |
| 492 void ModifyVideoConfigs( | 506 void ModifyVideoConfigs( |
| 493 VideoSendStream::Config* send_config, | 507 VideoSendStream::Config* send_config, |
| 494 std::vector<VideoReceiveStream::Config>* receive_configs, | 508 std::vector<VideoReceiveStream::Config>* receive_configs, |
| 495 VideoEncoderConfig* encoder_config) override { | 509 VideoEncoderConfig* encoder_config) override { |
| 496 send_config->overuse_callback = this; | |
| 497 send_config->encoder_settings.encoder = &encoder_; | 510 send_config->encoder_settings.encoder = &encoder_; |
| 498 } | 511 } |
| 499 | 512 |
| 500 void PerformTest() override { | 513 void PerformTest() override { |
| 501 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; | 514 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; |
| 502 } | 515 } |
| 503 | 516 |
| 504 LoadObserver::Load tested_load_; | 517 bool expect_lower_resolution_wants_; |
| 505 test::DelayedEncoder encoder_; | 518 test::DelayedEncoder encoder_; |
| 506 } test(tested_load, encode_delay_ms); | 519 } test; |
| 507 | 520 |
| 508 RunBaseTest(&test); | 521 RunBaseTest(&test); |
| 509 } | 522 } |
| 510 | 523 |
| 511 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { | |
| 512 const int kEncodeDelayMs = 2; | |
| 513 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs); | |
| 514 } | |
| 515 | |
| 516 TEST_F(CallPerfTest, ReceivesCpuOveruse) { | |
| 517 const int kEncodeDelayMs = 35; | |
| 518 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); | |
| 519 } | |
| 520 | |
| 521 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { | 524 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { |
| 522 static const int kMaxEncodeBitrateKbps = 30; | 525 static const int kMaxEncodeBitrateKbps = 30; |
| 523 static const int kMinTransmitBitrateBps = 150000; | 526 static const int kMinTransmitBitrateBps = 150000; |
| 524 static const int kMinAcceptableTransmitBitrate = 130; | 527 static const int kMinAcceptableTransmitBitrate = 130; |
| 525 static const int kMaxAcceptableTransmitBitrate = 170; | 528 static const int kMaxAcceptableTransmitBitrate = 170; |
| 526 static const int kNumBitrateObservationsInRange = 100; | 529 static const int kNumBitrateObservationsInRange = 100; |
| 527 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 | 530 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 |
| 528 class BitrateObserver : public test::EndToEndTest { | 531 class BitrateObserver : public test::EndToEndTest { |
| 529 public: | 532 public: |
| 530 explicit BitrateObserver(bool using_min_transmit_bitrate) | 533 explicit BitrateObserver(bool using_min_transmit_bitrate) |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 uint32_t last_set_bitrate_; | 729 uint32_t last_set_bitrate_; |
| 727 VideoSendStream* send_stream_; | 730 VideoSendStream* send_stream_; |
| 728 test::FrameGeneratorCapturer* frame_generator_; | 731 test::FrameGeneratorCapturer* frame_generator_; |
| 729 VideoEncoderConfig encoder_config_; | 732 VideoEncoderConfig encoder_config_; |
| 730 } test; | 733 } test; |
| 731 | 734 |
| 732 RunBaseTest(&test); | 735 RunBaseTest(&test); |
| 733 } | 736 } |
| 734 | 737 |
| 735 } // namespace webrtc | 738 } // namespace webrtc |
| OLD | NEW |