Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include <algorithm> | |
| 12 | |
| 13 #include "webrtc/modules/audio_coding/audio_network_adaptor/channel_controller.h " | |
| 14 #include "webrtc/base/checks.h" | |
| 15 | |
| 16 namespace webrtc { | |
| 17 | |
| 18 ChannelController::Config::Config(size_t num_encoder_channels, | |
| 19 size_t intial_channels_to_encode, | |
| 20 int channel_1_to_2_bandwidth_bps, | |
| 21 int channel_2_to_1_bandwidth_bps) | |
| 22 : num_encoder_channels(num_encoder_channels), | |
| 23 intial_channels_to_encode(intial_channels_to_encode), | |
| 24 channel_1_to_2_bandwidth_bps(channel_1_to_2_bandwidth_bps), | |
| 25 channel_2_to_1_bandwidth_bps(channel_2_to_1_bandwidth_bps) { | |
| 26 RTC_DCHECK_GT(intial_channels_to_encode, 0lu); | |
|
hlundin-webrtc
2016/09/08 07:47:44
I think these checks should go in the ChannelContr
minyue-webrtc
2016/09/08 08:37:00
True, good concern.
| |
| 27 RTC_DCHECK_GE(num_encoder_channels, intial_channels_to_encode); | |
| 28 } | |
| 29 | |
| 30 ChannelController::Config::~Config() = default; | |
| 31 | |
| 32 ChannelController::ChannelController(const Config& config) | |
| 33 : config_(config), channels_to_encode_(config.intial_channels_to_encode) {} | |
|
hlundin-webrtc
2016/09/08 07:47:44
You will have to make sure that config.intial_chan
minyue-webrtc
2016/09/08 08:36:59
True, will add DCHECK.
| |
| 34 | |
| 35 void ChannelController::MakeDecision( | |
| 36 const NetworkMetrics& metrics, | |
| 37 AudioNetworkAdaptor::EncoderRuntimeConfig* config) { | |
| 38 // Decision on |num_channels| should not have been made. | |
| 39 RTC_DCHECK(!config->num_channels); | |
| 40 | |
| 41 if (metrics.uplink_bandwidth_bps) { | |
| 42 if (channels_to_encode_ == 2 && | |
| 43 *metrics.uplink_bandwidth_bps <= config_.channel_2_to_1_bandwidth_bps) { | |
| 44 channels_to_encode_ = 1; | |
| 45 } else if (channels_to_encode_ == 1 && | |
| 46 *metrics.uplink_bandwidth_bps >= | |
| 47 config_.channel_1_to_2_bandwidth_bps) { | |
| 48 channels_to_encode_ = std::min(2lu, config_.num_encoder_channels); | |
| 49 } | |
| 50 } | |
| 51 config->num_channels = rtc::Optional<size_t>(channels_to_encode_); | |
| 52 } | |
| 53 | |
| 54 } // namespace webrtc | |
| OLD | NEW |