| 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 |
| 101 FrameLengthController::Config ctor_config( | 102 FrameLengthController::Config ctor_config( |
| 102 std::vector<int>(), initial_frame_length_ms, | 103 std::vector<int>(), initial_frame_length_ms, min_encoder_bitrate_bps, |
| 103 config.fl_increasing_packet_loss_fraction(), | 104 config.fl_increasing_packet_loss_fraction(), |
| 104 config.fl_decreasing_packet_loss_fraction(), | 105 config.fl_decreasing_packet_loss_fraction(), |
| 105 std::move(fl_changing_bandwidths_bps)); | 106 std::move(fl_changing_bandwidths_bps)); |
| 106 | 107 |
| 107 for (auto frame_length : encoder_frame_lengths_ms) | 108 for (auto frame_length : encoder_frame_lengths_ms) |
| 108 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); | 109 ctor_config.encoder_frame_lengths_ms.push_back(frame_length); |
| 109 | 110 |
| 110 return std::unique_ptr<FrameLengthController>( | 111 return std::unique_ptr<FrameLengthController>( |
| 111 new FrameLengthController(ctor_config)); | 112 new FrameLengthController(ctor_config)); |
| 112 } | 113 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 : min_reordering_time_ms(min_reordering_time_ms), | 153 : min_reordering_time_ms(min_reordering_time_ms), |
| 153 min_reordering_squared_distance(min_reordering_squared_distance), | 154 min_reordering_squared_distance(min_reordering_squared_distance), |
| 154 clock(clock) {} | 155 clock(clock) {} |
| 155 | 156 |
| 156 ControllerManagerImpl::Config::~Config() = default; | 157 ControllerManagerImpl::Config::~Config() = default; |
| 157 | 158 |
| 158 std::unique_ptr<ControllerManager> ControllerManagerImpl::Create( | 159 std::unique_ptr<ControllerManager> ControllerManagerImpl::Create( |
| 159 const std::string& config_string, | 160 const std::string& config_string, |
| 160 size_t num_encoder_channels, | 161 size_t num_encoder_channels, |
| 161 rtc::ArrayView<const int> encoder_frame_lengths_ms, | 162 rtc::ArrayView<const int> encoder_frame_lengths_ms, |
| 163 int min_encoder_bitrate_bps, |
| 162 size_t intial_channels_to_encode, | 164 size_t intial_channels_to_encode, |
| 163 int initial_frame_length_ms, | 165 int initial_frame_length_ms, |
| 164 int initial_bitrate_bps, | 166 int initial_bitrate_bps, |
| 165 bool initial_fec_enabled, | 167 bool initial_fec_enabled, |
| 166 bool initial_dtx_enabled, | 168 bool initial_dtx_enabled, |
| 167 const Clock* clock) { | 169 const Clock* clock) { |
| 168 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 170 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
| 169 audio_network_adaptor::config::ControllerManager controller_manager_config; | 171 audio_network_adaptor::config::ControllerManager controller_manager_config; |
| 170 controller_manager_config.ParseFromString(config_string); | 172 controller_manager_config.ParseFromString(config_string); |
| 171 | 173 |
| 172 std::vector<std::unique_ptr<Controller>> controllers; | 174 std::vector<std::unique_ptr<Controller>> controllers; |
| 173 std::map<const Controller*, std::pair<int, float>> chracteristic_points; | 175 std::map<const Controller*, std::pair<int, float>> chracteristic_points; |
| 174 | 176 |
| 175 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { | 177 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { |
| 176 auto& controller_config = controller_manager_config.controllers(i); | 178 auto& controller_config = controller_manager_config.controllers(i); |
| 177 std::unique_ptr<Controller> controller; | 179 std::unique_ptr<Controller> controller; |
| 178 switch (controller_config.controller_case()) { | 180 switch (controller_config.controller_case()) { |
| 179 case audio_network_adaptor::config::Controller::kFecController: | 181 case audio_network_adaptor::config::Controller::kFecController: |
| 180 controller = CreateFecController(controller_config.fec_controller(), | 182 controller = CreateFecController(controller_config.fec_controller(), |
| 181 initial_fec_enabled, clock); | 183 initial_fec_enabled, clock); |
| 182 break; | 184 break; |
| 183 case audio_network_adaptor::config::Controller::kFrameLengthController: | 185 case audio_network_adaptor::config::Controller::kFrameLengthController: |
| 184 controller = CreateFrameLengthController( | 186 controller = CreateFrameLengthController( |
| 185 controller_config.frame_length_controller(), | 187 controller_config.frame_length_controller(), |
| 186 encoder_frame_lengths_ms, initial_frame_length_ms); | 188 encoder_frame_lengths_ms, initial_frame_length_ms, |
| 189 min_encoder_bitrate_bps); |
| 187 break; | 190 break; |
| 188 case audio_network_adaptor::config::Controller::kChannelController: | 191 case audio_network_adaptor::config::Controller::kChannelController: |
| 189 controller = CreateChannelController( | 192 controller = CreateChannelController( |
| 190 controller_config.channel_controller(), num_encoder_channels, | 193 controller_config.channel_controller(), num_encoder_channels, |
| 191 intial_channels_to_encode); | 194 intial_channels_to_encode); |
| 192 break; | 195 break; |
| 193 case audio_network_adaptor::config::Controller::kDtxController: | 196 case audio_network_adaptor::config::Controller::kDtxController: |
| 194 controller = CreateDtxController(controller_config.dtx_controller(), | 197 controller = CreateDtxController(controller_config.dtx_controller(), |
| 195 initial_dtx_enabled); | 198 initial_dtx_enabled); |
| 196 break; | 199 break; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 344 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
| 342 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 345 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
| 343 float diff_normalized_packet_loss = | 346 float diff_normalized_packet_loss = |
| 344 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 347 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
| 345 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 348 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
| 346 return std::pow(diff_normalized_bitrate_bps, 2) + | 349 return std::pow(diff_normalized_bitrate_bps, 2) + |
| 347 std::pow(diff_normalized_packet_loss, 2); | 350 std::pow(diff_normalized_packet_loss, 2); |
| 348 } | 351 } |
| 349 | 352 |
| 350 } // namespace webrtc | 353 } // namespace webrtc |
| OLD | NEW |