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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 auto& characteristic_point = controller_config.scoring_point(); | 246 auto& characteristic_point = controller_config.scoring_point(); |
247 RTC_CHECK(characteristic_point.has_uplink_bandwidth_bps()); | 247 RTC_CHECK(characteristic_point.has_uplink_bandwidth_bps()); |
248 RTC_CHECK(characteristic_point.has_uplink_packet_loss_fraction()); | 248 RTC_CHECK(characteristic_point.has_uplink_packet_loss_fraction()); |
249 chracteristic_points[controller.get()] = std::make_pair<int, float>( | 249 chracteristic_points[controller.get()] = std::make_pair<int, float>( |
250 characteristic_point.uplink_bandwidth_bps(), | 250 characteristic_point.uplink_bandwidth_bps(), |
251 characteristic_point.uplink_packet_loss_fraction()); | 251 characteristic_point.uplink_packet_loss_fraction()); |
252 } | 252 } |
253 controllers.push_back(std::move(controller)); | 253 controllers.push_back(std::move(controller)); |
254 } | 254 } |
255 | 255 |
256 RTC_CHECK(controller_manager_config.has_min_reordering_time_ms()); | 256 if (chracteristic_points.size() == 0) { |
tschumi
2017/05/30 14:03:24
Do you think its worth the extra complexity ?
| |
257 RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance()); | 257 return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl( |
258 return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl( | 258 ControllerManagerImpl::Config(0, 0), std::move(controllers), |
259 ControllerManagerImpl::Config( | 259 chracteristic_points)); |
260 controller_manager_config.min_reordering_time_ms(), | 260 } else { |
261 controller_manager_config.min_reordering_squared_distance()), | 261 RTC_CHECK(controller_manager_config.has_min_reordering_time_ms()); |
262 std::move(controllers), chracteristic_points)); | 262 RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance()); |
263 return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl( | |
264 ControllerManagerImpl::Config( | |
265 controller_manager_config.min_reordering_time_ms(), | |
266 controller_manager_config.min_reordering_squared_distance()), | |
267 std::move(controllers), chracteristic_points)); | |
268 } | |
263 #else | 269 #else |
264 RTC_NOTREACHED(); | 270 RTC_NOTREACHED(); |
265 return nullptr; | 271 return nullptr; |
266 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP | 272 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP |
267 } | 273 } |
268 | 274 |
269 ControllerManagerImpl::ControllerManagerImpl(const Config& config) | 275 ControllerManagerImpl::ControllerManagerImpl(const Config& config) |
270 : ControllerManagerImpl( | 276 : ControllerManagerImpl( |
271 config, | 277 config, |
272 std::vector<std::unique_ptr<Controller>>(), | 278 std::vector<std::unique_ptr<Controller>>(), |
(...skipping 15 matching lines...) Expand all Loading... | |
288 controller_scoring_points_.insert(std::make_pair( | 294 controller_scoring_points_.insert(std::make_pair( |
289 controller_point.first, ScoringPoint(controller_point.second.first, | 295 controller_point.first, ScoringPoint(controller_point.second.first, |
290 controller_point.second.second))); | 296 controller_point.second.second))); |
291 } | 297 } |
292 } | 298 } |
293 | 299 |
294 ControllerManagerImpl::~ControllerManagerImpl() = default; | 300 ControllerManagerImpl::~ControllerManagerImpl() = default; |
295 | 301 |
296 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers( | 302 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers( |
297 const Controller::NetworkMetrics& metrics) { | 303 const Controller::NetworkMetrics& metrics) { |
298 int64_t now_ms = rtc::TimeMillis(); | 304 if (controller_scoring_points_.size() == 0) |
305 return default_sorted_controllers_; | |
299 | 306 |
300 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction) | 307 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction) |
301 return sorted_controllers_; | 308 return sorted_controllers_; |
302 | 309 |
310 const int64_t now_ms = rtc::TimeMillis(); | |
303 if (last_reordering_time_ms_ && | 311 if (last_reordering_time_ms_ && |
304 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms) | 312 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms) |
305 return sorted_controllers_; | 313 return sorted_controllers_; |
306 | 314 |
307 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps, | 315 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps, |
308 *metrics.uplink_packet_loss_fraction); | 316 *metrics.uplink_packet_loss_fraction); |
309 | 317 |
310 if (last_reordering_time_ms_ && | 318 if (last_reordering_time_ms_ && |
311 last_scoring_point_.SquaredDistanceTo(scoring_point) < | 319 last_scoring_point_.SquaredDistanceTo(scoring_point) < |
312 config_.min_reordering_squared_distance) | 320 config_.min_reordering_squared_distance) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - | 390 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - |
383 NormalizeUplinkBandwidth(uplink_bandwidth_bps); | 391 NormalizeUplinkBandwidth(uplink_bandwidth_bps); |
384 float diff_normalized_packet_loss = | 392 float diff_normalized_packet_loss = |
385 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - | 393 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - |
386 NormalizePacketLossFraction(uplink_packet_loss_fraction); | 394 NormalizePacketLossFraction(uplink_packet_loss_fraction); |
387 return std::pow(diff_normalized_bitrate_bps, 2) + | 395 return std::pow(diff_normalized_bitrate_bps, 2) + |
388 std::pow(diff_normalized_packet_loss, 2); | 396 std::pow(diff_normalized_packet_loss, 2); |
389 } | 397 } |
390 | 398 |
391 } // namespace webrtc | 399 } // namespace webrtc |
OLD | NEW |