LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_coding/audio_network_adaptor - bitrate_controller.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 21 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
       3             :  *
       4             :  *  Use of this source code is governed by a BSD-style license
       5             :  *  that can be found in the LICENSE file in the root of the source
       6             :  *  tree. An additional intellectual property rights grant can be found
       7             :  *  in the file PATENTS.  All contributing project authors may
       8             :  *  be found in the AUTHORS file in the root of the source tree.
       9             :  */
      10             : 
      11             : #include "webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.h"
      12             : 
      13             : #include <algorithm>
      14             : 
      15             : #include "webrtc/base/checks.h"
      16             : #include "webrtc/system_wrappers/include/field_trial.h"
      17             : 
      18             : namespace webrtc {
      19             : namespace audio_network_adaptor {
      20             : 
      21           0 : BitrateController::Config::Config(int initial_bitrate_bps,
      22           0 :                                   int initial_frame_length_ms)
      23             :     : initial_bitrate_bps(initial_bitrate_bps),
      24           0 :       initial_frame_length_ms(initial_frame_length_ms) {}
      25             : 
      26             : BitrateController::Config::~Config() = default;
      27             : 
      28           0 : BitrateController::BitrateController(const Config& config)
      29             :     : config_(config),
      30           0 :       bitrate_bps_(config_.initial_bitrate_bps),
      31           0 :       frame_length_ms_(config_.initial_frame_length_ms) {
      32           0 :   RTC_DCHECK_GT(bitrate_bps_, 0);
      33           0 :   RTC_DCHECK_GT(frame_length_ms_, 0);
      34           0 : }
      35             : 
      36           0 : void BitrateController::MakeDecision(
      37             :     const NetworkMetrics& metrics,
      38             :     AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
      39             :   // Decision on |bitrate_bps| should not have been made.
      40           0 :   RTC_DCHECK(!config->bitrate_bps);
      41           0 :   if (metrics.target_audio_bitrate_bps && metrics.overhead_bytes_per_packet) {
      42             :     // Current implementation of BitrateController can only work when
      43             :     // |metrics.target_audio_bitrate_bps| includes overhead is enabled. This is
      44             :     // currently governed by the following field trial.
      45           0 :     RTC_DCHECK_EQ("Enabled", webrtc::field_trial::FindFullName(
      46           0 :                                  "WebRTC-SendSideBwe-WithOverhead"));
      47           0 :     if (config->frame_length_ms)
      48           0 :       frame_length_ms_ = *config->frame_length_ms;
      49             :     int overhead_rate_bps =
      50           0 :         *metrics.overhead_bytes_per_packet * 8 * 1000 / frame_length_ms_;
      51           0 :     bitrate_bps_ =
      52           0 :         std::max(0, *metrics.target_audio_bitrate_bps - overhead_rate_bps);
      53             :   }
      54           0 :   config->bitrate_bps = rtc::Optional<int>(bitrate_bps_);
      55           0 : }
      56             : 
      57             : }  // namespace audio_network_adaptor
      58             : }  // namespace webrtc

Generated by: LCOV version 1.13