xref: /aosp_15_r20/external/webrtc/modules/audio_coding/audio_network_adaptor/bitrate_controller.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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_BITRATE_CONTROLLER_H_
12 #define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_BITRATE_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 
20 namespace webrtc {
21 namespace audio_network_adaptor {
22 
23 class BitrateController final : public Controller {
24  public:
25   struct Config {
26     Config(int initial_bitrate_bps,
27            int initial_frame_length_ms,
28            int fl_increase_overhead_offset,
29            int fl_decrease_overhead_offset);
30     ~Config();
31     int initial_bitrate_bps;
32     int initial_frame_length_ms;
33     int fl_increase_overhead_offset;
34     int fl_decrease_overhead_offset;
35   };
36 
37   explicit BitrateController(const Config& config);
38 
39   ~BitrateController() override;
40 
41   BitrateController(const BitrateController&) = delete;
42   BitrateController& operator=(const BitrateController&) = delete;
43 
44   void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override;
45 
46   void MakeDecision(AudioEncoderRuntimeConfig* config) override;
47 
48  private:
49   const Config config_;
50   int bitrate_bps_;
51   int frame_length_ms_;
52   absl::optional<int> target_audio_bitrate_bps_;
53   absl::optional<size_t> overhead_bytes_per_packet_;
54 };
55 
56 }  // namespace audio_network_adaptor
57 }  // namespace webrtc
58 
59 #endif  // MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_BITRATE_CONTROLLER_H_
60