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

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

Issue 2789823002: Reland of Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Deflake CallPerfTest.ReceivesCpuOveruseAndUnderuse 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
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 12 matching lines...) Expand all
23 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" 23 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
25 #include "webrtc/system_wrappers/include/metrics_default.h" 25 #include "webrtc/system_wrappers/include/metrics_default.h"
26 #include "webrtc/test/call_test.h" 26 #include "webrtc/test/call_test.h"
27 #include "webrtc/test/direct_transport.h" 27 #include "webrtc/test/direct_transport.h"
28 #include "webrtc/test/drifting_clock.h" 28 #include "webrtc/test/drifting_clock.h"
29 #include "webrtc/test/encoder_settings.h" 29 #include "webrtc/test/encoder_settings.h"
30 #include "webrtc/test/fake_audio_device.h" 30 #include "webrtc/test/fake_audio_device.h"
31 #include "webrtc/test/fake_decoder.h" 31 #include "webrtc/test/fake_decoder.h"
32 #include "webrtc/test/fake_encoder.h" 32 #include "webrtc/test/fake_encoder.h"
33 #include "webrtc/test/field_trial.h"
33 #include "webrtc/test/frame_generator.h" 34 #include "webrtc/test/frame_generator.h"
34 #include "webrtc/test/frame_generator_capturer.h" 35 #include "webrtc/test/frame_generator_capturer.h"
35 #include "webrtc/test/gtest.h" 36 #include "webrtc/test/gtest.h"
36 #include "webrtc/test/rtp_rtcp_observer.h" 37 #include "webrtc/test/rtp_rtcp_observer.h"
37 #include "webrtc/test/testsupport/fileutils.h" 38 #include "webrtc/test/testsupport/fileutils.h"
38 #include "webrtc/test/testsupport/perf_test.h" 39 #include "webrtc/test/testsupport/perf_test.h"
39 #include "webrtc/video/transport_adapter.h" 40 #include "webrtc/video/transport_adapter.h"
40 #include "webrtc/voice_engine/include/voe_base.h" 41 #include "webrtc/voice_engine/include/voe_base.h"
41 42
42 using webrtc::test::DriftingClock; 43 using webrtc::test::DriftingClock;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 net_config.delay_standard_deviation_ms = 10; 471 net_config.delay_standard_deviation_ms = 10;
471 // TODO(wu): lower the threshold as the calculation/estimatation becomes more 472 // TODO(wu): lower the threshold as the calculation/estimatation becomes more
472 // accurate. 473 // accurate.
473 const int kThresholdMs = 100; 474 const int kThresholdMs = 100;
474 const int kStartTimeMs = 10000; 475 const int kStartTimeMs = 10000;
475 const int kRunTimeMs = 20000; 476 const int kRunTimeMs = 20000;
476 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs); 477 TestCaptureNtpTime(net_config, kThresholdMs, kStartTimeMs, kRunTimeMs);
477 } 478 }
478 479
479 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) { 480 TEST_F(CallPerfTest, ReceivesCpuOveruseAndUnderuse) {
481 // Minimal normal usage at the start, then 30s overuse to allow filter to
482 // settle, and then 80s underuse to allow plenty of time for rampup again.
483 test::ScopedFieldTrials fake_overuse_settings(
484 "WebRTC-ForceSimulatedOveruseIntervalMs/1-30000-80000/");
485
480 class LoadObserver : public test::SendTest, 486 class LoadObserver : public test::SendTest,
481 public test::FrameGeneratorCapturer::SinkWantsObserver { 487 public test::FrameGeneratorCapturer::SinkWantsObserver {
482 public: 488 public:
483 LoadObserver() 489 LoadObserver()
484 : SendTest(kLongTimeoutMs), 490 : SendTest(kLongTimeoutMs), test_phase_(TestPhase::kStart) {}
485 expect_lower_resolution_wants_(true),
486 encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {}
487 491
488 void OnFrameGeneratorCapturerCreated( 492 void OnFrameGeneratorCapturerCreated(
489 test::FrameGeneratorCapturer* frame_generator_capturer) override { 493 test::FrameGeneratorCapturer* frame_generator_capturer) override {
490 frame_generator_capturer->SetSinkWantsObserver(this); 494 frame_generator_capturer->SetSinkWantsObserver(this);
491 // Set a high initial resolution to be sure that we can scale down. 495 // Set a high initial resolution to be sure that we can scale down.
492 frame_generator_capturer->ChangeResolution(1920, 1080); 496 frame_generator_capturer->ChangeResolution(1920, 1080);
493 } 497 }
494 498
495 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink 499 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
496 // is called. 500 // is called.
501 // TODO(sprang): Add integration test for maintain-framerate mode?
497 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, 502 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
498 const rtc::VideoSinkWants& wants) override { 503 const rtc::VideoSinkWants& wants) override {
499 // First expect CPU overuse. Then expect CPU underuse when the encoder 504 // First expect CPU overuse. Then expect CPU underuse when the encoder
500 // delay has been decreased. 505 // delay has been decreased.
501 if (wants.target_pixel_count && 506 switch (test_phase_) {
502 *wants.target_pixel_count < 507 case TestPhase::kStart:
503 wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) { 508 if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
504 // On adapting up, ViEEncoder::VideoSourceProxy will set the target 509 // On adapting down, ViEEncoder::VideoSourceProxy will set only the
505 // pixel count to a step up from the current and the max value to 510 // max pixel count, leaving the target unset.
506 // something higher than the target. 511 test_phase_ = TestPhase::kAdaptedDown;
507 EXPECT_FALSE(expect_lower_resolution_wants_); 512 } else {
508 observation_complete_.Set(); 513 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
509 } else if (wants.max_pixel_count) { 514 << wants.max_pixel_count << ", target res = "
510 // On adapting down, ViEEncoder::VideoSourceProxy will set only the max 515 << wants.target_pixel_count.value_or(-1)
511 // pixel count, leaving the target unset. 516 << ", max fps = " << wants.max_framerate_fps;
512 EXPECT_TRUE(expect_lower_resolution_wants_); 517 }
513 expect_lower_resolution_wants_ = false; 518 break;
514 encoder_.SetDelay(2); 519 case TestPhase::kAdaptedDown:
520 // On adapting up, the adaptation counter will again be at zero, and
521 // so all constraints will be reset.
522 if (wants.max_pixel_count == std::numeric_limits<int>::max() &&
523 !wants.target_pixel_count) {
524 test_phase_ = TestPhase::kAdaptedUp;
525 observation_complete_.Set();
526 } else {
527 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
528 << wants.max_pixel_count << ", target res = "
529 << wants.target_pixel_count.value_or(-1)
530 << ", max fps = " << wants.max_framerate_fps;
531 }
532 break;
533 case TestPhase::kAdaptedUp:
534 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
535 << wants.max_pixel_count << ", target res = "
536 << wants.target_pixel_count.value_or(-1)
537 << ", max fps = " << wants.max_framerate_fps;
515 } 538 }
516 } 539 }
517 540
518 void ModifyVideoConfigs( 541 void ModifyVideoConfigs(
519 VideoSendStream::Config* send_config, 542 VideoSendStream::Config* send_config,
520 std::vector<VideoReceiveStream::Config>* receive_configs, 543 std::vector<VideoReceiveStream::Config>* receive_configs,
521 VideoEncoderConfig* encoder_config) override { 544 VideoEncoderConfig* encoder_config) override {
522 send_config->encoder_settings.encoder = &encoder_;
523 } 545 }
524 546
525 void PerformTest() override { 547 void PerformTest() override {
526 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; 548 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
527 } 549 }
528 550
529 bool expect_lower_resolution_wants_; 551 enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_;
530 test::DelayedEncoder encoder_;
531 } test; 552 } test;
532 553
533 RunBaseTest(&test); 554 RunBaseTest(&test);
534 } 555 }
535 556
536 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { 557 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
537 static const int kMaxEncodeBitrateKbps = 30; 558 static const int kMaxEncodeBitrateKbps = 30;
538 static const int kMinTransmitBitrateBps = 150000; 559 static const int kMinTransmitBitrateBps = 150000;
539 static const int kMinAcceptableTransmitBitrate = 130; 560 static const int kMinAcceptableTransmitBitrate = 130;
540 static const int kMaxAcceptableTransmitBitrate = 170; 561 static const int kMaxAcceptableTransmitBitrate = 170;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 uint32_t last_set_bitrate_kbps_; 764 uint32_t last_set_bitrate_kbps_;
744 VideoSendStream* send_stream_; 765 VideoSendStream* send_stream_;
745 test::FrameGeneratorCapturer* frame_generator_; 766 test::FrameGeneratorCapturer* frame_generator_;
746 VideoEncoderConfig encoder_config_; 767 VideoEncoderConfig encoder_config_;
747 } test; 768 } test;
748 769
749 RunBaseTest(&test); 770 RunBaseTest(&test);
750 } 771 }
751 772
752 } // namespace webrtc 773 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698