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

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

Issue 1827953002: Make rtcp sender use max transfer unit. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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) 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void OnPacketReady(uint8_t* data, size_t length) override { 92 void OnPacketReady(uint8_t* data, size_t length) override {
93 if (transport_->SendRtcp(data, length)) { 93 if (transport_->SendRtcp(data, length)) {
94 bytes_sent_ += length; 94 bytes_sent_ += length;
95 if (event_log_) { 95 if (event_log_) {
96 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data, 96 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data,
97 length); 97 length);
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 size_t SendPackets() { 102 size_t SendPackets(size_t max_payload_length) {
103 rtcp::CompoundPacket::Build(this); 103 RTC_DCHECK_LE(max_payload_length, static_cast<size_t>(IP_PACKET_SIZE));
104 uint8_t buffer[IP_PACKET_SIZE];
105 BuildExternalBuffer(buffer, max_payload_length, this);
104 return bytes_sent_; 106 return bytes_sent_;
105 } 107 }
106 108
107 private: 109 private:
108 Transport* transport_; 110 Transport* transport_;
109 RtcEventLog* const event_log_; 111 RtcEventLog* const event_log_;
110 size_t bytes_sent_; 112 size_t bytes_sent_;
111 113
112 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer); 114 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer);
113 }; 115 };
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 remote_ssrc_(0), 164 remote_ssrc_(0),
163 receive_statistics_(receive_statistics), 165 receive_statistics_(receive_statistics),
164 166
165 sequence_number_fir_(0), 167 sequence_number_fir_(0),
166 168
167 remb_bitrate_(0), 169 remb_bitrate_(0),
168 170
169 tmmbr_help_(), 171 tmmbr_help_(),
170 tmmbr_send_(0), 172 tmmbr_send_(0),
171 packet_oh_send_(0), 173 packet_oh_send_(0),
174 max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
172 175
173 app_sub_type_(0), 176 app_sub_type_(0),
174 app_name_(0), 177 app_name_(0),
175 app_data_(nullptr), 178 app_data_(nullptr),
176 app_length_(0), 179 app_length_(0),
177 180
178 xr_send_receiver_reference_time_enabled_(false), 181 xr_send_receiver_reference_time_enabled_(false),
179 packet_type_counter_observer_(packet_type_counter_observer) { 182 packet_type_counter_observer_(packet_type_counter_observer) {
180 RTC_DCHECK(transport_ != nullptr); 183 RTC_DCHECK(transport_ != nullptr);
181 184
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 273
271 void RTCPSender::SetTMMBRStatus(bool enable) { 274 void RTCPSender::SetTMMBRStatus(bool enable) {
272 rtc::CritScope lock(&critical_section_rtcp_sender_); 275 rtc::CritScope lock(&critical_section_rtcp_sender_);
273 if (enable) { 276 if (enable) {
274 SetFlag(RTCPPacketType::kRtcpTmmbr, false); 277 SetFlag(RTCPPacketType::kRtcpTmmbr, false);
275 } else { 278 } else {
276 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true); 279 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true);
277 } 280 }
278 } 281 }
279 282
283 void RTCPSender::SetMaxPayloadLength(size_t max_payload_length) {
284 max_payload_length_ = max_payload_length;
285 }
286
280 void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) { 287 void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) {
281 rtc::CritScope lock(&critical_section_rtcp_sender_); 288 rtc::CritScope lock(&critical_section_rtcp_sender_);
282 start_timestamp_ = start_timestamp; 289 start_timestamp_ = start_timestamp;
283 } 290 }
284 291
285 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, 292 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
286 int64_t capture_time_ms) { 293 int64_t capture_time_ms) {
287 rtc::CritScope lock(&critical_section_rtcp_sender_); 294 rtc::CritScope lock(&critical_section_rtcp_sender_);
288 last_rtp_timestamp_ = rtp_timestamp; 295 last_rtp_timestamp_ = rtp_timestamp;
289 if (capture_time_ms < 0) { 296 if (capture_time_ms < 0) {
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 809 }
803 810
804 if (packet_type_counter_observer_ != nullptr) { 811 if (packet_type_counter_observer_ != nullptr) {
805 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( 812 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated(
806 remote_ssrc_, packet_type_counter_); 813 remote_ssrc_, packet_type_counter_);
807 } 814 }
808 815
809 RTC_DCHECK(AllVolatileFlagsConsumed()); 816 RTC_DCHECK(AllVolatileFlagsConsumed());
810 } 817 }
811 818
812 size_t bytes_sent = container.SendPackets(); 819 size_t bytes_sent = container.SendPackets(max_payload_length_);
813 return bytes_sent == 0 ? -1 : 0; 820 return bytes_sent == 0 ? -1 : 0;
814 } 821 }
815 822
816 void RTCPSender::PrepareReport(const std::set<RTCPPacketType>& packetTypes, 823 void RTCPSender::PrepareReport(const std::set<RTCPPacketType>& packetTypes,
817 const FeedbackState& feedback_state) { 824 const FeedbackState& feedback_state) {
818 // Add all flags as volatile. Non volatile entries will not be overwritten 825 // Add all flags as volatile. Non volatile entries will not be overwritten
819 // and all new volatile flags added will be consumed by the end of this call. 826 // and all new volatile flags added will be consumed by the end of this call.
820 SetFlags(packetTypes, true); 827 SetFlags(packetTypes, true);
821 828
822 if (packet_type_counter_.first_packet_time_ms == -1) 829 if (packet_type_counter_.first_packet_time_ms == -1)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 } 1030 }
1024 1031
1025 Transport* const transport_; 1032 Transport* const transport_;
1026 RtcEventLog* const event_log_; 1033 RtcEventLog* const event_log_;
1027 bool send_failure_; 1034 bool send_failure_;
1028 // TODO(terelius): We would like to 1035 // TODO(terelius): We would like to
1029 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); 1036 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender);
1030 // but we can't because of an incorrect warning (C4822) in MVS 2013. 1037 // but we can't because of an incorrect warning (C4822) in MVS 2013.
1031 } sender(transport_, event_log_); 1038 } sender(transport_, event_log_);
1032 1039
1040 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE));
1033 uint8_t buffer[IP_PACKET_SIZE]; 1041 uint8_t buffer[IP_PACKET_SIZE];
1034 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1042 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) &&
1035 !sender.send_failure_; 1043 !sender.send_failure_;
1036 } 1044 }
1037 1045
1038 } // namespace webrtc 1046 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698