OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // allocated bitrate for the send stream. The current network properties are | 27 // allocated bitrate for the send stream. The current network properties are |
28 // given at the same time, to let the send stream decide about possible loss | 28 // given at the same time, to let the send stream decide about possible loss |
29 // protection. | 29 // protection. |
30 class BitrateAllocatorObserver { | 30 class BitrateAllocatorObserver { |
31 public: | 31 public: |
32 // Returns the amount of protection used by the BitrateAllocatorObserver | 32 // Returns the amount of protection used by the BitrateAllocatorObserver |
33 // implementation, as bitrate in bps. | 33 // implementation, as bitrate in bps. |
34 virtual uint32_t OnBitrateUpdated(uint32_t bitrate_bps, | 34 virtual uint32_t OnBitrateUpdated(uint32_t bitrate_bps, |
35 uint8_t fraction_loss, | 35 uint8_t fraction_loss, |
36 int64_t rtt, | 36 int64_t rtt, |
37 int64_t probing_interval_ms) = 0; | 37 int64_t bwe_period_ms) = 0; |
38 | 38 |
39 protected: | 39 protected: |
40 virtual ~BitrateAllocatorObserver() {} | 40 virtual ~BitrateAllocatorObserver() {} |
41 }; | 41 }; |
42 | 42 |
43 // Usage: this class will register multiple RtcpBitrateObserver's one at each | 43 // Usage: this class will register multiple RtcpBitrateObserver's one at each |
44 // RTCP module. It will aggregate the results and run one bandwidth estimation | 44 // RTCP module. It will aggregate the results and run one bandwidth estimation |
45 // and push the result to the encoders via BitrateAllocatorObserver(s). | 45 // and push the result to the encoders via BitrateAllocatorObserver(s). |
46 class BitrateAllocator { | 46 class BitrateAllocator { |
47 public: | 47 public: |
48 // Used to get notified when send stream limits such as the minimum send | 48 // Used to get notified when send stream limits such as the minimum send |
49 // bitrate and max padding bitrate is changed. | 49 // bitrate and max padding bitrate is changed. |
50 class LimitObserver { | 50 class LimitObserver { |
51 public: | 51 public: |
52 virtual void OnAllocationLimitsChanged( | 52 virtual void OnAllocationLimitsChanged( |
53 uint32_t min_send_bitrate_bps, | 53 uint32_t min_send_bitrate_bps, |
54 uint32_t max_padding_bitrate_bps) = 0; | 54 uint32_t max_padding_bitrate_bps) = 0; |
55 | 55 |
56 protected: | 56 protected: |
57 virtual ~LimitObserver() {} | 57 virtual ~LimitObserver() {} |
58 }; | 58 }; |
59 | 59 |
60 explicit BitrateAllocator(LimitObserver* limit_observer); | 60 explicit BitrateAllocator(LimitObserver* limit_observer); |
61 ~BitrateAllocator(); | 61 ~BitrateAllocator(); |
62 | 62 |
63 // Allocate target_bitrate across the registered BitrateAllocatorObservers. | 63 // Allocate target_bitrate across the registered BitrateAllocatorObservers. |
64 void OnNetworkChanged(uint32_t target_bitrate_bps, | 64 void OnNetworkChanged(uint32_t target_bitrate_bps, |
65 uint8_t fraction_loss, | 65 uint8_t fraction_loss, |
66 int64_t rtt, | 66 int64_t rtt, |
67 int64_t probing_interval_ms); | 67 int64_t bwe_period_ms); |
68 | 68 |
69 // Set the start and max send bitrate used by the bandwidth management. | 69 // Set the start and max send bitrate used by the bandwidth management. |
70 // | 70 // |
71 // |observer| updates bitrates if already in use. | 71 // |observer| updates bitrates if already in use. |
72 // |min_bitrate_bps| = 0 equals no min bitrate. | 72 // |min_bitrate_bps| = 0 equals no min bitrate. |
73 // |max_bitrate_bps| = 0 equals no max bitrate. | 73 // |max_bitrate_bps| = 0 equals no max bitrate. |
74 // |enforce_min_bitrate| = 'true' will allocate at least |min_bitrate_bps| for | 74 // |enforce_min_bitrate| = 'true' will allocate at least |min_bitrate_bps| for |
75 // this observer, even if the BWE is too low, 'false' will allocate 0 to | 75 // this observer, even if the BWE is too low, 'false' will allocate 0 to |
76 // the observer if BWE doesn't allow |min_bitrate_bps|. | 76 // the observer if BWE doesn't allow |min_bitrate_bps|. |
77 // Note that |observer|->OnBitrateUpdated() will be called within the scope of | 77 // Note that |observer|->OnBitrateUpdated() will be called within the scope of |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 uint32_t sum_min_bitrates); | 153 uint32_t sum_min_bitrates); |
154 | 154 |
155 rtc::SequencedTaskChecker sequenced_checker_; | 155 rtc::SequencedTaskChecker sequenced_checker_; |
156 LimitObserver* const limit_observer_ GUARDED_BY(&sequenced_checker_); | 156 LimitObserver* const limit_observer_ GUARDED_BY(&sequenced_checker_); |
157 // Stored in a list to keep track of the insertion order. | 157 // Stored in a list to keep track of the insertion order. |
158 ObserverConfigs bitrate_observer_configs_ GUARDED_BY(&sequenced_checker_); | 158 ObserverConfigs bitrate_observer_configs_ GUARDED_BY(&sequenced_checker_); |
159 uint32_t last_bitrate_bps_ GUARDED_BY(&sequenced_checker_); | 159 uint32_t last_bitrate_bps_ GUARDED_BY(&sequenced_checker_); |
160 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_); | 160 uint32_t last_non_zero_bitrate_bps_ GUARDED_BY(&sequenced_checker_); |
161 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_); | 161 uint8_t last_fraction_loss_ GUARDED_BY(&sequenced_checker_); |
162 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_); | 162 int64_t last_rtt_ GUARDED_BY(&sequenced_checker_); |
163 int64_t last_probing_interval_ms_ GUARDED_BY(&sequenced_checker_); | 163 int64_t last_bwe_period_ms_ GUARDED_BY(&sequenced_checker_); |
164 // Number of mute events based on too low BWE, not network up/down. | 164 // Number of mute events based on too low BWE, not network up/down. |
165 int num_pause_events_ GUARDED_BY(&sequenced_checker_); | 165 int num_pause_events_ GUARDED_BY(&sequenced_checker_); |
166 Clock* const clock_ GUARDED_BY(&sequenced_checker_); | 166 Clock* const clock_ GUARDED_BY(&sequenced_checker_); |
167 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_); | 167 int64_t last_bwe_log_time_ GUARDED_BY(&sequenced_checker_); |
168 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_); | 168 uint32_t total_requested_padding_bitrate_ GUARDED_BY(&sequenced_checker_); |
169 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_); | 169 uint32_t total_requested_min_bitrate_ GUARDED_BY(&sequenced_checker_); |
170 }; | 170 }; |
171 } // namespace webrtc | 171 } // namespace webrtc |
172 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ | 172 #endif // WEBRTC_CALL_BITRATE_ALLOCATOR_H_ |
OLD | NEW |