diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index 77803deda9..6d5477be21 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -206,7 +206,7 @@ void RtpSenderEgress::ProcessBitrateAndNotifyObservers() { return; rtc::CritScope lock(&lock_); - RtpSendRates send_rates = GetSendRates(); + RtpSendRates send_rates = GetSendRatesLocked(); bitrate_callback_->Notify( send_rates.Sum().bps(), send_rates[RtpPacketMediaType::kRetransmission].bps(), ssrc_); @@ -214,6 +214,10 @@ void RtpSenderEgress::ProcessBitrateAndNotifyObservers() { RtpSendRates RtpSenderEgress::GetSendRates() const { rtc::CritScope lock(&lock_); + return GetSendRatesLocked(); +} + +RtpSendRates RtpSenderEgress::GetSendRatesLocked() const { const int64_t now_ms = clock_->TimeInMilliseconds(); RtpSendRates current_rates; for (size_t i = 0; i < kNumMediaTypes; ++i) { diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.h b/modules/rtp_rtcp/source/rtp_sender_egress.h index 298f57eff0..c9ecde3be8 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.h +++ b/modules/rtp_rtcp/source/rtp_sender_egress.h @@ -51,20 +51,23 @@ class RtpSenderEgress { RtpPacketHistory* packet_history); ~RtpSenderEgress() = default; - void SendPacket(RtpPacketToSend* packet, const PacedPacketInfo& pacing_info); + void SendPacket(RtpPacketToSend* packet, const PacedPacketInfo& pacing_info) + RTC_LOCKS_EXCLUDED(lock_); uint32_t Ssrc() const { return ssrc_; } absl::optional RtxSsrc() const { return rtx_ssrc_; } absl::optional FlexFecSsrc() const { return flexfec_ssrc_; } - void ProcessBitrateAndNotifyObservers(); - RtpSendRates GetSendRates() const; + void ProcessBitrateAndNotifyObservers() RTC_LOCKS_EXCLUDED(lock_); + RtpSendRates GetSendRates() const RTC_LOCKS_EXCLUDED(lock_); void GetDataCounters(StreamDataCounters* rtp_stats, - StreamDataCounters* rtx_stats) const; + StreamDataCounters* rtx_stats) const + RTC_LOCKS_EXCLUDED(lock_); - void ForceIncludeSendPacketsInAllocation(bool part_of_allocation); - bool MediaHasBeenSent() const; - void SetMediaHasBeenSent(bool media_sent); - void SetTimestampOffset(uint32_t timestamp); + void ForceIncludeSendPacketsInAllocation(bool part_of_allocation) + RTC_LOCKS_EXCLUDED(lock_); + bool MediaHasBeenSent() const RTC_LOCKS_EXCLUDED(lock_); + void SetMediaHasBeenSent(bool media_sent) RTC_LOCKS_EXCLUDED(lock_); + void SetTimestampOffset(uint32_t timestamp) RTC_LOCKS_EXCLUDED(lock_); // For each sequence number in |sequence_number|, recall the last RTP packet // which bore it - its timestamp and whether it was the first and/or last @@ -72,7 +75,8 @@ class RtpSenderEgress { // recalled, return a vector with all of them (in corresponding order). // If any could not be recalled, return an empty vector. std::vector GetSentRtpPacketInfos( - rtc::ArrayView sequence_numbers) const; + rtc::ArrayView sequence_numbers) const + RTC_LOCKS_EXCLUDED(lock_); private: // Maps capture time in milliseconds to send-side delay in milliseconds. @@ -80,6 +84,7 @@ class RtpSenderEgress { // time. typedef std::map SendDelayMap; + RtpSendRates GetSendRatesLocked() const RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); bool HasCorrectSsrc(const RtpPacketToSend& packet) const; void AddPacketToTransportFeedback(uint16_t packet_id, const RtpPacketToSend& packet,