OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
24 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
25 #include "webrtc/system_wrappers/include/field_trial.h" | 25 #include "webrtc/system_wrappers/include/field_trial.h" |
26 #include "webrtc/system_wrappers/include/trace.h" | 26 #include "webrtc/system_wrappers/include/trace.h" |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 const char kAdaptiveThresholdExperiment[] = "WebRTC-AdaptiveBweThreshold"; | 30 const char kAdaptiveThresholdExperiment[] = "WebRTC-AdaptiveBweThreshold"; |
31 const char kEnabledPrefix[] = "Enabled"; | 31 const char kEnabledPrefix[] = "Enabled"; |
32 const size_t kEnabledPrefixLength = sizeof(kEnabledPrefix) - 1; | 32 const size_t kEnabledPrefixLength = sizeof(kEnabledPrefix) - 1; |
33 const size_t kMinExperimentLength = kEnabledPrefixLength + 3; | 33 const char kDisabledPrefix[] = "Disabled"; |
| 34 const size_t kDisabledPrefixLength = sizeof(kDisabledPrefix) - 1; |
34 | 35 |
35 const double kMaxAdaptOffsetMs = 15.0; | 36 const double kMaxAdaptOffsetMs = 15.0; |
36 const double kOverUsingTimeThreshold = 10; | 37 const double kOverUsingTimeThreshold = 10; |
37 | 38 |
38 bool AdaptiveThresholdExperimentIsEnabled() { | 39 bool AdaptiveThresholdExperimentIsDisabled() { |
39 std::string experiment_string = | 40 std::string experiment_string = |
40 webrtc::field_trial::FindFullName(kAdaptiveThresholdExperiment); | 41 webrtc::field_trial::FindFullName(kAdaptiveThresholdExperiment); |
| 42 const size_t kMinExperimentLength = kDisabledPrefixLength; |
41 if (experiment_string.length() < kMinExperimentLength) | 43 if (experiment_string.length() < kMinExperimentLength) |
42 return false; | 44 return false; |
43 return experiment_string.substr(0, kEnabledPrefixLength) == kEnabledPrefix; | 45 return experiment_string.substr(0, kDisabledPrefixLength) == kDisabledPrefix; |
44 } | 46 } |
45 | 47 |
46 // Gets thresholds from the experiment name following the format | 48 // Gets thresholds from the experiment name following the format |
47 // "WebRTC-AdaptiveBweThreshold/Enabled-0.5,0.002/". | 49 // "WebRTC-AdaptiveBweThreshold/Enabled-0.5,0.002/". |
48 bool ReadExperimentConstants(double* k_up, double* k_down) { | 50 bool ReadExperimentConstants(double* k_up, double* k_down) { |
49 std::string experiment_string = | 51 std::string experiment_string = |
50 webrtc::field_trial::FindFullName(kAdaptiveThresholdExperiment); | 52 webrtc::field_trial::FindFullName(kAdaptiveThresholdExperiment); |
| 53 const size_t kMinExperimentLength = kEnabledPrefixLength + 3; |
| 54 if (experiment_string.length() < kMinExperimentLength || |
| 55 experiment_string.substr(0, kEnabledPrefixLength) != kEnabledPrefix) |
| 56 return false; |
51 return sscanf(experiment_string.substr(kEnabledPrefixLength + 1).c_str(), | 57 return sscanf(experiment_string.substr(kEnabledPrefixLength + 1).c_str(), |
52 "%lf,%lf", k_up, k_down) == 2; | 58 "%lf,%lf", k_up, k_down) == 2; |
53 } | 59 } |
54 | 60 |
55 OveruseDetector::OveruseDetector(const OverUseDetectorOptions& options) | 61 OveruseDetector::OveruseDetector(const OverUseDetectorOptions& options) |
56 : in_experiment_(AdaptiveThresholdExperimentIsEnabled()), | 62 // Experiment is on by default, but can be disabled with finch by setting |
57 k_up_(0.01), | 63 // the field trial string to "WebRTC-AdaptiveBweThreshold/Disabled/". |
58 k_down_(0.00018), | 64 : in_experiment_(!AdaptiveThresholdExperimentIsDisabled()), |
| 65 k_up_(0.004), |
| 66 k_down_(0.00006), |
59 overusing_time_threshold_(100), | 67 overusing_time_threshold_(100), |
60 options_(options), | 68 options_(options), |
61 threshold_(12.5), | 69 threshold_(12.5), |
62 last_update_ms_(-1), | 70 last_update_ms_(-1), |
63 prev_offset_(0.0), | 71 prev_offset_(0.0), |
64 time_over_using_(-1), | 72 time_over_using_(-1), |
65 overuse_counter_(0), | 73 overuse_counter_(0), |
66 hypothesis_(kBwNormal) { | 74 hypothesis_(kBwNormal) { |
67 if (in_experiment_) | 75 if (!AdaptiveThresholdExperimentIsDisabled()) |
68 InitializeExperiment(); | 76 InitializeExperiment(); |
69 } | 77 } |
70 | 78 |
71 OveruseDetector::~OveruseDetector() {} | 79 OveruseDetector::~OveruseDetector() {} |
72 | 80 |
73 BandwidthUsage OveruseDetector::State() const { | 81 BandwidthUsage OveruseDetector::State() const { |
74 return hypothesis_; | 82 return hypothesis_; |
75 } | 83 } |
76 | 84 |
77 BandwidthUsage OveruseDetector::Detect(double offset, | 85 BandwidthUsage OveruseDetector::Detect(double offset, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 RTC_DCHECK(in_experiment_); | 156 RTC_DCHECK(in_experiment_); |
149 double k_up = 0.0; | 157 double k_up = 0.0; |
150 double k_down = 0.0; | 158 double k_down = 0.0; |
151 overusing_time_threshold_ = kOverUsingTimeThreshold; | 159 overusing_time_threshold_ = kOverUsingTimeThreshold; |
152 if (ReadExperimentConstants(&k_up, &k_down)) { | 160 if (ReadExperimentConstants(&k_up, &k_down)) { |
153 k_up_ = k_up; | 161 k_up_ = k_up; |
154 k_down_ = k_down; | 162 k_down_ = k_down; |
155 } | 163 } |
156 } | 164 } |
157 } // namespace webrtc | 165 } // namespace webrtc |
OLD | NEW |