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

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

Issue 2320093002: Adding DTX controller to audio network adaptor. (Closed)
Patch Set: rebasing Created 4 years, 3 months 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
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc
diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e8fda9efe0820e018c7580805fba353a803a2fb3
--- /dev/null
+++ b/webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller_unittest.cc
@@ -0,0 +1,86 @@
+/*
+ * 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 <memory>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.h"
+
+namespace webrtc {
+
+namespace {
+
+constexpr int kDtxEnablingBandwidthBps = 55000;
+constexpr int kDtxDisablingBandwidthBps = 65000;
+constexpr int kMediumBandwidthBps =
+ (kDtxEnablingBandwidthBps + kDtxDisablingBandwidthBps) / 2;
+
+std::unique_ptr<DtxController> CreateController(int initial_dtx_enabled) {
+ std::unique_ptr<DtxController> controller(new DtxController(
+ DtxController::Config(initial_dtx_enabled, kDtxEnablingBandwidthBps,
+ kDtxDisablingBandwidthBps)));
+ return controller;
+}
+
+void CheckDecision(DtxController* controller,
+ const rtc::Optional<int>& uplink_bandwidth_bps,
+ bool expected_dtx_enabled) {
+ AudioNetworkAdaptor::EncoderRuntimeConfig config;
+ Controller::NetworkMetrics metrics;
+ metrics.uplink_bandwidth_bps = uplink_bandwidth_bps;
+ controller->MakeDecision(metrics, &config);
+ EXPECT_EQ(rtc::Optional<bool>(expected_dtx_enabled), config.enable_dtx);
+}
+
+} // namespace
+
+TEST(DtxControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) {
+ constexpr bool kInitialDtxEnabled = true;
+ auto controller = CreateController(kInitialDtxEnabled);
+ CheckDecision(controller.get(), rtc::Optional<int>(), kInitialDtxEnabled);
+}
+
+TEST(DtxControllerTest, TurnOnDtxForLowUplinkBandwidth) {
+ auto controller = CreateController(false);
+ CheckDecision(controller.get(), rtc::Optional<int>(kDtxEnablingBandwidthBps),
+ true);
+}
+
+TEST(DtxControllerTest, TurnOffDtxForHighUplinkBandwidth) {
+ auto controller = CreateController(true);
+ CheckDecision(controller.get(), rtc::Optional<int>(kDtxDisablingBandwidthBps),
+ false);
+}
+
+TEST(DtxControllerTest, MaintainDtxOffForMediumUplinkBandwidth) {
+ auto controller = CreateController(false);
+ CheckDecision(controller.get(), rtc::Optional<int>(kMediumBandwidthBps),
+ false);
+}
+
+TEST(DtxControllerTest, MaintainDtxOnForMediumUplinkBandwidth) {
+ auto controller = CreateController(true);
+ CheckDecision(controller.get(), rtc::Optional<int>(kMediumBandwidthBps),
+ true);
+}
+
+TEST(DtxControllerTest, CheckBehaviorOnChangingUplinkBandwidth) {
+ auto controller = CreateController(false);
+ CheckDecision(controller.get(), rtc::Optional<int>(kMediumBandwidthBps),
+ false);
+ CheckDecision(controller.get(), rtc::Optional<int>(kDtxEnablingBandwidthBps),
+ true);
+ CheckDecision(controller.get(), rtc::Optional<int>(kMediumBandwidthBps),
+ true);
+ CheckDecision(controller.get(), rtc::Optional<int>(kDtxDisablingBandwidthBps),
+ false);
+}
+
+} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698