Replacing bandwidth adaptation trial with stable target in Opus encoder.
This also means that the NetworkEstimate::bandwidth can be deprecated as it's currently just a copy of the target_rate. Bug: webrtc:10981 Change-Id: I1bc57b98480bd77ce052736b19d630c775428546 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/153669 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29288}
This commit is contained in:
committed by
Commit Bot
parent
c30bc169ea
commit
f34116e356
@ -425,8 +425,8 @@ AudioEncoderOpusImpl::AudioEncoderOpusImpl(
|
||||
: payload_type_(payload_type),
|
||||
send_side_bwe_with_overhead_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
|
||||
use_link_capacity_for_adaptation_(webrtc::field_trial::IsEnabled(
|
||||
"WebRTC-Audio-LinkCapacityAdaptation")),
|
||||
use_stable_target_for_adaptation_(webrtc::field_trial::IsEnabled(
|
||||
"WebRTC-Audio-StableTargetAdaptation")),
|
||||
adjust_bandwidth_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-AdjustOpusBandwidth")),
|
||||
bitrate_changed_(true),
|
||||
@ -563,26 +563,28 @@ void AudioEncoderOpusImpl::OnReceivedUplinkRecoverablePacketLossFraction(
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
absl::optional<int64_t> bwe_period_ms,
|
||||
absl::optional<int64_t> link_capacity_allocation_bps) {
|
||||
absl::optional<int64_t> stable_target_bitrate_bps) {
|
||||
if (audio_network_adaptor_) {
|
||||
audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps);
|
||||
// We give smoothed bitrate allocation to audio network adaptor as
|
||||
// the uplink bandwidth.
|
||||
// The BWE spikes should not affect the bitrate smoother more than 25%.
|
||||
// To simplify the calculations we use a step response as input signal.
|
||||
// The step response of an exponential filter is
|
||||
// u(t) = 1 - e^(-t / time_constant).
|
||||
// In order to limit the affect of a BWE spike within 25% of its value
|
||||
// before
|
||||
// the next BWE update, we would choose a time constant that fulfills
|
||||
// 1 - e^(-bwe_period_ms / time_constant) < 0.25
|
||||
// Then 4 * bwe_period_ms is a good choice.
|
||||
if (bwe_period_ms)
|
||||
bitrate_smoother_->SetTimeConstantMs(*bwe_period_ms * 4);
|
||||
bitrate_smoother_->AddSample(target_audio_bitrate_bps);
|
||||
|
||||
if (link_capacity_allocation_bps)
|
||||
link_capacity_allocation_bps_ = link_capacity_allocation_bps;
|
||||
if (use_stable_target_for_adaptation_) {
|
||||
if (stable_target_bitrate_bps)
|
||||
audio_network_adaptor_->SetUplinkBandwidth(*stable_target_bitrate_bps);
|
||||
} else {
|
||||
// We give smoothed bitrate allocation to audio network adaptor as
|
||||
// the uplink bandwidth.
|
||||
// The BWE spikes should not affect the bitrate smoother more than 25%.
|
||||
// To simplify the calculations we use a step response as input signal.
|
||||
// The step response of an exponential filter is
|
||||
// u(t) = 1 - e^(-t / time_constant).
|
||||
// In order to limit the affect of a BWE spike within 25% of its value
|
||||
// before
|
||||
// the next BWE update, we would choose a time constant that fulfills
|
||||
// 1 - e^(-bwe_period_ms / time_constant) < 0.25
|
||||
// Then 4 * bwe_period_ms is a good choice.
|
||||
if (bwe_period_ms)
|
||||
bitrate_smoother_->SetTimeConstantMs(*bwe_period_ms * 4);
|
||||
bitrate_smoother_->AddSample(target_audio_bitrate_bps);
|
||||
}
|
||||
|
||||
ApplyAudioNetworkAdaptor();
|
||||
} else if (send_side_bwe_with_overhead_) {
|
||||
@ -612,7 +614,7 @@ void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkAllocation(
|
||||
BitrateAllocationUpdate update) {
|
||||
OnReceivedUplinkBandwidth(update.target_bitrate.bps(), update.bwe_period.ms(),
|
||||
update.link_capacity.bps());
|
||||
update.stable_target_bitrate.bps());
|
||||
}
|
||||
|
||||
void AudioEncoderOpusImpl::OnReceivedRtt(int rtt_ms) {
|
||||
@ -857,21 +859,15 @@ AudioEncoderOpusImpl::DefaultAudioNetworkAdaptorCreator(
|
||||
}
|
||||
|
||||
void AudioEncoderOpusImpl::MaybeUpdateUplinkBandwidth() {
|
||||
if (audio_network_adaptor_) {
|
||||
if (use_link_capacity_for_adaptation_ && link_capacity_allocation_bps_) {
|
||||
audio_network_adaptor_->SetUplinkBandwidth(
|
||||
*link_capacity_allocation_bps_);
|
||||
} else {
|
||||
int64_t now_ms = rtc::TimeMillis();
|
||||
if (!bitrate_smoother_last_update_time_ ||
|
||||
now_ms - *bitrate_smoother_last_update_time_ >=
|
||||
config_.uplink_bandwidth_update_interval_ms) {
|
||||
absl::optional<float> smoothed_bitrate =
|
||||
bitrate_smoother_->GetAverage();
|
||||
if (smoothed_bitrate)
|
||||
audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate);
|
||||
bitrate_smoother_last_update_time_ = now_ms;
|
||||
}
|
||||
if (audio_network_adaptor_ && !use_stable_target_for_adaptation_) {
|
||||
int64_t now_ms = rtc::TimeMillis();
|
||||
if (!bitrate_smoother_last_update_time_ ||
|
||||
now_ms - *bitrate_smoother_last_update_time_ >=
|
||||
config_.uplink_bandwidth_update_interval_ms) {
|
||||
absl::optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage();
|
||||
if (smoothed_bitrate)
|
||||
audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate);
|
||||
bitrate_smoother_last_update_time_ = now_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
AudioEncoderOpusConfig config_;
|
||||
const int payload_type_;
|
||||
const bool send_side_bwe_with_overhead_;
|
||||
const bool use_link_capacity_for_adaptation_;
|
||||
const bool use_stable_target_for_adaptation_;
|
||||
const bool adjust_bandwidth_;
|
||||
bool bitrate_changed_;
|
||||
float packet_loss_rate_;
|
||||
@ -192,7 +192,6 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
absl::optional<size_t> overhead_bytes_per_packet_;
|
||||
const std::unique_ptr<SmoothingFilter> bitrate_smoother_;
|
||||
absl::optional<int64_t> bitrate_smoother_last_update_time_;
|
||||
absl::optional<int64_t> link_capacity_allocation_bps_;
|
||||
int consecutive_dtx_frames_;
|
||||
|
||||
friend struct AudioEncoderOpus;
|
||||
|
||||
Reference in New Issue
Block a user