Chromium Code Reviews| Index: webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc |
| diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4811c8954b8844323fcd9e2b265bb6f99ad40a72 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc |
| @@ -0,0 +1,38 @@ |
| +/* |
| + * 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 |
| + * 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 "webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.h" |
| +#include "webrtc/base/checks.h" |
| + |
| +namespace webrtc { |
| + |
| +DtxController::DtxController(const Config& config) |
| + : config_(config), dtx_enabled_(config_.initial_dtx_enabled) {} |
| + |
| +void DtxController::MakeDecision( |
| + const NetworkMetrics& metrics, |
| + AudioNetworkAdaptor::EncoderRuntimeConfig* config) { |
| + // Decision on |num_channels| should not have been made. |
|
minyue-webrtc
2016/09/08 14:57:54
num_channels -> enable_dtx
|
| + RTC_DCHECK(!config->enable_dtx); |
| + |
| + if (metrics.uplink_bandwidth_bps) { |
| + if (dtx_enabled_ && |
| + *metrics.uplink_bandwidth_bps >= config_.dtx_disabling_bandwidth_bps) { |
| + dtx_enabled_ = false; |
| + } else if (!dtx_enabled_ && |
| + *metrics.uplink_bandwidth_bps <= |
| + config_.dtx_enabling_bandwidth_bps) { |
| + dtx_enabled_ = true; |
| + } |
| + } |
| + config->enable_dtx = rtc::Optional<bool>(dtx_enabled_); |
| +} |
| + |
| +} // namespace webrtc |