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; |
| 30 | // Returns true if the transport sequence number extension should be enabled. |
| 31 | bool EnableTransportSequenceNumberExtension() const; |
| 32 | // Returns true if audio traffic should be included in transport wide feedback |
| 33 | // packets. |
| 34 | // |transport_seq_num_extension_header_id| the extension header id for |
| 35 | // transport sequence numbers. Set to 0 if not the extension is not |
| 36 | // configured. |
| 37 | bool IncludeAudioInFeedback(int transport_seq_num_extension_header_id) const; |
| 38 | // Returns true if target bitrate for audio streams should be updated. |
| 39 | // |transport_seq_num_extension_header_id| the extension header id for |
| 40 | // transport sequence numbers. Set to 0 if not the extension is not |
| 41 | // configured. |
| 42 | bool UpdateAudioTargetBitrate( |
| 43 | int transport_seq_num_extension_header_id) const; |
| 44 | // Returns true if audio should be added to rate allocation when the audio |
| 45 | // stream is started. |
| 46 | // |min_bitrate_bps| the configured min bitrate, set to -1 if unset. |
| 47 | // |max_bitrate_bps| the configured max bitrate, set to -1 if unset. |
| 48 | // |has_dscp| true is dscp is enabled. |
| 49 | // |transport_seq_num_extension_header_id| the extension header id for |
| 50 | // transport sequence numbers. Set to 0 if not the extension is not |
| 51 | // configured. |
| 52 | bool IncludeAudioInAllocationOnStart( |
| 53 | int min_bitrate_bps, |
| 54 | int max_bitrate_bps, |
| 55 | bool has_dscp, |
| 56 | int transport_seq_num_extension_header_id) const; |
| 57 | // Returns true if audio should be added to rate allocation when the audio |
| 58 | // stream is reconfigured. |
| 59 | // |min_bitrate_bps| the configured min bitrate, set to -1 if unset. |
| 60 | // |max_bitrate_bps| the configured max bitrate, set to -1 if unset. |
| 61 | // |has_dscp| true is dscp is enabled. |
| 62 | // |transport_seq_num_extension_header_id| the extension header id for |
| 63 | // transport sequence numbers. Set to 0 if not the extension is not |
| 64 | // configured. |
| 65 | bool IncludeAudioInAllocationOnReconfigure( |
| 66 | int min_bitrate_bps, |
| 67 | int max_bitrate_bps, |
| 68 | bool has_dscp, |
| 69 | int transport_seq_num_extension_header_id) const; |
| 70 | |
| 71 | // Returns the min bitrate for audio rate allocation, potentially including |
| 72 | // overhead. |
| 73 | int MinBitrateBps() const; |
| 74 | // Returns the max bitrate for audio rate allocation, potentially including |
| 75 | // overhead. |rtp_parameter_max_bitrate_bps| max bitrate as configured in rtp |
| 76 | // parameters, excluding overhead. |
| 77 | int MaxBitrateBps(absl::optional<int> rtp_parameter_max_bitrate_bps) const; |
| 78 | |
| 79 | private: |
| 80 | FieldTrialFlag audio_send_side_bwe_; |
| 81 | FieldTrialFlag allocate_audio_without_feedback_; |
| 82 | FieldTrialFlag force_no_audio_feedback_; |
| 83 | FieldTrialFlag audio_feedback_to_improve_video_bwe_; |
| 84 | FieldTrialFlag send_side_bwe_with_overhead_; |
| 85 | int min_overhead_bps_ = 0; |
| 86 | }; |
| 87 | } // namespace webrtc |
| 88 | |
| 89 | #endif // RTC_BASE_EXPERIMENTS_AUDIO_ALLOCATION_SETTINGS_H_ |