aboutsummaryrefslogtreecommitdiff
path: root/video/adaptation/quality_rampup_experiment_helper.h
blob: 81be982e7c7cd2c5d34aa0d018692d8aa47893ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 *  Copyright 2020 The WebRTC Project Authors. All rights reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
#define VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_

#include <memory>

#include "api/scoped_refptr.h"
#include "api/units/data_rate.h"
#include "rtc_base/experiments/quality_rampup_experiment.h"
#include "system_wrappers/include/clock.h"
#include "video/adaptation/quality_scaler_resource.h"

namespace webrtc {

class QualityRampUpExperimentListener {
 public:
  virtual ~QualityRampUpExperimentListener() = default;
  virtual void OnQualityRampUp() = 0;
};

// Helper class for orchestrating the WebRTC-Video-QualityRampupSettings
// experiment.
class QualityRampUpExperimentHelper {
 public:
  // Returns a QualityRampUpExperimentHelper if the experiment is enabled,
  // an nullptr otherwise.
  static std::unique_ptr<QualityRampUpExperimentHelper> CreateIfEnabled(
      QualityRampUpExperimentListener* experiment_listener,
      Clock* clock);

  QualityRampUpExperimentHelper(const QualityRampUpExperimentHelper&) = delete;
  QualityRampUpExperimentHelper& operator=(
      const QualityRampUpExperimentHelper&) = delete;

  void cpu_adapted(bool cpu_adapted);
  void qp_resolution_adaptations(int qp_adaptations);

  void PerformQualityRampupExperiment(
      rtc::scoped_refptr<QualityScalerResource> quality_scaler_resource,
      DataRate bandwidth,
      DataRate encoder_target_bitrate,
      DataRate max_bitrate,
      int pixels);

 private:
  QualityRampUpExperimentHelper(
      QualityRampUpExperimentListener* experiment_listener,
      Clock* clock,
      QualityRampupExperiment experiment);
  QualityRampUpExperimentListener* const experiment_listener_;
  Clock* clock_;
  QualityRampupExperiment quality_rampup_experiment_;
  bool cpu_adapted_;
  int qp_resolution_adaptations_;
};

}  // namespace webrtc

#endif  // VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_