From 0429f78992f7395e7785c46bf29dafd575d4c113 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 3 Oct 2019 18:32:45 +0200 Subject: [PATCH] Base overhead calculation for audio priority rate on available data. This improves the accuracy of the priority bitrate on IPv6 networks and when the min frame length is longer than 20 ms. Unless either of those are true, there's no significant change in behavior. Bug: webrtc:11001 Change-Id: I29530655cb607a8e7e8186431cd9362ca397910b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/155521 Reviewed-by: Oskar Sundbom Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#29375} --- audio/audio_send_stream.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 7f147684f5..22bd9831e4 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -877,17 +877,23 @@ void AudioSendStream::ConfigureBitrateObserver() { // TODO(srte): Add overhead compensation here. auto constraints = GetMinMaxBitrateConstraints(); - DataRate max_overhead = DataRate::Zero(); + DataRate priority_bitrate = allocation_settings_.priority_bitrate; if (send_side_bwe_with_overhead_) { - // TODO(srte): Respect |use_legacy_overhead_calculation_| here as well. - // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) - constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; - const TimeDelta kMinPacketDuration = TimeDelta::ms(20); - max_overhead = DataSize::bytes(kOverheadPerPacket) / kMinPacketDuration; + if (use_legacy_overhead_calculation_) { + // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) + constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; + const TimeDelta kMinPacketDuration = TimeDelta::ms(20); + DataRate max_overhead = + DataSize::bytes(kOverheadPerPacket) / kMinPacketDuration; + priority_bitrate += max_overhead; + } else { + RTC_DCHECK(frame_length_range_); + const DataSize kOverheadPerPacket = + DataSize::bytes(total_packet_overhead_bytes_); + DataRate max_overhead = kOverheadPerPacket / frame_length_range_->first; + priority_bitrate += max_overhead; + } } - DataRate priority_bitrate = - allocation_settings_.priority_bitrate + max_overhead; - if (allocation_settings_.priority_bitrate_raw) priority_bitrate = *allocation_settings_.priority_bitrate_raw;