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