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

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

Issue 2781433002: Reland of Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Time limit Created 3 years, 9 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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 net_config.delay_standard_deviation_ms = 10; 465 net_config.delay_standard_deviation_ms = 10;
466 // TODO(wu): lower the threshold as the calculation/estimatation becomes more 466 // TODO(wu): lower the threshold as the calculation/estimatation becomes more
467 // accurate. 467 // accurate.
468 const int kThresholdMs = 100; 468 const int kThresholdMs = 100;
469 const int kStartTimeMs = 10000; 469 const int kStartTimeMs = 10000;
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 // Set fake encoder delay to 150% (3/2) of time limit when simulating overuse.
476 const int kOveruseFrameIntervalMs = (3 * 1000) / (2 * kDefaultFramerate);
477
475 class LoadObserver : public test::SendTest, 478 class LoadObserver : public test::SendTest,
476 public test::FrameGeneratorCapturer::SinkWantsObserver { 479 public test::FrameGeneratorCapturer::SinkWantsObserver {
477 public: 480 public:
478 LoadObserver() 481 LoadObserver()
479 : SendTest(kLongTimeoutMs), 482 : SendTest(kLongTimeoutMs),
480 expect_lower_resolution_wants_(true), 483 test_phase_(TestPhase::kStart),
481 encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {} 484 encoder_(Clock::GetRealTimeClock(), kOveruseFrameIntervalMs) {}
482 485
483 void OnFrameGeneratorCapturerCreated( 486 void OnFrameGeneratorCapturerCreated(
484 test::FrameGeneratorCapturer* frame_generator_capturer) override { 487 test::FrameGeneratorCapturer* frame_generator_capturer) override {
485 frame_generator_capturer->SetSinkWantsObserver(this); 488 frame_generator_capturer->SetSinkWantsObserver(this);
486 // Set a high initial resolution to be sure that we can scale down. 489 // Set a high initial resolution to be sure that we can scale down.
487 frame_generator_capturer->ChangeResolution(1920, 1080); 490 frame_generator_capturer->ChangeResolution(1920, 1080);
488 } 491 }
489 492
490 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink 493 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
491 // is called. 494 // is called.
495 // TODO(sprang): Add integration test for maintain-framerate mode?
492 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, 496 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
493 const rtc::VideoSinkWants& wants) override { 497 const rtc::VideoSinkWants& wants) override {
494 // First expect CPU overuse. Then expect CPU underuse when the encoder 498 // First expect CPU overuse. Then expect CPU underuse when the encoder
495 // delay has been decreased. 499 // delay has been decreased.
496 if (wants.target_pixel_count && 500 switch (test_phase_) {
497 *wants.target_pixel_count < 501 case TestPhase::kStart:
498 wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) { 502 if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
499 // On adapting up, ViEEncoder::VideoSourceProxy will set the target 503 // On adapting down, ViEEncoder::VideoSourceProxy will set only the
500 // pixel count to a step up from the current and the max value to 504 // max pixel count, leaving the target unset.
501 // something higher than the target. 505 test_phase_ = TestPhase::kAdaptedDown;
502 EXPECT_FALSE(expect_lower_resolution_wants_); 506 encoder_.SetDelay(2);
503 observation_complete_.Set(); 507 } else {
504 } else if (wants.max_pixel_count) { 508 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
505 // On adapting down, ViEEncoder::VideoSourceProxy will set only the max 509 << wants.max_pixel_count << ", target res = "
506 // pixel count, leaving the target unset. 510 << wants.target_pixel_count.value_or(-1)
507 EXPECT_TRUE(expect_lower_resolution_wants_); 511 << ", max fps = " << wants.max_framerate_fps;
508 expect_lower_resolution_wants_ = false; 512 }
509 encoder_.SetDelay(2); 513 break;
514 case TestPhase::kAdaptedDown:
515 // On adapting up, the adaptation counter will again be at zero, and
516 // so all constraints will be reset.
517 if (wants.max_pixel_count == std::numeric_limits<int>::max() &&
518 !wants.target_pixel_count) {
519 test_phase_ = TestPhase::kAdaptedUp;
520 observation_complete_.Set();
521 } else {
522 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
523 << wants.max_pixel_count << ", target res = "
524 << wants.target_pixel_count.value_or(-1)
525 << ", max fps = " << wants.max_framerate_fps;
526 }
527 break;
528 case TestPhase::kAdaptedUp:
529 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
530 << wants.max_pixel_count << ", target res = "
531 << wants.target_pixel_count.value_or(-1)
532 << ", max fps = " << wants.max_framerate_fps;
510 } 533 }
511 } 534 }
512 535
513 void ModifyVideoConfigs( 536 void ModifyVideoConfigs(
514 VideoSendStream::Config* send_config, 537 VideoSendStream::Config* send_config,
515 std::vector<VideoReceiveStream::Config>* receive_configs, 538 std::vector<VideoReceiveStream::Config>* receive_configs,
516 VideoEncoderConfig* encoder_config) override { 539 VideoEncoderConfig* encoder_config) override {
517 send_config->encoder_settings.encoder = &encoder_; 540 send_config->encoder_settings.encoder = &encoder_;
518 } 541 }
519 542
520 void PerformTest() override { 543 void PerformTest() override {
521 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; 544 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
522 } 545 }
523 546
524 bool expect_lower_resolution_wants_; 547 enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_;
525 test::DelayedEncoder encoder_; 548 test::DelayedEncoder encoder_;
526 } test; 549 } test;
527 550
528 RunBaseTest(&test); 551 RunBaseTest(&test);
529 } 552 }
530 553
531 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { 554 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
532 static const int kMaxEncodeBitrateKbps = 30; 555 static const int kMaxEncodeBitrateKbps = 30;
533 static const int kMinTransmitBitrateBps = 150000; 556 static const int kMinTransmitBitrateBps = 150000;
534 static const int kMinAcceptableTransmitBitrate = 130; 557 static const int kMinAcceptableTransmitBitrate = 130;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 uint32_t last_set_bitrate_kbps_; 761 uint32_t last_set_bitrate_kbps_;
739 VideoSendStream* send_stream_; 762 VideoSendStream* send_stream_;
740 test::FrameGeneratorCapturer* frame_generator_; 763 test::FrameGeneratorCapturer* frame_generator_;
741 VideoEncoderConfig encoder_config_; 764 VideoEncoderConfig encoder_config_;
742 } test; 765 } test;
743 766
744 RunBaseTest(&test); 767 RunBaseTest(&test);
745 } 768 }
746 769
747 } // namespace webrtc 770 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698