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

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

Issue 2319873002: Adding ChannelController to audio network adaptor. (Closed)
Patch Set: further simplying test Created 4 years, 3 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
(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
27 ChannelController::Config::~Config() = default;
28
29 ChannelController::ChannelController(const Config& config)
30 : config_(config), channels_to_encode_(config_.intial_channels_to_encode) {
minyue-webrtc 2016/09/08 13:22:03 this is a minor change. it is just a style thingy.
31 RTC_DCHECK_GT(config_.intial_channels_to_encode, 0lu);
32 // Currently, we require |intial_channels_to_encode| to be <= 2.
33 RTC_DCHECK_LE(config_.intial_channels_to_encode, 2lu);
34 RTC_DCHECK_GE(config_.num_encoder_channels,
35 config_.intial_channels_to_encode);
36 }
37
38 void ChannelController::MakeDecision(
39 const NetworkMetrics& metrics,
40 AudioNetworkAdaptor::EncoderRuntimeConfig* config) {
41 // Decision on |num_channels| should not have been made.
42 RTC_DCHECK(!config->num_channels);
43
44 if (metrics.uplink_bandwidth_bps) {
45 if (channels_to_encode_ == 2 &&
46 *metrics.uplink_bandwidth_bps <= config_.channel_2_to_1_bandwidth_bps) {
47 channels_to_encode_ = 1;
48 } else if (channels_to_encode_ == 1 &&
49 *metrics.uplink_bandwidth_bps >=
50 config_.channel_1_to_2_bandwidth_bps) {
51 channels_to_encode_ = std::min(static_cast<size_t>(2),
52 config_.num_encoder_channels);
53 }
54 }
55 config->num_channels = rtc::Optional<size_t>(channels_to_encode_);
56 }
57
58 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698