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

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2827333005: Moving overhead counting to bitrate estimators.
Patch Set: Created 3 years, 8 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) 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
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 detector_(), 154 detector_(),
155 receiver_incoming_bitrate_(), 155 receiver_incoming_bitrate_(),
156 last_seen_packet_ms_(-1), 156 last_seen_packet_ms_(-1),
157 uma_recorded_(false), 157 uma_recorded_(false),
158 probe_bitrate_estimator_(event_log), 158 probe_bitrate_estimator_(event_log),
159 trendline_window_size_(kDefaultTrendlineWindowSize), 159 trendline_window_size_(kDefaultTrendlineWindowSize),
160 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), 160 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff),
161 trendline_threshold_gain_(kDefaultTrendlineThresholdGain), 161 trendline_threshold_gain_(kDefaultTrendlineThresholdGain),
162 consecutive_delayed_feedbacks_(0), 162 consecutive_delayed_feedbacks_(0),
163 last_logged_bitrate_(0), 163 last_logged_bitrate_(0),
164 last_logged_state_(BandwidthUsage::kBwNormal) { 164 last_logged_state_(BandwidthUsage::kBwNormal),
165 send_side_bwe_with_overhead_(
166 webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")) {
165 LOG(LS_INFO) << "Using Trendline filter for delay change estimation."; 167 LOG(LS_INFO) << "Using Trendline filter for delay change estimation.";
166 168
167 network_thread_.DetachFromThread(); 169 network_thread_.DetachFromThread();
168 } 170 }
169 171
170 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector( 172 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedbackVector(
171 const std::vector<PacketFeedback>& packet_feedback_vector) { 173 const std::vector<PacketFeedback>& packet_feedback_vector) {
172 RTC_DCHECK(network_thread_.CalledOnValidThread()); 174 RTC_DCHECK(network_thread_.CalledOnValidThread());
173 175
174 std::vector<PacketFeedback> sorted_packet_feedback_vector; 176 std::vector<PacketFeedback> sorted_packet_feedback_vector;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 result.target_bitrate_bps = rate_control_.LatestEstimate(); 227 result.target_bitrate_bps = rate_control_.LatestEstimate();
226 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to " 228 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to "
227 << result.target_bitrate_bps; 229 << result.target_bitrate_bps;
228 return result; 230 return result;
229 } 231 }
230 232
231 void DelayBasedBwe::IncomingPacketFeedback( 233 void DelayBasedBwe::IncomingPacketFeedback(
232 const PacketFeedback& packet_feedback) { 234 const PacketFeedback& packet_feedback) {
233 int64_t now_ms = clock_->TimeInMilliseconds(); 235 int64_t now_ms = clock_->TimeInMilliseconds();
234 236
237 const size_t packet_size = send_side_bwe_with_overhead_
238 ? packet_feedback.payload_size +
239 packet_feedback.rtp_headers_size +
240 packet_feedback.transport_headers_size
241 : packet_feedback.payload_size;
235 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms, 242 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms,
236 packet_feedback.payload_size); 243 packet_size);
237 Result result; 244 Result result;
238 // Reset if the stream has timed out. 245 // Reset if the stream has timed out.
239 if (last_seen_packet_ms_ == -1 || 246 if (last_seen_packet_ms_ == -1 ||
240 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { 247 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) {
241 inter_arrival_.reset( 248 inter_arrival_.reset(
242 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000, 249 new InterArrival((kTimestampGroupLengthMs << kInterArrivalShift) / 1000,
243 kTimestampToMs, true)); 250 kTimestampToMs, true));
244 trendline_estimator_.reset(new TrendlineEstimator( 251 trendline_estimator_.reset(new TrendlineEstimator(
245 trendline_window_size_, trendline_smoothing_coeff_, 252 trendline_window_size_, trendline_smoothing_coeff_,
246 trendline_threshold_gain_)); 253 trendline_threshold_gain_));
247 } 254 }
248 last_seen_packet_ms_ = now_ms; 255 last_seen_packet_ms_ = now_ms;
249 256
250 uint32_t send_time_24bits = 257 uint32_t send_time_24bits =
251 static_cast<uint32_t>( 258 static_cast<uint32_t>(
252 ((static_cast<uint64_t>(packet_feedback.send_time_ms) 259 ((static_cast<uint64_t>(packet_feedback.send_time_ms)
253 << kAbsSendTimeFraction) + 260 << kAbsSendTimeFraction) +
254 500) / 261 500) /
255 1000) & 262 1000) &
256 0x00FFFFFF; 263 0x00FFFFFF;
257 // Shift up send time to use the full 32 bits that inter_arrival works with, 264 // Shift up send time to use the full 32 bits that inter_arrival works with,
258 // so wrapping works properly. 265 // so wrapping works properly.
259 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift; 266 uint32_t timestamp = send_time_24bits << kAbsSendTimeInterArrivalUpshift;
260 267
261 uint32_t ts_delta = 0; 268 uint32_t ts_delta = 0;
262 int64_t t_delta = 0; 269 int64_t t_delta = 0;
263 int size_delta = 0; 270 int size_delta = 0;
264 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms, 271 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms,
265 now_ms, packet_feedback.payload_size, 272 now_ms, packet_size, &ts_delta, &t_delta,
266 &ts_delta, &t_delta, &size_delta)) { 273 &size_delta)) {
267 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); 274 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift);
268 trendline_estimator_->Update(t_delta, ts_delta_ms, 275 trendline_estimator_->Update(t_delta, ts_delta_ms,
269 packet_feedback.arrival_time_ms); 276 packet_feedback.arrival_time_ms);
270 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms, 277 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms,
271 trendline_estimator_->num_of_deltas(), 278 trendline_estimator_->num_of_deltas(),
272 packet_feedback.arrival_time_ms); 279 packet_feedback.arrival_time_ms);
273 } 280 }
274 if (packet_feedback.pacing_info.probe_cluster_id != 281 if (packet_feedback.pacing_info.probe_cluster_id !=
275 PacedPacketInfo::kNotAProbe) { 282 PacedPacketInfo::kNotAProbe) {
276 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback); 283 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 362 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
356 // Called from both the configuration thread and the network thread. Shouldn't 363 // Called from both the configuration thread and the network thread. Shouldn't
357 // be called from the network thread in the future. 364 // be called from the network thread in the future.
358 rate_control_.SetMinBitrate(min_bitrate_bps); 365 rate_control_.SetMinBitrate(min_bitrate_bps);
359 } 366 }
360 367
361 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { 368 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const {
362 return rate_control_.GetExpectedBandwidthPeriodMs(); 369 return rate_control_.GetExpectedBandwidthPeriodMs();
363 } 370 }
364 } // namespace webrtc 371 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698