Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Unified Diff: webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc

Issue 2530653003: Adding packet overhead to audio network adaptor. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc b/webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc
index ac0045ec4dee39dc0127c82df9de25258759673f..432b269a99cb81c303b51d6f8551ee596862e8e3 100644
--- a/webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.cc
@@ -17,13 +17,6 @@
namespace webrtc {
namespace audio_network_adaptor {
-namespace {
-// TODO(minyue): consider passing this from a higher layer through
-// SetConstraints().
-// L2(14B) + IPv4(20B) + UDP(8B) + RTP(12B) + SRTP_AUTH(10B) = 64B = 512 bits
-constexpr int kPacketOverheadBits = 512;
-}
-
BitrateController::Config::Config(int initial_bitrate_bps,
int initial_frame_length_ms)
: initial_bitrate_bps(initial_bitrate_bps),
@@ -34,10 +27,9 @@ BitrateController::Config::~Config() = default;
BitrateController::BitrateController(const Config& config)
: config_(config),
bitrate_bps_(config_.initial_bitrate_bps),
- overhead_rate_bps_(kPacketOverheadBits * 1000 /
- config_.initial_frame_length_ms) {
+ frame_length_ms_(config_.initial_frame_length_ms) {
RTC_DCHECK_GT(bitrate_bps_, 0);
- RTC_DCHECK_GT(overhead_rate_bps_, 0);
+ RTC_DCHECK_GT(frame_length_ms_, 0);
}
void BitrateController::MakeDecision(
@@ -45,23 +37,15 @@ void BitrateController::MakeDecision(
AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
// Decision on |bitrate_bps| should not have been made.
RTC_DCHECK(!config->bitrate_bps);
-
- if (metrics.target_audio_bitrate_bps) {
- int overhead_rate =
- config->frame_length_ms
- ? kPacketOverheadBits * 1000 / *config->frame_length_ms
- : overhead_rate_bps_;
- // If |metrics.target_audio_bitrate_bps| had included overhead, we would
- // simply do:
- // bitrate_bps_ = metrics.target_audio_bitrate_bps - overhead_rate;
- // Follow https://bugs.chromium.org/p/webrtc/issues/detail?id=6315 to track
- // progress regarding this.
- // Now we assume that |metrics.target_audio_bitrate_bps| can handle the
- // overhead of most recent packets.
- bitrate_bps_ = std::max(0, *metrics.target_audio_bitrate_bps +
- overhead_rate_bps_ - overhead_rate);
- // TODO(minyue): apply a smoothing on the |overhead_rate_bps_|.
- overhead_rate_bps_ = overhead_rate;
+ // TODO(minyue): DCHECK that field trial that indicates that
minyue-webrtc 2016/11/24 09:03:47 Will add this check according to https://coderevie
+ // |target_audio_bitrate_bps| includes overhead is enabled.
+ if (metrics.target_audio_bitrate_bps && metrics.overhead_bytes_per_packet) {
+ if (config->frame_length_ms)
+ frame_length_ms_ = *config->frame_length_ms;
+ int overhead_rate_bps =
+ *metrics.overhead_bytes_per_packet * 8 * 1000 / frame_length_ms_;
+ bitrate_bps_ =
+ std::max(0, *metrics.target_audio_bitrate_bps - overhead_rate_bps);
}
config->bitrate_bps = rtc::Optional<int>(bitrate_bps_);
}

Powered by Google App Engine
This is Rietveld 408576698