| 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/rate_statistics.h" |
| 14 #include "webrtc/common_types.h" | 15 #include "webrtc/common_types.h" |
| 15 #include "webrtc/modules/pacing/paced_sender.h" | 16 #include "webrtc/modules/pacing/paced_sender.h" |
| 16 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
| 17 | 18 |
| 18 namespace webrtc { | 19 namespace webrtc { |
| 19 | 20 |
| 20 // Application limited region detector is a class that utilizes signals of | 21 // Application limited region detector is a class that utilizes signals of |
| 21 // elapsed time and bytes sent to estimate whether network traffic is | 22 // elapsed time and bytes sent to estimate whether network traffic is |
| 22 // currently limited by the application's ability to generate traffic. | 23 // currently limited by the application's ability to generate traffic. |
| 23 // | 24 // |
| 24 // AlrDetector provides a signal that can be utilized to adjust | 25 // AlrDetector provides a signal that can be utilized to adjust |
| 25 // estimate bandwidth. | 26 // estimate bandwidth. |
| 26 // Note: This class is not thread-safe. | 27 // Note: This class is not thread-safe. |
| 27 class AlrDetector { | 28 class AlrDetector { |
| 28 public: | 29 public: |
| 29 AlrDetector(); | 30 AlrDetector(); |
| 30 ~AlrDetector(); | 31 ~AlrDetector(); |
| 31 void OnBytesSent(size_t bytes_sent, int64_t elapsed_time_ms); | 32 |
| 33 void OnBytesSent(size_t bytes_sent, int64_t now_ms); |
| 34 |
| 32 // Set current estimated bandwidth. | 35 // Set current estimated bandwidth. |
| 33 void SetEstimatedBitrate(int bitrate_bps); | 36 void SetEstimatedBitrate(int bitrate_bps); |
| 37 |
| 34 // Returns true if currently in application-limited region. | 38 // Returns true if currently in application-limited region. |
| 35 bool InApplicationLimitedRegion(); | 39 bool InApplicationLimitedRegion(); |
| 36 | 40 |
| 37 private: | 41 private: |
| 38 size_t measurement_interval_bytes_sent_; | 42 RateStatistics rate_; |
| 39 int64_t measurement_interval_elapsed_time_ms_; | 43 int estimated_bitrate_bps_ = 0; |
| 40 int estimated_bitrate_bps_; | 44 bool application_limited_ = false; |
| 41 // Number of consecutive periods over which we observe traffic is application | |
| 42 // limited. | |
| 43 int application_limited_count_; | |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 } // namespace webrtc | 47 } // namespace webrtc |
| 47 | 48 |
| 48 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ | 49 #endif // WEBRTC_MODULES_PACING_ALR_DETECTOR_H_ |
| OLD | NEW |