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: Rebase fix 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 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() : SendTest(kLongTimeoutMs), test_phase_(TestPhase::kStart) {}
484 : SendTest(kLongTimeoutMs),
485 expect_lower_resolution_wants_(true),
486 encoder_(Clock::GetRealTimeClock(), 60 /* delay_ms */) {}
487 490
488 void OnFrameGeneratorCapturerCreated( 491 void OnFrameGeneratorCapturerCreated(
489 test::FrameGeneratorCapturer* frame_generator_capturer) override { 492 test::FrameGeneratorCapturer* frame_generator_capturer) override {
490 frame_generator_capturer->SetSinkWantsObserver(this); 493 frame_generator_capturer->SetSinkWantsObserver(this);
491 // Set a high initial resolution to be sure that we can scale down. 494 // Set a high initial resolution to be sure that we can scale down.
492 frame_generator_capturer->ChangeResolution(1920, 1080); 495 frame_generator_capturer->ChangeResolution(1920, 1080);
493 } 496 }
494 497
495 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink 498 // OnSinkWantsChanged is called when FrameGeneratorCapturer::AddOrUpdateSink
496 // is called. 499 // is called.
500 // TODO(sprang): Add integration test for maintain-framerate mode?
497 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink, 501 void OnSinkWantsChanged(rtc::VideoSinkInterface<VideoFrame>* sink,
498 const rtc::VideoSinkWants& wants) override { 502 const rtc::VideoSinkWants& wants) override {
499 // First expect CPU overuse. Then expect CPU underuse when the encoder 503 // First expect CPU overuse. Then expect CPU underuse when the encoder
500 // delay has been decreased. 504 // delay has been decreased.
501 if (wants.target_pixel_count && 505 switch (test_phase_) {
502 *wants.target_pixel_count < 506 case TestPhase::kStart:
503 wants.max_pixel_count.value_or(std::numeric_limits<int>::max())) { 507 if (wants.max_pixel_count < std::numeric_limits<int>::max()) {
504 // On adapting up, ViEEncoder::VideoSourceProxy will set the target 508 // On adapting down, ViEEncoder::VideoSourceProxy will set only the
505 // pixel count to a step up from the current and the max value to 509 // max pixel count, leaving the target unset.
506 // something higher than the target. 510 test_phase_ = TestPhase::kAdaptedDown;
507 EXPECT_FALSE(expect_lower_resolution_wants_); 511 } else {
508 observation_complete_.Set(); 512 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
509 } else if (wants.max_pixel_count) { 513 << wants.max_pixel_count << ", target res = "
510 // On adapting down, ViEEncoder::VideoSourceProxy will set only the max 514 << wants.target_pixel_count.value_or(-1)
511 // pixel count, leaving the target unset. 515 << ", max fps = " << wants.max_framerate_fps;
512 EXPECT_TRUE(expect_lower_resolution_wants_); 516 }
513 expect_lower_resolution_wants_ = false; 517 break;
514 encoder_.SetDelay(2); 518 case TestPhase::kAdaptedDown:
519 // On adapting up, the adaptation counter will again be at zero, and
520 // so all constraints will be reset.
521 if (wants.max_pixel_count == std::numeric_limits<int>::max() &&
522 !wants.target_pixel_count) {
523 test_phase_ = TestPhase::kAdaptedUp;
524 observation_complete_.Set();
525 } else {
526 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
527 << wants.max_pixel_count << ", target res = "
528 << wants.target_pixel_count.value_or(-1)
529 << ", max fps = " << wants.max_framerate_fps;
530 }
531 break;
532 case TestPhase::kAdaptedUp:
533 ADD_FAILURE() << "Got unexpected adaptation request, max res = "
534 << wants.max_pixel_count << ", target res = "
535 << wants.target_pixel_count.value_or(-1)
536 << ", max fps = " << wants.max_framerate_fps;
515 } 537 }
516 } 538 }
517 539
518 void ModifyVideoConfigs( 540 void ModifyVideoConfigs(
519 VideoSendStream::Config* send_config, 541 VideoSendStream::Config* send_config,
520 std::vector<VideoReceiveStream::Config>* receive_configs, 542 std::vector<VideoReceiveStream::Config>* receive_configs,
521 VideoEncoderConfig* encoder_config) override { 543 VideoEncoderConfig* encoder_config) override {
522 send_config->encoder_settings.encoder = &encoder_;
523 } 544 }
524 545
525 void PerformTest() override { 546 void PerformTest() override {
526 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; 547 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
527 } 548 }
528 549
529 bool expect_lower_resolution_wants_; 550 enum class TestPhase { kStart, kAdaptedDown, kAdaptedUp } test_phase_;
530 test::DelayedEncoder encoder_;
531 } test; 551 } test;
532 552
533 RunBaseTest(&test); 553 RunBaseTest(&test);
534 } 554 }
535 555
536 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { 556 void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) {
537 static const int kMaxEncodeBitrateKbps = 30; 557 static const int kMaxEncodeBitrateKbps = 30;
538 static const int kMinTransmitBitrateBps = 150000; 558 static const int kMinTransmitBitrateBps = 150000;
539 static const int kMinAcceptableTransmitBitrate = 130; 559 static const int kMinAcceptableTransmitBitrate = 130;
540 static const int kMaxAcceptableTransmitBitrate = 170; 560 static const int kMaxAcceptableTransmitBitrate = 170;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 uint32_t last_set_bitrate_kbps_; 763 uint32_t last_set_bitrate_kbps_;
744 VideoSendStream* send_stream_; 764 VideoSendStream* send_stream_;
745 test::FrameGeneratorCapturer* frame_generator_; 765 test::FrameGeneratorCapturer* frame_generator_;
746 VideoEncoderConfig encoder_config_; 766 VideoEncoderConfig encoder_config_;
747 } test; 767 } test;
748 768
749 RunBaseTest(&test); 769 RunBaseTest(&test);
750 } 770 }
751 771
752 } // namespace webrtc 772 } // 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