From 3361af35ddfef81dcc35983a155c6521f63a138f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85sa=20Persson?= Date: Mon, 18 May 2020 11:01:33 +0200 Subject: [PATCH] Add option to disable reduced jitter delay through field trial. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: none Change-Id: Id07cb7dd69cd6198eb95a5e9c0987943471f7da2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175565 Reviewed-by: Christoffer Rodbro Commit-Queue: Åsa Persson Cr-Commit-Position: refs/heads/master@{#31320} --- modules/video_coding/jitter_estimator.cc | 34 +++++++++++-------- modules/video_coding/jitter_estimator.h | 1 + .../video_coding/jitter_estimator_tests.cc | 16 +++++++++ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc index cd505835d1..44e2a9811e 100644 --- a/modules/video_coding/jitter_estimator.cc +++ b/modules/video_coding/jitter_estimator.cc @@ -23,6 +23,7 @@ #include "rtc_base/experiments/jitter_upper_bound_experiment.h" #include "rtc_base/numerics/safe_conversions.h" #include "system_wrappers/include/clock.h" +#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { @@ -50,6 +51,8 @@ VCMJitterEstimator::VCMJitterEstimator(Clock* clock) time_deviation_upper_bound_( JitterUpperBoundExperiment::GetUpperBoundSigmas().value_or( kDefaultMaxTimestampDeviationInSigmas)), + enable_reduced_delay_( + !field_trial::IsEnabled("WebRTC-ReducedJitterDelayKillSwitch")), clock_(clock) { Reset(); } @@ -395,22 +398,25 @@ int VCMJitterEstimator::GetJitterEstimate( } } - static const double kJitterScaleLowThreshold = 5.0; - static const double kJitterScaleHighThreshold = 10.0; - double fps = GetFrameRate(); - // Ignore jitter for very low fps streams. - if (fps < kJitterScaleLowThreshold) { - if (fps == 0.0) { - return rtc::checked_cast(std::max(0.0, jitterMS) + 0.5); + if (enable_reduced_delay_) { + static const double kJitterScaleLowThreshold = 5.0; + static const double kJitterScaleHighThreshold = 10.0; + double fps = GetFrameRate(); + // Ignore jitter for very low fps streams. + if (fps < kJitterScaleLowThreshold) { + if (fps == 0.0) { + return rtc::checked_cast(std::max(0.0, jitterMS) + 0.5); + } + return 0; } - return 0; - } - // Semi-low frame rate; scale by factor linearly interpolated from 0.0 at - // kJitterScaleLowThreshold to 1.0 at kJitterScaleHighThreshold. - if (fps < kJitterScaleHighThreshold) { - jitterMS = (1.0 / (kJitterScaleHighThreshold - kJitterScaleLowThreshold)) * - (fps - kJitterScaleLowThreshold) * jitterMS; + // Semi-low frame rate; scale by factor linearly interpolated from 0.0 at + // kJitterScaleLowThreshold to 1.0 at kJitterScaleHighThreshold. + if (fps < kJitterScaleHighThreshold) { + jitterMS = + (1.0 / (kJitterScaleHighThreshold - kJitterScaleLowThreshold)) * + (fps - kJitterScaleLowThreshold) * jitterMS; + } } return rtc::checked_cast(std::max(0.0, jitterMS) + 0.5); diff --git a/modules/video_coding/jitter_estimator.h b/modules/video_coding/jitter_estimator.h index d9798b40a1..1d69b95769 100644 --- a/modules/video_coding/jitter_estimator.h +++ b/modules/video_coding/jitter_estimator.h @@ -150,6 +150,7 @@ class VCMJitterEstimator { rtc::RollingAccumulator fps_counter_; const double time_deviation_upper_bound_; + const bool enable_reduced_delay_; Clock* clock_; }; diff --git a/modules/video_coding/jitter_estimator_tests.cc b/modules/video_coding/jitter_estimator_tests.cc index 1ad9abb56f..14baae7e81 100644 --- a/modules/video_coding/jitter_estimator_tests.cc +++ b/modules/video_coding/jitter_estimator_tests.cc @@ -72,6 +72,22 @@ TEST_F(TestVCMJitterEstimator, TestLowRate) { } } +TEST_F(TestVCMJitterEstimator, TestLowRateDisabled) { + test::ScopedFieldTrials field_trials( + "WebRTC-ReducedJitterDelayKillSwitch/Enabled/"); + SetUp(); + + ValueGenerator gen(10); + uint64_t time_delta_us = rtc::kNumMicrosecsPerSec / 5; + for (int i = 0; i < 60; ++i) { + estimator_->UpdateEstimate(gen.Delay(), gen.FrameSize()); + AdvanceClock(time_delta_us); + if (i > 2) + EXPECT_GT(estimator_->GetJitterEstimate(0, absl::nullopt), 0); + gen.Advance(); + } +} + TEST_F(TestVCMJitterEstimator, TestUpperBound) { struct TestContext { TestContext()