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