OLD | NEW |
(Empty) | |
| 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/dtx_controller.h" |
| 12 #include "webrtc/base/checks.h" |
| 13 |
| 14 namespace webrtc { |
| 15 |
| 16 DtxController::Config::Config(bool initial_dtx_enabled, |
| 17 int dtx_enabling_bandwidth_bps, |
| 18 int dtx_disabling_bandwidth_bps) |
| 19 : initial_dtx_enabled(initial_dtx_enabled), |
| 20 dtx_enabling_bandwidth_bps(dtx_enabling_bandwidth_bps), |
| 21 dtx_disabling_bandwidth_bps(dtx_disabling_bandwidth_bps) {} |
| 22 |
| 23 DtxController::DtxController(const Config& config) |
| 24 : config_(config), dtx_enabled_(config_.initial_dtx_enabled) {} |
| 25 |
| 26 void DtxController::MakeDecision( |
| 27 const NetworkMetrics& metrics, |
| 28 AudioNetworkAdaptor::EncoderRuntimeConfig* config) { |
| 29 // Decision on |enable_dtx| should not have been made. |
| 30 RTC_DCHECK(!config->enable_dtx); |
| 31 |
| 32 if (metrics.uplink_bandwidth_bps) { |
| 33 if (dtx_enabled_ && |
| 34 *metrics.uplink_bandwidth_bps >= config_.dtx_disabling_bandwidth_bps) { |
| 35 dtx_enabled_ = false; |
| 36 } else if (!dtx_enabled_ && |
| 37 *metrics.uplink_bandwidth_bps <= |
| 38 config_.dtx_enabling_bandwidth_bps) { |
| 39 dtx_enabled_ = true; |
| 40 } |
| 41 } |
| 42 config->enable_dtx = rtc::Optional<bool>(dtx_enabled_); |
| 43 } |
| 44 |
| 45 } // namespace webrtc |
OLD | NEW |