blob: c0999735ee77f8b7e581fafce80c8b30dc1b0844 [file] [log] [blame]
Sebastian Jansson470a5ea2019-01-23 12:37:49 +01001/*
2 * Copyright 2019 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#ifndef RTC_BASE_EXPERIMENTS_AUDIO_ALLOCATION_SETTINGS_H_
11#define RTC_BASE_EXPERIMENTS_AUDIO_ALLOCATION_SETTINGS_H_
12
13#include "rtc_base/experiments/field_trial_parser.h"
14#include "rtc_base/experiments/field_trial_units.h"
15namespace webrtc {
16// This class encapsulates the logic that controls how allocation of audio
17// bitrate is done. This is primarily based on field trials, but also on the
18// values of audio parameters.
19class AudioAllocationSettings {
20 public:
21 AudioAllocationSettings();
22 ~AudioAllocationSettings();
23 // Returns true if audio feedback should be force disabled.
24 bool ForceNoAudioFeedback() const;
25 // Returns true if changes in transport sequence number id should be ignored
26 // as a trigger for reconfiguration.
27 bool IgnoreSeqNumIdChange() const;
28 // Returns true if the bitrate allocation range should be configured.
29 bool ConfigureRateAllocationRange() const;
Per Kjellander914351d2019-02-15 10:54:55 +010030 // Returns true if sent audio packets should have transport wide sequence
31 // numbers.
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010032 // |transport_seq_num_extension_header_id| the extension header id for
33 // transport sequence numbers. Set to 0 if not the extension is not
34 // configured.
Per Kjellander914351d2019-02-15 10:54:55 +010035 bool ShouldSendTransportSequenceNumber(
36 int transport_seq_num_extension_header_id) const;
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010037 // Returns true if audio should be added to rate allocation when the audio
38 // stream is started.
39 // |min_bitrate_bps| the configured min bitrate, set to -1 if unset.
40 // |max_bitrate_bps| the configured max bitrate, set to -1 if unset.
41 // |has_dscp| true is dscp is enabled.
42 // |transport_seq_num_extension_header_id| the extension header id for
43 // transport sequence numbers. Set to 0 if not the extension is not
44 // configured.
45 bool IncludeAudioInAllocationOnStart(
46 int min_bitrate_bps,
47 int max_bitrate_bps,
48 bool has_dscp,
49 int transport_seq_num_extension_header_id) const;
50 // Returns true if audio should be added to rate allocation when the audio
51 // stream is reconfigured.
52 // |min_bitrate_bps| the configured min bitrate, set to -1 if unset.
53 // |max_bitrate_bps| the configured max bitrate, set to -1 if unset.
54 // |has_dscp| true is dscp is enabled.
55 // |transport_seq_num_extension_header_id| the extension header id for
56 // transport sequence numbers. Set to 0 if not the extension is not
57 // configured.
58 bool IncludeAudioInAllocationOnReconfigure(
59 int min_bitrate_bps,
60 int max_bitrate_bps,
61 bool has_dscp,
62 int transport_seq_num_extension_header_id) const;
Daniel Lee93562522019-05-03 14:40:13 +020063 // Returns true if we should include packet overhead in audio allocation.
64 bool IncludeOverheadInAudioAllocation() const;
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010065
Daniel Lee93562522019-05-03 14:40:13 +020066 // Returns the min bitrate for audio rate allocation.
67 absl::optional<DataRate> MinBitrate() const;
68 // Returns the max bitrate for audio rate allocation.
69 absl::optional<DataRate> MaxBitrate() const;
Sebastian Jansson464a5572019-02-12 13:32:32 +010070 // Indicates the default priority bitrate for audio streams. The bitrate
71 // allocator will prioritize audio until it reaches this bitrate and will
72 // divide bitrate evently between audio and video above this bitrate.
73 DataRate DefaultPriorityBitrate() const;
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010074
75 private:
76 FieldTrialFlag audio_send_side_bwe_;
77 FieldTrialFlag allocate_audio_without_feedback_;
78 FieldTrialFlag force_no_audio_feedback_;
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010079 FieldTrialFlag send_side_bwe_with_overhead_;
80 int min_overhead_bps_ = 0;
Daniel Lee93562522019-05-03 14:40:13 +020081 // Field Trial configured bitrates to use as overrides over default/user
82 // configured bitrate range when audio bitrate allocation is enabled.
83 FieldTrialOptional<DataRate> min_bitrate_;
84 FieldTrialOptional<DataRate> max_bitrate_;
Sebastian Jansson464a5572019-02-12 13:32:32 +010085 FieldTrialParameter<DataRate> priority_bitrate_;
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010086};
87} // namespace webrtc
88
89#endif // RTC_BASE_EXPERIMENTS_AUDIO_ALLOCATION_SETTINGS_H_