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/base/optional.h" |
14 #include "webrtc/base/rate_statistics.h" | 15 #include "webrtc/base/rate_statistics.h" |
15 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
16 #include "webrtc/modules/pacing/paced_sender.h" | 17 #include "webrtc/modules/pacing/paced_sender.h" |
17 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 // Application limited region detector is a class that utilizes signals of | 22 // Application limited region detector is a class that utilizes signals of |
22 // elapsed time and bytes sent to estimate whether network traffic is | 23 // elapsed time and bytes sent to estimate whether network traffic is |
23 // currently limited by the application's ability to generate traffic. | 24 // currently limited by the application's ability to generate traffic. |
24 // | 25 // |
25 // AlrDetector provides a signal that can be utilized to adjust | 26 // AlrDetector provides a signal that can be utilized to adjust |
26 // estimate bandwidth. | 27 // estimate bandwidth. |
27 // Note: This class is not thread-safe. | 28 // Note: This class is not thread-safe. |
| 29 |
28 class AlrDetector { | 30 class AlrDetector { |
29 public: | 31 public: |
30 AlrDetector(); | 32 AlrDetector(); |
31 ~AlrDetector(); | 33 ~AlrDetector(); |
32 | 34 |
33 void OnBytesSent(size_t bytes_sent, int64_t now_ms); | 35 void OnBytesSent(size_t bytes_sent, int64_t now_ms); |
34 | 36 |
35 // Set current estimated bandwidth. | 37 // Set current estimated bandwidth. |
36 void SetEstimatedBitrate(int bitrate_bps); | 38 void SetEstimatedBitrate(int bitrate_bps); |
37 | 39 |
38 // Returns time in milliseconds when the current application-limited region | 40 // Returns time in milliseconds when the current application-limited region |
39 // 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. |
40 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const; | 42 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const; |
41 | 43 |
| 44 struct AlrExperimentSettings { |
| 45 float pacing_factor = PacedSender::kDefaultPaceMultiplier; |
| 46 int64_t max_paced_queue_time = PacedSender::kMaxQueueLengthMs; |
| 47 int alr_start_usage_percent = kDefaultAlrStartUsagePercent; |
| 48 int alr_end_usage_percent = kDefaultAlrEndUsagePercent; |
| 49 }; |
| 50 static rtc::Optional<AlrExperimentSettings> ParseAlrSettingsFromFieldTrial(); |
| 51 |
| 52 // Sent traffic percentage as a function of network capacity used to determine |
| 53 // application-limited region. ALR region start when bandwidth usage drops |
| 54 // below kAlrStartUsagePercent and ends when it raises above |
| 55 // kAlrEndUsagePercent. NOTE: This is intentionally conservative at the moment |
| 56 // until BW adjustments of application limited region is fine tuned. |
| 57 static constexpr int kDefaultAlrStartUsagePercent = 60; |
| 58 static constexpr int kDefaultAlrEndUsagePercent = 70; |
| 59 static const char* kScreenshareProbingBweExperimentName; |
| 60 |
42 private: | 61 private: |
| 62 int alr_start_usage_percent_; |
| 63 int alr_end_usage_percent_; |
43 RateStatistics rate_; | 64 RateStatistics rate_; |
44 int estimated_bitrate_bps_ = 0; | 65 int estimated_bitrate_bps_; |
45 | 66 |
46 // Non-empty in ALR state. | 67 // Non-empty in ALR state. |
47 rtc::Optional<int64_t> alr_started_time_ms_; | 68 rtc::Optional<int64_t> alr_started_time_ms_; |
48 }; | 69 }; |
49 | 70 |
50 } // namespace webrtc | 71 } // namespace webrtc |
51 | 72 |
52 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ | 73 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ |
OLD | NEW |