Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: webrtc/call/call_perf_tests.cc

Issue 2304363002: Let ViEEncoder express resolution requests as Sinkwants (Closed)
Patch Set: Fix broken test RunOnTqNormalUsage. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 }; 56 };
57 enum class CreateOrder { 57 enum class CreateOrder {
58 kAudioFirst, kVideoFirst 58 kAudioFirst, kVideoFirst
59 }; 59 };
60 void TestAudioVideoSync(FecMode fec, 60 void TestAudioVideoSync(FecMode fec,
61 CreateOrder create_first, 61 CreateOrder create_first,
62 float video_ntp_speed, 62 float video_ntp_speed,
63 float video_rtp_speed, 63 float video_rtp_speed,
64 float audio_rtp_speed); 64 float audio_rtp_speed);
65 65
66 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); 66 void TestCpuOveruse(bool expect_lower_resolution_wants);
67 67
68 void TestMinTransmitBitrate(bool pad_to_min_bitrate); 68 void TestMinTransmitBitrate(bool pad_to_min_bitrate);
69 69
70 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, 70 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config,
71 int threshold_ms, 71 int threshold_ms,
72 int start_time_ms, 72 int start_time_ms,
73 int run_time_ms); 73 int run_time_ms);
74 }; 74 };
75 75
76 class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver, 76 class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 net_config.queue_delay_ms = 100; 474 net_config.queue_delay_ms = 100;
475 net_config.delay_standard_deviation_ms = 10; 475 net_config.delay_standard_deviation_ms = 10;
476 // TODO(wu): lower the threshold as the calculation/estimatation becomes more 476 // TODO(wu): lower the threshold as the calculation/estimatation becomes more
477 // accurate. 477 // accurate.
478 const int kThresholdMs = 100; 478 const int kThresholdMs = 100;
479 const int kStartTimeMs = 10000; 479 const int kStartTimeMs = 10000;
480 const int kRunTimeMs = 20000; 480 const int kRunTimeMs = 20000;
481 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); 481 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs);
482 } 482 }
483 483
484 void CallPerfTest::TestCpuOveruse(LoadObserver::Load tested_load, 484 void CallPerfTest::TestCpuOveruse(bool expect_lower_resolution_wants) {
485 int encode_delay_ms) { 485 class LoadObserver : public test::SendTest,
486 class LoadObserver : public test::SendTest, public webrtc::LoadObserver { 486 public test::FrameGeneratorCapturer::SinkWantsObserver {
487 public: 487 public:
488 LoadObserver(LoadObserver::Load tested_load, int encode_delay_ms) 488 LoadObserver(bool expect_lower_resolution_wants)
489 : SendTest(kLongTimeoutMs), 489 : SendTest(kLongTimeoutMs),
490 tested_load_(tested_load), 490 expect_lower_resolution_wants_(expect_lower_resolution_wants),
491 encoder_(Clock::GetRealTimeClock(), encode_delay_ms) {} 491 encoder_(Clock::GetRealTimeClock(), 35 /* delay_ms */) {}
492 492
493 void OnLoadUpdate(Load load) override { 493 void OnFrameGeneratorCapturerCreated(
494 if (load == tested_load_) 494 test::FrameGeneratorCapturer* frame_generator_capturer) override {
495 observation_complete_.Set(); 495 frame_generator_capturer->SetSinkWantsObserver(this);
496 }
497
498 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
499 // is called.
500 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
501 const rtc::VideoSinkWants& wants) override {
502 if (expect_lower_resolution_wants_) {
503 if (wants.max_pixel_count) {
504 observation_complete_.Set();
505 }
506 } else {
507 // First expect CPU overuse. Then expect CPU underuse when the encoder
508 // delay has been decreased.
509 if (wants.max_pixel_count) {
510 encoder_.SetDelay(2);
511 } else if (wants.max_pixel_count_step_up) {
512 observation_complete_.Set();
513 }
514 }
496 } 515 }
497 516
498 void ModifyVideoConfigs( 517 void ModifyVideoConfigs(
499 VideoSendStream::Config* send_config, 518 VideoSendStream::Config* send_config,
500 std::vector<VideoReceiveStream::Config>* receive_configs, 519 std::vector<VideoReceiveStream::Config>* receive_configs,
501 VideoEncoderConfig* encoder_config) override { 520 VideoEncoderConfig* encoder_config) override {
502 send_config->overuse_callback = this;
503 send_config->encoder_settings.encoder = &encoder_; 521 send_config->encoder_settings.encoder = &encoder_;
504 } 522 }
505 523
506 void PerformTest() override { 524 void PerformTest() override {
507 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; 525 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
508 } 526 }
509 527
510 LoadObserver::Load tested_load_; 528 bool expect_lower_resolution_wants_;
åsapersson 2016/10/24 07:54:05 const
perkj_webrtc 2016/10/26 16:40:16 used your second suggestion. This is used as state
511 test::DelayedEncoder encoder_; 529 test::DelayedEncoder encoder_;
512 } test(tested_load, encode_delay_ms); 530 } test(expect_lower_resolution_wants);
513 531
514 RunBaseTest(&test); 532 RunBaseTest(&test);
515 } 533 }
516 534
517 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { 535 TEST_F(CallPerfTest, ReceivesCpuUnderuse) {
518 const int kEncodeDelayMs = 2; 536 TestCpuOveruse(false);
519 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs);
520 } 537 }
521 538
522 TEST_F(CallPerfTest, ReceivesCpuOveruse) { 539 TEST_F(CallPerfTest, ReceivesCpuOveruse) {
523 const int kEncodeDelayMs = 35; 540 TestCpuOveruse(true);
åsapersson 2016/10/24 07:54:05 maybe remove since overuse is tested in test above
perkj_webrtc 2016/10/26 16:40:16 Done.
524 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs);
525 } 541 }
526 542
527 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { 543 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
528 static const int kMaxEncodeBitrateKbps = 30; 544 static const int kMaxEncodeBitrateKbps = 30;
529 static const int kMinTransmitBitrateBps = 150000; 545 static const int kMinTransmitBitrateBps = 150000;
530 static const int kMinAcceptableTransmitBitrate = 130; 546 static const int kMinAcceptableTransmitBitrate = 130;
531 static const int kMaxAcceptableTransmitBitrate = 170; 547 static const int kMaxAcceptableTransmitBitrate = 170;
532 static const int kNumBitrateObservationsInRange = 100; 548 static const int kNumBitrateObservationsInRange = 100;
533 static const int kAcceptableBitrateErrorMargin = 15; // +- 7 549 static const int kAcceptableBitrateErrorMargin = 15; // +- 7
534 class BitrateObserver : public test::EndToEndTest { 550 class BitrateObserver : public test::EndToEndTest {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 uint32_t last_set_bitrate_; 745 uint32_t last_set_bitrate_;
730 VideoSendStream* send_stream_; 746 VideoSendStream* send_stream_;
731 test::FrameGeneratorCapturer* frame_generator_; 747 test::FrameGeneratorCapturer* frame_generator_;
732 VideoEncoderConfig encoder_config_; 748 VideoEncoderConfig encoder_config_;
733 } test; 749 } test;
734 750
735 RunBaseTest(&test); 751 RunBaseTest(&test);
736 } 752 }
737 753
738 } // namespace webrtc 754 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698