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

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

Issue 2907153004: Cosmetic change in ANA: renaming characteristic points for consistency. (Closed)
Patch Set: 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 | « webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h ('k') | no next file » | 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 size_t intial_channels_to_encode, 199 size_t intial_channels_to_encode,
200 int initial_frame_length_ms, 200 int initial_frame_length_ms,
201 int initial_bitrate_bps, 201 int initial_bitrate_bps,
202 bool initial_fec_enabled, 202 bool initial_fec_enabled,
203 bool initial_dtx_enabled) { 203 bool initial_dtx_enabled) {
204 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP 204 #ifdef WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP
205 audio_network_adaptor::config::ControllerManager controller_manager_config; 205 audio_network_adaptor::config::ControllerManager controller_manager_config;
206 controller_manager_config.ParseFromString(config_string); 206 controller_manager_config.ParseFromString(config_string);
207 207
208 std::vector<std::unique_ptr<Controller>> controllers; 208 std::vector<std::unique_ptr<Controller>> controllers;
209 std::map<const Controller*, std::pair<int, float>> chracteristic_points; 209 std::map<const Controller*, std::pair<int, float>> scoring_points;
210 210
211 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) { 211 for (int i = 0; i < controller_manager_config.controllers_size(); ++i) {
212 auto& controller_config = controller_manager_config.controllers(i); 212 auto& controller_config = controller_manager_config.controllers(i);
213 std::unique_ptr<Controller> controller; 213 std::unique_ptr<Controller> controller;
214 switch (controller_config.controller_case()) { 214 switch (controller_config.controller_case()) {
215 case audio_network_adaptor::config::Controller::kFecController: 215 case audio_network_adaptor::config::Controller::kFecController:
216 controller = CreateFecControllerPlrBased( 216 controller = CreateFecControllerPlrBased(
217 controller_config.fec_controller(), initial_fec_enabled); 217 controller_config.fec_controller(), initial_fec_enabled);
218 break; 218 break;
219 case audio_network_adaptor::config::Controller::kFecControllerRplrBased: 219 case audio_network_adaptor::config::Controller::kFecControllerRplrBased:
(...skipping 16 matching lines...) Expand all
236 initial_dtx_enabled); 236 initial_dtx_enabled);
237 break; 237 break;
238 case audio_network_adaptor::config::Controller::kBitrateController: 238 case audio_network_adaptor::config::Controller::kBitrateController:
239 controller = CreateBitrateController(initial_bitrate_bps, 239 controller = CreateBitrateController(initial_bitrate_bps,
240 initial_frame_length_ms); 240 initial_frame_length_ms);
241 break; 241 break;
242 default: 242 default:
243 RTC_NOTREACHED(); 243 RTC_NOTREACHED();
244 } 244 }
245 if (controller_config.has_scoring_point()) { 245 if (controller_config.has_scoring_point()) {
246 auto& characteristic_point = controller_config.scoring_point(); 246 auto& scoring_point = controller_config.scoring_point();
247 RTC_CHECK(characteristic_point.has_uplink_bandwidth_bps()); 247 RTC_CHECK(scoring_point.has_uplink_bandwidth_bps());
248 RTC_CHECK(characteristic_point.has_uplink_packet_loss_fraction()); 248 RTC_CHECK(scoring_point.has_uplink_packet_loss_fraction());
249 chracteristic_points[controller.get()] = std::make_pair<int, float>( 249 scoring_points[controller.get()] = std::make_pair<int, float>(
250 characteristic_point.uplink_bandwidth_bps(), 250 scoring_point.uplink_bandwidth_bps(),
251 characteristic_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 RTC_CHECK(controller_manager_config.has_min_reordering_time_ms());
257 RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance()); 257 RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance());
258 return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl( 258 return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl(
259 ControllerManagerImpl::Config( 259 ControllerManagerImpl::Config(
260 controller_manager_config.min_reordering_time_ms(), 260 controller_manager_config.min_reordering_time_ms(),
261 controller_manager_config.min_reordering_squared_distance()), 261 controller_manager_config.min_reordering_squared_distance()),
262 std::move(controllers), chracteristic_points)); 262 std::move(controllers), scoring_points));
263 #else 263 #else
264 RTC_NOTREACHED(); 264 RTC_NOTREACHED();
265 return nullptr; 265 return nullptr;
266 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP 266 #endif // WEBRTC_AUDIO_NETWORK_ADAPTOR_DEBUG_DUMP
267 } 267 }
268 268
269 ControllerManagerImpl::ControllerManagerImpl(const Config& config) 269 ControllerManagerImpl::ControllerManagerImpl(const Config& config)
270 : ControllerManagerImpl( 270 : ControllerManagerImpl(
271 config, 271 config,
272 std::vector<std::unique_ptr<Controller>>(), 272 std::vector<std::unique_ptr<Controller>>(),
273 std::map<const Controller*, std::pair<int, float>>()) {} 273 std::map<const Controller*, std::pair<int, float>>()) {}
274 274
275 ControllerManagerImpl::ControllerManagerImpl( 275 ControllerManagerImpl::ControllerManagerImpl(
276 const Config& config, 276 const Config& config,
277 std::vector<std::unique_ptr<Controller>>&& controllers, 277 std::vector<std::unique_ptr<Controller>>&& controllers,
278 const std::map<const Controller*, std::pair<int, float>>& 278 const std::map<const Controller*, std::pair<int, float>>& scoring_points)
279 chracteristic_points)
280 : config_(config), 279 : config_(config),
281 controllers_(std::move(controllers)), 280 controllers_(std::move(controllers)),
282 last_reordering_time_ms_(rtc::Optional<int64_t>()), 281 last_reordering_time_ms_(rtc::Optional<int64_t>()),
283 last_scoring_point_(0, 0.0) { 282 last_scoring_point_(0, 0.0) {
284 for (auto& controller : controllers_) 283 for (auto& controller : controllers_)
285 default_sorted_controllers_.push_back(controller.get()); 284 default_sorted_controllers_.push_back(controller.get());
286 sorted_controllers_ = default_sorted_controllers_; 285 sorted_controllers_ = default_sorted_controllers_;
287 for (auto& controller_point : chracteristic_points) { 286 for (auto& controller_point : scoring_points) {
288 controller_scoring_points_.insert(std::make_pair( 287 controller_scoring_points_.insert(std::make_pair(
289 controller_point.first, ScoringPoint(controller_point.second.first, 288 controller_point.first, ScoringPoint(controller_point.second.first,
290 controller_point.second.second))); 289 controller_point.second.second)));
291 } 290 }
292 } 291 }
293 292
294 ControllerManagerImpl::~ControllerManagerImpl() = default; 293 ControllerManagerImpl::~ControllerManagerImpl() = default;
295 294
296 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers( 295 std::vector<Controller*> ControllerManagerImpl::GetSortedControllers(
297 const Controller::NetworkMetrics& metrics) { 296 const Controller::NetworkMetrics& metrics) {
298 int64_t now_ms = rtc::TimeMillis(); 297 int64_t now_ms = rtc::TimeMillis();
299 298
300 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction) 299 if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction)
301 return sorted_controllers_; 300 return sorted_controllers_;
302 301
303 if (last_reordering_time_ms_ && 302 if (last_reordering_time_ms_ &&
304 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms) 303 now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms)
305 return sorted_controllers_; 304 return sorted_controllers_;
306 305
307 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps, 306 ScoringPoint scoring_point(*metrics.uplink_bandwidth_bps,
308 *metrics.uplink_packet_loss_fraction); 307 *metrics.uplink_packet_loss_fraction);
309 308
310 if (last_reordering_time_ms_ && 309 if (last_reordering_time_ms_ &&
311 last_scoring_point_.SquaredDistanceTo(scoring_point) < 310 last_scoring_point_.SquaredDistanceTo(scoring_point) <
312 config_.min_reordering_squared_distance) 311 config_.min_reordering_squared_distance)
313 return sorted_controllers_; 312 return sorted_controllers_;
314 313
315 // Sort controllers according to the distances of |scoring_point| to the 314 // Sort controllers according to the distances of |scoring_point| to the
316 // characteristic scoring points of controllers. 315 // scoring points of controllers.
317 // 316 //
318 // A controller that does not associate with any scoring point 317 // A controller that does not associate with any scoring point
319 // are treated as if 318 // are treated as if
320 // 1) they are less important than any controller that has a scoring point, 319 // 1) they are less important than any controller that has a scoring point,
321 // 2) they are equally important to any controller that has no scoring point, 320 // 2) they are equally important to any controller that has no scoring point,
322 // and their relative order will follow |default_sorted_controllers_|. 321 // and their relative order will follow |default_sorted_controllers_|.
323 std::vector<Controller*> sorted_controllers(default_sorted_controllers_); 322 std::vector<Controller*> sorted_controllers(default_sorted_controllers_);
324 std::stable_sort( 323 std::stable_sort(
325 sorted_controllers.begin(), sorted_controllers.end(), 324 sorted_controllers.begin(), sorted_controllers.end(),
326 [this, &scoring_point](const Controller* lhs, const Controller* rhs) { 325 [this, &scoring_point](const Controller* lhs, const Controller* rhs) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) - 381 NormalizeUplinkBandwidth(scoring_point.uplink_bandwidth_bps) -
383 NormalizeUplinkBandwidth(uplink_bandwidth_bps); 382 NormalizeUplinkBandwidth(uplink_bandwidth_bps);
384 float diff_normalized_packet_loss = 383 float diff_normalized_packet_loss =
385 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) - 384 NormalizePacketLossFraction(scoring_point.uplink_packet_loss_fraction) -
386 NormalizePacketLossFraction(uplink_packet_loss_fraction); 385 NormalizePacketLossFraction(uplink_packet_loss_fraction);
387 return std::pow(diff_normalized_bitrate_bps, 2) + 386 return std::pow(diff_normalized_bitrate_bps, 2) +
388 std::pow(diff_normalized_packet_loss, 2); 387 std::pow(diff_normalized_packet_loss, 2);
389 } 388 }
390 389
391 } // namespace webrtc 390 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698