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

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, 9 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ssrc_(0), 163 ssrc_(0),
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_overhead_(28),
174 max_payload_length_(IP_PACKET_SIZE - packet_overhead_),
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 length, uint16_t packet_overhead) {
284 rtc::CritScope lock(&critical_section_rtcp_sender_);
285 max_payload_length_ = length;
286 packet_overhead_ = packet_overhead;
287 }
288
280 void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) { 289 void RTCPSender::SetStartTimestamp(uint32_t start_timestamp) {
281 rtc::CritScope lock(&critical_section_rtcp_sender_); 290 rtc::CritScope lock(&critical_section_rtcp_sender_);
282 start_timestamp_ = start_timestamp; 291 start_timestamp_ = start_timestamp;
283 } 292 }
284 293
285 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, 294 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp,
286 int64_t capture_time_ms) { 295 int64_t capture_time_ms) {
287 rtc::CritScope lock(&critical_section_rtcp_sender_); 296 rtc::CritScope lock(&critical_section_rtcp_sender_);
288 last_rtp_timestamp_ = rtp_timestamp; 297 last_rtp_timestamp_ = rtp_timestamp;
289 if (capture_time_ms < 0) { 298 if (capture_time_ms < 0) {
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 592
584 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which 593 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which
585 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but 594 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
586 // since RTCPreceiver is not doing the reverse we should be fine 595 // since RTCPreceiver is not doing the reverse we should be fine
587 int32_t lengthOfBoundingSet = 596 int32_t lengthOfBoundingSet =
588 ctx.feedback_state_.module->BoundingSet(&tmmbrOwner, candidateSet); 597 ctx.feedback_state_.module->BoundingSet(&tmmbrOwner, candidateSet);
589 598
590 if (lengthOfBoundingSet > 0) { 599 if (lengthOfBoundingSet > 0) {
591 for (int32_t i = 0; i < lengthOfBoundingSet; i++) { 600 for (int32_t i = 0; i < lengthOfBoundingSet; i++) {
592 if (candidateSet->Tmmbr(i) == tmmbr_send_ && 601 if (candidateSet->Tmmbr(i) == tmmbr_send_ &&
593 candidateSet->PacketOH(i) == packet_oh_send_) { 602 candidateSet->PacketOH(i) == packet_overhead_) {
594 // Do not send the same tuple. 603 // Do not send the same tuple.
595 return nullptr; 604 return nullptr;
596 } 605 }
597 } 606 }
598 if (!tmmbrOwner) { 607 if (!tmmbrOwner) {
599 // use received bounding set as candidate set 608 // use received bounding set as candidate set
600 // add current tuple 609 // add current tuple
601 candidateSet->SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_oh_send_, 610 candidateSet->SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_overhead_,
åsapersson 2016/03/30 10:28:36 Should packet_overhead_ for tmmbr include the RTP
danilchap 2016/03/30 12:38:24 Yes, in fact it should, as well as rtp header exte
602 ssrc_); 611 ssrc_);
603 int numCandidates = lengthOfBoundingSet + 1; 612 int numCandidates = lengthOfBoundingSet + 1;
604 613
605 // find bounding set 614 // find bounding set
606 TMMBRSet* boundingSet = nullptr; 615 TMMBRSet* boundingSet = nullptr;
607 int numBoundingSet = tmmbr_help_.FindTMMBRBoundingSet(boundingSet); 616 int numBoundingSet = tmmbr_help_.FindTMMBRBoundingSet(boundingSet);
608 if (numBoundingSet > 0 || numBoundingSet <= numCandidates) 617 if (numBoundingSet > 0 || numBoundingSet <= numCandidates)
609 tmmbrOwner = tmmbr_help_.IsOwner(ssrc_, numBoundingSet); 618 tmmbrOwner = tmmbr_help_.IsOwner(ssrc_, numBoundingSet);
610 if (!tmmbrOwner) { 619 if (!tmmbrOwner) {
611 // Did not enter bounding set, no meaning to send this request. 620 // Did not enter bounding set, no meaning to send this request.
612 return nullptr; 621 return nullptr;
613 } 622 }
614 } 623 }
615 } 624 }
616 625
617 if (!tmmbr_send_) 626 if (!tmmbr_send_)
618 return nullptr; 627 return nullptr;
619 628
620 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr(); 629 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
621 tmmbr->From(ssrc_); 630 tmmbr->From(ssrc_);
622 rtcp::TmmbItem request; 631 rtcp::TmmbItem request;
623 request.set_ssrc(remote_ssrc_); 632 request.set_ssrc(remote_ssrc_);
624 request.set_bitrate_bps(tmmbr_send_ * 1000); 633 request.set_bitrate_bps(tmmbr_send_ * 1000);
625 request.set_packet_overhead(packet_oh_send_); 634 request.set_packet_overhead(packet_overhead_);
626 tmmbr->WithTmmbr(request); 635 tmmbr->WithTmmbr(request);
627 636
628 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr); 637 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr);
629 } 638 }
630 639
631 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN( 640 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN(
632 const RtcpContext& ctx) { 641 const RtcpContext& ctx) {
633 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend(); 642 TMMBRSet* boundingSet = tmmbr_help_.BoundingSetToSend();
634 if (boundingSet == nullptr) 643 if (boundingSet == nullptr)
635 return nullptr; 644 return nullptr;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 811 }
803 812
804 if (packet_type_counter_observer_ != nullptr) { 813 if (packet_type_counter_observer_ != nullptr) {
805 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( 814 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated(
806 remote_ssrc_, packet_type_counter_); 815 remote_ssrc_, packet_type_counter_);
807 } 816 }
808 817
809 RTC_DCHECK(AllVolatileFlagsConsumed()); 818 RTC_DCHECK(AllVolatileFlagsConsumed());
810 } 819 }
811 820
812 size_t bytes_sent = container.SendPackets(); 821 size_t bytes_sent = container.SendPackets(max_payload_length_);
813 return bytes_sent == 0 ? -1 : 0; 822 return bytes_sent == 0 ? -1 : 0;
814 } 823 }
815 824
816 void RTCPSender::PrepareReport(const std::set<RTCPPacketType>& packetTypes, 825 void RTCPSender::PrepareReport(const std::set<RTCPPacketType>& packetTypes,
817 const FeedbackState& feedback_state) { 826 const FeedbackState& feedback_state) {
818 // Add all flags as volatile. Non volatile entries will not be overwritten 827 // 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. 828 // and all new volatile flags added will be consumed by the end of this call.
820 SetFlags(packetTypes, true); 829 SetFlags(packetTypes, true);
821 830
822 if (packet_type_counter_.first_packet_time_ms == -1) 831 if (packet_type_counter_.first_packet_time_ms == -1)
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 } 1032 }
1024 1033
1025 Transport* const transport_; 1034 Transport* const transport_;
1026 RtcEventLog* const event_log_; 1035 RtcEventLog* const event_log_;
1027 bool send_failure_; 1036 bool send_failure_;
1028 // TODO(terelius): We would like to 1037 // TODO(terelius): We would like to
1029 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); 1038 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender);
1030 // but we can't because of an incorrect warning (C4822) in MVS 2013. 1039 // but we can't because of an incorrect warning (C4822) in MVS 2013.
1031 } sender(transport_, event_log_); 1040 } sender(transport_, event_log_);
1032 1041
1042 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE));
1033 uint8_t buffer[IP_PACKET_SIZE]; 1043 uint8_t buffer[IP_PACKET_SIZE];
1034 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1044 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) &&
1035 !sender.send_failure_; 1045 !sender.send_failure_;
1036 } 1046 }
1037 1047
1038 } // namespace webrtc 1048 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698