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

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

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

Powered by Google App Engine
This is Rietveld 408576698