You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.7 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #include "rtc_base/experiments/alr_experiment.h"
  11. #include <inttypes.h>
  12. #include <stdio.h>
  13. #include <string>
  14. #include "api/transport/field_trial_based_config.h"
  15. #include "rtc_base/logging.h"
  16. namespace webrtc {
  17. const char AlrExperimentSettings::kScreenshareProbingBweExperimentName[] =
  18. "WebRTC-ProbingScreenshareBwe";
  19. const char AlrExperimentSettings::kStrictPacingAndProbingExperimentName[] =
  20. "WebRTC-StrictPacingAndProbing";
  21. const char kDefaultProbingScreenshareBweSettings[] = "1.0,2875,80,40,-60,3";
  22. bool AlrExperimentSettings::MaxOneFieldTrialEnabled() {
  23. return AlrExperimentSettings::MaxOneFieldTrialEnabled(
  24. FieldTrialBasedConfig());
  25. }
  26. bool AlrExperimentSettings::MaxOneFieldTrialEnabled(
  27. const WebRtcKeyValueConfig& key_value_config) {
  28. return key_value_config.Lookup(kStrictPacingAndProbingExperimentName)
  29. .empty() ||
  30. key_value_config.Lookup(kScreenshareProbingBweExperimentName).empty();
  31. }
  32. absl::optional<AlrExperimentSettings>
  33. AlrExperimentSettings::CreateFromFieldTrial(const char* experiment_name) {
  34. return AlrExperimentSettings::CreateFromFieldTrial(FieldTrialBasedConfig(),
  35. experiment_name);
  36. }
  37. absl::optional<AlrExperimentSettings>
  38. AlrExperimentSettings::CreateFromFieldTrial(
  39. const WebRtcKeyValueConfig& key_value_config,
  40. const char* experiment_name) {
  41. absl::optional<AlrExperimentSettings> ret;
  42. std::string group_name = key_value_config.Lookup(experiment_name);
  43. const std::string kIgnoredSuffix = "_Dogfood";
  44. std::string::size_type suffix_pos = group_name.rfind(kIgnoredSuffix);
  45. if (suffix_pos != std::string::npos &&
  46. suffix_pos == group_name.length() - kIgnoredSuffix.length()) {
  47. group_name.resize(group_name.length() - kIgnoredSuffix.length());
  48. }
  49. if (group_name.empty()) {
  50. if (experiment_name == kScreenshareProbingBweExperimentName) {
  51. // This experiment is now default-on with fixed settings.
  52. // TODO(sprang): Remove this kill-switch and clean up experiment code.
  53. group_name = kDefaultProbingScreenshareBweSettings;
  54. } else {
  55. return ret;
  56. }
  57. }
  58. AlrExperimentSettings settings;
  59. if (sscanf(group_name.c_str(), "%f,%" PRId64 ",%d,%d,%d,%d",
  60. &settings.pacing_factor, &settings.max_paced_queue_time,
  61. &settings.alr_bandwidth_usage_percent,
  62. &settings.alr_start_budget_level_percent,
  63. &settings.alr_stop_budget_level_percent,
  64. &settings.group_id) == 6) {
  65. ret.emplace(settings);
  66. RTC_LOG(LS_INFO) << "Using ALR experiment settings: "
  67. "pacing factor: "
  68. << settings.pacing_factor << ", max pacer queue length: "
  69. << settings.max_paced_queue_time
  70. << ", ALR bandwidth usage percent: "
  71. << settings.alr_bandwidth_usage_percent
  72. << ", ALR start budget level percent: "
  73. << settings.alr_start_budget_level_percent
  74. << ", ALR end budget level percent: "
  75. << settings.alr_stop_budget_level_percent
  76. << ", ALR experiment group ID: " << settings.group_id;
  77. } else {
  78. RTC_LOG(LS_INFO) << "Failed to parse ALR experiment: " << experiment_name;
  79. }
  80. return ret;
  81. }
  82. } // namespace webrtc