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 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 fec_disabling_threshold.low_bandwidth_bps(), | 68 fec_disabling_threshold.low_bandwidth_bps(), |
69 fec_disabling_threshold.low_bandwidth_packet_loss(), | 69 fec_disabling_threshold.low_bandwidth_packet_loss(), |
70 fec_disabling_threshold.high_bandwidth_bps(), | 70 fec_disabling_threshold.high_bandwidth_bps(), |
71 fec_disabling_threshold.high_bandwidth_packet_loss()), | 71 fec_disabling_threshold.high_bandwidth_packet_loss()), |
72 config.time_constant_ms(), clock))); | 72 config.time_constant_ms(), clock))); |
73 } | 73 } |
74 | 74 |
75 std::unique_ptr<FrameLengthController> CreateFrameLengthController( | 75 std::unique_ptr<FrameLengthController> CreateFrameLengthController( |
76 const audio_network_adaptor::config::FrameLengthController& config, | 76 const audio_network_adaptor::config::FrameLengthController& config, |
77 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 77 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
78 int initial_frame_length_ms) { | 78 int initial_frame_length_ms, |
| 79 int min_encoder_bitrate_bps) { |
79 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); | 80 RTC_CHECK(config.has_fl_increasing_packet_loss_fraction()); |
80 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); | 81 RTC_CHECK(config.has_fl_decreasing_packet_loss_fraction()); |
81 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); | 82 RTC_CHECK(config.has_fl_20ms_to_60ms_bandwidth_bps()); |
82 RTC_CHECK(config.has_fl_60ms_to_20ms_bandwidth_bps()); | 83 RTC_CHECK(config.has_fl_60ms_to_20ms_bandwidth_bps()); |
83 | 84 |
84 std::map<FrameLengthController::Config::FrameLengthChange, int> | 85 std::map<FrameLengthController::Config::FrameLengthChange, int> |
85 fl_changing_bandwidths_bps = { | 86 fl_changing_bandwidths_bps = { |
86 {FrameLengthController::Config::FrameLengthChange(20, 60), | 87 {FrameLengthController::Config::FrameLengthChange(20, 60), |
87 config.fl_20ms_to_60ms_bandwidth_bps()}, | 88 config.fl_20ms_to_60ms_bandwidth_bps()}, |
88 {FrameLengthController::Config::FrameLengthChange(60, 20), | 89 {FrameLengthController::Config::FrameLengthChange(60, 20), |
89 config.fl_60ms_to_20ms_bandwidth_bps()}}; | 90 config.fl_60ms_to_20ms_bandwidth_bps()}}; |
90 | 91 |
91 if (config.has_fl_60ms_to_120ms_bandwidth_bps() && | 92 if (config.has_fl_60ms_to_120ms_bandwidth_bps() && |
92 config.has_fl_120ms_to_60ms_bandwidth_bps()) { | 93 config.has_fl_120ms_to_60ms_bandwidth_bps()) { |
93 fl_changing_bandwidths_bps.insert(std::make_pair( | 94 fl_changing_bandwidths_bps.insert(std::make_pair( |
94 FrameLengthController::Config::FrameLengthChange(60, 120), | 95 FrameLengthController::Config::FrameLengthChange(60, 120), |
95 config.fl_60ms_to_120ms_bandwidth_bps())); | 96 config.fl_60ms_to_120ms_bandwidth_bps())); |
96 fl_changing_bandwidths_bps.insert(std::make_pair( | 97 fl_changing_bandwidths_bps.insert(std::make_pair( |
97 FrameLengthController::Config::FrameLengthChange(120, 60), | 98 FrameLengthController::Config::FrameLengthChange(120, 60), |
98 config.fl_120ms_to_60ms_bandwidth_bps())); | 99 config.fl_120ms_to_60ms_bandwidth_bps())); |
99 } | 100 } |
100 | 101 |
| 102 constexpr int kPreventOveruseMarginBps = 5000; |
101 FrameLengthController::Config ctor_config( | 103 FrameLengthController::Config ctor_config( |
102 std::vector<int>(), initial_frame_length_ms, | 104 std::vector<int>(), initial_frame_length_ms, min_encoder_bitrate_bps, |
103 config.fl_increasing_packet_loss_fraction(), | 105 kPreventOveruseMarginBps, config.fl_increasing_packet_loss_fraction(), |
104 config.fl_decreasing_packet_loss_fraction(), | 106 config.fl_decreasing_packet_loss_fraction(), |
105 std::move(fl_changing_bandwidths_bps)); | 107 std::move(fl_changing_bandwidths_bps)); |
106 | 108 |
107 for (auto frame_length : encoder_frame_lengths_ms) | 109 for (auto frame_length : encoder_frame_lengths_ms) |
108 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); | 110 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); |
109 | 111 |
110 return std::unique_ptr<FrameLengthController>( | 112 return std::unique_ptr<FrameLengthController>( |
111 new FrameLengthController(ctor_config)); | 113 new FrameLengthController(ctor_config)); |
112 } | 114 } |
113 | 115 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 : min_reordering_time_ms(min_reordering_time_ms), | 154 : min_reordering_time_ms(min_reordering_time_ms), |
153 min_reordering_squared_distance(min_reordering_squared_distance), | 155 min_reordering_squared_distance(min_reordering_squared_distance), |
154 clock(clock) {} | 156 clock(clock) {} |
155 | 157 |
156 ControllerManagerImpl::Config::~Config() = default; | 158 ControllerManagerImpl::Config::~Config() = default; |
157 | 159 |
158 std::unique_ptr<ControllerManager> ControllerManagerImpl::Create( | 160 std::unique_ptr<ControllerManager> ControllerManagerImpl::Create( |
159 const std::string& config_string, | 161 const std::string& config_string, |
160 size_t num_encoder_channels, | 162 size_t num_encoder_channels, |
161 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 163 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
| 164 int min_encoder_bitrate_bps, |
162 size_t intial_channels_to_encode, | 165 size_t intial_channels_to_encode, |
163 int initial_frame_length_ms, | 166 int initial_frame_length_ms, |
164 int initial_bitrate_bps, | 167 int initial_bitrate_bps, |
165 bool initial_fec_enabled, | 168 bool initial_fec_enabled, |
166 bool initial_dtx_enabled, | 169 bool initial_dtx_enabled, |
167 const Clock* clock) { | 170 const Clock* clock) { |
168 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 171 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
169 audio_network_adaptor::config::ControllerManager controller_manager_config; | 172 audio_network_adaptor::config::ControllerManager controller_manager_config; |
170 controller_manager_config.ParseFromString(config_string); | 173 controller_manager_config.ParseFromString(config_string); |
171 | 174 |
172 std::vector<std::unique_ptr<Controller>> controllers; | 175 std::vector<std::unique_ptr<Controller>> controllers; |
173 std::map<const Controller*, std::pair<int, float>> chracteristic_points; | 176 std::map<const Controller*, std::pair<int, float>> chracteristic_points; |
174 | 177 |
175 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { | 178 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { |
176 auto& controller_config = controller_manager_config.controllers(i); | 179 auto& controller_config = controller_manager_config.controllers(i); |
177 std::unique_ptr<Controller> controller; | 180 std::unique_ptr<Controller> controller; |
178 switch (controller_config.controller_case()) { | 181 switch (controller_config.controller_case()) { |
179 case audio_network_adaptor::config::Controller::kFecController: | 182 case audio_network_adaptor::config::Controller::kFecController: |
180 controller = CreateFecController(controller_config.fec_controller(), | 183 controller = CreateFecController(controller_config.fec_controller(), |
181 initial_fec_enabled, clock); | 184 initial_fec_enabled, clock); |
182 break; | 185 break; |
183 case audio_network_adaptor::config::Controller::kFrameLengthController: | 186 case audio_network_adaptor::config::Controller::kFrameLengthController: |
184 controller = CreateFrameLengthController( | 187 controller = CreateFrameLengthController( |
185 controller_config.frame_length_controller(), | 188 controller_config.frame_length_controller(), |
186 encoder_frame_lengths_ms, initial_frame_length_ms); | 189 encoder_frame_lengths_ms, initial_frame_length_ms, |
| 190 min_encoder_bitrate_bps); |
187 break; | 191 break; |
188 case audio_network_adaptor::config::Controller::kChannelController: | 192 case audio_network_adaptor::config::Controller::kChannelController: |
189 controller = CreateChannelController( | 193 controller = CreateChannelController( |
190 controller_config.channel_controller(), num_encoder_channels, | 194 controller_config.channel_controller(), num_encoder_channels, |
191 intial_channels_to_encode); | 195 intial_channels_to_encode); |
192 break; | 196 break; |
193 case audio_network_adaptor::config::Controller::kDtxController: | 197 case audio_network_adaptor::config::Controller::kDtxController: |
194 controller = CreateDtxController(controller_config.dtx_controller(), | 198 controller = CreateDtxController(controller_config.dtx_controller(), |
195 initial_dtx_enabled); | 199 initial_dtx_enabled); |
196 break; | 200 break; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 345 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
342 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 346 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
343 float diff_normalized_packet_loss = | 347 float diff_normalized_packet_loss = |
344 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 348 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
345 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 349 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
346 return std::pow(diff_normalized_bitrate_bps, 2) + | 350 return std::pow(diff_normalized_bitrate_bps, 2) + |
347 std::pow(diff_normalized_packet_loss, 2); | 351 std::pow(diff_normalized_packet_loss, 2); |
348 } | 352 } |
349 | 353 |
350 } // namespace webrtc | 354 } // namespace webrtc |
OLD | NEW |