Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 1 | /* |
| 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" |
| 15 | namespace 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. |
| 19 | class 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 Kjellander | 914351d | 2019-02-15 10:54:55 +0100 | [diff] [blame] | 30 | // Returns true if sent audio packets should have transport wide sequence |
| 31 | // numbers. |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 32 | // |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 Kjellander | 914351d | 2019-02-15 10:54:55 +0100 | [diff] [blame] | 35 | bool ShouldSendTransportSequenceNumber( |
| 36 | int transport_seq_num_extension_header_id) const; |
Christoffer Rodbro | a352248 | 2019-05-23 12:12:48 +0200 | [diff] [blame] | 37 | // Returns true if audio should request ALR probing from network controller. |
| 38 | bool RequestAlrProbing() const; |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 39 | // Returns true if audio should be added to rate allocation when the audio |
| 40 | // stream is started. |
| 41 | // |min_bitrate_bps| the configured min bitrate, set to -1 if unset. |
| 42 | // |max_bitrate_bps| the configured max bitrate, set to -1 if unset. |
| 43 | // |has_dscp| true is dscp is enabled. |
| 44 | // |transport_seq_num_extension_header_id| the extension header id for |
| 45 | // transport sequence numbers. Set to 0 if not the extension is not |
| 46 | // configured. |
| 47 | bool IncludeAudioInAllocationOnStart( |
| 48 | int min_bitrate_bps, |
| 49 | int max_bitrate_bps, |
| 50 | bool has_dscp, |
| 51 | int transport_seq_num_extension_header_id) const; |
| 52 | // Returns true if audio should be added to rate allocation when the audio |
| 53 | // stream is reconfigured. |
| 54 | // |min_bitrate_bps| the configured min bitrate, set to -1 if unset. |
| 55 | // |max_bitrate_bps| the configured max bitrate, set to -1 if unset. |
| 56 | // |has_dscp| true is dscp is enabled. |
| 57 | // |transport_seq_num_extension_header_id| the extension header id for |
| 58 | // transport sequence numbers. Set to 0 if not the extension is not |
| 59 | // configured. |
| 60 | bool IncludeAudioInAllocationOnReconfigure( |
| 61 | int min_bitrate_bps, |
| 62 | int max_bitrate_bps, |
| 63 | bool has_dscp, |
| 64 | int transport_seq_num_extension_header_id) const; |
Daniel Lee | 9356252 | 2019-05-03 14:40:13 +0200 | [diff] [blame] | 65 | // Returns true if we should include packet overhead in audio allocation. |
| 66 | bool IncludeOverheadInAudioAllocation() const; |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 67 | |
Daniel Lee | 9356252 | 2019-05-03 14:40:13 +0200 | [diff] [blame] | 68 | // Returns the min bitrate for audio rate allocation. |
| 69 | absl::optional<DataRate> MinBitrate() const; |
| 70 | // Returns the max bitrate for audio rate allocation. |
| 71 | absl::optional<DataRate> MaxBitrate() const; |
Sebastian Jansson | 464a557 | 2019-02-12 13:32:32 +0100 | [diff] [blame] | 72 | // Indicates the default priority bitrate for audio streams. The bitrate |
| 73 | // allocator will prioritize audio until it reaches this bitrate and will |
| 74 | // divide bitrate evently between audio and video above this bitrate. |
| 75 | DataRate DefaultPriorityBitrate() const; |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 76 | |
Jonas Olsson | 8f119ca | 2019-05-08 10:56:23 +0200 | [diff] [blame] | 77 | // The bitrate priority is used to determine how much of the available bitrate |
| 78 | // beyond the min or priority bitrate audio streams should receive. |
| 79 | absl::optional<double> BitratePriority() const; |
| 80 | |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 81 | private: |
Sebastian Jansson | d9b4f33 | 2019-05-23 16:39:42 +0200 | [diff] [blame^] | 82 | const bool audio_send_side_bwe_; |
| 83 | const bool allocate_audio_without_feedback_; |
| 84 | const bool force_no_audio_feedback_; |
| 85 | const bool enable_audio_alr_probing_; |
| 86 | const bool send_side_bwe_with_overhead_; |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 87 | int min_overhead_bps_ = 0; |
Daniel Lee | 9356252 | 2019-05-03 14:40:13 +0200 | [diff] [blame] | 88 | // Field Trial configured bitrates to use as overrides over default/user |
| 89 | // configured bitrate range when audio bitrate allocation is enabled. |
| 90 | FieldTrialOptional<DataRate> min_bitrate_; |
| 91 | FieldTrialOptional<DataRate> max_bitrate_; |
Sebastian Jansson | 464a557 | 2019-02-12 13:32:32 +0100 | [diff] [blame] | 92 | FieldTrialParameter<DataRate> priority_bitrate_; |
Jonas Olsson | 8f119ca | 2019-05-08 10:56:23 +0200 | [diff] [blame] | 93 | FieldTrialOptional<double> bitrate_priority_; |
Sebastian Jansson | 470a5ea | 2019-01-23 12:37:49 +0100 | [diff] [blame] | 94 | }; |
| 95 | } // namespace webrtc |
| 96 | |
| 97 | #endif // RTC_BASE_EXPERIMENTS_AUDIO_ALLOCATION_SETTINGS_H_ |