Erik Språng | b1e031a | 2018-11-01 11:20:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 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 | #include "rtc_base/experiments/jitter_upper_bound_experiment.h" |
| 12 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 13 | #include <stdio.h> |
Erik Språng | b1e031a | 2018-11-01 11:20:49 +0100 | [diff] [blame] | 14 | #include <string> |
| 15 | |
| 16 | #include "rtc_base/logging.h" |
| 17 | #include "system_wrappers/include/field_trial.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | const char JitterUpperBoundExperiment::kJitterUpperBoundExperimentName[] = |
| 22 | "WebRTC-JitterUpperBound"; |
| 23 | |
| 24 | absl::optional<double> JitterUpperBoundExperiment::GetUpperBoundSigmas() { |
| 25 | if (!field_trial::IsEnabled(kJitterUpperBoundExperimentName)) { |
| 26 | return absl::nullopt; |
| 27 | } |
| 28 | const std::string group = |
| 29 | webrtc::field_trial::FindFullName(kJitterUpperBoundExperimentName); |
| 30 | |
| 31 | double upper_bound_sigmas; |
| 32 | if (sscanf(group.c_str(), "Enabled-%lf", &upper_bound_sigmas) != 1) { |
| 33 | RTC_LOG(LS_WARNING) << "Invalid number of parameters provided."; |
| 34 | return absl::nullopt; |
| 35 | } |
| 36 | |
| 37 | if (upper_bound_sigmas < 0) { |
| 38 | RTC_LOG(LS_WARNING) << "Invalid jitter upper bound sigmas, must be >= 0.0: " |
| 39 | << upper_bound_sigmas; |
| 40 | return absl::nullopt; |
| 41 | } |
| 42 | |
| 43 | return upper_bound_sigmas; |
| 44 | } |
| 45 | |
| 46 | } // namespace webrtc |