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 | 10 |
11 #include "webrtc/call/congestion_controller.h" | 11 #include "webrtc/call/congestion_controller.h" |
12 | 12 |
| 13 #include <algorithm> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
17 #include "webrtc/base/socket.h" | 18 #include "webrtc/base/socket.h" |
18 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
19 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 20 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
20 #include "webrtc/modules/pacing/paced_sender.h" | 21 #include "webrtc/modules/pacing/paced_sender.h" |
21 #include "webrtc/modules/pacing/packet_router.h" | 22 #include "webrtc/modules/pacing/packet_router.h" |
22 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 CriticalSectionScoped cs(crit_sect_.get()); | 76 CriticalSectionScoped cs(crit_sect_.get()); |
76 rbe_->RemoveStream(ssrc); | 77 rbe_->RemoveStream(ssrc); |
77 } | 78 } |
78 | 79 |
79 bool LatestEstimate(std::vector<unsigned int>* ssrcs, | 80 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
80 unsigned int* bitrate_bps) const override { | 81 unsigned int* bitrate_bps) const override { |
81 CriticalSectionScoped cs(crit_sect_.get()); | 82 CriticalSectionScoped cs(crit_sect_.get()); |
82 return rbe_->LatestEstimate(ssrcs, bitrate_bps); | 83 return rbe_->LatestEstimate(ssrcs, bitrate_bps); |
83 } | 84 } |
84 | 85 |
85 bool GetStats(ReceiveBandwidthEstimatorStats* output) const override { | |
86 CriticalSectionScoped cs(crit_sect_.get()); | |
87 return rbe_->GetStats(output); | |
88 } | |
89 | |
90 void SetMinBitrate(int min_bitrate_bps) { | 86 void SetMinBitrate(int min_bitrate_bps) { |
91 CriticalSectionScoped cs(crit_sect_.get()); | 87 CriticalSectionScoped cs(crit_sect_.get()); |
92 rbe_->SetMinBitrate(min_bitrate_bps); | 88 rbe_->SetMinBitrate(min_bitrate_bps); |
93 min_bitrate_bps_ = min_bitrate_bps; | 89 min_bitrate_bps_ = min_bitrate_bps; |
94 } | 90 } |
95 | 91 |
96 private: | 92 private: |
97 void PickEstimatorFromHeader(const RTPHeader& header) | 93 void PickEstimatorFromHeader(const RTPHeader& header) |
98 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { | 94 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { |
99 if (header.extension.hasAbsoluteSendTime) { | 95 if (header.extension.hasAbsoluteSendTime) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 process_thread_->DeRegisterModule(remote_bitrate_estimator_.get()); | 182 process_thread_->DeRegisterModule(remote_bitrate_estimator_.get()); |
187 call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get()); | 183 call_stats_->DeregisterStatsObserver(remote_bitrate_estimator_.get()); |
188 if (transport_feedback_adapter_.get()) | 184 if (transport_feedback_adapter_.get()) |
189 call_stats_->DeregisterStatsObserver(transport_feedback_adapter_.get()); | 185 call_stats_->DeregisterStatsObserver(transport_feedback_adapter_.get()); |
190 } | 186 } |
191 | 187 |
192 | 188 |
193 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 189 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
194 int start_bitrate_bps, | 190 int start_bitrate_bps, |
195 int max_bitrate_bps) { | 191 int max_bitrate_bps) { |
196 if (start_bitrate_bps > 0) | 192 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| 193 // and that we don't try to set the min bitrate to 0 from any applications. |
| 194 // The congestion controller should allow a min bitrate of 0. |
| 195 const int kMinBitrateBps = 10000; |
| 196 if (min_bitrate_bps < kMinBitrateBps) |
| 197 min_bitrate_bps = kMinBitrateBps; |
| 198 if (max_bitrate_bps > 0) |
| 199 max_bitrate_bps = std::max(min_bitrate_bps, max_bitrate_bps); |
| 200 if (start_bitrate_bps > 0) { |
| 201 start_bitrate_bps = std::max(min_bitrate_bps, start_bitrate_bps); |
197 bitrate_controller_->SetStartBitrate(start_bitrate_bps); | 202 bitrate_controller_->SetStartBitrate(start_bitrate_bps); |
| 203 } |
198 bitrate_controller_->SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps); | 204 bitrate_controller_->SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps); |
199 if (remote_bitrate_estimator_.get()) | 205 if (remote_bitrate_estimator_.get()) |
200 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | 206 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); |
201 if (transport_feedback_adapter_.get()) | 207 if (transport_feedback_adapter_.get()) |
202 transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate( | 208 transport_feedback_adapter_->GetBitrateEstimator()->SetMinBitrate( |
203 min_bitrate_bps); | 209 min_bitrate_bps); |
204 min_bitrate_bps_ = min_bitrate_bps; | 210 min_bitrate_bps_ = min_bitrate_bps; |
205 } | 211 } |
206 | 212 |
207 BitrateController* CongestionController::GetBitrateController() const { | 213 BitrateController* CongestionController::GetBitrateController() const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 256 } |
251 } | 257 } |
252 | 258 |
253 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { | 259 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
254 if (transport_feedback_adapter_) { | 260 if (transport_feedback_adapter_) { |
255 transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id, | 261 transport_feedback_adapter_->OnSentPacket(sent_packet.packet_id, |
256 sent_packet.send_time_ms); | 262 sent_packet.send_time_ms); |
257 } | 263 } |
258 } | 264 } |
259 } // namespace webrtc | 265 } // namespace webrtc |
OLD | NEW |