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.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/frame_length_control
ler.h" | 21 #include "webrtc/modules/audio_coding/audio_network_adaptor/frame_length_control
ler.h" |
22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
23 | 23 |
24 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 24 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
25 RTC_PUSH_IGNORING_WUNDEF() | 25 RTC_PUSH_IGNORING_WUNDEF() |
26 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 26 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
27 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" | 27 #include "external/webrtc/webrtc/modules/audio_coding/audio_network_adaptor/conf
ig.pb.h" |
28 #else | 28 #else |
29 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" | 29 #include "webrtc/modules/audio_coding/audio_network_adaptor/config.pb.h" |
30 #endif | 30 #endif |
31 RTC_POP_IGNORING_WUNDEF() | 31 RTC_POP_IGNORING_WUNDEF() |
32 #endif | 32 #endif |
33 | 33 |
34 namespace webrtc { | 34 namespace webrtc { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 38 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
39 | 39 |
40 std::unique_ptr<FecController> CreateFecController( | 40 std::unique_ptr<FecControllerPlrBased> CreateFecControllerPlrBased( |
41 const audio_network_adaptor::config::FecController& config, | 41 const audio_network_adaptor::config::FecController& config, |
42 bool initial_fec_enabled, | 42 bool initial_fec_enabled, |
43 const Clock* clock) { | 43 const Clock* clock) { |
44 RTC_CHECK(config.has_fec_enabling_threshold()); | 44 RTC_CHECK(config.has_fec_enabling_threshold()); |
45 RTC_CHECK(config.has_fec_disabling_threshold()); | 45 RTC_CHECK(config.has_fec_disabling_threshold()); |
46 RTC_CHECK(config.has_time_constant_ms()); | 46 RTC_CHECK(config.has_time_constant_ms()); |
47 | 47 |
48 auto& fec_enabling_threshold = config.fec_enabling_threshold(); | 48 auto& fec_enabling_threshold = config.fec_enabling_threshold(); |
49 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps()); | 49 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_bps()); |
50 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_packet_loss()); | 50 RTC_CHECK(fec_enabling_threshold.has_low_bandwidth_packet_loss()); |
51 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps()); | 51 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_bps()); |
52 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_packet_loss()); | 52 RTC_CHECK(fec_enabling_threshold.has_high_bandwidth_packet_loss()); |
53 | 53 |
54 auto& fec_disabling_threshold = config.fec_disabling_threshold(); | 54 auto& fec_disabling_threshold = config.fec_disabling_threshold(); |
55 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); | 55 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_bps()); |
56 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_packet_loss()); | 56 RTC_CHECK(fec_disabling_threshold.has_low_bandwidth_packet_loss()); |
57 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); | 57 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_bps()); |
58 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_packet_loss()); | 58 RTC_CHECK(fec_disabling_threshold.has_high_bandwidth_packet_loss()); |
59 | 59 |
60 return std::unique_ptr<FecController>(new FecController(FecController::Config( | 60 return std::unique_ptr<FecControllerPlrBased>( |
61 initial_fec_enabled, | 61 new FecControllerPlrBased(FecControllerPlrBased::Config( |
62 FecController::Config::Threshold( | 62 initial_fec_enabled, |
63 fec_enabling_threshold.low_bandwidth_bps(), | 63 FecControllerPlrBased::Config::Threshold( |
64 fec_enabling_threshold.low_bandwidth_packet_loss(), | 64 fec_enabling_threshold.low_bandwidth_bps(), |
65 fec_enabling_threshold.high_bandwidth_bps(), | 65 fec_enabling_threshold.low_bandwidth_packet_loss(), |
66 fec_enabling_threshold.high_bandwidth_packet_loss()), | 66 fec_enabling_threshold.high_bandwidth_bps(), |
67 FecController::Config::Threshold( | 67 fec_enabling_threshold.high_bandwidth_packet_loss()), |
68 fec_disabling_threshold.low_bandwidth_bps(), | 68 FecControllerPlrBased::Config::Threshold( |
69 fec_disabling_threshold.low_bandwidth_packet_loss(), | 69 fec_disabling_threshold.low_bandwidth_bps(), |
70 fec_disabling_threshold.high_bandwidth_bps(), | 70 fec_disabling_threshold.low_bandwidth_packet_loss(), |
71 fec_disabling_threshold.high_bandwidth_packet_loss()), | 71 fec_disabling_threshold.high_bandwidth_bps(), |
72 config.time_constant_ms(), clock))); | 72 fec_disabling_threshold.high_bandwidth_packet_loss()), |
| 73 config.time_constant_ms(), clock))); |
73 } | 74 } |
74 | 75 |
75 std::unique_ptr<FrameLengthController> CreateFrameLengthController( | 76 std::unique_ptr<FrameLengthController> CreateFrameLengthController( |
76 const audio_network_adaptor::config::FrameLengthController& config, | 77 const audio_network_adaptor::config::FrameLengthController& config, |
77 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 78 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
78 int initial_frame_length_ms, | 79 int initial_frame_length_ms, |
79 int min_encoder_bitrate_bps) { | 80 int min_encoder_bitrate_bps) { |
80 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); | 81 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); |
81 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); | 82 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); |
82 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); | 83 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 controller_manager_config.ParseFromString(config_string); | 173 controller_manager_config.ParseFromString(config_string); |
173 | 174 |
174 std::vector<std::unique_ptr<Controller>> controllers; | 175 std::vector<std::unique_ptr<Controller>> controllers; |
175 std::map<const Controller*, std::pair<int, float>> chracteristic_points; | 176 std::map<const Controller*, std::pair<int, float>> chracteristic_points; |
176 | 177 |
177 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { | 178 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { |
178 auto& controller_config = controller_manager_config.controllers(i); | 179 auto& controller_config = controller_manager_config.controllers(i); |
179 std::unique_ptr<Controller> controller; | 180 std::unique_ptr<Controller> controller; |
180 switch (controller_config.controller_case()) { | 181 switch (controller_config.controller_case()) { |
181 case audio_network_adaptor::config::Controller::kFecController: | 182 case audio_network_adaptor::config::Controller::kFecController: |
182 controller = CreateFecController(controller_config.fec_controller(), | 183 controller = CreateFecControllerPlrBased( |
183 initial_fec_enabled, clock); | 184 controller_config.fec_controller(), initial_fec_enabled, clock); |
184 break; | 185 break; |
185 case audio_network_adaptor::config::Controller::kFrameLengthController: | 186 case audio_network_adaptor::config::Controller::kFrameLengthController: |
186 controller = CreateFrameLengthController( | 187 controller = CreateFrameLengthController( |
187 controller_config.frame_length_controller(), | 188 controller_config.frame_length_controller(), |
188 encoder_frame_lengths_ms, initial_frame_length_ms, | 189 encoder_frame_lengths_ms, initial_frame_length_ms, |
189 min_encoder_bitrate_bps); | 190 min_encoder_bitrate_bps); |
190 break; | 191 break; |
191 case audio_network_adaptor::config::Controller::kChannelController: | 192 case audio_network_adaptor::config::Controller::kChannelController: |
192 controller = CreateChannelController( | 193 controller = CreateChannelController( |
193 controller_config.channel_controller(), num_encoder_channels, | 194 controller_config.channel_controller(), num_encoder_channels, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 345 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
345 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 346 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
346 float diff_normalized_packet_loss = | 347 float diff_normalized_packet_loss = |
347 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 348 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
348 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 349 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
349 return std::pow(diff_normalized_bitrate_bps, 2) + | 350 return std::pow(diff_normalized_bitrate_bps, 2) + |
350 std::pow(diff_normalized_packet_loss, 2); | 351 std::pow(diff_normalized_packet_loss, 2); |
351 } | 352 } |
352 | 353 |
353 } // namespace webrtc | 354 } // namespace webrtc |
OLD | NEW |