OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 * FEC and NACK added bitrate is handled outside class | 10 * FEC and NACK added bitrate is handled outside class |
11 */ | 11 */ |
12 | 12 |
13 #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ | 13 #ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ |
14 #define WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ | 14 #define WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ |
15 | 15 |
16 #include <deque> | 16 #include <deque> |
17 #include <utility> | 17 #include <utility> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 class RtcEventLog; | 25 class RtcEventLog; |
26 | 26 |
27 class SendSideBandwidthEstimation { | 27 class SendSideBandwidthEstimation { |
28 public: | 28 public: |
29 SendSideBandwidthEstimation() = delete; | 29 SendSideBandwidthEstimation(); |
30 explicit SendSideBandwidthEstimation(RtcEventLog* event_log); | |
31 virtual ~SendSideBandwidthEstimation(); | 30 virtual ~SendSideBandwidthEstimation(); |
32 | 31 |
33 void CurrentEstimate(int* bitrate, uint8_t* loss, int64_t* rtt) const; | 32 void CurrentEstimate(int* bitrate, uint8_t* loss, int64_t* rtt) const; |
34 | 33 |
35 // Call periodically to update estimate. | 34 // Call periodically to update estimate. |
36 void UpdateEstimate(int64_t now_ms); | 35 void UpdateEstimate(int64_t now_ms); |
37 | 36 |
38 // Call when we receive a RTCP message with TMMBR or REMB. | 37 // Call when we receive a RTCP message with TMMBR or REMB. |
39 void UpdateReceiverEstimate(int64_t now_ms, uint32_t bandwidth); | 38 void UpdateReceiverEstimate(int64_t now_ms, uint32_t bandwidth); |
40 | 39 |
41 // Call when a new delay-based estimate is available. | 40 // Call when a new delay-based estimate is available. |
42 void UpdateDelayBasedEstimate(int64_t now_ms, uint32_t bitrate_bps); | 41 void UpdateDelayBasedEstimate(int64_t now_ms, uint32_t bitrate_bps); |
43 | 42 |
44 // Call when we receive a RTCP message with a ReceiveBlock. | 43 // Call when we receive a RTCP message with a ReceiveBlock. |
45 void UpdateReceiverBlock(uint8_t fraction_loss, | 44 void UpdateReceiverBlock(uint8_t fraction_loss, |
46 int64_t rtt, | 45 int64_t rtt, |
47 int number_of_packets, | 46 int number_of_packets, |
48 int64_t now_ms); | 47 int64_t now_ms); |
49 | 48 |
50 void SetBitrates(int send_bitrate, | 49 void SetBitrates(int send_bitrate, |
51 int min_bitrate, | 50 int min_bitrate, |
52 int max_bitrate); | 51 int max_bitrate); |
53 void SetSendBitrate(int bitrate); | 52 void SetSendBitrate(int bitrate); |
54 void SetMinMaxBitrate(int min_bitrate, int max_bitrate); | 53 void SetMinMaxBitrate(int min_bitrate, int max_bitrate); |
55 int GetMinBitrate() const; | 54 int GetMinBitrate() const; |
56 | 55 |
| 56 void SetEventLog(RtcEventLog* event_log); |
| 57 |
57 private: | 58 private: |
58 enum UmaState { kNoUpdate, kFirstDone, kDone }; | 59 enum UmaState { kNoUpdate, kFirstDone, kDone }; |
59 | 60 |
60 bool IsInStartPhase(int64_t now_ms) const; | 61 bool IsInStartPhase(int64_t now_ms) const; |
61 | 62 |
62 void UpdateUmaStats(int64_t now_ms, int64_t rtt, int lost_packets); | 63 void UpdateUmaStats(int64_t now_ms, int64_t rtt, int lost_packets); |
63 | 64 |
64 // Returns the input bitrate capped to the thresholds defined by the max, | 65 // Returns the input bitrate capped to the thresholds defined by the max, |
65 // min and incoming bandwidth. | 66 // min and incoming bandwidth. |
66 uint32_t CapBitrateToThresholds(int64_t now_ms, uint32_t bitrate); | 67 uint32_t CapBitrateToThresholds(int64_t now_ms, uint32_t bitrate); |
(...skipping 24 matching lines...) Expand all Loading... |
91 int64_t time_last_decrease_ms_; | 92 int64_t time_last_decrease_ms_; |
92 int64_t first_report_time_ms_; | 93 int64_t first_report_time_ms_; |
93 int initially_lost_packets_; | 94 int initially_lost_packets_; |
94 int bitrate_at_2_seconds_kbps_; | 95 int bitrate_at_2_seconds_kbps_; |
95 UmaState uma_update_state_; | 96 UmaState uma_update_state_; |
96 std::vector<bool> rampup_uma_stats_updated_; | 97 std::vector<bool> rampup_uma_stats_updated_; |
97 RtcEventLog* event_log_; | 98 RtcEventLog* event_log_; |
98 }; | 99 }; |
99 } // namespace webrtc | 100 } // namespace webrtc |
100 #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ | 101 #endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ |
OLD | NEW |