Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.cc

Issue 2910193002: Avoiding check on reordering configs in ANA if there is no controller has scoring point. (Closed)
Patch Set: rebasing Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
246 auto& scoring_point = controller_config.scoring_point(); 246 auto& scoring_point = controller_config.scoring_point();
247 RTC_CHECK(scoring_point.has_uplink_bandwidth_bps()); 247 RTC_CHECK(scoring_point.has_uplink_bandwidth_bps());
248 RTC_CHECK(scoring_point.has_uplink_packet_loss_fraction()); 248 RTC_CHECK(scoring_point.has_uplink_packet_loss_fraction());
249 scoring_points[controller.get()] = std::make_pair<int, float>( 249 scoring_points[controller.get()] = std::make_pair<int, float>(
250 scoring_point.uplink_bandwidth_bps(), 250 scoring_point.uplink_bandwidth_bps(),
251 scoring_point.uplink_packet_loss_fraction()); 251 scoring_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 (scoring_points.size() == 0) {
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 scoring_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), scoring_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), scoring_points));
268 }
269
263 #else 270 #else
264 RTC_NOTREACHED(); 271 RTC_NOTREACHED();
265 return nullptr; 272 return nullptr;
266 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP 273 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP
267 } 274 }
268 275
269 ControllerManagerImpl::ControllerManagerImpl(const Config& config) 276 ControllerManagerImpl::ControllerManagerImpl(const Config& config)
270 : ControllerManagerImpl( 277 : ControllerManagerImpl(
271 config, 278 config,
272 std::vector<std::unique_ptr<Controller>>(), 279 std::vector<std::unique_ptr<Controller>>(),
(...skipping 14 matching lines...) Expand all
287 controller_scoring_points_.insert(std::make_pair( 294 controller_scoring_points_.insert(std::make_pair(
288 controller_point.first, ScoringPoint(controller_point.second.first, 295 controller_point.first, ScoringPoint(controller_point.second.first,
289 controller_point.second.second))); 296 controller_point.second.second)));
290 } 297 }
291 } 298 }
292 299
293 ControllerManagerImpl::~ControllerManagerImpl() = default; 300 ControllerManagerImpl::~ControllerManagerImpl() = default;
294 301
295 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers( 302 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers(
296 const Controller::NetworkMetrics& metrics) { 303 const Controller::NetworkMetrics& metrics) {
297 int64_t now_ms = rtc::TimeMillis(); 304 if (controller_scoring_points_.size() == 0)
305 return default_sorted_controllers_;
298 306
299 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction) 307 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction)
300 return sorted_controllers_; 308 return sorted_controllers_;
301 309
310 const int64_t now_ms = rtc::TimeMillis();
302 if (last_reordering_time_ms_ && 311 if (last_reordering_time_ms_ &&
303 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms) 312 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms)
304 return sorted_controllers_; 313 return sorted_controllers_;
305 314
306 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps, 315 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps,
307 *metrics.uplink_packet_loss_fraction); 316 *metrics.uplink_packet_loss_fraction);
308 317
309 if (last_reordering_time_ms_ && 318 if (last_reordering_time_ms_ &&
310 last_scoring_point_.SquaredDistanceTo(scoring_point) < 319 last_scoring_point_.SquaredDistanceTo(scoring_point) <
311 config_.min_reordering_squared_distance) 320 config_.min_reordering_squared_distance)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - 390 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) -
382 NormalizeUplinkBandwidth(uplink_bandwidth_bps); 391 NormalizeUplinkBandwidth(uplink_bandwidth_bps);
383 float diff_normalized_packet_loss = 392 float diff_normalized_packet_loss =
384 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - 393 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) -
385 NormalizePacketLossFraction(uplink_packet_loss_fraction); 394 NormalizePacketLossFraction(uplink_packet_loss_fraction);
386 return std::pow(diff_normalized_bitrate_bps, 2) + 395 return std::pow(diff_normalized_bitrate_bps, 2) +
387 std::pow(diff_normalized_packet_loss, 2); 396 std::pow(diff_normalized_packet_loss, 2);
388 } 397 }
389 398
390 } // namespace webrtc 399 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/audio_network_adaptor/controller_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698