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

Side by Side Diff: webrtc/video/video_send_stream.cc

Issue 2589743002: Make OverheadObserver::OnOverheadChanged count RTP headers only (Closed)
Patch Set: Created 4 years 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 #include "webrtc/video/video_send_stream.h" 10 #include "webrtc/video/video_send_stream.h"
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps, 1181 uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps,
1182 uint8_t fraction_loss, 1182 uint8_t fraction_loss,
1183 int64_t rtt, 1183 int64_t rtt,
1184 int64_t probing_interval_ms) { 1184 int64_t probing_interval_ms) {
1185 RTC_DCHECK_RUN_ON(worker_queue_); 1185 RTC_DCHECK_RUN_ON(worker_queue_);
1186 RTC_DCHECK(payload_router_.IsActive()) 1186 RTC_DCHECK(payload_router_.IsActive())
1187 << "VideoSendStream::Start has not been called."; 1187 << "VideoSendStream::Start has not been called.";
1188 1188
1189 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") == 1189 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") ==
1190 "Enabled") { 1190 "Enabled") {
1191 // Substract overhead from bitrate. 1191 // Substract total overhead (transport + rtp) from bitrate.
1192 rtc::CritScope lock(&overhead_bytes_per_packet_crit_); 1192 int rtp_overhead;
1193 int packets_per_second = 1193 {
1194 std::ceil(bitrate_bps / (8 * (config_->rtp.max_packet_size + 1194 rtc::CritScope lock(&overhead_bytes_per_packet_crit_);
1195 transport_overhead_bytes_per_packet_))); 1195 rtp_overhead = overhead_bytes_per_packet_;
1196 uint32_t overhead_bps = static_cast<uint32_t>( 1196 }
1197 8 * overhead_bytes_per_packet_ * packets_per_second); 1197 RTC_CHECK_GE(rtp_overhead, 0);
1198 bitrate_bps = overhead_bps > bitrate_bps ? 0u : bitrate_bps - overhead_bps; 1198 RTC_DCHECK_LT(rtp_overhead, config_->rtp.max_packet_size);
1199 if (static_cast<size_t>(rtp_overhead) >= config_->rtp.max_packet_size) {
1200 bitrate_bps = 0;
1201 } else {
1202 bitrate_bps =
1203 (uint64_t) bitrate_bps *
stefan-webrtc 2016/12/19 13:55:41 static_cast please
nisse-webrtc 2016/12/19 14:41:04 Done.
1204 (config_->rtp.max_packet_size - rtp_overhead) /
1205 (config_->rtp.max_packet_size + transport_overhead_bytes_per_packet_);
1206 }
1199 } 1207 }
1200 1208
1201 // Get the encoder target rate. It is the estimated network rate - 1209 // Get the encoder target rate. It is the estimated network rate -
1202 // protection overhead. 1210 // protection overhead.
1203 encoder_target_rate_bps_ = protection_bitrate_calculator_.SetTargetRates( 1211 encoder_target_rate_bps_ = protection_bitrate_calculator_.SetTargetRates(
1204 bitrate_bps, stats_proxy_->GetSendFrameRate(), fraction_loss, rtt); 1212 bitrate_bps, stats_proxy_->GetSendFrameRate(), fraction_loss, rtt);
1205 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps_; 1213 uint32_t protection_bitrate = bitrate_bps - encoder_target_rate_bps_;
1206 1214
1207 encoder_target_rate_bps_ = 1215 encoder_target_rate_bps_ =
1208 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_); 1216 std::min(encoder_max_bitrate_bps_, encoder_target_rate_bps_);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 overhead_bytes_per_packet_ = overhead_bytes_per_packet; 1270 overhead_bytes_per_packet_ = overhead_bytes_per_packet;
1263 } 1271 }
1264 1272
1265 void VideoSendStreamImpl::SetTransportOverhead( 1273 void VideoSendStreamImpl::SetTransportOverhead(
1266 int transport_overhead_bytes_per_packet) { 1274 int transport_overhead_bytes_per_packet) {
1267 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; 1275 transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet;
1268 RTC_DCHECK_LE(config_->rtp.max_packet_size, 1276 RTC_DCHECK_LE(config_->rtp.max_packet_size,
1269 0xFFFFu + transport_overhead_bytes_per_packet); 1277 0xFFFFu + transport_overhead_bytes_per_packet);
1270 const uint16_t mtu = static_cast<uint16_t>( 1278 const uint16_t mtu = static_cast<uint16_t>(
1271 config_->rtp.max_packet_size + transport_overhead_bytes_per_packet); 1279 config_->rtp.max_packet_size + transport_overhead_bytes_per_packet);
1280 congestion_controller_->SetTransportOverhead(
1281 transport_overhead_bytes_per_packet);
1282
1272 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 1283 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
1273 rtp_rtcp->SetTransportOverhead(transport_overhead_bytes_per_packet); 1284 // TODO(nisse): Also call SetMaxPayloadLength?
nisse-webrtc 2016/12/19 12:37:23 I don't quite get the notation here. The deleted S
stefan-webrtc 2016/12/19 13:55:41 This is probably legacy. We should clean it up the
michaelt 2016/12/19 14:17:01 Calling SetMaxTransferUnit here will be senseless.
nisse-webrtc 2016/12/19 14:41:04 I'll give it a try.
1274 rtp_rtcp->SetMaxTransferUnit(mtu); 1285 rtp_rtcp->SetMaxTransferUnit(mtu);
1275 } 1286 }
1276 } 1287 }
1277 1288
1278 } // namespace internal 1289 } // namespace internal
1279 } // namespace webrtc 1290 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698