DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */


#include "modules/audio_coding/audio_network_adaptor/dtx_controller.h"
#include "rtc_base/checks.h"

namespace webrtc {


DtxController::Config::Config(bool initial_dtx_enabled,
                              int dtx_enabling_bandwidth_bps,
                              int dtx_disabling_bandwidth_bps)
    : initial_dtx_enabled(initial_dtx_enabled),
      dtx_enabling_bandwidth_bps(dtx_enabling_bandwidth_bps),
      dtx_enabling_bandwidth_bps(dtx_enabling_bandwidth_bps),
      dtx_disabling_bandwidth_bps(dtx_disabling_bandwidth_bps) {}

DtxController::DtxController(const Config& config)
    : config_(config), dtx_enabled_(config_.initial_dtx_enabled) {}


DtxController::~DtxController() = default;

void DtxController::UpdateNetworkMetrics(
    const NetworkMetrics& network_metrics) {
  if (network_metrics.uplink_bandwidth_bps)
  if (network_metrics.uplink_bandwidth_bps)
    uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps;
}

void DtxController::MakeDecision(AudioEncoderRuntimeConfig* config) {
  // Decision on |enable_dtx| should not have been made.
  // Decision on |enable_dtx| should not have been made.
  RTC_DCHECK(!config->enable_dtx);

  if (uplink_bandwidth_bps_) {
    if (dtx_enabled_ &&
        *uplink_bandwidth_bps_ >= config_.dtx_disabling_bandwidth_bps) {
        *uplink_bandwidth_bps_ >= config_.dtx_disabling_bandwidth_bps) {
      dtx_enabled_ = false;
    } else if (!dtx_enabled_ &&
               *uplink_bandwidth_bps_ <= config_.dtx_enabling_bandwidth_bps) {
      dtx_enabled_ = true;
    }
    }
  }
  config->enable_dtx = dtx_enabled_;
}

}  // namespace webrtc
}  // namespace webrtc