OLD | NEW |
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 size_t bytes_sent_; | 121 size_t bytes_sent_; |
122 | 122 |
123 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer); | 123 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer); |
124 }; | 124 }; |
125 | 125 |
126 class RTCPSender::RtcpContext { | 126 class RTCPSender::RtcpContext { |
127 public: | 127 public: |
128 RtcpContext(const FeedbackState& feedback_state, | 128 RtcpContext(const FeedbackState& feedback_state, |
129 int32_t nack_size, | 129 int32_t nack_size, |
130 const uint16_t* nack_list, | 130 const uint16_t* nack_list, |
131 bool repeat, | |
132 uint64_t picture_id, | 131 uint64_t picture_id, |
133 NtpTime now) | 132 NtpTime now) |
134 : feedback_state_(feedback_state), | 133 : feedback_state_(feedback_state), |
135 nack_size_(nack_size), | 134 nack_size_(nack_size), |
136 nack_list_(nack_list), | 135 nack_list_(nack_list), |
137 repeat_(repeat), | |
138 picture_id_(picture_id), | 136 picture_id_(picture_id), |
139 now_(now) {} | 137 now_(now) {} |
140 | 138 |
141 const FeedbackState& feedback_state_; | 139 const FeedbackState& feedback_state_; |
142 const int32_t nack_size_; | 140 const int32_t nack_size_; |
143 const uint16_t* nack_list_; | 141 const uint16_t* nack_list_; |
144 const bool repeat_; | |
145 const uint64_t picture_id_; | 142 const uint64_t picture_id_; |
146 const NtpTime now_; | 143 const NtpTime now_; |
147 }; | 144 }; |
148 | 145 |
149 RTCPSender::RTCPSender( | 146 RTCPSender::RTCPSender( |
150 bool audio, | 147 bool audio, |
151 Clock* clock, | 148 Clock* clock, |
152 ReceiveStatistics* receive_statistics, | 149 ReceiveStatistics* receive_statistics, |
153 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 150 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
154 RtcEventLog* event_log, | 151 RtcEventLog* event_log, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 492 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
496 "RTCPSender::PLI"); | 493 "RTCPSender::PLI"); |
497 ++packet_type_counter_.pli_packets; | 494 ++packet_type_counter_.pli_packets; |
498 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_PLICount", | 495 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_PLICount", |
499 ssrc_, packet_type_counter_.pli_packets); | 496 ssrc_, packet_type_counter_.pli_packets); |
500 | 497 |
501 return std::unique_ptr<rtcp::RtcpPacket>(pli); | 498 return std::unique_ptr<rtcp::RtcpPacket>(pli); |
502 } | 499 } |
503 | 500 |
504 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildFIR(const RtcpContext& ctx) { | 501 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildFIR(const RtcpContext& ctx) { |
505 if (!ctx.repeat_) | 502 ++sequence_number_fir_; |
506 ++sequence_number_fir_; // Do not increase if repetition. | |
507 | 503 |
508 rtcp::Fir* fir = new rtcp::Fir(); | 504 rtcp::Fir* fir = new rtcp::Fir(); |
509 fir->SetSenderSsrc(ssrc_); | 505 fir->SetSenderSsrc(ssrc_); |
510 fir->AddRequestTo(remote_ssrc_, sequence_number_fir_); | 506 fir->AddRequestTo(remote_ssrc_, sequence_number_fir_); |
511 | 507 |
512 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 508 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
513 "RTCPSender::FIR"); | 509 "RTCPSender::FIR"); |
514 ++packet_type_counter_.fir_packets; | 510 ++packet_type_counter_.fir_packets; |
515 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_FIRCount", | 511 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RTCP_FIRCount", |
516 ssrc_, packet_type_counter_.fir_packets); | 512 ssrc_, packet_type_counter_.fir_packets); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 xr->SetVoipMetric(voip); | 728 xr->SetVoipMetric(voip); |
733 } | 729 } |
734 | 730 |
735 return std::move(xr); | 731 return std::move(xr); |
736 } | 732 } |
737 | 733 |
738 int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, | 734 int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state, |
739 RTCPPacketType packetType, | 735 RTCPPacketType packetType, |
740 int32_t nack_size, | 736 int32_t nack_size, |
741 const uint16_t* nack_list, | 737 const uint16_t* nack_list, |
742 bool repeat, | |
743 uint64_t pictureID) { | 738 uint64_t pictureID) { |
744 return SendCompoundRTCP( | 739 return SendCompoundRTCP( |
745 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1), | 740 feedback_state, std::set<RTCPPacketType>(&packetType, &packetType + 1), |
746 nack_size, nack_list, repeat, pictureID); | 741 nack_size, nack_list, pictureID); |
747 } | 742 } |
748 | 743 |
749 int32_t RTCPSender::SendCompoundRTCP( | 744 int32_t RTCPSender::SendCompoundRTCP( |
750 const FeedbackState& feedback_state, | 745 const FeedbackState& feedback_state, |
751 const std::set<RTCPPacketType>& packet_types, | 746 const std::set<RTCPPacketType>& packet_types, |
752 int32_t nack_size, | 747 int32_t nack_size, |
753 const uint16_t* nack_list, | 748 const uint16_t* nack_list, |
754 bool repeat, | |
755 uint64_t pictureID) { | 749 uint64_t pictureID) { |
756 PacketContainer container(transport_, event_log_); | 750 PacketContainer container(transport_, event_log_); |
757 { | 751 { |
758 rtc::CritScope lock(&critical_section_rtcp_sender_); | 752 rtc::CritScope lock(&critical_section_rtcp_sender_); |
759 if (method_ == RtcpMode::kOff) { | 753 if (method_ == RtcpMode::kOff) { |
760 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; | 754 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; |
761 return -1; | 755 return -1; |
762 } | 756 } |
763 // Add all flags as volatile. Non volatile entries will not be overwritten. | 757 // Add all flags as volatile. Non volatile entries will not be overwritten. |
764 // All new volatile flags added will be consumed by the end of this call. | 758 // All new volatile flags added will be consumed by the end of this call. |
(...skipping 12 matching lines...) Expand all Loading... |
777 if (sending_ && method_ == RtcpMode::kCompound) { | 771 if (sending_ && method_ == RtcpMode::kCompound) { |
778 // Not allowed to send any RTCP packet without sender report. | 772 // Not allowed to send any RTCP packet without sender report. |
779 return -1; | 773 return -1; |
780 } | 774 } |
781 } | 775 } |
782 | 776 |
783 if (packet_type_counter_.first_packet_time_ms == -1) | 777 if (packet_type_counter_.first_packet_time_ms == -1) |
784 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds(); | 778 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds(); |
785 | 779 |
786 // We need to send our NTP even if we haven't received any reports. | 780 // We need to send our NTP even if we haven't received any reports. |
787 RtcpContext context(feedback_state, nack_size, nack_list, repeat, pictureID, | 781 RtcpContext context(feedback_state, nack_size, nack_list, pictureID, |
788 NtpTime(*clock_)); | 782 NtpTime(*clock_)); |
789 | 783 |
790 PrepareReport(feedback_state); | 784 PrepareReport(feedback_state); |
791 | 785 |
792 std::unique_ptr<rtcp::RtcpPacket> packet_bye; | 786 std::unique_ptr<rtcp::RtcpPacket> packet_bye; |
793 | 787 |
794 auto it = report_flags_.begin(); | 788 auto it = report_flags_.begin(); |
795 while (it != report_flags_.end()) { | 789 while (it != report_flags_.end()) { |
796 auto builder_it = builders_.find(it->type); | 790 auto builder_it = builders_.find(it->type); |
797 RTC_DCHECK(builder_it != builders_.end()) | 791 RTC_DCHECK(builder_it != builders_.end()) |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 return false; | 1049 return false; |
1056 } | 1050 } |
1057 | 1051 |
1058 RTC_DCHECK_LE(max_packet_size_, IP_PACKET_SIZE); | 1052 RTC_DCHECK_LE(max_packet_size_, IP_PACKET_SIZE); |
1059 uint8_t buffer[IP_PACKET_SIZE]; | 1053 uint8_t buffer[IP_PACKET_SIZE]; |
1060 return packet.BuildExternalBuffer(buffer, max_packet_size_, &sender) && | 1054 return packet.BuildExternalBuffer(buffer, max_packet_size_, &sender) && |
1061 !sender.send_failure_; | 1055 !sender.send_failure_; |
1062 } | 1056 } |
1063 | 1057 |
1064 } // namespace webrtc | 1058 } // namespace webrtc |
OLD | NEW |