OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h
" | 11 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h
" |
12 | 12 |
13 #include <cmath> | 13 #include <cmath> |
14 #include <utility> | 14 #include <utility> |
15 | 15 |
16 #include "webrtc/base/ignore_wundef.h" | 16 #include "webrtc/base/ignore_wundef.h" |
17 #include "webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.h
" | 17 #include "webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.h
" |
18 #include "webrtc/modules/audio_coding/audio_network_adaptor/channel_controller.h
" | 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/channel_controller.h
" |
19 #include "webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.h" | 19 #include "webrtc/modules/audio_coding/audio_network_adaptor/dtx_controller.h" |
20 #include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_b
ased.h" | 20 #include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_plr_b
ased.h" |
21 #include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_
based.h" | 21 #include "webrtc/modules/audio_coding/audio_network_adaptor/fec_controller_rplr_
based.h" |
22 #include "webrtc/modules/audio_coding/audio_network_adaptor/frame_length_control
ler.h" | 22 #include "webrtc/modules/audio_coding/audio_network_adaptor/frame_length_control
ler.h" |
| 23 #include "webrtc/modules/audio_coding/audio_network_adaptor/util/threshold_curve
.h" |
23 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
24 | 25 |
25 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 26 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
26 RTC_PUSH_IGNORING_WUNDEF() | 27 RTC_PUSH_IGNORING_WUNDEF() |
27 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 28 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
28 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" | 29 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" |
29 #else | 30 #else |
30 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" | 31 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" |
31 #endif | 32 #endif |
32 RTC_POP_IGNORING_WUNDEF() | 33 RTC_POP_IGNORING_WUNDEF() |
(...skipping 21 matching lines...) Expand all Loading... |
54 | 55 |
55 auto& fec_disabling_threshold = config.fec_disabling_threshold(); | 56 auto& fec_disabling_threshold = config.fec_disabling_threshold(); |
56 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); | 57 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); |
57 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_packet_loss()); | 58 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_packet_loss()); |
58 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); | 59 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); |
59 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_packet_loss()); | 60 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_packet_loss()); |
60 | 61 |
61 return std::unique_ptr<FecControllerPlrBased>( | 62 return std::unique_ptr<FecControllerPlrBased>( |
62 new FecControllerPlrBased(FecControllerPlrBased::Config( | 63 new FecControllerPlrBased(FecControllerPlrBased::Config( |
63 initial_fec_enabled, | 64 initial_fec_enabled, |
64 FecControllerPlrBased::Config::Threshold( | 65 ThresholdCurve(fec_enabling_threshold.low_bandwidth_bps(), |
65 fec_enabling_threshold.low_bandwidth_bps(), | 66 fec_enabling_threshold.low_bandwidth_packet_loss(), |
66 fec_enabling_threshold.low_bandwidth_packet_loss(), | 67 fec_enabling_threshold.high_bandwidth_bps(), |
67 fec_enabling_threshold.high_bandwidth_bps(), | 68 fec_enabling_threshold.high_bandwidth_packet_loss()), |
68 fec_enabling_threshold.high_bandwidth_packet_loss()), | 69 ThresholdCurve(fec_disabling_threshold.low_bandwidth_bps(), |
69 FecControllerPlrBased::Config::Threshold( | 70 fec_disabling_threshold.low_bandwidth_packet_loss(), |
70 fec_disabling_threshold.low_bandwidth_bps(), | 71 fec_disabling_threshold.high_bandwidth_bps(), |
71 fec_disabling_threshold.low_bandwidth_packet_loss(), | 72 fec_disabling_threshold.high_bandwidth_packet_loss()), |
72 fec_disabling_threshold.high_bandwidth_bps(), | |
73 fec_disabling_threshold.high_bandwidth_packet_loss()), | |
74 config.time_constant_ms(), clock))); | 73 config.time_constant_ms(), clock))); |
75 } | 74 } |
76 | 75 |
77 std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased( | 76 std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased( |
78 const audio_network_adaptor::config::FecControllerRplrBased& config, | 77 const audio_network_adaptor::config::FecControllerRplrBased& config, |
79 bool initial_fec_enabled) { | 78 bool initial_fec_enabled) { |
80 RTC_CHECK(config.has_fec_enabling_threshold()); | 79 RTC_CHECK(config.has_fec_enabling_threshold()); |
81 RTC_CHECK(config.has_fec_disabling_threshold()); | 80 RTC_CHECK(config.has_fec_disabling_threshold()); |
82 | 81 |
83 auto& fec_enabling_threshold = config.fec_enabling_threshold(); | 82 auto& fec_enabling_threshold = config.fec_enabling_threshold(); |
84 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps()); | 83 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps()); |
85 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_recoverable_packet_loss()); | 84 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_recoverable_packet_loss()); |
86 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps()); | 85 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps()); |
87 RTC_CHECK( | 86 RTC_CHECK( |
88 fec_enabling_threshold.has_high_bandwidth_recoverable_packet_loss()); | 87 fec_enabling_threshold.has_high_bandwidth_recoverable_packet_loss()); |
89 | 88 |
90 auto& fec_disabling_threshold = config.fec_disabling_threshold(); | 89 auto& fec_disabling_threshold = config.fec_disabling_threshold(); |
91 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); | 90 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); |
92 RTC_CHECK( | 91 RTC_CHECK( |
93 fec_disabling_threshold.has_low_bandwidth_recoverable_packet_loss()); | 92 fec_disabling_threshold.has_low_bandwidth_recoverable_packet_loss()); |
94 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); | 93 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); |
95 RTC_CHECK( | 94 RTC_CHECK( |
96 fec_disabling_threshold.has_high_bandwidth_recoverable_packet_loss()); | 95 fec_disabling_threshold.has_high_bandwidth_recoverable_packet_loss()); |
97 | 96 |
98 return std::unique_ptr<FecControllerRplrBased>( | 97 return std::unique_ptr<FecControllerRplrBased>( |
99 new FecControllerRplrBased(FecControllerRplrBased::Config( | 98 new FecControllerRplrBased(FecControllerRplrBased::Config( |
100 initial_fec_enabled, | 99 initial_fec_enabled, |
101 FecControllerRplrBased::Config::Threshold( | 100 ThresholdCurve( |
102 fec_enabling_threshold.low_bandwidth_bps(), | 101 fec_enabling_threshold.low_bandwidth_bps(), |
103 fec_enabling_threshold.low_bandwidth_recoverable_packet_loss(), | 102 fec_enabling_threshold.low_bandwidth_recoverable_packet_loss(), |
104 fec_enabling_threshold.high_bandwidth_bps(), | 103 fec_enabling_threshold.high_bandwidth_bps(), |
105 fec_enabling_threshold.high_bandwidth_recoverable_packet_loss()), | 104 fec_enabling_threshold.high_bandwidth_recoverable_packet_loss()), |
106 FecControllerRplrBased::Config::Threshold( | 105 ThresholdCurve( |
107 fec_disabling_threshold.low_bandwidth_bps(), | 106 fec_disabling_threshold.low_bandwidth_bps(), |
108 fec_disabling_threshold.low_bandwidth_recoverable_packet_loss(), | 107 fec_disabling_threshold.low_bandwidth_recoverable_packet_loss(), |
109 fec_disabling_threshold.high_bandwidth_bps(), | 108 fec_disabling_threshold.high_bandwidth_bps(), |
110 fec_disabling_threshold | 109 fec_disabling_threshold |
111 .high_bandwidth_recoverable_packet_loss())))); | 110 .high_bandwidth_recoverable_packet_loss())))); |
112 } | 111 } |
113 | 112 |
114 std::unique_ptr<FrameLengthController> CreateFrameLengthController( | 113 std::unique_ptr<FrameLengthController> CreateFrameLengthController( |
115 const audio_network_adaptor::config::FrameLengthController& config, | 114 const audio_network_adaptor::config::FrameLengthController& config, |
116 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 115 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 386 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
388 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 387 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
389 float diff_normalized_packet_loss = | 388 float diff_normalized_packet_loss = |
390 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 389 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
391 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 390 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
392 return std::pow(diff_normalized_bitrate_bps, 2) + | 391 return std::pow(diff_normalized_bitrate_bps, 2) + |
393 std::pow(diff_normalized_packet_loss, 2); | 392 std::pow(diff_normalized_packet_loss, 2); |
394 } | 393 } |
395 | 394 |
396 } // namespace webrtc | 395 } // namespace webrtc |
OLD | NEW |