red: make amount of redundancy controllable via field trial parameter
BUG=webrtc:11640 Change-Id: If46e3e6c84fa8781affaa400028b73571dae9108 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217384 Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33975}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
6e661f47cf
commit
b1606a3352
@ -123,6 +123,7 @@ rtc_library("red") {
|
||||
"../../common_audio",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../system_wrappers:field_trial",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#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 =
|
||||
@ -36,6 +38,17 @@ AudioEncoderCopyRed::Config::Config() = default;
|
||||
AudioEncoderCopyRed::Config::Config(Config&&) = default;
|
||||
AudioEncoderCopyRed::Config::~Config() = default;
|
||||
|
||||
size_t GetMaxRedundancyFromFieldTrial() {
|
||||
const std::string red_trial =
|
||||
webrtc::field_trial::FindFullName("WebRTC-Audio-Red-For-Opus");
|
||||
size_t redundancy = 0;
|
||||
if (sscanf(red_trial.c_str(), "Enabled-%zu", &redundancy) != 1 ||
|
||||
redundancy < 1 || redundancy > 9) {
|
||||
return kRedNumberOfRedundantEncodings;
|
||||
}
|
||||
return redundancy;
|
||||
}
|
||||
|
||||
AudioEncoderCopyRed::AudioEncoderCopyRed(Config&& config)
|
||||
: speech_encoder_(std::move(config.speech_encoder)),
|
||||
primary_encoded_(0, kAudioMaxRtpPacketLen),
|
||||
@ -43,7 +56,8 @@ AudioEncoderCopyRed::AudioEncoderCopyRed(Config&& config)
|
||||
red_payload_type_(config.payload_type) {
|
||||
RTC_CHECK(speech_encoder_) << "Speech encoder not provided.";
|
||||
|
||||
for (size_t i = 0; i < kRedNumberOfRedundantEncodings; i++) {
|
||||
auto number_of_redundant_encodings = GetMaxRedundancyFromFieldTrial();
|
||||
for (size_t i = 0; i < number_of_redundant_encodings; i++) {
|
||||
std::pair<EncodedInfo, rtc::Buffer> redundant;
|
||||
redundant.second.EnsureCapacity(kAudioMaxRtpPacketLen);
|
||||
redundant_encodings_.push_front(std::move(redundant));
|
||||
@ -167,8 +181,9 @@ AudioEncoder::EncodedInfo AudioEncoderCopyRed::EncodeImpl(
|
||||
|
||||
void AudioEncoderCopyRed::Reset() {
|
||||
speech_encoder_->Reset();
|
||||
auto number_of_redundant_encodings = redundant_encodings_.size();
|
||||
redundant_encodings_.clear();
|
||||
for (size_t i = 0; i < kRedNumberOfRedundantEncodings; i++) {
|
||||
for (size_t i = 0; i < number_of_redundant_encodings; i++) {
|
||||
std::pair<EncodedInfo, rtc::Buffer> redundant;
|
||||
redundant.second.EnsureCapacity(kAudioMaxRtpPacketLen);
|
||||
redundant_encodings_.push_front(std::move(redundant));
|
||||
|
Reference in New Issue
Block a user