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/frame_length_control
ler.h" | 22 #include "webrtc/modules/audio_coding/audio_network_adaptor/frame_length_control
ler.h" |
22 #include "webrtc/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
23 | 24 |
24 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 25 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
25 RTC_PUSH_IGNORING_WUNDEF() | 26 RTC_PUSH_IGNORING_WUNDEF() |
26 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 27 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
27 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" | 28 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" |
28 #else | 29 #else |
29 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" | 30 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" |
30 #endif | 31 #endif |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 fec_enabling_threshold.high_bandwidth_bps(), | 67 fec_enabling_threshold.high_bandwidth_bps(), |
67 fec_enabling_threshold.high_bandwidth_packet_loss()), | 68 fec_enabling_threshold.high_bandwidth_packet_loss()), |
68 FecControllerPlrBased::Config::Threshold( | 69 FecControllerPlrBased::Config::Threshold( |
69 fec_disabling_threshold.low_bandwidth_bps(), | 70 fec_disabling_threshold.low_bandwidth_bps(), |
70 fec_disabling_threshold.low_bandwidth_packet_loss(), | 71 fec_disabling_threshold.low_bandwidth_packet_loss(), |
71 fec_disabling_threshold.high_bandwidth_bps(), | 72 fec_disabling_threshold.high_bandwidth_bps(), |
72 fec_disabling_threshold.high_bandwidth_packet_loss()), | 73 fec_disabling_threshold.high_bandwidth_packet_loss()), |
73 config.time_constant_ms(), clock))); | 74 config.time_constant_ms(), clock))); |
74 } | 75 } |
75 | 76 |
| 77 std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased( |
| 78 const audio_network_adaptor::config::FecControllerRplrBased& config, |
| 79 bool initial_fec_enabled, |
| 80 const Clock* clock) { |
| 81 RTC_CHECK(config.has_fec_enabling_threshold()); |
| 82 RTC_CHECK(config.has_fec_disabling_threshold()); |
| 83 RTC_CHECK(config.has_time_constant_ms()); |
| 84 |
| 85 auto& fec_enabling_threshold = config.fec_enabling_threshold(); |
| 86 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps()); |
| 87 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_recoverable_packet_loss()); |
| 88 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps()); |
| 89 RTC_CHECK( |
| 90 fec_enabling_threshold.has_high_bandwidth_recoverable_packet_loss()); |
| 91 |
| 92 auto& fec_disabling_threshold = config.fec_disabling_threshold(); |
| 93 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); |
| 94 RTC_CHECK( |
| 95 fec_disabling_threshold.has_low_bandwidth_recoverable_packet_loss()); |
| 96 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); |
| 97 RTC_CHECK( |
| 98 fec_disabling_threshold.has_high_bandwidth_recoverable_packet_loss()); |
| 99 |
| 100 return std::unique_ptr<FecControllerRplrBased>( |
| 101 new FecControllerRplrBased(FecControllerRplrBased::Config( |
| 102 initial_fec_enabled, |
| 103 FecControllerRplrBased::Config::Threshold( |
| 104 fec_enabling_threshold.low_bandwidth_bps(), |
| 105 fec_enabling_threshold.low_bandwidth_recoverable_packet_loss(), |
| 106 fec_enabling_threshold.high_bandwidth_bps(), |
| 107 fec_enabling_threshold.high_bandwidth_recoverable_packet_loss()), |
| 108 FecControllerRplrBased::Config::Threshold( |
| 109 fec_disabling_threshold.low_bandwidth_bps(), |
| 110 fec_disabling_threshold.low_bandwidth_recoverable_packet_loss(), |
| 111 fec_disabling_threshold.high_bandwidth_bps(), |
| 112 fec_disabling_threshold.high_bandwidth_recoverable_packet_loss()), |
| 113 config.time_constant_ms(), clock))); |
| 114 } |
| 115 |
76 std::unique_ptr<FrameLengthController> CreateFrameLengthController( | 116 std::unique_ptr<FrameLengthController> CreateFrameLengthController( |
77 const audio_network_adaptor::config::FrameLengthController& config, | 117 const audio_network_adaptor::config::FrameLengthController& config, |
78 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 118 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
79 int initial_frame_length_ms, | 119 int initial_frame_length_ms, |
80 int min_encoder_bitrate_bps) { | 120 int min_encoder_bitrate_bps) { |
81 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); | 121 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); |
82 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); | 122 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); |
83 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); | 123 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); |
84 RTC_CHECK(config.has_fl_60ms_to_20ms_bandwidth_bps()); | 124 RTC_CHECK(config.has_fl_60ms_to_20ms_bandwidth_bps()); |
85 | 125 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 std::map<const Controller*, std::pair<int, float>> chracteristic_points; | 216 std::map<const Controller*, std::pair<int, float>> chracteristic_points; |
177 | 217 |
178 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { | 218 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { |
179 auto& controller_config = controller_manager_config.controllers(i); | 219 auto& controller_config = controller_manager_config.controllers(i); |
180 std::unique_ptr<Controller> controller; | 220 std::unique_ptr<Controller> controller; |
181 switch (controller_config.controller_case()) { | 221 switch (controller_config.controller_case()) { |
182 case audio_network_adaptor::config::Controller::kFecController: | 222 case audio_network_adaptor::config::Controller::kFecController: |
183 controller = CreateFecControllerPlrBased( | 223 controller = CreateFecControllerPlrBased( |
184 controller_config.fec_controller(), initial_fec_enabled, clock); | 224 controller_config.fec_controller(), initial_fec_enabled, clock); |
185 break; | 225 break; |
| 226 case audio_network_adaptor::config::Controller::kFecControllerRplrBased: |
| 227 controller = CreateFecControllerRplrBased( |
| 228 controller_config.fec_controller_rplr_based(), initial_fec_enabled, |
| 229 clock); |
| 230 break; |
186 case audio_network_adaptor::config::Controller::kFrameLengthController: | 231 case audio_network_adaptor::config::Controller::kFrameLengthController: |
187 controller = CreateFrameLengthController( | 232 controller = CreateFrameLengthController( |
188 controller_config.frame_length_controller(), | 233 controller_config.frame_length_controller(), |
189 encoder_frame_lengths_ms, initial_frame_length_ms, | 234 encoder_frame_lengths_ms, initial_frame_length_ms, |
190 min_encoder_bitrate_bps); | 235 min_encoder_bitrate_bps); |
191 break; | 236 break; |
192 case audio_network_adaptor::config::Controller::kChannelController: | 237 case audio_network_adaptor::config::Controller::kChannelController: |
193 controller = CreateChannelController( | 238 controller = CreateChannelController( |
194 controller_config.channel_controller(), num_encoder_channels, | 239 controller_config.channel_controller(), num_encoder_channels, |
195 intial_channels_to_encode); | 240 intial_channels_to_encode); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 390 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
346 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 391 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
347 float diff_normalized_packet_loss = | 392 float diff_normalized_packet_loss = |
348 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 393 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
349 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 394 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
350 return std::pow(diff_normalized_bitrate_bps, 2) + | 395 return std::pow(diff_normalized_bitrate_bps, 2) + |
351 std::pow(diff_normalized_packet_loss, 2); | 396 std::pow(diff_normalized_packet_loss, 2); |
352 } | 397 } |
353 | 398 |
354 } // namespace webrtc | 399 } // namespace webrtc |
OLD | NEW |