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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.cc

Issue 2589743002: Make OverheadObserver::OnOverheadChanged count RTP headers only (Closed)
Patch Set: Add explicit cast. Created 3 years, 11 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 clock_delta_ms_(clock_->TimeInMilliseconds() - rtc::TimeMillis()), 85 clock_delta_ms_(clock_->TimeInMilliseconds() - rtc::TimeMillis()),
86 random_(clock_->TimeInMicroseconds()), 86 random_(clock_->TimeInMicroseconds()),
87 audio_configured_(audio), 87 audio_configured_(audio),
88 audio_(audio ? new RTPSenderAudio(clock, this) : nullptr), 88 audio_(audio ? new RTPSenderAudio(clock, this) : nullptr),
89 video_(audio ? nullptr : new RTPSenderVideo(clock, this, flexfec_sender)), 89 video_(audio ? nullptr : new RTPSenderVideo(clock, this, flexfec_sender)),
90 paced_sender_(paced_sender), 90 paced_sender_(paced_sender),
91 transport_sequence_number_allocator_(sequence_number_allocator), 91 transport_sequence_number_allocator_(sequence_number_allocator),
92 transport_feedback_observer_(transport_feedback_observer), 92 transport_feedback_observer_(transport_feedback_observer),
93 last_capture_time_ms_sent_(0), 93 last_capture_time_ms_sent_(0),
94 transport_(transport), 94 transport_(transport),
95 sending_media_(true), // Default to sending media. 95 sending_media_(true), // Default to sending media.
96 max_payload_length_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP. 96 max_packet_size_(IP_PACKET_SIZE - 28), // Default is IP-v4/UDP.
97 payload_type_(-1), 97 payload_type_(-1),
98 payload_type_map_(), 98 payload_type_map_(),
99 rtp_header_extension_map_(), 99 rtp_header_extension_map_(),
100 packet_history_(clock), 100 packet_history_(clock),
101 flexfec_packet_history_(clock), 101 flexfec_packet_history_(clock),
102 // Statistics 102 // Statistics
103 rtp_stats_callback_(nullptr), 103 rtp_stats_callback_(nullptr),
104 total_bitrate_sent_(kBitrateStatisticsWindowMs, 104 total_bitrate_sent_(kBitrateStatisticsWindowMs,
105 RateStatistics::kBpsScale), 105 RateStatistics::kBpsScale),
106 nack_bitrate_sent_(kBitrateStatisticsWindowMs, RateStatistics::kBpsScale), 106 nack_bitrate_sent_(kBitrateStatisticsWindowMs, RateStatistics::kBpsScale),
107 frame_count_observer_(frame_count_observer), 107 frame_count_observer_(frame_count_observer),
108 send_side_delay_observer_(send_side_delay_observer), 108 send_side_delay_observer_(send_side_delay_observer),
109 event_log_(event_log), 109 event_log_(event_log),
110 send_packet_observer_(send_packet_observer), 110 send_packet_observer_(send_packet_observer),
111 bitrate_callback_(bitrate_callback), 111 bitrate_callback_(bitrate_callback),
112 // RTP variables 112 // RTP variables
113 ssrc_db_(SSRCDatabase::GetSSRCDatabase()), 113 ssrc_db_(SSRCDatabase::GetSSRCDatabase()),
114 remote_ssrc_(0), 114 remote_ssrc_(0),
115 sequence_number_forced_(false), 115 sequence_number_forced_(false),
116 ssrc_forced_(false), 116 ssrc_forced_(false),
117 last_rtp_timestamp_(0), 117 last_rtp_timestamp_(0),
118 capture_time_ms_(0), 118 capture_time_ms_(0),
119 last_timestamp_time_ms_(0), 119 last_timestamp_time_ms_(0),
120 media_has_been_sent_(false), 120 media_has_been_sent_(false),
121 last_packet_marker_bit_(false), 121 last_packet_marker_bit_(false),
122 csrcs_(), 122 csrcs_(),
123 rtx_(kRtxOff), 123 rtx_(kRtxOff),
124 transport_overhead_bytes_per_packet_(0),
125 rtp_overhead_bytes_per_packet_(0), 124 rtp_overhead_bytes_per_packet_(0),
126 retransmission_rate_limiter_(retransmission_rate_limiter), 125 retransmission_rate_limiter_(retransmission_rate_limiter),
127 overhead_observer_(overhead_observer) { 126 overhead_observer_(overhead_observer) {
128 ssrc_ = ssrc_db_->CreateSSRC(); 127 ssrc_ = ssrc_db_->CreateSSRC();
129 RTC_DCHECK(ssrc_ != 0); 128 RTC_DCHECK(ssrc_ != 0);
130 ssrc_rtx_ = ssrc_db_->CreateSSRC(); 129 ssrc_rtx_ = ssrc_db_->CreateSSRC();
131 RTC_DCHECK(ssrc_rtx_ != 0); 130 RTC_DCHECK(ssrc_rtx_ != 0);
132 131
133 // This random initialization is not intended to be cryptographic strong. 132 // This random initialization is not intended to be cryptographic strong.
134 timestamp_offset_ = random_.Rand<uint32_t>(); 133 timestamp_offset_ = random_.Rand<uint32_t>();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 void RTPSender::SetSendPayloadType(int8_t payload_type) { 289 void RTPSender::SetSendPayloadType(int8_t payload_type) {
291 rtc::CritScope lock(&send_critsect_); 290 rtc::CritScope lock(&send_critsect_);
292 payload_type_ = payload_type; 291 payload_type_ = payload_type;
293 } 292 }
294 293
295 int8_t RTPSender::SendPayloadType() const { 294 int8_t RTPSender::SendPayloadType() const {
296 rtc::CritScope lock(&send_critsect_); 295 rtc::CritScope lock(&send_critsect_);
297 return payload_type_; 296 return payload_type_;
298 } 297 }
299 298
300 void RTPSender::SetMaxPayloadLength(size_t max_payload_length) { 299 void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
301 // Sanity check. 300 // Sanity check.
302 RTC_DCHECK(max_payload_length >= 100 && max_payload_length <= IP_PACKET_SIZE) 301 RTC_DCHECK(max_packet_size >= 100 && max_packet_size <= IP_PACKET_SIZE)
303 << "Invalid max payload length: " << max_payload_length; 302 << "Invalid max payload length: " << max_packet_size;
304 rtc::CritScope lock(&send_critsect_); 303 rtc::CritScope lock(&send_critsect_);
305 max_payload_length_ = max_payload_length; 304 max_packet_size_ = max_packet_size;
306 } 305 }
307 306
308 size_t RTPSender::MaxDataPayloadLength() const { 307 size_t RTPSender::MaxPayloadSize() const {
309 if (audio_configured_) { 308 if (audio_configured_) {
310 return max_payload_length_ - RtpHeaderLength(); 309 return max_packet_size_ - RtpHeaderLength();
311 } else { 310 } else {
312 return max_payload_length_ - RtpHeaderLength() // RTP overhead. 311 return max_packet_size_ - RtpHeaderLength() // RTP overhead.
313 - video_->FecPacketOverhead() // FEC/ULP/RED overhead. 312 - video_->FecPacketOverhead() // FEC/ULP/RED overhead.
314 - (RtxStatus() ? kRtxHeaderSize : 0); // RTX overhead. 313 - (RtxStatus() ? kRtxHeaderSize : 0); // RTX overhead.
315 } 314 }
316 } 315 }
317 316
318 size_t RTPSender::MaxPayloadLength() const { 317 size_t RTPSender::MaxRtpPacketSize() const {
319 return max_payload_length_; 318 return max_packet_size_;
320 } 319 }
321 320
322 void RTPSender::SetRtxStatus(int mode) { 321 void RTPSender::SetRtxStatus(int mode) {
323 rtc::CritScope lock(&send_critsect_); 322 rtc::CritScope lock(&send_critsect_);
324 rtx_ = mode; 323 rtx_ = mode;
325 } 324 }
326 325
327 int RTPSender::RtxStatus() const { 326 int RTPSender::RtxStatus() const {
328 rtc::CritScope lock(&send_critsect_); 327 rtc::CritScope lock(&send_critsect_);
329 return rtx_; 328 return rtx_;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 bytes_left -= payload_size; 475 bytes_left -= payload_size;
477 } 476 }
478 return bytes_to_send - bytes_left; 477 return bytes_to_send - bytes_left;
479 } 478 }
480 479
481 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) { 480 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) {
482 // Always send full padding packets. This is accounted for by the 481 // Always send full padding packets. This is accounted for by the
483 // RtpPacketSender, which will make sure we don't send too much padding even 482 // RtpPacketSender, which will make sure we don't send too much padding even
484 // if a single packet is larger than requested. 483 // if a single packet is larger than requested.
485 size_t padding_bytes_in_packet = 484 size_t padding_bytes_in_packet =
486 std::min(MaxDataPayloadLength(), kMaxPaddingLength); 485 std::min(MaxPayloadSize(), kMaxPaddingLength);
487 size_t bytes_sent = 0; 486 size_t bytes_sent = 0;
488 while (bytes_sent < bytes) { 487 while (bytes_sent < bytes) {
489 int64_t now_ms = clock_->TimeInMilliseconds(); 488 int64_t now_ms = clock_->TimeInMilliseconds();
490 uint32_t ssrc; 489 uint32_t ssrc;
491 uint32_t timestamp; 490 uint32_t timestamp;
492 int64_t capture_time_ms; 491 int64_t capture_time_ms;
493 uint16_t sequence_number; 492 uint16_t sequence_number;
494 int payload_type; 493 int payload_type;
495 bool over_rtx; 494 bool over_rtx;
496 { 495 {
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 void RTPSender::GetDataCounters(StreamDataCounters* rtp_stats, 966 void RTPSender::GetDataCounters(StreamDataCounters* rtp_stats,
968 StreamDataCounters* rtx_stats) const { 967 StreamDataCounters* rtx_stats) const {
969 rtc::CritScope lock(&statistics_crit_); 968 rtc::CritScope lock(&statistics_crit_);
970 *rtp_stats = rtp_stats_; 969 *rtp_stats = rtp_stats_;
971 *rtx_stats = rtx_rtp_stats_; 970 *rtx_stats = rtx_rtp_stats_;
972 } 971 }
973 972
974 std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket() const { 973 std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket() const {
975 rtc::CritScope lock(&send_critsect_); 974 rtc::CritScope lock(&send_critsect_);
976 std::unique_ptr<RtpPacketToSend> packet( 975 std::unique_ptr<RtpPacketToSend> packet(
977 new RtpPacketToSend(&rtp_header_extension_map_, max_payload_length_)); 976 new RtpPacketToSend(&rtp_header_extension_map_, max_packet_size_));
978 packet->SetSsrc(ssrc_); 977 packet->SetSsrc(ssrc_);
979 packet->SetCsrcs(csrcs_); 978 packet->SetCsrcs(csrcs_);
980 // Reserve extensions, if registered, RtpSender set in SendToNetwork. 979 // Reserve extensions, if registered, RtpSender set in SendToNetwork.
981 packet->ReserveExtension<AbsoluteSendTime>(); 980 packet->ReserveExtension<AbsoluteSendTime>();
982 packet->ReserveExtension<TransmissionOffset>(); 981 packet->ReserveExtension<TransmissionOffset>();
983 packet->ReserveExtension<TransportSequenceNumber>(); 982 packet->ReserveExtension<TransportSequenceNumber>();
984 if (playout_delay_oracle_.send_playout_delay()) { 983 if (playout_delay_oracle_.send_playout_delay()) {
985 packet->SetExtension<PlayoutDelayLimits>( 984 packet->SetExtension<PlayoutDelayLimits>(
986 playout_delay_oracle_.playout_delay()); 985 playout_delay_oracle_.playout_delay());
987 } 986 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 RtpState RTPSender::GetRtxRtpState() const { 1245 RtpState RTPSender::GetRtxRtpState() const {
1247 rtc::CritScope lock(&send_critsect_); 1246 rtc::CritScope lock(&send_critsect_);
1248 1247
1249 RtpState state; 1248 RtpState state;
1250 state.sequence_number = sequence_number_rtx_; 1249 state.sequence_number = sequence_number_rtx_;
1251 state.start_timestamp = timestamp_offset_; 1250 state.start_timestamp = timestamp_offset_;
1252 1251
1253 return state; 1252 return state;
1254 } 1253 }
1255 1254
1256 void RTPSender::SetTransportOverhead(int transport_overhead) {
1257 if (!overhead_observer_)
1258 return;
1259 size_t overhead_bytes_per_packet = 0;
1260 {
1261 rtc::CritScope lock(&send_critsect_);
1262 if (transport_overhead_bytes_per_packet_ ==
1263 static_cast<size_t>(transport_overhead)) {
1264 return;
1265 }
1266 transport_overhead_bytes_per_packet_ = transport_overhead;
1267 overhead_bytes_per_packet =
1268 rtp_overhead_bytes_per_packet_ + transport_overhead_bytes_per_packet_;
1269 }
1270 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet);
1271 }
1272
1273 void RTPSender::AddPacketToTransportFeedback(uint16_t packet_id, 1255 void RTPSender::AddPacketToTransportFeedback(uint16_t packet_id,
1274 const RtpPacketToSend& packet, 1256 const RtpPacketToSend& packet,
1275 int probe_cluster_id) { 1257 int probe_cluster_id) {
1276 size_t packet_size = packet.payload_size() + packet.padding_size(); 1258 size_t packet_size = packet.payload_size() + packet.padding_size();
1277 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") == 1259 if (webrtc::field_trial::FindFullName("WebRTC-SendSideBwe-WithOverhead") ==
1278 "Enabled") { 1260 "Enabled") {
1279 rtc::CritScope lock(&send_critsect_); 1261 packet_size = packet.size();
1280 packet_size = packet.size() + transport_overhead_bytes_per_packet_;
1281 } 1262 }
1282 1263
1283 if (transport_feedback_observer_) { 1264 if (transport_feedback_observer_) {
1284 transport_feedback_observer_->AddPacket(packet_id, packet_size, 1265 transport_feedback_observer_->AddPacket(packet_id, packet_size,
1285 probe_cluster_id); 1266 probe_cluster_id);
1286 } 1267 }
1287 } 1268 }
1288 1269
1289 void RTPSender::UpdateRtpOverhead(const RtpPacketToSend& packet) { 1270 void RTPSender::UpdateRtpOverhead(const RtpPacketToSend& packet) {
1290 if (!overhead_observer_) 1271 if (!overhead_observer_)
1291 return; 1272 return;
1292 size_t overhead_bytes_per_packet = 0; 1273 size_t overhead_bytes_per_packet;
1293 { 1274 {
1294 rtc::CritScope lock(&send_critsect_); 1275 rtc::CritScope lock(&send_critsect_);
1295 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { 1276 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) {
1296 return; 1277 return;
1297 } 1278 }
1298 rtp_overhead_bytes_per_packet_ = packet.headers_size(); 1279 rtp_overhead_bytes_per_packet_ = packet.headers_size();
1299 overhead_bytes_per_packet = 1280 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_;
1300 rtp_overhead_bytes_per_packet_ + transport_overhead_bytes_per_packet_;
1301 } 1281 }
1302 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); 1282 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet);
1303 } 1283 }
1304 1284
1305 } // namespace webrtc 1285 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698