Adds trial to use link capacity estimate in Opus encoder.
Since the link capacity is designed to be a more stable value, we don't need the smoothing. This allows us to react faster to changes in link capacity while still avoiding to react to changes in target bitrate due to normal control behavior. Bug: webrtc:9718 Change-Id: I2fbf6bb882f312a7b28ea43d27057886d035ac45 Reviewed-on: https://webrtc-review.googlesource.com/c/111511 Commit-Queue: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Minyue Li <minyue@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25745}
This commit is contained in:
committed by
Commit Bot
parent
2ff3f49700
commit
8ac05ccaa7
@ -471,6 +471,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")),
|
||||
adjust_bandwidth_(
|
||||
webrtc::field_trial::IsEnabled("WebRTC-AdjustOpusBandwidth")),
|
||||
bitrate_changed_(true),
|
||||
@ -605,7 +607,8 @@ void AudioEncoderOpusImpl::OnReceivedUplinkRecoverablePacketLossFraction(
|
||||
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
absl::optional<int64_t> bwe_period_ms) {
|
||||
absl::optional<int64_t> bwe_period_ms,
|
||||
absl::optional<int64_t> link_capacity_allocation_bps) {
|
||||
if (audio_network_adaptor_) {
|
||||
audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps);
|
||||
// We give smoothed bitrate allocation to audio network adaptor as
|
||||
@ -623,6 +626,9 @@ void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
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;
|
||||
|
||||
ApplyAudioNetworkAdaptor();
|
||||
} else if (send_side_bwe_with_overhead_) {
|
||||
if (!overhead_bytes_per_packet_) {
|
||||
@ -641,6 +647,18 @@ void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
SetTargetBitrate(target_audio_bitrate_bps);
|
||||
}
|
||||
}
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
absl::optional<int64_t> bwe_period_ms) {
|
||||
OnReceivedUplinkBandwidth(target_audio_bitrate_bps, bwe_period_ms,
|
||||
absl::nullopt);
|
||||
}
|
||||
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkAllocation(
|
||||
BitrateAllocationUpdate update) {
|
||||
OnReceivedUplinkBandwidth(update.target_bitrate.bps(), update.bwe_period.ms(),
|
||||
update.link_capacity.bps());
|
||||
}
|
||||
|
||||
void AudioEncoderOpusImpl::OnReceivedRtt(int rtt_ms) {
|
||||
if (!audio_network_adaptor_)
|
||||
@ -875,14 +893,20 @@ AudioEncoderOpusImpl::DefaultAudioNetworkAdaptorCreator(
|
||||
|
||||
void AudioEncoderOpusImpl::MaybeUpdateUplinkBandwidth() {
|
||||
if (audio_network_adaptor_) {
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user