Add field trial and test for NetEq extra delay
Adding field trial WebRTC-Audio-NetEqExtraDelay with a parameter value
to set the extra delay in NetEq. This overrides the
extra_output_delay_ms parameter in NetEq::Config.
Bug: b/156734419
Change-Id: Iae7d439fafa3059494249959ac13a02de63d6b7a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176858
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31493}
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 163a287..f1cd801 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -51,6 +51,7 @@
#include "rtc_base/strings/audio_format_to_string.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/clock.h"
+#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
@@ -73,6 +74,24 @@
return controller_factory.CreateNetEqController(config);
}
+int GetDelayChainLengthMs(int config_extra_delay_ms) {
+ constexpr char kExtraDelayFieldTrial[] = "WebRTC-Audio-NetEqExtraDelay";
+ if (webrtc::field_trial::IsEnabled(kExtraDelayFieldTrial)) {
+ const auto field_trial_string =
+ webrtc::field_trial::FindFullName(kExtraDelayFieldTrial);
+ int extra_delay_ms = -1;
+ if (sscanf(field_trial_string.c_str(), "Enabled-%d", &extra_delay_ms) ==
+ 1 &&
+ extra_delay_ms >= 0 && extra_delay_ms <= 2000) {
+ RTC_LOG(LS_INFO) << "Delay chain length set to " << extra_delay_ms
+ << " ms in field trial";
+ return (extra_delay_ms / 10) * 10; // Rounding down to multiple of 10.
+ }
+ }
+ // Field trial not set, or invalid value read. Use value from config.
+ return config_extra_delay_ms;
+}
+
} // namespace
NetEqImpl::Dependencies::Dependencies(
@@ -141,9 +160,9 @@
tick_timer_.get()),
no_time_stretching_(config.for_test_no_time_stretching),
enable_rtx_handling_(config.enable_rtx_handling),
- output_delay_chain_(
- rtc::CheckedDivExact(config.extra_output_delay_ms, 10)),
- output_delay_chain_ms_(config.extra_output_delay_ms) {
+ output_delay_chain_ms_(
+ GetDelayChainLengthMs(config.extra_output_delay_ms)),
+ output_delay_chain_(rtc::CheckedDivExact(output_delay_chain_ms_, 10)) {
RTC_LOG(LS_INFO) << "NetEq config: " << config.ToString();
int fs = config.sample_rate_hz;
if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) {