commit 9a443f432adc7afe11650b4ea488f3cea8ebad9b parent 65809abc0f0c8f160595693387be050352a65f5d Author: Michael Froman <mfroman@mozilla.com> Date: Wed, 8 Oct 2025 15:45:03 -0500 Bug 1993083 - Vendor libwebrtc from d1475bdd72 Upstream commit: https://webrtc.googlesource.com/src/+/d1475bdd72f3cc2d7a72b8971891b9dcdc885cb4 Add and use CreateTestFieldTrialsPtr function for convinience and clarity Though many tests use FieldTrials by value or const reference, some tests need FieldTrials wrapped into unique_ptr, for example, to pass it to Environment. To better support 2nd set of tests, this patch suggest a new simple wrapper for the common need to create unique_ptr<FieldTrials>. Bug: webrtc:419453427 Change-Id: Icff3e69d858642f43ad79cea5016a5d850616146 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/397162 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#44991} Diffstat:
17 files changed, 49 insertions(+), 61 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-08T20:43:51.601754+00:00. +libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-08T20:44:54.391067+00:00. # base of lastest vendoring -4a5a5a3e06 +d1475bdd72 diff --git a/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_unittest.cc b/third_party/libwebrtc/api/audio_codecs/opus/audio_decoder_opus_unittest.cc @@ -17,7 +17,6 @@ #include "api/audio_codecs/audio_format.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "test/create_test_field_trials.h" #include "test/gmock.h" #include "test/gtest.h" @@ -88,9 +87,8 @@ TEST(AudioDecoderOpusTest, MakeAudioDecoderCannotForceDefaultNumChannels) { } TEST(AudioDecoderOpusTest, MakeAudioDecoderForcesStereo) { - const Environment env = - CreateEnvironment(std::make_unique<FieldTrials>(CreateTestFieldTrials( - "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/"))); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/")); auto decoder = AudioDecoderOpus::MakeAudioDecoder( env, /*config=*/{.num_channels = std::nullopt}); @@ -99,9 +97,8 @@ TEST(AudioDecoderOpusTest, MakeAudioDecoderForcesStereo) { } TEST(AudioDecoderOpusTest, MakeAudioDecoderCannotForceStereo) { - const Environment env = - CreateEnvironment(std::make_unique<FieldTrials>(CreateTestFieldTrials( - "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/"))); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Audio-OpusDecodeStereoByDefault/Enabled/")); auto decoder = AudioDecoderOpus::MakeAudioDecoder(env, /*config=*/{.num_channels = 1}); diff --git a/third_party/libwebrtc/api/test/pclf/peer_configurer.cc b/third_party/libwebrtc/api/test/pclf/peer_configurer.cc @@ -55,8 +55,7 @@ PeerConfigurer::PeerConfigurer(PeerNetworkDependencies& network) network.socket_factory())), params_(std::make_unique<Params>()), configurable_params_(std::make_unique<ConfigurableParams>()) { - components_->pcf_dependencies->field_trials = - std::make_unique<FieldTrials>(CreateTestFieldTrials()); + components_->pcf_dependencies->field_trials = CreateTestFieldTrialsPtr(); } PeerConfigurer* PeerConfigurer::SetName(absl::string_view name) { diff --git a/third_party/libwebrtc/modules/audio_coding/test/TestRedFec.cc b/third_party/libwebrtc/modules/audio_coding/test/TestRedFec.cc @@ -33,7 +33,6 @@ #include "api/audio_codecs/opus/audio_decoder_opus.h" #include "api/audio_codecs/opus/audio_encoder_opus.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/neteq/default_neteq_factory.h" #include "api/neteq/neteq.h" #include "common_audio/vad/include/vad.h" @@ -49,8 +48,7 @@ namespace webrtc { TestRedFec::TestRedFec() - : env_(CreateEnvironment( - std::make_unique<FieldTrials>(CreateTestFieldTrials()))), + : env_(CreateEnvironment(CreateTestFieldTrialsPtr())), encoder_factory_(CreateAudioEncoderFactory<AudioEncoderG711, AudioEncoderG722, AudioEncoderL16, diff --git a/third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc b/third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_unittest.cc @@ -18,7 +18,6 @@ #include "api/array_view.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/video/encoded_image.h" #include "api/video/video_frame.h" #include "api/video_codecs/video_decoder.h" @@ -97,9 +96,8 @@ TEST(Dav1dDecoderTest, KeepsDecodedResolutionByDefault) { } TEST(Dav1dDecoderTest, CropsToRenderResolutionWhenCropIsEnabled) { - TestAv1Decoder decoder( - CreateEnvironment(std::make_unique<FieldTrials>(CreateTestFieldTrials( - "WebRTC-Dav1dDecoder-CropToRenderResolution/Enabled/")))); + TestAv1Decoder decoder(CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Dav1dDecoder-CropToRenderResolution/Enabled/"))); decoder.Decode( CreateEncodedImage(kAv1FrameWith36x20EncodededAnd32x16RenderResolution)); EXPECT_EQ(decoder.decoded_frame().width(), 32); @@ -107,9 +105,8 @@ TEST(Dav1dDecoderTest, CropsToRenderResolutionWhenCropIsEnabled) { } TEST(Dav1dDecoderTest, DoesNotCropToRenderResolutionWhenCropIsDisabled) { - TestAv1Decoder decoder( - CreateEnvironment(std::make_unique<FieldTrials>(CreateTestFieldTrials( - "WebRTC-Dav1dDecoder-CropToRenderResolution/Disabled/")))); + TestAv1Decoder decoder(CreateEnvironment(CreateTestFieldTrialsPtr( + "WebRTC-Dav1dDecoder-CropToRenderResolution/Disabled/"))); decoder.Decode( CreateEncodedImage(kAv1FrameWith36x20EncodededAnd32x16RenderResolution)); EXPECT_EQ(decoder.decoded_frame().width(), 36); diff --git a/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc b/third_party/libwebrtc/modules/video_coding/codecs/test/video_codec_test.cc @@ -23,7 +23,6 @@ #include "absl/flags/flag.h" #include "api/environment/environment.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/test/metrics/global_metrics_logger_and_exporter.h" #include "api/units/data_rate.h" #include "api/units/frequency.h" @@ -575,8 +574,7 @@ INSTANTIATE_TEST_SUITE_P(All, FramerateAdaptationTest::TestParamsToString); TEST(VideoCodecTest, DISABLED_EncodeDecode) { - const Environment env = - CreateEnvironment(std::make_unique<FieldTrials>(CreateTestFieldTrials())); + const Environment env = CreateEnvironment(CreateTestFieldTrialsPtr()); VideoSourceSettings source_settings{ .file_path = absl::GetFlag(FLAGS_input_path), diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -1194,10 +1194,10 @@ index c1181618e9..4a772795ed 100644 deps += [ "..:logging", diff --git a/test/BUILD.gn b/test/BUILD.gn -index c5d3791a2a..075db77d4e 100644 +index 739678aa84..9ac30f1b79 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn -@@ -258,6 +258,7 @@ rtc_library("audio_test_common") { +@@ -259,6 +259,7 @@ rtc_library("audio_test_common") { ] } @@ -1205,7 +1205,7 @@ index c5d3791a2a..075db77d4e 100644 if (!build_with_chromium) { if (is_mac || is_ios) { rtc_library("video_test_mac") { -@@ -314,8 +315,12 @@ if (!build_with_chromium) { +@@ -315,8 +316,12 @@ if (!build_with_chromium) { } } } @@ -1218,7 +1218,7 @@ index c5d3791a2a..075db77d4e 100644 testonly = true sources = [ "rtcp_packet_parser.cc", -@@ -325,6 +330,7 @@ rtc_library("rtp_test_utils") { +@@ -326,6 +331,7 @@ rtc_library("rtp_test_utils") { "rtp_file_writer.cc", "rtp_file_writer.h", ] @@ -1226,7 +1226,7 @@ index c5d3791a2a..075db77d4e 100644 deps = [ "../api:array_view", -@@ -542,7 +548,9 @@ rtc_library("video_frame_writer") { +@@ -543,7 +549,9 @@ rtc_library("video_frame_writer") { ] if (!is_ios) { @@ -1236,7 +1236,7 @@ index c5d3791a2a..075db77d4e 100644 sources += [ "testsupport/jpeg_frame_writer.cc" ] } else { sources += [ "testsupport/jpeg_frame_writer_ios.cc" ] -@@ -1385,6 +1393,7 @@ if (!build_with_chromium) { +@@ -1386,6 +1394,7 @@ if (!build_with_chromium) { } } @@ -1244,7 +1244,7 @@ index c5d3791a2a..075db77d4e 100644 if (!build_with_chromium && is_android) { rtc_android_library("native_test_java") { testonly = true -@@ -1427,6 +1436,7 @@ if (!build_with_chromium && is_android) { +@@ -1428,6 +1437,7 @@ if (!build_with_chromium && is_android) { sources = [ "android/org/webrtc/native_test/NativeTestWebrtc.java" ] } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0099.patch b/third_party/libwebrtc/moz-patch-stack/s0099.patch @@ -86,10 +86,10 @@ index 7aa3c3f428..2ca0a36dbb 100644 if (!build_with_mozilla) { diff --git a/test/BUILD.gn b/test/BUILD.gn -index 075db77d4e..a4d00f02e2 100644 +index 9ac30f1b79..1dda47bb61 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn -@@ -509,6 +509,12 @@ rtc_source_set("test_support") { +@@ -510,6 +510,12 @@ rtc_source_set("test_support") { "//testing/gmock", "//testing/gtest", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0103.patch b/third_party/libwebrtc/moz-patch-stack/s0103.patch @@ -756,7 +756,7 @@ index 8222263e1f..913382709e 100644 import("../webrtc.gni") diff --git a/test/BUILD.gn b/test/BUILD.gn -index a4d00f02e2..359e600bab 100644 +index 1dda47bb61..c1ae6bba46 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -6,10 +6,10 @@ @@ -772,7 +772,7 @@ index a4d00f02e2..359e600bab 100644 import("//third_party/jni_zero/jni_zero.gni") } -@@ -454,7 +454,7 @@ if (is_ios) { +@@ -455,7 +455,7 @@ if (is_ios) { testonly = true visibility = [ "*" ] sources = [ "ios/google_test_runner.mm" ] diff --git a/third_party/libwebrtc/pc/peer_connection_callsetup_perf_tests.cc b/third_party/libwebrtc/pc/peer_connection_callsetup_perf_tests.cc @@ -21,7 +21,6 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/data_channel_interface.h" -#include "api/field_trials.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/rtc_error.h" @@ -72,10 +71,9 @@ class PeerConnectionDataChannelOpenTest absl::string_view field_trials = "") { auto pc_wrapper = make_ref_counted<PeerConnectionTestWrapper>( "pc", &vss_, background_thread_.get(), background_thread_.get()); - pc_wrapper->CreatePc( - {}, CreateBuiltinAudioEncoderFactory(), - CreateBuiltinAudioDecoderFactory(), - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials))); + pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + CreateTestFieldTrialsPtr(field_trials)); return pc_wrapper; } diff --git a/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc b/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc @@ -26,7 +26,6 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" -#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/jsep.h" #include "api/make_ref_counted.h" @@ -235,10 +234,9 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test { absl::string_view field_trials = "") { auto pc_wrapper = make_ref_counted<PeerConnectionTestWrapper>( "pc", &pss_, background_thread_.get(), background_thread_.get()); - pc_wrapper->CreatePc( - {}, CreateBuiltinAudioEncoderFactory(), - CreateBuiltinAudioDecoderFactory(), - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials))); + pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(), + CreateBuiltinAudioDecoderFactory(), + CreateTestFieldTrialsPtr(field_trials)); return pc_wrapper; } diff --git a/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc b/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc @@ -19,7 +19,6 @@ #include "absl/strings/string_view.h" #include "api/enable_media_with_defaults.h" #include "api/environment/environment_factory.h" -#include "api/field_trials.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/rtp_parameters.h" @@ -66,8 +65,7 @@ class PeerConnectionFieldTrialTest : public ::testing::Test { void CreatePCFactory(absl::string_view field_trials) { PeerConnectionFactoryDependencies pcf_deps; pcf_deps.signaling_thread = Thread::Current(); - pcf_deps.env = CreateEnvironment( - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials))); + pcf_deps.env = CreateEnvironment(CreateTestFieldTrialsPtr(field_trials)); pcf_deps.adm = FakeAudioCaptureModule::Create(); EnableMediaWithDefaults(pcf_deps); pc_factory_ = CreateModularPeerConnectionFactory(std::move(pcf_deps)); diff --git a/third_party/libwebrtc/pc/sdp_munging_detector_unittest.cc b/third_party/libwebrtc/pc/sdp_munging_detector_unittest.cc @@ -128,8 +128,7 @@ class SdpMungingTest : public ::testing::Test { absl::string_view field_trials) { auto observer = std::make_unique<MockPeerConnectionObserver>(); PeerConnectionDependencies pc_deps(observer.get()); - pc_deps.trials = - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials)); + pc_deps.trials = CreateTestFieldTrialsPtr(field_trials); auto result = pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps)); EXPECT_TRUE(result.ok()); diff --git a/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc b/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc @@ -24,7 +24,6 @@ #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" -#include "api/field_trials.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" @@ -123,8 +122,7 @@ class SdpOfferAnswerTest : public ::testing::Test { absl::string_view field_trials) { auto observer = std::make_unique<MockPeerConnectionObserver>(); PeerConnectionDependencies pc_deps(observer.get()); - pc_deps.trials = - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials)); + pc_deps.trials = CreateTestFieldTrialsPtr(field_trials); auto result = pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps)); EXPECT_TRUE(result.ok()); diff --git a/third_party/libwebrtc/pc/test/integration_test_helpers.h b/third_party/libwebrtc/pc/test/integration_test_helpers.h @@ -34,7 +34,6 @@ #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" #include "api/dtls_transport_interface.h" -#include "api/field_trials.h" #include "api/field_trials_view.h" #include "api/ice_transport_interface.h" #include "api/jsep.h" @@ -1469,12 +1468,11 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { if (it != field_trials_overrides_.end()) { field_trials = it->second; } - if (!client->Init( - options, &modified_config, std::move(dependencies), fss_.get(), - network_thread_.get(), worker_thread_.get(), - std::make_unique<FieldTrials>(CreateTestFieldTrials(field_trials)), - std::move(event_log_factory), reset_encoder_factory, - reset_decoder_factory, create_media_engine)) { + if (!client->Init(options, &modified_config, std::move(dependencies), + fss_.get(), network_thread_.get(), worker_thread_.get(), + CreateTestFieldTrialsPtr(field_trials), + std::move(event_log_factory), reset_encoder_factory, + reset_decoder_factory, create_media_engine)) { return nullptr; } return client; diff --git a/third_party/libwebrtc/test/BUILD.gn b/third_party/libwebrtc/test/BUILD.gn @@ -154,6 +154,7 @@ rtc_library("create_test_field_trials") { sources = [ "create_test_field_trials.h" ] deps = [ "../api:field_trials", + "//third_party/abseil-cpp/absl/base:nullability", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/third_party/libwebrtc/test/create_test_field_trials.h b/third_party/libwebrtc/test/create_test_field_trials.h @@ -10,6 +10,9 @@ #ifndef TEST_CREATE_TEST_FIELD_TRIALS_H_ #define TEST_CREATE_TEST_FIELD_TRIALS_H_ +#include <memory> + +#include "absl/base/nullability.h" #include "absl/strings/string_view.h" #include "api/field_trials.h" @@ -20,9 +23,15 @@ namespace webrtc { // the command line flag. // Crashes if command line flag or the `s` are not a valid field trial string. // -// The intention of this function is to be the default source of field trials +// The intention of these functions is to be the default source of field trials // in tests so that tests always use the command line flag. +// The behavior of these two functions is identical, they differ only in the +// return types for convenience. FieldTrials CreateTestFieldTrials(absl::string_view s = ""); +inline absl_nonnull std::unique_ptr<FieldTrials> CreateTestFieldTrialsPtr( + absl::string_view s = "") { + return std::make_unique<FieldTrials>(CreateTestFieldTrials(s)); +} } // namespace webrtc