diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index 776e5bb620..986d51acd4 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -282,6 +282,7 @@ void RTCPSender::SetTMMBRStatus(bool enable) { } void RTCPSender::SetMaxRtpPacketSize(size_t max_packet_size) { + rtc::CritScope lock(&critical_section_rtcp_sender_); max_packet_size_ = max_packet_size; } @@ -749,6 +750,8 @@ int32_t RTCPSender::SendCompoundRTCP( const uint16_t* nack_list, uint64_t pictureID) { PacketContainer container(transport_, event_log_); + size_t max_packet_size; + { rtc::CritScope lock(&critical_section_rtcp_sender_); if (method_ == RtcpMode::kOff) { @@ -821,9 +824,10 @@ int32_t RTCPSender::SendCompoundRTCP( } RTC_DCHECK(AllVolatileFlagsConsumed()); + max_packet_size = max_packet_size_; } - size_t bytes_sent = container.SendPackets(max_packet_size_); + size_t bytes_sent = container.SendPackets(max_packet_size); return bytes_sent == 0 ? -1 : 0; } @@ -1040,15 +1044,17 @@ bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { // but we can't because of an incorrect warning (C4822) in MVS 2013. } sender(transport_, event_log_); + size_t max_packet_size; { rtc::CritScope lock(&critical_section_rtcp_sender_); if (method_ == RtcpMode::kOff) return false; + max_packet_size = max_packet_size_; } - RTC_DCHECK_LE(max_packet_size_, IP_PACKET_SIZE); + RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE); uint8_t buffer[IP_PACKET_SIZE]; - return packet.BuildExternalBuffer(buffer, max_packet_size_, &sender) && + return packet.BuildExternalBuffer(buffer, max_packet_size, &sender) && !sender.send_failure_; } diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h index ccfbd48124..76abf63853 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h @@ -238,7 +238,7 @@ class RTCPSender { GUARDED_BY(critical_section_rtcp_sender_); uint32_t tmmbr_send_bps_ GUARDED_BY(critical_section_rtcp_sender_); uint32_t packet_oh_send_ GUARDED_BY(critical_section_rtcp_sender_); - size_t max_packet_size_; + size_t max_packet_size_ GUARDED_BY(critical_section_rtcp_sender_); // APP uint8_t app_sub_type_ GUARDED_BY(critical_section_rtcp_sender_);