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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 void RTCPSender::SetTMMBRStatus(bool enable) { | 275 void RTCPSender::SetTMMBRStatus(bool enable) { |
276 rtc::CritScope lock(&critical_section_rtcp_sender_); | 276 rtc::CritScope lock(&critical_section_rtcp_sender_); |
277 if (enable) { | 277 if (enable) { |
278 SetFlag(RTCPPacketType::kRtcpTmmbr, false); | 278 SetFlag(RTCPPacketType::kRtcpTmmbr, false); |
279 } else { | 279 } else { |
280 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true); | 280 ConsumeFlag(RTCPPacketType::kRtcpTmmbr, true); |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) { | 284 void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) { |
285 rtc::CritScope lock(&critical_section_rtcp_sender_); | |
285 max_packet_size_ = max_packet_size; | 286 max_packet_size_ = max_packet_size; |
286 } | 287 } |
287 | 288 |
288 void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) { | 289 void RTCPSender::SetTimestampOffset(uint32_t timestamp_offset) { |
289 rtc::CritScope lock(&critical_section_rtcp_sender_); | 290 rtc::CritScope lock(&critical_section_rtcp_sender_); |
290 timestamp_offset_ = timestamp_offset; | 291 timestamp_offset_ = timestamp_offset; |
291 } | 292 } |
292 | 293 |
293 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, | 294 void RTCPSender::SetLastRtpTime(uint32_t rtp_timestamp, |
294 int64_t capture_time_ms) { | 295 int64_t capture_time_ms) { |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 nack_size, nack_list, pictureID); | 743 nack_size, nack_list, pictureID); |
743 } | 744 } |
744 | 745 |
745 int32_t RTCPSender::SendCompoundRTCP( | 746 int32_t RTCPSender::SendCompoundRTCP( |
746 const FeedbackState& feedback_state, | 747 const FeedbackState& feedback_state, |
747 const std::set<RTCPPacketType>& packet_types, | 748 const std::set<RTCPPacketType>& packet_types, |
748 int32_t nack_size, | 749 int32_t nack_size, |
749 const uint16_t* nack_list, | 750 const uint16_t* nack_list, |
750 uint64_t pictureID) { | 751 uint64_t pictureID) { |
751 PacketContainer container(transport_, event_log_); | 752 PacketContainer container(transport_, event_log_); |
753 size_t max_packet_size; | |
754 | |
752 { | 755 { |
753 rtc::CritScope lock(&critical_section_rtcp_sender_); | 756 rtc::CritScope lock(&critical_section_rtcp_sender_); |
754 if (method_ == RtcpMode::kOff) { | 757 if (method_ == RtcpMode::kOff) { |
755 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; | 758 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; |
756 return -1; | 759 return -1; |
757 } | 760 } |
758 // Add all flags as volatile. Non volatile entries will not be overwritten. | 761 // Add all flags as volatile. Non volatile entries will not be overwritten. |
759 // All new volatile flags added will be consumed by the end of this call. | 762 // All new volatile flags added will be consumed by the end of this call. |
760 SetFlags(packet_types, true); | 763 SetFlags(packet_types, true); |
761 | 764 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
814 if (packet_bye) { | 817 if (packet_bye) { |
815 container.Append(packet_bye.release()); | 818 container.Append(packet_bye.release()); |
816 } | 819 } |
817 | 820 |
818 if (packet_type_counter_observer_ != nullptr) { | 821 if (packet_type_counter_observer_ != nullptr) { |
819 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( | 822 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( |
820 remote_ssrc_, packet_type_counter_); | 823 remote_ssrc_, packet_type_counter_); |
821 } | 824 } |
822 | 825 |
823 RTC_DCHECK(AllVolatileFlagsConsumed()); | 826 RTC_DCHECK(AllVolatileFlagsConsumed()); |
827 max_packet_size = max_packet_size_; | |
824 } | 828 } |
825 | 829 |
826 size_t bytes_sent = container.SendPackets(max_packet_size_); | 830 size_t bytes_sent = container.SendPackets(max_packet_size); |
nisse-webrtc
2017/02/21 09:07:26
Or can we move this inside the above scope, which
danilchap
2017/02/21 09:16:31
Better not: SendPackets involves calling transport
| |
827 return bytes_sent == 0 ? -1 : 0; | 831 return bytes_sent == 0 ? -1 : 0; |
828 } | 832 } |
829 | 833 |
830 void RTCPSender::PrepareReport(const FeedbackState& feedback_state) { | 834 void RTCPSender::PrepareReport(const FeedbackState& feedback_state) { |
831 bool generate_report; | 835 bool generate_report; |
832 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) { | 836 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) { |
833 // Report type already explicitly set, don't automatically populate. | 837 // Report type already explicitly set, don't automatically populate. |
834 generate_report = true; | 838 generate_report = true; |
835 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false); | 839 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false); |
836 } else { | 840 } else { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1033 } | 1037 } |
1034 | 1038 |
1035 Transport* const transport_; | 1039 Transport* const transport_; |
1036 RtcEventLog* const event_log_; | 1040 RtcEventLog* const event_log_; |
1037 bool send_failure_; | 1041 bool send_failure_; |
1038 // TODO(terelius): We would like to | 1042 // TODO(terelius): We would like to |
1039 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); | 1043 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender); |
1040 // but we can't because of an incorrect warning (C4822) in MVS 2013. | 1044 // but we can't because of an incorrect warning (C4822) in MVS 2013. |
1041 } sender(transport_, event_log_); | 1045 } sender(transport_, event_log_); |
1042 | 1046 |
1047 size_t max_packet_size; | |
1043 { | 1048 { |
1044 rtc::CritScope lock(&critical_section_rtcp_sender_); | 1049 rtc::CritScope lock(&critical_section_rtcp_sender_); |
1045 if (method_ == RtcpMode::kOff) | 1050 if (method_ == RtcpMode::kOff) |
1046 return false; | 1051 return false; |
1052 max_packet_size = max_packet_size_; | |
1047 } | 1053 } |
1048 | 1054 |
1049 RTC_DCHECK_LE(max_packet_size_, IP_PACKET_SIZE); | 1055 RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); |
1050 uint8_t buffer[IP_PACKET_SIZE]; | 1056 uint8_t buffer[IP_PACKET_SIZE]; |
1051 return packet.BuildExternalBuffer(buffer, max_packet_size_, &sender) && | 1057 return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && |
nisse-webrtc
2017/02/21 09:07:26
Same here, can we move this inside the above, prot
danilchap
2017/02/21 09:16:31
same here: calling BuildExternalBuffer would call
| |
1052 !sender.send_failure_; | 1058 !sender.send_failure_; |
1053 } | 1059 } |
1054 | 1060 |
1055 } // namespace webrtc | 1061 } // namespace webrtc |
OLD | NEW |