commit a9ace7e09467a3299badadacc274e22c0e6354de parent c2490c82adc5963d21bb06d1b383ad924bae3cbc Author: Michael Froman <mfroman@mozilla.com> Date: Wed, 8 Oct 2025 17:12:29 -0500 Bug 1993083 - Vendor libwebrtc from 1542bb1859 Upstream commit: https://webrtc.googlesource.com/src/+/1542bb185940e678d337f305153155d944ac57f2 Create delay manager API in NetEq Bug: webrtc:428147754 Change-Id: Idf6d7534add0b1b096a9997d0c1a3cec00e31768 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/398280 Commit-Queue: Diep Bui <diepbp@webrtc.org> Reviewed-by: Jakob Ivarsson‎ <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45037} Diffstat:
16 files changed, 227 insertions(+), 34 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T22:11:03.587841+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T22:12:18.849456+00:00. # base of lastest vendoring -912a0d864d +1542bb1859 diff --git a/third_party/libwebrtc/api/neteq/BUILD.gn b/third_party/libwebrtc/api/neteq/BUILD.gn @@ -89,6 +89,34 @@ rtc_library("default_neteq_controller_factory") { ] } +rtc_library("custom_neteq_controller_factory") { + visibility = [ "*" ] + sources = [ + "custom_neteq_controller_factory.cc", + "custom_neteq_controller_factory.h", + ] + deps = [ + ":delay_manager_api", + ":neteq_controller_api", + "../../modules/audio_coding:neteq", + "../../rtc_base:checks", + "../environment", + ] +} + +rtc_library("delay_manager_api") { + visibility = [ "*" ] + sources = [ + "delay_manager_factory.h", + "delay_manager_interface.h", + ] + deps = [ + ":neteq_controller_api", + ":tick_timer", + "..:field_trials_view", + ] +} + rtc_library("tick_timer") { visibility = [ "*" ] sources = [ diff --git a/third_party/libwebrtc/api/neteq/custom_neteq_controller_factory.cc b/third_party/libwebrtc/api/neteq/custom_neteq_controller_factory.cc @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "api/neteq/custom_neteq_controller_factory.h" + +#include <memory> +#include <utility> + +#include "api/environment/environment.h" +#include "api/neteq/delay_manager_factory.h" +#include "api/neteq/neteq_controller.h" +#include "modules/audio_coding/neteq/decision_logic.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +CustomNetEqControllerFactory::CustomNetEqControllerFactory( + std::unique_ptr<DelayManagerFactory> delay_manager_factory) + : delay_manager_factory_(std::move(delay_manager_factory)) {} +CustomNetEqControllerFactory::~CustomNetEqControllerFactory() = default; + +std::unique_ptr<NetEqController> CustomNetEqControllerFactory::Create( + const Environment& env, + const NetEqController::Config& config) const { + RTC_DCHECK(delay_manager_factory_); + return std::make_unique<DecisionLogic>( + env, config, + delay_manager_factory_->Create(env.field_trials(), config.tick_timer)); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/api/neteq/custom_neteq_controller_factory.h b/third_party/libwebrtc/api/neteq/custom_neteq_controller_factory.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ +#define API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ + +#include <memory> + +#include "api/environment/environment.h" +#include "api/neteq/delay_manager_factory.h" +#include "api/neteq/neteq_controller.h" +#include "api/neteq/neteq_controller_factory.h" +namespace webrtc { + +// This factory can be used to generate NetEqController instances that make +// use of a custom DelayManagerFactory. +class CustomNetEqControllerFactory : public NetEqControllerFactory { + public: + explicit CustomNetEqControllerFactory( + std::unique_ptr<DelayManagerFactory> delay_manager_factory); + ~CustomNetEqControllerFactory() override; + CustomNetEqControllerFactory(const CustomNetEqControllerFactory&) = delete; + CustomNetEqControllerFactory& operator=(const CustomNetEqControllerFactory&) = + delete; + + std::unique_ptr<NetEqController> Create( + const Environment& env, + const NetEqController::Config& config) const override; + + private: + std::unique_ptr<DelayManagerFactory> delay_manager_factory_; +}; + +} // namespace webrtc + +#endif // API_NETEQ_CUSTOM_NETEQ_CONTROLLER_FACTORY_H_ diff --git a/third_party/libwebrtc/api/neteq/default_neteq_controller_factory.cc b/third_party/libwebrtc/api/neteq/default_neteq_controller_factory.cc @@ -11,10 +11,12 @@ #include "api/neteq/default_neteq_controller_factory.h" #include <memory> +#include <utility> #include "api/environment/environment.h" #include "api/neteq/neteq_controller.h" #include "modules/audio_coding/neteq/decision_logic.h" +#include "modules/audio_coding/neteq/delay_manager.h" namespace webrtc { @@ -24,7 +26,9 @@ DefaultNetEqControllerFactory::~DefaultNetEqControllerFactory() = default; std::unique_ptr<NetEqController> DefaultNetEqControllerFactory::Create( const Environment& env, const NetEqController::Config& config) const { - return std::make_unique<DecisionLogic>(env, config); + auto delay_manager = std::make_unique<DelayManager>( + DelayManager::Config(env.field_trials()), config.tick_timer); + return std::make_unique<DecisionLogic>(env, config, std::move(delay_manager)); } } // namespace webrtc diff --git a/third_party/libwebrtc/api/neteq/delay_manager_factory.h b/third_party/libwebrtc/api/neteq/delay_manager_factory.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_DELAY_MANAGER_FACTORY_H_ +#define API_NETEQ_DELAY_MANAGER_FACTORY_H_ + +#include <memory> + +#include "api/field_trials_view.h" +#include "api/neteq/delay_manager_interface.h" +#include "api/neteq/tick_timer.h" +namespace webrtc { + +// Creates DelayManagerInterface instances. +class DelayManagerFactory { + public: + virtual ~DelayManagerFactory() = default; + + // Creates a new DelayManager object. + virtual std::unique_ptr<DelayManagerInterface> Create( + const FieldTrialsView& field_trials, + const TickTimer* tick_timer) const = 0; +}; + +} // namespace webrtc + +#endif // API_NETEQ_DELAY_MANAGER_FACTORY_H_ diff --git a/third_party/libwebrtc/api/neteq/delay_manager_interface.h b/third_party/libwebrtc/api/neteq/delay_manager_interface.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef API_NETEQ_DELAY_MANAGER_INTERFACE_H_ +#define API_NETEQ_DELAY_MANAGER_INTERFACE_H_ + +#include "api/neteq/neteq_controller.h" + +namespace webrtc { + +// Interface for the delay manager. +class DelayManagerInterface { + public: + virtual ~DelayManagerInterface() = default; + + // Updates the delay manager that a new packet arrived with delay + // `arrival_delay_ms`. This updates the statistics and a new target buffer + // level is calculated. The `reordered` flag indicates if the packet was + // reordered. The `info` argument contains information about the packet. + virtual void Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) = 0; + + // Resets all state. + virtual void Reset() = 0; + + // Gets the target buffer level in milliseconds. + virtual int TargetDelayMs() const = 0; +}; + +} // namespace webrtc + +#endif // API_NETEQ_DELAY_MANAGER_INTERFACE_H_ diff --git a/third_party/libwebrtc/modules/audio_coding/BUILD.gn b/third_party/libwebrtc/modules/audio_coding/BUILD.gn @@ -528,6 +528,7 @@ rtc_library("neteq") { "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api", "../../api/environment", + "../../api/neteq:delay_manager_api", "../../api/neteq:neteq_api", "../../api/neteq:neteq_controller_api", "../../api/neteq:tick_timer", diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.cc @@ -17,10 +17,10 @@ #include <utility> #include "api/environment/environment.h" +#include "api/neteq/delay_manager_interface.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "modules/audio_coding/neteq/buffer_level_filter.h" -#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" #include "modules/audio_coding/neteq/packet_buffer.h" #include "rtc_base/checks.h" @@ -38,14 +38,6 @@ constexpr int kDelayAdjustmentGranularityMs = 20; constexpr int kPacketHistorySizeMs = 2000; constexpr size_t kCngTimeoutMs = 1000; -std::unique_ptr<DelayManager> CreateDelayManager( - const Environment& env, - const NetEqController::Config& neteq_config) { - DelayManager::Config config(env.field_trials()); - config.Log(); - return std::make_unique<DelayManager>(config, neteq_config.tick_timer); -} - bool IsTimestretch(NetEq::Mode mode) { return mode == NetEq::Mode::kAccelerateSuccess || mode == NetEq::Mode::kAccelerateLowEnergy || @@ -64,15 +56,17 @@ bool IsExpand(NetEq::Mode mode) { } // namespace -DecisionLogic::DecisionLogic(const Environment& env, - NetEqController::Config config) +DecisionLogic::DecisionLogic( + const Environment& env, + NetEqController::Config config, + std::unique_ptr<DelayManagerInterface> delay_manager) : DecisionLogic(config, - CreateDelayManager(env, config), + std::move(delay_manager), std::make_unique<BufferLevelFilter>()) {} DecisionLogic::DecisionLogic( NetEqController::Config config, - std::unique_ptr<DelayManager> delay_manager, + std::unique_ptr<DelayManagerInterface> delay_manager, std::unique_ptr<BufferLevelFilter> buffer_level_filter, std::unique_ptr<PacketArrivalHistory> packet_arrival_history) : delay_manager_(std::move(delay_manager)), @@ -196,7 +190,7 @@ std::optional<int> DecisionLogic::PacketArrived(int fs_hz, packet_arrival_history_->GetDelayMs(info.main_timestamp); bool reordered = !packet_arrival_history_->IsNewestRtpTimestamp(info.main_timestamp); - delay_manager_->Update(arrival_delay_ms, reordered); + delay_manager_->Update(arrival_delay_ms, reordered, info); return arrival_delay_ms; } diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic.h @@ -17,12 +17,12 @@ #include <optional> #include "api/environment/environment.h" +#include "api/neteq/delay_manager_interface.h" #include "api/neteq/neteq.h" #include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/buffer_level_filter.h" #include "modules/audio_coding/neteq/delay_constraints.h" -#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/packet_arrival_history.h" namespace webrtc { @@ -30,10 +30,12 @@ namespace webrtc { // This is the class for the decision tree implementation. class DecisionLogic : public NetEqController { public: - DecisionLogic(const Environment& env, NetEqController::Config config); + DecisionLogic(const Environment& env, + NetEqController::Config config, + std::unique_ptr<DelayManagerInterface> delay_manager); DecisionLogic( NetEqController::Config config, - std::unique_ptr<DelayManager> delay_manager, + std::unique_ptr<DelayManagerInterface> delay_manager, std::unique_ptr<BufferLevelFilter> buffer_level_filter, std::unique_ptr<PacketArrivalHistory> packet_arrival_history = nullptr); @@ -150,7 +152,7 @@ class DecisionLogic : public NetEqController { int GetPlayoutDelayMs(NetEqController::NetEqStatus status) const; - std::unique_ptr<DelayManager> delay_manager_; + std::unique_ptr<DelayManagerInterface> delay_manager_; DelayConstraints delay_constraints_; std::unique_ptr<BufferLevelFilter> buffer_level_filter_; std::unique_ptr<PacketArrivalHistory> packet_arrival_history_; diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager.cc b/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager.cc @@ -15,6 +15,7 @@ #include <memory> #include "api/field_trials_view.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/reorder_optimizer.h" #include "rtc_base/experiments/struct_parameters_parser.h" @@ -72,9 +73,9 @@ DelayManager::DelayManager(const Config& config, const TickTimer* tick_timer) Reset(); } -DelayManager::~DelayManager() {} - -void DelayManager::Update(int arrival_delay_ms, bool reordered) { +void DelayManager::Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) { if (!reorder_optimizer_ || !reordered) { underrun_optimizer_.Update(arrival_delay_ms); } diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager.h b/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager.h @@ -15,13 +15,15 @@ #include <optional> #include "api/field_trials_view.h" +#include "api/neteq/delay_manager_interface.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "modules/audio_coding/neteq/reorder_optimizer.h" #include "modules/audio_coding/neteq/underrun_optimizer.h" namespace webrtc { -class DelayManager { +class DelayManager : public DelayManagerInterface { public: struct Config { explicit Config(const FieldTrialsView& field_trials); @@ -40,7 +42,7 @@ class DelayManager { DelayManager(const Config& config, const TickTimer* tick_timer); - virtual ~DelayManager(); + ~DelayManager() override = default; DelayManager(const DelayManager&) = delete; DelayManager& operator=(const DelayManager&) = delete; @@ -49,15 +51,17 @@ class DelayManager { // `arrival_delay_ms`. This updates the statistics and a new target buffer // level is calculated. The `reordered` flag indicates if the packet was // reordered. - virtual void Update(int arrival_delay_ms, bool reordered); + void Update(int arrival_delay_ms, + bool reordered, + NetEqController::PacketArrivedInfo info) override; // Resets all state. - virtual void Reset(); + void Reset() override; // Gets the target buffer level in milliseconds. If a minimum or maximum delay // has been set, the target delay reported here also respects the configured // min/max delay. - virtual int TargetDelayMs() const; + int TargetDelayMs() const override; private: UnderrunOptimizer underrun_optimizer_; diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/delay_manager_unittest.cc @@ -12,6 +12,7 @@ #include "modules/audio_coding/neteq/delay_manager.h" +#include "api/neteq/neteq_controller.h" #include "api/neteq/tick_timer.h" #include "test/create_test_field_trials.h" #include "test/gtest.h" @@ -23,7 +24,7 @@ TEST(DelayManagerTest, UpdateNormal) { TickTimer tick_timer; DelayManager dm(DelayManager::Config(CreateTestFieldTrials()), &tick_timer); for (int i = 0; i < 50; ++i) { - dm.Update(0, false); + dm.Update(0, false, NetEqController::PacketArrivedInfo()); tick_timer.Increment(2); } EXPECT_EQ(20, dm.TargetDelayMs()); diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -36,6 +36,7 @@ #include "api/scoped_refptr.h" #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" #include "modules/audio_coding/neteq/decision_logic.h" +#include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/expand.h" #include "modules/audio_coding/neteq/mock/mock_decoder_database.h" #include "modules/audio_coding/neteq/mock/mock_dtmf_buffer.h" @@ -141,8 +142,10 @@ class NetEqImplTest : public ::testing::Test { controller_config.base_min_delay_ms = config_.min_delay_ms; controller_config.allow_time_stretching = true; controller_config.max_packets_in_buffer = config_.max_packets_in_buffer; - deps.neteq_controller = - std::make_unique<DecisionLogic>(env_, std::move(controller_config)); + auto delay_manager = std::make_unique<DelayManager>( + DelayManager::Config(env_.field_trials()), tick_timer_); + deps.neteq_controller = std::make_unique<DecisionLogic>( + env_, std::move(controller_config), std::move(delay_manager)); } neteq_controller_ = deps.neteq_controller.get(); diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -718,7 +718,7 @@ index 6d4d4a2363..316408a9b3 100644 : content_hint(VideoTrackInterface::ContentHint::kNone) {} VideoOptions::~VideoOptions() = default; diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn -index c3f061f69f..71ab9a1f47 100644 +index 77b22dc5bd..3d11071e89 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -362,7 +362,7 @@ rtc_library("webrtc_opus_wrapper") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0099.patch b/third_party/libwebrtc/moz-patch-stack/s0099.patch @@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/bbec1b95ddb5e0096 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn -index 71ab9a1f47..292864d32c 100644 +index 3d11071e89..3701a56caf 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -362,7 +362,7 @@ rtc_library("webrtc_opus_wrapper") {