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