diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc index af1c49bce1..ba29919714 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc @@ -157,10 +157,12 @@ uint32_t RTPSender::NackOverheadRate() const { bool RTPSender::GetSendSideDelay(int* avg_send_delay_ms, int* max_send_delay_ms) const { + if (!SendingMedia()) + return false; CriticalSectionScoped cs(statistics_crit_.get()); SendDelayMap::const_iterator it = send_delays_.upper_bound( clock_->TimeInMilliseconds() - kSendSideDelayWindowMs); - if (!sending_media_ || it == send_delays_.end()) + if (it == send_delays_.end()) return false; int num_delays = 0; for (; it != send_delays_.end(); ++it) { @@ -528,7 +530,7 @@ int RTPSender::SendPadData(int payload_type, uint32_t timestamp, StorageType store, bool force_full_size_packets, bool only_pad_after_markerbit) { // Drop this packet if we're not sending media packets. - if (!sending_media_) { + if (!SendingMedia()) { return bytes; } int padding_bytes_in_packet = 0; @@ -888,14 +890,14 @@ bool RTPSender::IsFecPacket(const uint8_t* buffer, } int RTPSender::TimeToSendPadding(int bytes) { - if (!sending_media_) { - return 0; - } int payload_type; int64_t capture_time_ms; uint32_t timestamp; { CriticalSectionScoped cs(send_critsect_); + if (!sending_media_) { + return 0; + } payload_type = ((rtx_ & kRtxRedundantPayloads) > 0) ? payload_type_rtx_ : payload_type_; timestamp = timestamp_; diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h index 8153396cfb..128ea001dc 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.h @@ -25,6 +25,7 @@ #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" +#include "webrtc/system_wrappers/interface/thread_annotations.h" #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. @@ -336,7 +337,7 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer { CriticalSectionWrapper *send_critsect_; Transport *transport_; - bool sending_media_; + bool sending_media_ GUARDED_BY(send_critsect_); uint16_t max_payload_length_; uint16_t target_send_bitrate_;