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 <hta@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36229}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
e72f4bc524
commit
a943e730b2
@ -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",
|
||||
|
@ -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<EncodedInfo, rtc::Buffer> redundant;
|
||||
redundant.second.EnsureCapacity(kAudioMaxRtpPacketLen);
|
||||
|
@ -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<AudioEncoder> speech_encoder;
|
||||
};
|
||||
|
||||
explicit AudioEncoderCopyRed(Config&& config);
|
||||
AudioEncoderCopyRed(Config&& config,
|
||||
const WebRtcKeyValueConfig& field_trials);
|
||||
|
||||
~AudioEncoderCopyRed() override;
|
||||
|
||||
|
@ -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<AudioEncoder>(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<uint32_t>(num_audio_samples_10ms);
|
||||
}
|
||||
|
||||
test::ScopedKeyValueConfig field_trials_;
|
||||
MockAudioEncoder* mock_encoder_;
|
||||
std::unique_ptr<AudioEncoderCopyRed> 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;
|
||||
}
|
||||
|
@ -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<AudioEncoderCopyRed>(std::move(config));
|
||||
encoder = std::make_unique<AudioEncoderCopyRed>(std::move(config),
|
||||
field_trials_);
|
||||
receive_codecs.emplace(
|
||||
std::make_pair(red_payload_type,
|
||||
SdpAudioFormat("red", codec_format.clockrate_hz, 1)));
|
||||
|
@ -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<AudioEncoderFactory> encoder_factory_;
|
||||
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
||||
std::unique_ptr<AudioCodingModule> _acmA;
|
||||
|
Reference in New Issue
Block a user