blob: beb577c1be20e20a96fbfa19cc0f1ba324991ae2 [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
Yves Gerey3e707812018-11-28 16:47:49 +010012#include <stdio.h>
“Michaelf9fc1712018-08-27 10:08:58 -050013#include <algorithm>
14#include <string>
15
16#include "rtc_base/logging.h"
17#include "system_wrappers/include/field_trial.h"
18
19namespace webrtc {
20
21namespace {
22const char kRttMultExperiment[] = "WebRTC-RttMult";
23const float max_rtt_mult_setting = 1.0;
24const float min_rtt_mult_setting = 0.0;
25} // namespace
26
27bool RttMultExperiment::RttMultEnabled() {
28 return field_trial::IsEnabled(kRttMultExperiment);
29}
30
31float 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