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

Side by Side Diff: webrtc/modules/bitrate_controller/bitrate_controller_impl.cc

Issue 1917793002: Remove SendPacer from ViEEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed SenderDelegate to PacketSender. Created 4 years, 7 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) 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 */
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 std::map<uint32_t, uint32_t> ssrc_to_last_received_extended_high_seq_num_; 76 std::map<uint32_t, uint32_t> ssrc_to_last_received_extended_high_seq_num_;
77 BitrateControllerImpl* owner_; 77 BitrateControllerImpl* owner_;
78 }; 78 };
79 79
80 BitrateController* BitrateController::CreateBitrateController( 80 BitrateController* BitrateController::CreateBitrateController(
81 Clock* clock, 81 Clock* clock,
82 BitrateObserver* observer) { 82 BitrateObserver* observer) {
83 return new BitrateControllerImpl(clock, observer); 83 return new BitrateControllerImpl(clock, observer);
84 } 84 }
85 85
86 BitrateController* BitrateController::CreateBitrateController(Clock* clock) {
87 return new BitrateControllerImpl(clock, nullptr);
88 }
89
86 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, 90 BitrateControllerImpl::BitrateControllerImpl(Clock* clock,
87 BitrateObserver* observer) 91 BitrateObserver* observer)
88 : clock_(clock), 92 : clock_(clock),
89 observer_(observer), 93 observer_(observer),
90 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), 94 last_bitrate_update_ms_(clock_->TimeInMilliseconds()),
91 bandwidth_estimation_(), 95 bandwidth_estimation_(),
92 reserved_bitrate_bps_(0), 96 reserved_bitrate_bps_(0),
93 last_bitrate_bps_(0), 97 last_bitrate_bps_(0),
94 last_fraction_loss_(0), 98 last_fraction_loss_(0),
95 last_rtt_ms_(0), 99 last_rtt_ms_(0),
96 last_reserved_bitrate_bps_(0) { 100 last_reserved_bitrate_bps_(0) {
97 // This calls the observer_, which means that the observer provided by the 101 // This calls the observer_ if set, which means that the observer provided by
98 // user must be ready to accept a bitrate update when it constructs the 102 // the user must be ready to accept a bitrate update when it constructs the
99 // controller. We do this to avoid having to keep synchronized initial values 103 // controller. We do this to avoid having to keep synchronized initial values
100 // in both the controller and the allocator. 104 // in both the controller and the allocator.
101 MaybeTriggerOnNetworkChanged(); 105 MaybeTriggerOnNetworkChanged();
102 } 106 }
103 107
104 RtcpBandwidthObserver* BitrateControllerImpl::CreateRtcpBandwidthObserver() { 108 RtcpBandwidthObserver* BitrateControllerImpl::CreateRtcpBandwidthObserver() {
105 return new RtcpBandwidthObserverImpl(this); 109 return new RtcpBandwidthObserverImpl(this);
106 } 110 }
107 111
108 void BitrateControllerImpl::SetStartBitrate(int start_bitrate_bps) { 112 void BitrateControllerImpl::SetStartBitrate(int start_bitrate_bps) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int64_t now_ms) { 196 int64_t now_ms) {
193 { 197 {
194 rtc::CritScope cs(&critsect_); 198 rtc::CritScope cs(&critsect_);
195 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt, 199 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt,
196 number_of_packets, now_ms); 200 number_of_packets, now_ms);
197 } 201 }
198 MaybeTriggerOnNetworkChanged(); 202 MaybeTriggerOnNetworkChanged();
199 } 203 }
200 204
201 void BitrateControllerImpl::MaybeTriggerOnNetworkChanged() { 205 void BitrateControllerImpl::MaybeTriggerOnNetworkChanged() {
202 uint32_t bitrate; 206 if (!observer_)
207 return;
208
209 uint32_t bitrate_bps;
203 uint8_t fraction_loss; 210 uint8_t fraction_loss;
204 int64_t rtt; 211 int64_t rtt;
205 if (GetNetworkParameters(&bitrate, &fraction_loss, &rtt)) 212
206 observer_->OnNetworkChanged(bitrate, fraction_loss, rtt); 213 if (GetNetworkParameters(&bitrate_bps, &fraction_loss, &rtt))
214 observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt);
207 } 215 }
208 216
209 bool BitrateControllerImpl::GetNetworkParameters(uint32_t* bitrate, 217 bool BitrateControllerImpl::GetNetworkParameters(uint32_t* bitrate,
210 uint8_t* fraction_loss, 218 uint8_t* fraction_loss,
211 int64_t* rtt) { 219 int64_t* rtt) {
212 rtc::CritScope cs(&critsect_); 220 rtc::CritScope cs(&critsect_);
213 int current_bitrate; 221 int current_bitrate;
214 bandwidth_estimation_.CurrentEstimate(&current_bitrate, fraction_loss, rtt); 222 bandwidth_estimation_.CurrentEstimate(&current_bitrate, fraction_loss, rtt);
215 *bitrate = current_bitrate; 223 *bitrate = current_bitrate;
216 *bitrate -= std::min(*bitrate, reserved_bitrate_bps_); 224 *bitrate -= std::min(*bitrate, reserved_bitrate_bps_);
(...skipping 21 matching lines...) Expand all
238 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); 246 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt);
239 if (bitrate > 0) { 247 if (bitrate > 0) {
240 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); 248 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_);
241 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); 249 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate());
242 *bandwidth = bitrate; 250 *bandwidth = bitrate;
243 return true; 251 return true;
244 } 252 }
245 return false; 253 return false;
246 } 254 }
247 } // namespace webrtc 255 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698