From a943e730b2acced12fa1028ad43b9c9c91bf631c Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 16 Mar 2022 13:50:58 +0100 Subject: [PATCH] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 7/inf Convert audio/ and collateral (audio encoder copy red). Bug: webrtc:10335 Change-Id: Iac54c0cfd2f62f4402f3deec35ae2725ec35b81a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255820 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36229} --- audio/BUILD.gn | 2 + audio/audio_send_stream.cc | 69 ++++++++++--------- audio/audio_send_stream.h | 10 ++- audio/audio_send_stream_unittest.cc | 33 +++++---- audio/channel_send.cc | 14 ++-- audio/channel_send.h | 4 +- call/call.cc | 2 +- modules/audio_coding/BUILD.gn | 3 +- .../codecs/red/audio_encoder_copy_red.cc | 13 ++-- .../codecs/red/audio_encoder_copy_red.h | 4 +- .../red/audio_encoder_copy_red_unittest.cc | 40 ++++++----- modules/audio_coding/test/TestRedFec.cc | 3 +- modules/audio_coding/test/TestRedFec.h | 2 + 13 files changed, 117 insertions(+), 82 deletions(-) diff --git a/audio/BUILD.gn b/audio/BUILD.gn index b31ab0451e..dcafe3bf7b 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -49,6 +49,7 @@ rtc_library("audio") { "../api:scoped_refptr", "../api:sequence_checker", "../api:transport_api", + "../api:webrtc_key_value_config", "../api/audio:aec3_factory", "../api/audio:audio_frame_api", "../api/audio:audio_frame_processor", @@ -190,6 +191,7 @@ if (rtc_include_tests) { "../test:mock_transformable_frame", "../test:mock_transport", "../test:rtp_test_utils", + "../test:scoped_key_value_config", "../test:test_common", "../test:test_support", "utility:utility_tests", diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 08bb4e6bbf..6aa0ec940f 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -39,7 +39,6 @@ #include "rtc_base/logging.h" #include "rtc_base/strings/audio_format_to_string.h" #include "rtc_base/task_queue.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { @@ -88,8 +87,9 @@ std::unique_ptr AudioAllocationConfig::Parser() { "rate_prio", &bitrate_priority); } -AudioAllocationConfig::AudioAllocationConfig() { - Parser()->Parse(field_trial::FindFullName(kKey)); +AudioAllocationConfig::AudioAllocationConfig( + const WebRtcKeyValueConfig& field_trials) { + Parser()->Parse(field_trials.Lookup(kKey)); if (priority_bitrate_raw && !priority_bitrate.IsZero()) { RTC_LOG(LS_WARNING) << "'priority_bitrate' and '_raw' are mutually " "exclusive but both were configured."; @@ -106,28 +106,31 @@ AudioSendStream::AudioSendStream( BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state) - : AudioSendStream(clock, - config, - audio_state, - task_queue_factory, - rtp_transport, - bitrate_allocator, - event_log, - suspended_rtp_state, - voe::CreateChannelSend( - clock, - task_queue_factory, - config.send_transport, - rtcp_rtt_stats, - event_log, - config.frame_encryptor, - config.crypto_options, - config.rtp.extmap_allow_mixed, - config.rtcp_report_interval_ms, - config.rtp.ssrc, - config.frame_transformer, - rtp_transport->transport_feedback_observer())) {} + const absl::optional& suspended_rtp_state, + const WebRtcKeyValueConfig& field_trials) + : AudioSendStream( + clock, + config, + audio_state, + task_queue_factory, + rtp_transport, + bitrate_allocator, + event_log, + suspended_rtp_state, + voe::CreateChannelSend(clock, + task_queue_factory, + config.send_transport, + rtcp_rtt_stats, + event_log, + config.frame_encryptor, + config.crypto_options, + config.rtp.extmap_allow_mixed, + config.rtcp_report_interval_ms, + config.rtp.ssrc, + config.frame_transformer, + rtp_transport->transport_feedback_observer(), + field_trials), + field_trials) {} AudioSendStream::AudioSendStream( Clock* clock, @@ -138,21 +141,24 @@ AudioSendStream::AudioSendStream( BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, const absl::optional& suspended_rtp_state, - std::unique_ptr channel_send) + std::unique_ptr channel_send, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), + field_trials_(field_trials), rtp_transport_queue_(rtp_transport->GetWorkerQueue()), allocate_audio_without_feedback_( - field_trial::IsEnabled("WebRTC-Audio-ABWENoTWCC")), + field_trials_.IsEnabled("WebRTC-Audio-ABWENoTWCC")), enable_audio_alr_probing_( - !field_trial::IsDisabled("WebRTC-Audio-AlrProbing")), + !field_trials_.IsDisabled("WebRTC-Audio-AlrProbing")), send_side_bwe_with_overhead_( - !field_trial::IsDisabled("WebRTC-SendSideBwe-WithOverhead")), + !field_trials_.IsDisabled("WebRTC-SendSideBwe-WithOverhead")), + allocation_settings_(field_trials_), config_(Config(/*send_transport=*/nullptr)), audio_state_(audio_state), channel_send_(std::move(channel_send)), event_log_(event_log), use_legacy_overhead_calculation_( - field_trial::IsEnabled("WebRTC-Audio-LegacyOverhead")), + field_trials_.IsEnabled("WebRTC-Audio-LegacyOverhead")), bitrate_allocator_(bitrate_allocator), rtp_transport_(rtp_transport), rtp_rtcp_module_(channel_send_->GetRtpRtcp()), @@ -640,7 +646,8 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { AudioEncoderCopyRed::Config red_config; red_config.payload_type = *spec.red_payload_type; red_config.speech_encoder = std::move(encoder); - encoder = std::make_unique(std::move(red_config)); + encoder = std::make_unique(std::move(red_config), + field_trials_); } // Set currently known overhead (used in ANA, opus only). diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index b40750891c..ad40a8939b 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -16,6 +16,7 @@ #include #include "api/sequence_checker.h" +#include "api/webrtc_key_value_config.h" #include "audio/audio_level.h" #include "audio/channel_send.h" #include "call/audio_send_stream.h" @@ -46,7 +47,7 @@ struct AudioAllocationConfig { absl::optional bitrate_priority; std::unique_ptr Parser(); - AudioAllocationConfig(); + explicit AudioAllocationConfig(const WebRtcKeyValueConfig& field_trials); }; namespace internal { class AudioState; @@ -62,7 +63,8 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state); + const absl::optional& suspended_rtp_state, + const WebRtcKeyValueConfig& field_trials); // For unit tests, which need to supply a mock ChannelSend. AudioSendStream(Clock* clock, const webrtc::AudioSendStream::Config& config, @@ -72,7 +74,8 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, const absl::optional& suspended_rtp_state, - std::unique_ptr channel_send); + std::unique_ptr channel_send, + const WebRtcKeyValueConfig& field_trials); AudioSendStream() = delete; AudioSendStream(const AudioSendStream&) = delete; @@ -160,6 +163,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RTC_RUN_ON(worker_thread_checker_); Clock* clock_; + const WebRtcKeyValueConfig& field_trials_; SequenceChecker worker_thread_checker_; SequenceChecker pacer_thread_checker_; diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 9228611e31..2d2e64c155 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -32,10 +32,10 @@ #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "rtc_base/task_queue_for_test.h" #include "system_wrappers/include/clock.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" #include "test/mock_audio_encoder_factory.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace test { @@ -196,7 +196,8 @@ struct ConfigHelper { Clock::GetRealTimeClock(), stream_config_, audio_state_, task_queue_factory_.get(), &rtp_transport_, &bitrate_allocator_, &event_log_, absl::nullopt, - std::unique_ptr(channel_send_))); + std::unique_ptr(channel_send_), + field_trials)); } AudioSendStream::Config& config() { return stream_config_; } @@ -321,6 +322,8 @@ struct ConfigHelper { TaskQueueForTest* worker() { return &worker_queue_; } + test::ScopedKeyValueConfig field_trials; + private: SimulatedClock clock_; std::unique_ptr task_queue_factory_; @@ -659,10 +662,10 @@ TEST(AudioSendStreamTest, SSBweTargetInRangeRespected) { } TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); auto send_stream = helper.CreateAudioSendStream(); EXPECT_CALL( *helper.channel_send(), @@ -676,10 +679,10 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) { } TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); auto send_stream = helper.CreateAudioSendStream(); EXPECT_CALL( *helper.channel_send(), @@ -693,10 +696,10 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) { } TEST(AudioSendStreamTest, SSBweWithOverhead) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials(helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); @@ -714,11 +717,12 @@ TEST(AudioSendStreamTest, SSBweWithOverhead) { } TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/" - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/" + "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); @@ -734,11 +738,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) { } TEST(AudioSendStreamTest, SSBweWithOverheadMaxRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/" - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/" + "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index d1135e5adc..d6b5823f3e 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -43,7 +43,6 @@ #include "rtc_base/task_queue.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { @@ -78,7 +77,8 @@ class ChannelSend : public ChannelSendInterface, int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer); + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials); ~ChannelSend() override; @@ -458,7 +458,8 @@ ChannelSend::ChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer) + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials) : ssrc_(ssrc), event_log_(rtc_event_log), _timeStamp(0), // This is just an offset, RTP module will add it's own @@ -477,7 +478,7 @@ ChannelSend::ChannelSend( "AudioEncoder", TaskQueueFactory::Priority::NORMAL)), fixing_timestamp_stall_( - !field_trial::IsDisabled("WebRTC-Audio-FixTimestampStall")) { + field_trials.IsDisabled("WebRTC-Audio-FixTimestampStall")) { audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config())); RtpRtcpInterface::Configuration configuration; @@ -948,12 +949,13 @@ std::unique_ptr CreateChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer) { + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials) { return std::make_unique( clock, task_queue_factory, rtp_transport, rtcp_rtt_stats, rtc_event_log, frame_encryptor, crypto_options, extmap_allow_mixed, rtcp_report_interval_ms, ssrc, std::move(frame_transformer), - feedback_observer); + feedback_observer, field_trials); } } // namespace voe diff --git a/audio/channel_send.h b/audio/channel_send.h index e100725460..bfbfbeedfa 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -21,6 +21,7 @@ #include "api/frame_transformer_interface.h" #include "api/function_view.h" #include "api/task_queue/task_queue_factory.h" +#include "api/webrtc_key_value_config.h" #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" @@ -135,7 +136,8 @@ std::unique_ptr CreateChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer); + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials); } // namespace voe } // namespace webrtc diff --git a/call/call.cc b/call/call.cc index 16f7b9058f..f2101cfc6b 100644 --- a/call/call.cc +++ b/call/call.cc @@ -915,7 +915,7 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( AudioSendStream* send_stream = new AudioSendStream( clock_, config, config_.audio_state, task_queue_factory_, transport_send_.get(), bitrate_allocator_.get(), event_log_, - call_stats_->AsRtcpRttStats(), suspended_rtp_state); + call_stats_->AsRtcpRttStats(), suspended_rtp_state, trials()); RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == audio_send_ssrcs_.end()); audio_send_ssrcs_[config.rtp.ssrc] = send_stream; diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index c4814ce1f8..af76a11eae 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -118,12 +118,12 @@ rtc_library("red") { deps = [ "../../api:array_view", + "../../api:webrtc_key_value_config", "../../api/audio_codecs:audio_codecs_api", "../../api/units:time_delta", "../../common_audio", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", - "../../system_wrappers:field_trial", ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -2079,6 +2079,7 @@ if (rtc_include_tests) { "../../test:fileutils", "../../test:rtc_expect_death", "../../test:rtp_test_utils", + "../../test:scoped_key_value_config", "../../test:test_common", "../../test:test_support", "codecs/opus/test", diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc index 9643c7b1a5..c8a26e8c61 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -18,7 +18,6 @@ #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { static constexpr const int kRedMaxPacketSize = @@ -40,9 +39,10 @@ AudioEncoderCopyRed::Config::Config() = default; AudioEncoderCopyRed::Config::Config(Config&&) = default; AudioEncoderCopyRed::Config::~Config() = default; -size_t GetMaxRedundancyFromFieldTrial() { +size_t GetMaxRedundancyFromFieldTrial( + const WebRtcKeyValueConfig& field_trials) { const std::string red_trial = - webrtc::field_trial::FindFullName("WebRTC-Audio-Red-For-Opus"); + field_trials.Lookup("WebRTC-Audio-Red-For-Opus"); size_t redundancy = 0; if (sscanf(red_trial.c_str(), "Enabled-%zu", &redundancy) != 1 || redundancy > 9) { @@ -51,14 +51,17 @@ size_t GetMaxRedundancyFromFieldTrial() { return redundancy; } -AudioEncoderCopyRed::AudioEncoderCopyRed(Config&& config) +AudioEncoderCopyRed::AudioEncoderCopyRed( + Config&& config, + const WebRtcKeyValueConfig& field_trials) : speech_encoder_(std::move(config.speech_encoder)), primary_encoded_(0, kAudioMaxRtpPacketLen), max_packet_length_(kAudioMaxRtpPacketLen), red_payload_type_(config.payload_type) { RTC_CHECK(speech_encoder_) << "Speech encoder not provided."; - auto number_of_redundant_encodings = GetMaxRedundancyFromFieldTrial(); + auto number_of_redundant_encodings = + GetMaxRedundancyFromFieldTrial(field_trials); for (size_t i = 0; i < number_of_redundant_encodings; i++) { std::pair redundant; redundant.second.EnsureCapacity(kAudioMaxRtpPacketLen); diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h index d163193251..e7471b3e12 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h @@ -22,6 +22,7 @@ #include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/units/time_delta.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/buffer.h" namespace webrtc { @@ -42,7 +43,8 @@ class AudioEncoderCopyRed final : public AudioEncoder { std::unique_ptr speech_encoder; }; - explicit AudioEncoderCopyRed(Config&& config); + AudioEncoderCopyRed(Config&& config, + const WebRtcKeyValueConfig& field_trials); ~AudioEncoderCopyRed() override; diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index 0eeac011e0..795a996624 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -18,6 +18,7 @@ #include "test/field_trial.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" +#include "test/scoped_key_value_config.h" #include "test/testsupport/rtc_expect_death.h" using ::testing::_; @@ -49,7 +50,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::unique_ptr(mock_encoder_); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials_)); memset(audio_, 0, sizeof(audio_)); EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1U)); EXPECT_CALL(*mock_encoder_, SampleRateHz()) @@ -68,6 +69,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { timestamp_ += rtc::checked_cast(num_audio_samples_10ms); } + test::ScopedKeyValueConfig field_trials_; MockAudioEncoder* mock_encoder_; std::unique_ptr red_; uint32_t timestamp_; @@ -198,13 +200,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes1) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 0. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-0/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -224,13 +226,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 2. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-2/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -266,13 +268,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 3. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes3) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-3/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-3/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials_)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -463,13 +465,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header) { // Variant with a redundancy of 0. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-0/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); const int primary_payload_type = red_payload_type_ + 1; AudioEncoder::EncodedInfo info; @@ -491,13 +493,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { } // Variant with a redundancy of 2. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header2) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-2/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); const int primary_payload_type = red_payload_type_ + 1; AudioEncoder::EncodedInfo info; @@ -623,11 +625,13 @@ TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { } TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { + test::ScopedKeyValueConfig field_trials; AudioEncoderCopyRed* red = NULL; AudioEncoderCopyRed::Config config; config.speech_encoder = NULL; - RTC_EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)), - "Speech encoder not provided."); + RTC_EXPECT_DEATH( + red = new AudioEncoderCopyRed(std::move(config), field_trials), + "Speech encoder not provided."); // The delete operation is needed to avoid leak reports from memcheck. delete red; } diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index d2c8d8a132..892fbc83d6 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -190,7 +190,8 @@ void TestRedFec::RegisterSendCodec( AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type; config.speech_encoder = std::move(encoder); - encoder = std::make_unique(std::move(config)); + encoder = std::make_unique(std::move(config), + field_trials_); receive_codecs.emplace( std::make_pair(red_payload_type, SdpAudioFormat("red", codec_format.clockrate_hz, 1))); diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h index 0e92d27330..dbadd88487 100644 --- a/modules/audio_coding/test/TestRedFec.h +++ b/modules/audio_coding/test/TestRedFec.h @@ -19,6 +19,7 @@ #include "common_audio/vad/include/vad.h" #include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -37,6 +38,7 @@ class TestRedFec { void Run(); void OpenOutFile(int16_t testNumber); + test::ScopedKeyValueConfig field_trials_; const rtc::scoped_refptr encoder_factory_; const rtc::scoped_refptr decoder_factory_; std::unique_ptr _acmA;