• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CHANNEL_CONTROLLER_H_
12 #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CHANNEL_CONTROLLER_H_
13 
14 #include <stddef.h>
15 
16 #include "absl/types/optional.h"
17 #include "modules/audio_coding/audio_network_adaptor/controller.h"
18 #include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
19 #include "rtc_base/constructor_magic.h"
20 
21 namespace webrtc {
22 
23 class ChannelController final : public Controller {
24  public:
25   struct Config {
26     Config(size_t num_encoder_channels,
27            size_t intial_channels_to_encode,
28            int channel_1_to_2_bandwidth_bps,
29            int channel_2_to_1_bandwidth_bps);
30     size_t num_encoder_channels;
31     size_t intial_channels_to_encode;
32     // Uplink bandwidth above which the number of encoded channels should switch
33     // from 1 to 2.
34     int channel_1_to_2_bandwidth_bps;
35     // Uplink bandwidth below which the number of encoded channels should switch
36     // from 2 to 1.
37     int channel_2_to_1_bandwidth_bps;
38   };
39 
40   explicit ChannelController(const Config& config);
41 
42   ~ChannelController() override;
43 
44   void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
45 
46   void MakeDecision(AudioEncoderRuntimeConfig* config) override;
47 
48  private:
49   const Config config_;
50   size_t channels_to_encode_;
51   absl::optional<int> uplink_bandwidth_bps_;
52   RTC_DISALLOW_COPY_AND_ASSIGN(ChannelController);
53 };
54 
55 }  // namespace webrtc
56 
57 #endif  // MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CHANNEL_CONTROLLER_H_
58