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,16 +893,22 @@ 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();
|
||||
absl::optional<float> smoothed_bitrate =
|
||||
bitrate_smoother_->GetAverage();
|
||||
if (smoothed_bitrate)
|
||||
audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate);
|
||||
bitrate_smoother_last_update_time_ = now_ms;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ANAStats AudioEncoderOpusImpl::GetANAStats() const {
|
||||
|
@ -119,6 +119,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
void OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
absl::optional<int64_t> bwe_period_ms) override;
|
||||
void OnReceivedUplinkAllocation(BitrateAllocationUpdate update) override;
|
||||
void OnReceivedRtt(int rtt_ms) override;
|
||||
void OnReceivedOverhead(size_t overhead_bytes_per_packet) override;
|
||||
void SetReceiverFrameLengthRange(int min_frame_length_ms,
|
||||
@ -164,6 +165,11 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
void SetNumChannelsToEncode(size_t num_channels_to_encode);
|
||||
void SetProjectedPacketLossRate(float fraction);
|
||||
|
||||
void OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
absl::optional<int64_t> bwe_period_ms,
|
||||
absl::optional<int64_t> link_capacity_allocation);
|
||||
|
||||
// TODO(minyue): remove "override" when we can deprecate
|
||||
// |AudioEncoder::SetTargetBitrate|.
|
||||
void SetTargetBitrate(int target_bps) override;
|
||||
@ -178,6 +184,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 adjust_bandwidth_;
|
||||
bool bitrate_changed_;
|
||||
float packet_loss_rate_;
|
||||
@ -195,6 +202,7 @@ 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