Åsa Persson | f8ba95e | 2018-11-02 11:38:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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_CPU_SPEED_EXPERIMENT_H_ |
| 12 | #define RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_ |
| 13 | |
| 14 | #include <vector> |
| 15 | |
| 16 | #include "absl/types/optional.h" |
| 17 | |
| 18 | namespace webrtc { |
| 19 | |
| 20 | class CpuSpeedExperiment { |
| 21 | public: |
| 22 | struct Config { |
| 23 | bool operator==(const Config& o) const { |
| 24 | return pixels == o.pixels && cpu_speed == o.cpu_speed; |
| 25 | } |
| 26 | |
| 27 | int pixels; // The video frame size. |
| 28 | int cpu_speed; // The |cpu_speed| to be used if the frame size is less |
| 29 | // than or equal to |pixels|. |
| 30 | }; |
| 31 | |
| 32 | // Returns the configurations from field trial on success. |
| 33 | static absl::optional<std::vector<Config>> GetConfigs(); |
| 34 | |
| 35 | // Gets the cpu speed from the |configs| based on |pixels|. |
| 36 | static int GetValue(int pixels, const std::vector<Config>& configs); |
| 37 | }; |
| 38 | |
| 39 | } // namespace webrtc |
| 40 | |
| 41 | #endif // RTC_BASE_EXPERIMENTS_CPU_SPEED_EXPERIMENT_H_ |