Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
| 11 #ifndef WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ | 11 #ifndef WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ |
| 12 #define WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ | 12 #define WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ |
| 13 | 13 |
| 14 #include "webrtc/common_types.h" | 14 #include "webrtc/common_types.h" |
| 15 #include "webrtc/modules/pacing/interval_budget.h" | 15 #include "webrtc/modules/pacing/interval_budget.h" |
| 16 #include "webrtc/modules/pacing/paced_sender.h" | 16 #include "webrtc/modules/pacing/paced_sender.h" |
| 17 #include "webrtc/rtc_base/optional.h" | 17 #include "webrtc/rtc_base/optional.h" |
| 18 #include "webrtc/rtc_base/rate_statistics.h" | 18 #include "webrtc/rtc_base/rate_statistics.h" |
| 19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 | 22 |
| 23 // Application limited region detector is a class that utilizes signals of | 23 // Application limited region detector is a class that utilizes signals of |
| 24 // elapsed time and bytes sent to estimate whether network traffic is | 24 // elapsed time and bytes sent to estimate whether network traffic is |
| 25 // currently limited by the application's ability to generate traffic. | 25 // currently limited by the application's ability to generate traffic. |
| 26 // | 26 // |
| 27 // AlrDetector provides a signal that can be utilized to adjust | 27 // AlrDetector provides a signal that can be utilized to adjust |
| 28 // estimate bandwidth. | 28 // estimate bandwidth. |
| 29 // Note: This class is not thread-safe. | 29 // Note: This class is not thread-safe. |
| 30 | |
| 31 class AlrDetector { | 30 class AlrDetector { |
| 32 public: | 31 public: |
| 33 AlrDetector(); | 32 AlrDetector(); |
| 34 ~AlrDetector(); | 33 ~AlrDetector(); |
| 35 | 34 |
| 36 void OnBytesSent(size_t bytes_sent, int64_t delta_time_ms); | 35 void OnBytesSent(size_t bytes_sent, int64_t delta_time_ms); |
| 37 | 36 |
| 38 // Set current estimated bandwidth. | 37 // Set current estimated bandwidth. |
| 39 void SetEstimatedBitrate(int bitrate_bps); | 38 void SetEstimatedBitrate(int bitrate_bps); |
| 40 | 39 |
| 41 // Returns time in milliseconds when the current application-limited region | 40 // Returns time in milliseconds when the current application-limited region |
| 42 // started or empty result if the sender is currently not application-limited. | 41 // started or empty result if the sender is currently not application-limited. |
| 43 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const; | 42 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const; |
| 44 | 43 |
| 45 struct AlrExperimentSettings { | 44 struct AlrExperimentSettings { |
| 46 float pacing_factor = PacedSender::kDefaultPaceMultiplier; | 45 float pacing_factor = PacedSender::kDefaultPaceMultiplier; |
| 47 int64_t max_paced_queue_time = PacedSender::kMaxQueueLengthMs; | 46 int64_t max_paced_queue_time = PacedSender::kMaxQueueLengthMs; |
| 48 int alr_bandwidth_usage_percent = kDefaultAlrBandwidthUsagePercent; | 47 int alr_bandwidth_usage_percent = kDefaultAlrBandwidthUsagePercent; |
| 49 int alr_start_budget_level_percent = kDefaultAlrStartBudgetLevelPercent; | 48 int alr_start_budget_level_percent = kDefaultAlrStartBudgetLevelPercent; |
| 50 int alr_stop_budget_level_percent = kDefaultAlrStopBudgetLevelPercent; | 49 int alr_stop_budget_level_percent = kDefaultAlrStopBudgetLevelPercent; |
| 51 }; | 50 }; |
| 52 static rtc::Optional<AlrExperimentSettings> ParseAlrSettingsFromFieldTrial(); | 51 static rtc::Optional<AlrExperimentSettings> ParseAlrSettingsFromFieldTrial(); |
| 53 | 52 |
| 54 // Sent traffic percentage as a function of network capacity used to determine | 53 // Sent traffic percentage as a function of network capacity used to determine |
| 55 // application-limited region. ALR region start when bandwidth usage drops | 54 // application-limited region. ALR region start when bandwidth usage drops |
| 56 // below kAlrStartUsagePercent and ends when it raises above | 55 // below kAlrStartUsagePercent and ends when it raises above |
| 57 // kAlrEndUsagePercent. NOTE: This is intentionally conservative at the moment | 56 // kAlrEndUsagePercent. NOTE: This is intentionally conservative at the moment |
| 58 // until BW adjustments of application limited region is fine tuned. | 57 // until BW adjustments of application limited region is fine tuned. |
| 59 static constexpr int kDefaultAlrBandwidthUsagePercent = 65; | 58 static constexpr int kDefaultAlrBandwidthUsagePercent = 65; |
| 60 static constexpr int kDefaultAlrStartBudgetLevelPercent = 20; | 59 static constexpr int kDefaultAlrStartBudgetLevelPercent = 80; |
| 61 static constexpr int kDefaultAlrStopBudgetLevelPercent = -20; | 60 static constexpr int kDefaultAlrStopBudgetLevelPercent = 50; |
| 62 static const char* kScreenshareProbingBweExperimentName; | 61 static const char* kScreenshareProbingBweExperimentName; |
| 63 | 62 |
| 64 void UpdateBudgetWithElapsedTime(int64_t delta_time_ms); | 63 void UpdateBudgetWithElapsedTime(int64_t delta_time_ms); |
| 65 void UpdateBudgetWithBytesSent(size_t bytes_sent); | 64 void UpdateBudgetWithBytesSent(size_t bytes_sent); |
| 66 | 65 |
| 67 private: | 66 private: |
| 68 int bandwidth_usage_percent_; | 67 int bandwidth_usage_percent_; |
| 69 int alr_start_budget_level_percent_; | 68 int alr_start_budget_level_percent_; |
| 70 int alr_stop_budget_level_percent_; | 69 int alr_stop_budget_level_percent_; |
| 71 | 70 |
| 72 IntervalBudget alr_budget_; | 71 IntervalBudget alr_budget_; |
| 72 int estimated_bitrate_bps_; | |
| 73 rtc::Optional<int64_t> alr_started_time_ms_; | 73 rtc::Optional<int64_t> alr_started_time_ms_; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class AlrState { | |
|
philipel
2017/07/14 13:56:23
Do we really need a class to keep track of whether
tschumi
2017/07/14 15:36:51
Removed AlrState
| |
| 77 public: | |
| 78 enum class State { | |
| 79 kInAlr, | |
| 80 kNotInAlr, | |
| 81 }; | |
| 82 AlrState(); | |
| 83 | |
| 84 void Update(rtc::Optional<int64_t> alr_start_time_ms); | |
| 85 bool HasChangedTo(State state); | |
| 86 | |
| 87 private: | |
| 88 bool was_in_alr_; | |
| 89 rtc::Optional<State> alr_state_changed_to_; | |
| 90 }; | |
| 91 | |
| 76 } // namespace webrtc | 92 } // namespace webrtc |
| 77 | 93 |
| 78 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ | 94 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ |
| OLD | NEW |