Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: webrtc/modules/pacing/alr_detector.h

Issue 2965233002: Let alr dectector use a budged to detect underuse. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/optional.h"
15 #include "webrtc/base/rate_statistics.h" 15 #include "webrtc/base/rate_statistics.h"
16 #include "webrtc/common_types.h" 16 #include "webrtc/common_types.h"
17 #include "webrtc/modules/pacing/interval_budget.h"
17 #include "webrtc/modules/pacing/paced_sender.h" 18 #include "webrtc/modules/pacing/paced_sender.h"
18 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 // Application limited region detector is a class that utilizes signals of 23 // Application limited region detector is a class that utilizes signals of
23 // elapsed time and bytes sent to estimate whether network traffic is 24 // elapsed time and bytes sent to estimate whether network traffic is
24 // currently limited by the application's ability to generate traffic. 25 // currently limited by the application's ability to generate traffic.
25 // 26 //
26 // AlrDetector provides a signal that can be utilized to adjust 27 // AlrDetector provides a signal that can be utilized to adjust
27 // estimate bandwidth. 28 // estimate bandwidth.
28 // Note: This class is not thread-safe. 29 // Note: This class is not thread-safe.
29 30
30 class AlrDetector { 31 class AlrDetector {
31 public: 32 public:
32 AlrDetector(); 33 AlrDetector();
33 ~AlrDetector(); 34 ~AlrDetector();
34 35
35 void OnBytesSent(size_t bytes_sent, int64_t now_ms); 36 void OnBytesSent(size_t bytes_sent, int64_t delta_time_ms);
36 37
37 // Set current estimated bandwidth. 38 // Set current estimated bandwidth.
38 void SetEstimatedBitrate(int bitrate_bps); 39 void SetEstimatedBitrate(int bitrate_bps);
39 40
40 // Returns time in milliseconds when the current application-limited region 41 // Returns time in milliseconds when the current application-limited region
41 // started or empty result if the sender is currently not application-limited. 42 // started or empty result if the sender is currently not application-limited.
42 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const; 43 rtc::Optional<int64_t> GetApplicationLimitedRegionStartTime() const;
43 44
44 struct AlrExperimentSettings { 45 struct AlrExperimentSettings {
45 float pacing_factor = PacedSender::kDefaultPaceMultiplier; 46 float pacing_factor = PacedSender::kDefaultPaceMultiplier;
46 int64_t max_paced_queue_time = PacedSender::kMaxQueueLengthMs; 47 int64_t max_paced_queue_time = PacedSender::kMaxQueueLengthMs;
47 int alr_start_usage_percent = kDefaultAlrStartUsagePercent; 48 int alr_bandwidth_usage_percent = kDefaultAlrBandwidthUsagePercent;
48 int alr_end_usage_percent = kDefaultAlrEndUsagePercent; 49 int alr_start_budget_level_percent = kDefaultAlrStartBudgetLevePercent;
50 int alr_stop_budget_level_percent = kDefaultAlrStopBudgetLevePercent;
49 }; 51 };
50 static rtc::Optional<AlrExperimentSettings> ParseAlrSettingsFromFieldTrial(); 52 static rtc::Optional<AlrExperimentSettings> ParseAlrSettingsFromFieldTrial();
51 53
52 // Sent traffic percentage as a function of network capacity used to determine 54 // Sent traffic percentage as a function of network capacity used to determine
53 // application-limited region. ALR region start when bandwidth usage drops 55 // application-limited region. ALR region start when bandwidth usage drops
54 // below kAlrStartUsagePercent and ends when it raises above 56 // below kAlrStartUsagePercent and ends when it raises above
55 // kAlrEndUsagePercent. NOTE: This is intentionally conservative at the moment 57 // kAlrEndUsagePercent. NOTE: This is intentionally conservative at the moment
56 // until BW adjustments of application limited region is fine tuned. 58 // until BW adjustments of application limited region is fine tuned.
57 static constexpr int kDefaultAlrStartUsagePercent = 60; 59 static constexpr int kDefaultAlrBandwidthUsagePercent = 65;
58 static constexpr int kDefaultAlrEndUsagePercent = 70; 60 static constexpr int kDefaultAlrStartBudgetLevePercent = 20;
stefan-webrtc 2017/07/06 14:55:37 Level?
tschumi 2017/07/07 08:47:30 Yes :)
61 static constexpr int kDefaultAlrStopBudgetLevePercent = -20;
59 static const char* kScreenshareProbingBweExperimentName; 62 static const char* kScreenshareProbingBweExperimentName;
60 63
64 void UpdateBudgetWithElapsedTime(int64_t delta_time_ms);
65 void UpdateBudgetWithBytesSent(size_t bytes_sent);
66
61 private: 67 private:
62 int alr_start_usage_percent_; 68 int bandwidth_usage_percent_;
63 int alr_end_usage_percent_; 69 int alr_start_budget_level_percent_;
64 RateStatistics rate_; 70 int alr_stop_budget_level_percent_;
65 int estimated_bitrate_bps_;
66 71
67 // Non-empty in ALR state. 72 IntervalBudget alr_budget_;
68 rtc::Optional<int64_t> alr_started_time_ms_; 73 rtc::Optional<int64_t> alr_started_time_ms_;
69 }; 74 };
70 75
71 } // namespace webrtc 76 } // namespace webrtc
72 77
73 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ 78 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698