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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 if (config.has_fl_60ms_to_120ms_bandwidth_bps() && | 130 if (config.has_fl_60ms_to_120ms_bandwidth_bps() && |
131 config.has_fl_120ms_to_60ms_bandwidth_bps()) { | 131 config.has_fl_120ms_to_60ms_bandwidth_bps()) { |
132 fl_changing_bandwidths_bps.insert(std::make_pair( | 132 fl_changing_bandwidths_bps.insert(std::make_pair( |
133 FrameLengthController::Config::FrameLengthChange(60, 120), | 133 FrameLengthController::Config::FrameLengthChange(60, 120), |
134 config.fl_60ms_to_120ms_bandwidth_bps())); | 134 config.fl_60ms_to_120ms_bandwidth_bps())); |
135 fl_changing_bandwidths_bps.insert(std::make_pair( | 135 fl_changing_bandwidths_bps.insert(std::make_pair( |
136 FrameLengthController::Config::FrameLengthChange(120, 60), | 136 FrameLengthController::Config::FrameLengthChange(120, 60), |
137 config.fl_120ms_to_60ms_bandwidth_bps())); | 137 config.fl_120ms_to_60ms_bandwidth_bps())); |
138 } | 138 } |
139 | 139 |
| 140 int fl_increase_overhead_offset = 0; |
| 141 if (config.has_fl_increase_overhead_offset()) { |
| 142 fl_increase_overhead_offset = config.fl_increase_overhead_offset(); |
| 143 } |
| 144 int fl_decrease_overhead_offset = 0; |
| 145 if (config.has_fl_decrease_overhead_offset()) { |
| 146 fl_decrease_overhead_offset = config.fl_decrease_overhead_offset(); |
| 147 } |
| 148 |
140 FrameLengthController::Config ctor_config( | 149 FrameLengthController::Config ctor_config( |
141 std::vector<int>(), initial_frame_length_ms, min_encoder_bitrate_bps, | 150 std::vector<int>(), initial_frame_length_ms, min_encoder_bitrate_bps, |
142 config.fl_increasing_packet_loss_fraction(), | 151 config.fl_increasing_packet_loss_fraction(), |
143 config.fl_decreasing_packet_loss_fraction(), | 152 config.fl_decreasing_packet_loss_fraction(), fl_increase_overhead_offset, |
144 std::move(fl_changing_bandwidths_bps)); | 153 fl_decrease_overhead_offset, std::move(fl_changing_bandwidths_bps)); |
145 | 154 |
146 for (auto frame_length : encoder_frame_lengths_ms) | 155 for (auto frame_length : encoder_frame_lengths_ms) |
147 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); | 156 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); |
148 | 157 |
149 return std::unique_ptr<FrameLengthController>( | 158 return std::unique_ptr<FrameLengthController>( |
150 new FrameLengthController(ctor_config)); | 159 new FrameLengthController(ctor_config)); |
151 } | 160 } |
152 | 161 |
153 std::unique_ptr<ChannelController> CreateChannelController( | 162 std::unique_ptr<ChannelController> CreateChannelController( |
154 const audio_network_adaptor::config::ChannelController& config, | 163 const audio_network_adaptor::config::ChannelController& config, |
(...skipping 14 matching lines...) Expand all Loading... |
169 RTC_CHECK(dtx_config.has_dtx_enabling_bandwidth_bps()); | 178 RTC_CHECK(dtx_config.has_dtx_enabling_bandwidth_bps()); |
170 RTC_CHECK(dtx_config.has_dtx_disabling_bandwidth_bps()); | 179 RTC_CHECK(dtx_config.has_dtx_disabling_bandwidth_bps()); |
171 | 180 |
172 return std::unique_ptr<DtxController>(new DtxController(DtxController::Config( | 181 return std::unique_ptr<DtxController>(new DtxController(DtxController::Config( |
173 initial_dtx_enabled, dtx_config.dtx_enabling_bandwidth_bps(), | 182 initial_dtx_enabled, dtx_config.dtx_enabling_bandwidth_bps(), |
174 dtx_config.dtx_disabling_bandwidth_bps()))); | 183 dtx_config.dtx_disabling_bandwidth_bps()))); |
175 } | 184 } |
176 | 185 |
177 using audio_network_adaptor::BitrateController; | 186 using audio_network_adaptor::BitrateController; |
178 std::unique_ptr<BitrateController> CreateBitrateController( | 187 std::unique_ptr<BitrateController> CreateBitrateController( |
| 188 const audio_network_adaptor::config::BitrateController& bitrate_config, |
179 int initial_bitrate_bps, | 189 int initial_bitrate_bps, |
180 int initial_frame_length_ms) { | 190 int initial_frame_length_ms) { |
181 return std::unique_ptr<BitrateController>(new BitrateController( | 191 int fl_increase_overhead_offset = 0; |
182 BitrateController::Config(initial_bitrate_bps, initial_frame_length_ms))); | 192 if (bitrate_config.has_fl_increase_overhead_offset()) { |
| 193 fl_increase_overhead_offset = bitrate_config.fl_increase_overhead_offset(); |
| 194 } |
| 195 int fl_decrease_overhead_offset = 0; |
| 196 if (bitrate_config.has_fl_decrease_overhead_offset()) { |
| 197 fl_decrease_overhead_offset = bitrate_config.fl_decrease_overhead_offset(); |
| 198 } |
| 199 return std::unique_ptr<BitrateController>( |
| 200 new BitrateController(BitrateController::Config( |
| 201 initial_bitrate_bps, initial_frame_length_ms, |
| 202 fl_increase_overhead_offset, fl_decrease_overhead_offset))); |
183 } | 203 } |
184 #endif // WEBRTC_ENABLE_PROTOBUF | 204 #endif // WEBRTC_ENABLE_PROTOBUF |
185 | 205 |
186 } // namespace | 206 } // namespace |
187 | 207 |
188 ControllerManagerImpl::Config::Config(int min_reordering_time_ms, | 208 ControllerManagerImpl::Config::Config(int min_reordering_time_ms, |
189 float min_reordering_squared_distance) | 209 float min_reordering_squared_distance) |
190 : min_reordering_time_ms(min_reordering_time_ms), | 210 : min_reordering_time_ms(min_reordering_time_ms), |
191 min_reordering_squared_distance(min_reordering_squared_distance) {} | 211 min_reordering_squared_distance(min_reordering_squared_distance) {} |
192 | 212 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 case audio_network_adaptor::config::Controller::kChannelController: | 270 case audio_network_adaptor::config::Controller::kChannelController: |
251 controller = CreateChannelController( | 271 controller = CreateChannelController( |
252 controller_config.channel_controller(), num_encoder_channels, | 272 controller_config.channel_controller(), num_encoder_channels, |
253 intial_channels_to_encode); | 273 intial_channels_to_encode); |
254 break; | 274 break; |
255 case audio_network_adaptor::config::Controller::kDtxController: | 275 case audio_network_adaptor::config::Controller::kDtxController: |
256 controller = CreateDtxController(controller_config.dtx_controller(), | 276 controller = CreateDtxController(controller_config.dtx_controller(), |
257 initial_dtx_enabled); | 277 initial_dtx_enabled); |
258 break; | 278 break; |
259 case audio_network_adaptor::config::Controller::kBitrateController: | 279 case audio_network_adaptor::config::Controller::kBitrateController: |
260 controller = CreateBitrateController(initial_bitrate_bps, | 280 controller = CreateBitrateController( |
261 initial_frame_length_ms); | 281 controller_config.bitrate_controller(), initial_bitrate_bps, |
| 282 initial_frame_length_ms); |
262 break; | 283 break; |
263 default: | 284 default: |
264 RTC_NOTREACHED(); | 285 RTC_NOTREACHED(); |
265 } | 286 } |
266 if (controller_config.has_scoring_point()) { | 287 if (controller_config.has_scoring_point()) { |
267 auto& scoring_point = controller_config.scoring_point(); | 288 auto& scoring_point = controller_config.scoring_point(); |
268 RTC_CHECK(scoring_point.has_uplink_bandwidth_bps()); | 289 RTC_CHECK(scoring_point.has_uplink_bandwidth_bps()); |
269 RTC_CHECK(scoring_point.has_uplink_packet_loss_fraction()); | 290 RTC_CHECK(scoring_point.has_uplink_packet_loss_fraction()); |
270 scoring_points[controller.get()] = std::make_pair<int, float>( | 291 scoring_points[controller.get()] = std::make_pair<int, float>( |
271 scoring_point.uplink_bandwidth_bps(), | 292 scoring_point.uplink_bandwidth_bps(), |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 432 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
412 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 433 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
413 float diff_normalized_packet_loss = | 434 float diff_normalized_packet_loss = |
414 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 435 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
415 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 436 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
416 return std::pow(diff_normalized_bitrate_bps, 2) + | 437 return std::pow(diff_normalized_bitrate_bps, 2) + |
417 std::pow(diff_normalized_packet_loss, 2); | 438 std::pow(diff_normalized_packet_loss, 2); |
418 } | 439 } |
419 | 440 |
420 } // namespace webrtc | 441 } // namespace webrtc |
OLD | NEW |