Åsa Persson | e644a03 | 2019-11-08 15:56:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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 | |
| 11 | #ifndef RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ |
| 12 | #define RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ |
| 13 | |
| 14 | #include "absl/types/optional.h" |
| 15 | #include "api/transport/webrtc_key_value_config.h" |
| 16 | #include "rtc_base/experiments/field_trial_parser.h" |
| 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class QualityRampupExperiment final { |
| 21 | public: |
| 22 | static QualityRampupExperiment ParseSettings(); |
| 23 | |
| 24 | absl::optional<int> MinPixels() const; |
| 25 | absl::optional<int> MinDurationMs() const; |
| 26 | absl::optional<double> MaxBitrateFactor() const; |
| 27 | |
| 28 | // Sets the max bitrate and the frame size. |
| 29 | // The call has no effect if the frame size is less than |min_pixels_|. |
| 30 | void SetMaxBitrate(int pixels, uint32_t max_bitrate_kbps); |
| 31 | |
| 32 | // Returns true if the available bandwidth is a certain percentage |
| 33 | // (max_bitrate_factor_) above |max_bitrate_kbps_| for |min_duration_ms_|. |
| 34 | bool BwHigh(int64_t now_ms, uint32_t available_bw_kbps); |
| 35 | |
| 36 | private: |
| 37 | explicit QualityRampupExperiment( |
| 38 | const WebRtcKeyValueConfig* const key_value_config); |
| 39 | |
| 40 | FieldTrialOptional<int> min_pixels_; |
| 41 | FieldTrialOptional<int> min_duration_ms_; |
| 42 | FieldTrialOptional<double> max_bitrate_factor_; |
| 43 | |
| 44 | absl::optional<int64_t> start_ms_; |
| 45 | absl::optional<uint32_t> max_bitrate_kbps_; |
| 46 | }; |
| 47 | |
| 48 | } // namespace webrtc |
| 49 | |
| 50 | #endif // RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_ |