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

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

Issue 2643133003: Instantly pass network changes to controllers in audio network adaptor. (Closed)
Patch Set: fixing unittests Created 3 years, 10 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
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 15 matching lines...) Expand all
26 26
27 ChannelController::ChannelController(const Config& config) 27 ChannelController::ChannelController(const Config& config)
28 : config_(config), channels_to_encode_(config_.intial_channels_to_encode) { 28 : config_(config), channels_to_encode_(config_.intial_channels_to_encode) {
29 RTC_DCHECK_GT(config_.intial_channels_to_encode, 0lu); 29 RTC_DCHECK_GT(config_.intial_channels_to_encode, 0lu);
30 // Currently, we require |intial_channels_to_encode| to be <= 2. 30 // Currently, we require |intial_channels_to_encode| to be <= 2.
31 RTC_DCHECK_LE(config_.intial_channels_to_encode, 2lu); 31 RTC_DCHECK_LE(config_.intial_channels_to_encode, 2lu);
32 RTC_DCHECK_GE(config_.num_encoder_channels, 32 RTC_DCHECK_GE(config_.num_encoder_channels,
33 config_.intial_channels_to_encode); 33 config_.intial_channels_to_encode);
34 } 34 }
35 35
36 ChannelController::~ChannelController() = default;
37
38 void ChannelController::UpdateNetworkMetrics(
39 const NetworkMetrics& network_metrics) {
40 if (network_metrics.uplink_bandwidth_bps)
41 uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps;
42 }
43
36 void ChannelController::MakeDecision( 44 void ChannelController::MakeDecision(
37 const NetworkMetrics& metrics,
38 AudioNetworkAdaptor::EncoderRuntimeConfig* config) { 45 AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
39 // Decision on |num_channels| should not have been made. 46 // Decision on |num_channels| should not have been made.
40 RTC_DCHECK(!config->num_channels); 47 RTC_DCHECK(!config->num_channels);
41 48
42 if (metrics.uplink_bandwidth_bps) { 49 if (uplink_bandwidth_bps_) {
43 if (channels_to_encode_ == 2 && 50 if (channels_to_encode_ == 2 &&
44 *metrics.uplink_bandwidth_bps <= config_.channel_2_to_1_bandwidth_bps) { 51 *uplink_bandwidth_bps_ <= config_.channel_2_to_1_bandwidth_bps) {
45 channels_to_encode_ = 1; 52 channels_to_encode_ = 1;
46 } else if (channels_to_encode_ == 1 && 53 } else if (channels_to_encode_ == 1 &&
47 *metrics.uplink_bandwidth_bps >= 54 *uplink_bandwidth_bps_ >= config_.channel_1_to_2_bandwidth_bps) {
48 config_.channel_1_to_2_bandwidth_bps) {
49 channels_to_encode_ = 55 channels_to_encode_ =
50 std::min(static_cast<size_t>(2), config_.num_encoder_channels); 56 std::min(static_cast<size_t>(2), config_.num_encoder_channels);
51 } 57 }
52 } 58 }
53 config->num_channels = rtc::Optional<size_t>(channels_to_encode_); 59 config->num_channels = rtc::Optional<size_t>(channels_to_encode_);
54 } 60 }
55 61
56 } // namespace webrtc 62 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698