From ea233be459bb4c415355fdcad14fa2acf3888364 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 12 Aug 2024 13:54:12 +0200 Subject: [PATCH] Remove passing FieldTrialsView into AudioDecoderFactory as unused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plan is to pass field trials using Environment when creating individual AudioDecoder rather than providing single set of field trials for the factory. Current implementation is not used, and doesn't pass field trials when actually creating an AudioDecoder Bug: webrtc:356878416 Change-Id: I0f79f09f7a6aa63e20fbdd783e90e8d026158330 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/359221 Reviewed-by: Jakob Ivarsson‎ Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#42762} --- api/audio_codecs/BUILD.gn | 1 - .../audio_decoder_factory_template.h | 27 +++++-------------- api/audio_codecs/test/BUILD.gn | 1 - ...audio_decoder_factory_template_unittest.cc | 5 +--- ...audio_encoder_factory_template_unittest.cc | 4 +-- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index 1a90815c0a..d91c50119b 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -34,7 +34,6 @@ rtc_library("audio_codecs_api") { "..:make_ref_counted", "..:ref_count", "..:scoped_refptr", - "../../api:field_trials_view", "../../api:rtp_parameters", "../../rtc_base:buffer", "../../rtc_base:checks", diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h index 0c026564dc..47f47b5b38 100644 --- a/api/audio_codecs/audio_decoder_factory_template.h +++ b/api/audio_codecs/audio_decoder_factory_template.h @@ -20,7 +20,6 @@ #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_format.h" -#include "api/field_trials_view.h" #include "api/make_ref_counted.h" #include "api/scoped_refptr.h" @@ -38,8 +37,7 @@ struct Helper<> { static bool IsSupportedDecoder(const SdpAudioFormat& format) { return false; } static std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - absl::optional codec_pair_id, - const FieldTrialsView* field_trials) { + absl::optional codec_pair_id) { return nullptr; } }; @@ -62,22 +60,16 @@ struct Helper { } static std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - absl::optional codec_pair_id, - const FieldTrialsView* field_trials) { + absl::optional codec_pair_id) { auto opt_config = T::SdpToConfig(format); return opt_config ? T::MakeAudioDecoder(*opt_config, codec_pair_id) - : Helper::MakeAudioDecoder(format, codec_pair_id, - field_trials); + : Helper::MakeAudioDecoder(format, codec_pair_id); } }; template class AudioDecoderFactoryT : public AudioDecoderFactory { public: - explicit AudioDecoderFactoryT(const FieldTrialsView* field_trials) { - field_trials_ = field_trials; - } - std::vector GetSupportedDecoders() override { std::vector specs; Helper::AppendSupportedDecoders(&specs); @@ -91,11 +83,8 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, absl::optional codec_pair_id) override { - return Helper::MakeAudioDecoder(format, codec_pair_id, - field_trials_); + return Helper::MakeAudioDecoder(format, codec_pair_id); } - - const FieldTrialsView* field_trials_; }; } // namespace audio_decoder_factory_template_impl @@ -131,8 +120,7 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { // TODO(kwiberg): Point at CreateBuiltinAudioDecoderFactory() for an example of // how it is used. template -rtc::scoped_refptr CreateAudioDecoderFactory( - const FieldTrialsView* field_trials = nullptr) { +scoped_refptr CreateAudioDecoderFactory() { // There's no technical reason we couldn't allow zero template parameters, // but such a factory couldn't create any decoders, and callers can do this // by mistake by simply forgetting the <> altogether. So we forbid it in @@ -140,9 +128,8 @@ rtc::scoped_refptr CreateAudioDecoderFactory( static_assert(sizeof...(Ts) >= 1, "Caller must give at least one template parameter"); - return rtc::make_ref_counted< - audio_decoder_factory_template_impl::AudioDecoderFactoryT>( - field_trials); + return make_ref_counted< + audio_decoder_factory_template_impl::AudioDecoderFactoryT>(); } } // namespace webrtc diff --git a/api/audio_codecs/test/BUILD.gn b/api/audio_codecs/test/BUILD.gn index 702772c57c..0ed352c100 100644 --- a/api/audio_codecs/test/BUILD.gn +++ b/api/audio_codecs/test/BUILD.gn @@ -24,7 +24,6 @@ if (rtc_include_tests) { "../..:make_ref_counted", "../..:scoped_refptr", "../../../test:audio_codec_mocks", - "../../../test:scoped_key_value_config", "../../../test:test_support", "../../environment", "../../environment:environment_factory", diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc index dd112c9459..6db86108de 100644 --- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc @@ -29,7 +29,6 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder.h" -#include "test/scoped_key_value_config.h" namespace webrtc { @@ -85,11 +84,9 @@ struct AudioDecoderFakeApi { } // namespace TEST(AudioDecoderFactoryTemplateTest, NoDecoderTypes) { - test::ScopedKeyValueConfig field_trials; rtc::scoped_refptr factory( rtc::make_ref_counted< - audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>( - &field_trials)); + audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>()); EXPECT_THAT(factory->GetSupportedDecoders(), ::testing::IsEmpty()); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_EQ(nullptr, diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc index 7b08fbb391..92277f576b 100644 --- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc @@ -31,7 +31,6 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" -#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -186,8 +185,7 @@ TEST(AudioEncoderFactoryTemplateTest, CanUseTraitWithOnlyV2MakeAudioEncoder) { } TEST(AudioEncoderFactoryTemplateTest, NoEncoderTypes) { - test::ScopedKeyValueConfig field_trials; - const Environment env = CreateEnvironment(&field_trials); + const Environment env = CreateEnvironment(); rtc::scoped_refptr factory( rtc::make_ref_counted< audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>());