quality_rampup_experiment_helper.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2020 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 VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
  11. #define VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
  12. #include <memory>
  13. #include "api/scoped_refptr.h"
  14. #include "api/units/data_rate.h"
  15. #include "rtc_base/experiments/quality_rampup_experiment.h"
  16. #include "system_wrappers/include/clock.h"
  17. #include "video/adaptation/quality_scaler_resource.h"
  18. namespace webrtc {
  19. class QualityRampUpExperimentListener {
  20. public:
  21. virtual ~QualityRampUpExperimentListener() = default;
  22. virtual void OnQualityRampUp() = 0;
  23. };
  24. // Helper class for orchestrating the WebRTC-Video-QualityRampupSettings
  25. // experiment.
  26. class QualityRampUpExperimentHelper {
  27. public:
  28. // Returns a QualityRampUpExperimentHelper if the experiment is enabled,
  29. // an nullptr otherwise.
  30. static std::unique_ptr<QualityRampUpExperimentHelper> CreateIfEnabled(
  31. QualityRampUpExperimentListener* experiment_listener,
  32. Clock* clock);
  33. QualityRampUpExperimentHelper(const QualityRampUpExperimentHelper&) = delete;
  34. QualityRampUpExperimentHelper& operator=(
  35. const QualityRampUpExperimentHelper&) = delete;
  36. void cpu_adapted(bool cpu_adapted);
  37. void qp_resolution_adaptations(int qp_adaptations);
  38. void PerformQualityRampupExperiment(
  39. rtc::scoped_refptr<QualityScalerResource> quality_scaler_resource,
  40. DataRate bandwidth,
  41. DataRate encoder_target_bitrate,
  42. DataRate max_bitrate,
  43. int pixels);
  44. private:
  45. QualityRampUpExperimentHelper(
  46. QualityRampUpExperimentListener* experiment_listener,
  47. Clock* clock,
  48. QualityRampupExperiment experiment);
  49. QualityRampUpExperimentListener* const experiment_listener_;
  50. Clock* clock_;
  51. QualityRampupExperiment quality_rampup_experiment_;
  52. bool cpu_adapted_;
  53. int qp_resolution_adaptations_;
  54. };
  55. } // namespace webrtc
  56. #endif // VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_