quality_rampup_experiment.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_
  11. #define RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_
  12. #include "absl/types/optional.h"
  13. #include "api/transport/webrtc_key_value_config.h"
  14. #include "rtc_base/experiments/field_trial_parser.h"
  15. namespace webrtc {
  16. class QualityRampupExperiment final {
  17. public:
  18. static QualityRampupExperiment ParseSettings();
  19. absl::optional<int> MinPixels() const;
  20. absl::optional<int> MinDurationMs() const;
  21. absl::optional<double> MaxBitrateFactor() const;
  22. // Sets the max bitrate and the frame size.
  23. // The call has no effect if the frame size is less than |min_pixels_|.
  24. void SetMaxBitrate(int pixels, uint32_t max_bitrate_kbps);
  25. // Returns true if the available bandwidth is a certain percentage
  26. // (max_bitrate_factor_) above |max_bitrate_kbps_| for |min_duration_ms_|.
  27. bool BwHigh(int64_t now_ms, uint32_t available_bw_kbps);
  28. bool Enabled() const;
  29. private:
  30. explicit QualityRampupExperiment(
  31. const WebRtcKeyValueConfig* const key_value_config);
  32. FieldTrialOptional<int> min_pixels_;
  33. FieldTrialOptional<int> min_duration_ms_;
  34. FieldTrialOptional<double> max_bitrate_factor_;
  35. absl::optional<int64_t> start_ms_;
  36. absl::optional<uint32_t> max_bitrate_kbps_;
  37. };
  38. } // namespace webrtc
  39. #endif // RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_