“Michael | f9fc171 | 2018-08-27 10:08:58 -0500 | [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 | #include "rtc_base/experiments/rtt_mult_experiment.h" |
| 11 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 12 | #include <stdio.h> |
“Michael | f9fc171 | 2018-08-27 10:08:58 -0500 | [diff] [blame] | 13 | #include <algorithm> |
| 14 | #include <string> |
| 15 | |
| 16 | #include "rtc_base/logging.h" |
| 17 | #include "system_wrappers/include/field_trial.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | namespace { |
| 22 | const char kRttMultExperiment[] = "WebRTC-RttMult"; |
| 23 | const float max_rtt_mult_setting = 1.0; |
| 24 | const float min_rtt_mult_setting = 0.0; |
| 25 | } // namespace |
| 26 | |
| 27 | bool RttMultExperiment::RttMultEnabled() { |
| 28 | return field_trial::IsEnabled(kRttMultExperiment); |
| 29 | } |
| 30 | |
| 31 | float RttMultExperiment::GetRttMultValue() { |
| 32 | const std::string group = |
| 33 | webrtc::field_trial::FindFullName(kRttMultExperiment); |
| 34 | if (group.empty()) { |
| 35 | RTC_LOG(LS_WARNING) << "Could not find rtt_mult_experiment."; |
| 36 | return 0.0; |
| 37 | } |
| 38 | |
| 39 | float rtt_mult_setting; |
| 40 | if (sscanf(group.c_str(), "Enabled-%f", &rtt_mult_setting) != 1) { |
| 41 | RTC_LOG(LS_WARNING) << "Invalid number of parameters provided."; |
| 42 | return 0.0; |
| 43 | } |
| 44 | // Bounds check rtt_mult_setting value. |
| 45 | rtt_mult_setting = std::min(rtt_mult_setting, max_rtt_mult_setting); |
| 46 | rtt_mult_setting = std::max(rtt_mult_setting, min_rtt_mult_setting); |
| 47 | return rtt_mult_setting; |
| 48 | } |
| 49 | |
| 50 | } // namespace webrtc |