Migrate modules/rtp_rtcp to webrtc::Mutex.

Bug: webrtc:11567
Change-Id: I4c71f3a28ef875af2c232b1b553840d6e21649d3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178804
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31645}
This commit is contained in:
Markus Handell
2020-07-07 11:44:28 +02:00
committed by Commit Bot
parent 6deec38ede
commit e7c015e112
33 changed files with 273 additions and 275 deletions

View File

@ -294,6 +294,7 @@ rtc_library("rtp_rtcp") {
"../../rtc_base:rtc_numerics",
"../../rtc_base:safe_minmax",
"../../rtc_base/experiments:field_trial_parser",
"../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/task_utils:pending_task_safety_flag",
"../../rtc_base/task_utils:repeating_task",

View File

@ -24,6 +24,7 @@
#include "modules/rtp_rtcp/source/video_fec_generator.h"
#include "rtc_base/random.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -92,8 +93,8 @@ class FlexfecSender : public VideoFecGenerator {
const RtpHeaderExtensionMap rtp_header_extension_map_;
const size_t header_extensions_size_;
rtc::CriticalSection crit_;
RateStatistics fec_bitrate_ RTC_GUARDED_BY(crit_);
mutable Mutex mutex_;
RateStatistics fec_bitrate_ RTC_GUARDED_BY(mutex_);
};
} // namespace webrtc

View File

@ -39,7 +39,7 @@ uint32_t AbsoluteCaptureTimeReceiver::GetSource(
void AbsoluteCaptureTimeReceiver::SetRemoteToLocalClockOffset(
absl::optional<int64_t> value_q32x32) {
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
remote_to_local_clock_offset_ = value_q32x32;
}
@ -52,7 +52,7 @@ AbsoluteCaptureTimeReceiver::OnReceivePacket(
const absl::optional<AbsoluteCaptureTime>& received_extension) {
const Timestamp receive_time = clock_->CurrentTime();
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
AbsoluteCaptureTime extension;
if (received_extension == absl::nullopt) {

View File

@ -15,7 +15,7 @@
#include "api/rtp_headers.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
@ -73,26 +73,26 @@ class AbsoluteCaptureTimeReceiver {
uint32_t source,
uint32_t rtp_timestamp,
uint32_t rtp_clock_frequency) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
absl::optional<int64_t> AdjustEstimatedCaptureClockOffset(
absl::optional<int64_t> received_value) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
Clock* const clock_;
rtc::CriticalSection crit_;
Mutex mutex_;
absl::optional<int64_t> remote_to_local_clock_offset_ RTC_GUARDED_BY(crit_);
absl::optional<int64_t> remote_to_local_clock_offset_ RTC_GUARDED_BY(mutex_);
Timestamp last_receive_time_ RTC_GUARDED_BY(crit_);
Timestamp last_receive_time_ RTC_GUARDED_BY(mutex_);
uint32_t last_source_ RTC_GUARDED_BY(crit_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(crit_);
uint32_t last_rtp_clock_frequency_ RTC_GUARDED_BY(crit_);
uint64_t last_absolute_capture_timestamp_ RTC_GUARDED_BY(crit_);
uint32_t last_source_ RTC_GUARDED_BY(mutex_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(mutex_);
uint32_t last_rtp_clock_frequency_ RTC_GUARDED_BY(mutex_);
uint64_t last_absolute_capture_timestamp_ RTC_GUARDED_BY(mutex_);
absl::optional<int64_t> last_estimated_capture_clock_offset_
RTC_GUARDED_BY(crit_);
RTC_GUARDED_BY(mutex_);
}; // AbsoluteCaptureTimeReceiver
} // namespace webrtc

View File

@ -47,7 +47,7 @@ absl::optional<AbsoluteCaptureTime> AbsoluteCaptureTimeSender::OnSendPacket(
absl::optional<int64_t> estimated_capture_clock_offset) {
const Timestamp send_time = clock_->CurrentTime();
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
if (!ShouldSendExtension(send_time, source, rtp_timestamp,
rtp_clock_frequency, absolute_capture_timestamp,

View File

@ -15,7 +15,7 @@
#include "api/rtp_headers.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
@ -67,20 +67,20 @@ class AbsoluteCaptureTimeSender {
uint32_t rtp_clock_frequency,
uint64_t absolute_capture_timestamp,
absl::optional<int64_t> estimated_capture_clock_offset) const
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
Clock* const clock_;
rtc::CriticalSection crit_;
Mutex mutex_;
Timestamp last_send_time_ RTC_GUARDED_BY(crit_);
Timestamp last_send_time_ RTC_GUARDED_BY(mutex_);
uint32_t last_source_ RTC_GUARDED_BY(crit_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(crit_);
uint32_t last_rtp_clock_frequency_ RTC_GUARDED_BY(crit_);
uint64_t last_absolute_capture_timestamp_ RTC_GUARDED_BY(crit_);
uint32_t last_source_ RTC_GUARDED_BY(mutex_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(mutex_);
uint32_t last_rtp_clock_frequency_ RTC_GUARDED_BY(mutex_);
uint64_t last_absolute_capture_timestamp_ RTC_GUARDED_BY(mutex_);
absl::optional<int64_t> last_estimated_capture_clock_offset_
RTC_GUARDED_BY(crit_);
RTC_GUARDED_BY(mutex_);
}; // AbsoluteCaptureTimeSender
} // namespace webrtc

View File

@ -120,7 +120,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
PacketOptions options;
{
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
options.included_in_allocation = force_part_of_allocation_;
if (need_rtp_packet_infos_ &&
@ -198,7 +198,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket(
}
if (send_success) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
UpdateRtpStats(*packet);
media_has_been_sent_ = true;
}
@ -208,7 +208,7 @@ void DEPRECATED_RtpSenderEgress::ProcessBitrateAndNotifyObservers() {
if (!bitrate_callback_)
return;
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
RtpSendRates send_rates = GetSendRatesLocked();
bitrate_callback_->Notify(
send_rates.Sum().bps(),
@ -216,7 +216,7 @@ void DEPRECATED_RtpSenderEgress::ProcessBitrateAndNotifyObservers() {
}
RtpSendRates DEPRECATED_RtpSenderEgress::GetSendRates() const {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
return GetSendRatesLocked();
}
@ -234,29 +234,29 @@ RtpSendRates DEPRECATED_RtpSenderEgress::GetSendRatesLocked() const {
void DEPRECATED_RtpSenderEgress::GetDataCounters(
StreamDataCounters* rtp_stats,
StreamDataCounters* rtx_stats) const {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
*rtp_stats = rtp_stats_;
*rtx_stats = rtx_rtp_stats_;
}
void DEPRECATED_RtpSenderEgress::ForceIncludeSendPacketsInAllocation(
bool part_of_allocation) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
force_part_of_allocation_ = part_of_allocation;
}
bool DEPRECATED_RtpSenderEgress::MediaHasBeenSent() const {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
return media_has_been_sent_;
}
void DEPRECATED_RtpSenderEgress::SetMediaHasBeenSent(bool media_sent) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
media_has_been_sent_ = media_sent;
}
void DEPRECATED_RtpSenderEgress::SetTimestampOffset(uint32_t timestamp) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
timestamp_offset_ = timestamp;
}
@ -271,7 +271,7 @@ DEPRECATED_RtpSenderEgress::GetSentRtpPacketInfos(
std::vector<RtpSequenceNumberMap::Info> results;
results.reserve(sequence_numbers.size());
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
for (uint16_t sequence_number : sequence_numbers) {
const auto& info = rtp_sequence_number_map_->Get(sequence_number);
if (!info) {
@ -334,7 +334,7 @@ void DEPRECATED_RtpSenderEgress::UpdateDelayStatistics(int64_t capture_time_ms,
int max_delay_ms = 0;
uint64_t total_packet_send_delay_ms = 0;
{
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
// Compute the max and average of the recent capture-to-send delays.
// The time complexity of the current approach depends on the distribution
// of the delay values. This could be done more efficiently.

View File

@ -24,8 +24,8 @@
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -121,7 +121,7 @@ class DEPRECATED_RtpSenderEgress {
StreamDataCountersCallback* const rtp_stats_callback_;
BitrateStatisticsObserver* const bitrate_callback_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
bool media_has_been_sent_ RTC_GUARDED_BY(lock_);
bool force_part_of_allocation_ RTC_GUARDED_BY(lock_);
uint32_t timestamp_offset_ RTC_GUARDED_BY(lock_);

View File

@ -24,7 +24,7 @@ DtmfQueue::DtmfQueue() {}
DtmfQueue::~DtmfQueue() {}
bool DtmfQueue::AddDtmf(const Event& event) {
rtc::CritScope lock(&dtmf_critsect_);
MutexLock lock(&dtmf_mutex_);
if (queue_.size() >= kDtmfOutbandMax) {
return false;
}
@ -34,7 +34,7 @@ bool DtmfQueue::AddDtmf(const Event& event) {
bool DtmfQueue::NextDtmf(Event* event) {
RTC_DCHECK(event);
rtc::CritScope lock(&dtmf_critsect_);
MutexLock lock(&dtmf_mutex_);
if (queue_.empty()) {
return false;
}
@ -45,7 +45,7 @@ bool DtmfQueue::NextDtmf(Event* event) {
}
bool DtmfQueue::PendingDtmf() const {
rtc::CritScope lock(&dtmf_critsect_);
MutexLock lock(&dtmf_mutex_);
return !queue_.empty();
}
} // namespace webrtc

View File

@ -15,7 +15,7 @@
#include <list>
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
class DtmfQueue {
@ -35,7 +35,7 @@ class DtmfQueue {
bool PendingDtmf() const;
private:
rtc::CriticalSection dtmf_critsect_;
mutable Mutex dtmf_mutex_;
std::list<Event> queue_;
};
} // namespace webrtc

View File

@ -176,7 +176,7 @@ std::vector<std::unique_ptr<RtpPacketToSend>> FlexfecSender::GetFecPackets() {
last_generated_packet_ms_ = now_ms;
}
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
fec_bitrate_.Update(total_fec_data_bytes, now_ms);
return fec_packets_to_send;
@ -188,7 +188,7 @@ size_t FlexfecSender::MaxPacketOverhead() const {
}
DataRate FlexfecSender::CurrentFecRate() const {
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
return DataRate::BitsPerSec(
fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0));
}

View File

@ -100,7 +100,7 @@ bool StreamStatisticianImpl::UpdateOutOfOrder(const RtpPacketReceived& packet,
}
void StreamStatisticianImpl::UpdateCounters(const RtpPacketReceived& packet) {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
RTC_DCHECK_EQ(ssrc_, packet.Ssrc());
int64_t now_ms = clock_->TimeInMilliseconds();
@ -159,17 +159,17 @@ void StreamStatisticianImpl::UpdateJitter(const RtpPacketReceived& packet,
void StreamStatisticianImpl::SetMaxReorderingThreshold(
int max_reordering_threshold) {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
max_reordering_threshold_ = max_reordering_threshold;
}
void StreamStatisticianImpl::EnableRetransmitDetection(bool enable) {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
enable_retransmit_detection_ = enable;
}
RtpReceiveStats StreamStatisticianImpl::GetStats() const {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
RtpReceiveStats stats;
stats.packets_lost = cumulative_loss_;
// TODO(nisse): Can we return a float instead?
@ -183,7 +183,7 @@ RtpReceiveStats StreamStatisticianImpl::GetStats() const {
bool StreamStatisticianImpl::GetActiveStatisticsAndReset(
RtcpStatistics* statistics) {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
if (clock_->TimeInMilliseconds() - last_receive_time_ms_ >=
kStatisticsTimeoutMs) {
// Not active.
@ -241,7 +241,7 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics() {
}
absl::optional<int> StreamStatisticianImpl::GetFractionLostInPercent() const {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
if (!ReceivedRtpPacket()) {
return absl::nullopt;
}
@ -257,12 +257,12 @@ absl::optional<int> StreamStatisticianImpl::GetFractionLostInPercent() const {
StreamDataCounters StreamStatisticianImpl::GetReceiveStreamDataCounters()
const {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
return receive_counters_;
}
uint32_t StreamStatisticianImpl::BitrateReceived() const {
rtc::CritScope cs(&stream_lock_);
MutexLock lock(&stream_lock_);
return incoming_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0);
}
@ -320,7 +320,7 @@ void ReceiveStatisticsImpl::OnRtpPacket(const RtpPacketReceived& packet) {
StreamStatisticianImpl* ReceiveStatisticsImpl::GetStatistician(
uint32_t ssrc) const {
rtc::CritScope cs(&receive_statistics_lock_);
MutexLock lock(&receive_statistics_lock_);
const auto& it = statisticians_.find(ssrc);
if (it == statisticians_.end())
return NULL;
@ -329,7 +329,7 @@ StreamStatisticianImpl* ReceiveStatisticsImpl::GetStatistician(
StreamStatisticianImpl* ReceiveStatisticsImpl::GetOrCreateStatistician(
uint32_t ssrc) {
rtc::CritScope cs(&receive_statistics_lock_);
MutexLock lock(&receive_statistics_lock_);
StreamStatisticianImpl*& impl = statisticians_[ssrc];
if (impl == nullptr) { // new element
impl = new StreamStatisticianImpl(ssrc, clock_, max_reordering_threshold_);
@ -341,7 +341,7 @@ void ReceiveStatisticsImpl::SetMaxReorderingThreshold(
int max_reordering_threshold) {
std::map<uint32_t, StreamStatisticianImpl*> statisticians;
{
rtc::CritScope cs(&receive_statistics_lock_);
MutexLock lock(&receive_statistics_lock_);
max_reordering_threshold_ = max_reordering_threshold;
statisticians = statisticians_;
}
@ -366,7 +366,7 @@ std::vector<rtcp::ReportBlock> ReceiveStatisticsImpl::RtcpReportBlocks(
size_t max_blocks) {
std::map<uint32_t, StreamStatisticianImpl*> statisticians;
{
rtc::CritScope cs(&receive_statistics_lock_);
MutexLock lock(&receive_statistics_lock_);
statisticians = statisticians_;
}
std::vector<rtcp::ReportBlock> result;

View File

@ -18,8 +18,8 @@
#include "absl/types/optional.h"
#include "modules/include/module_common_types_public.h"
#include "modules/rtp_rtcp/include/receive_statistics.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -65,7 +65,7 @@ class StreamStatisticianImpl : public StreamStatistician {
const uint32_t ssrc_;
Clock* const clock_;
rtc::CriticalSection stream_lock_;
mutable Mutex stream_lock_;
RateStatistics incoming_bitrate_ RTC_GUARDED_BY(&stream_lock_);
// In number of packets or sequence numbers.
int max_reordering_threshold_ RTC_GUARDED_BY(&stream_lock_);
@ -123,7 +123,7 @@ class ReceiveStatisticsImpl : public ReceiveStatistics {
StreamStatisticianImpl* GetOrCreateStatistician(uint32_t ssrc);
Clock* const clock_;
rtc::CriticalSection receive_statistics_lock_;
mutable Mutex receive_statistics_lock_;
uint32_t last_returned_ssrc_;
int max_reordering_threshold_ RTC_GUARDED_BY(receive_statistics_lock_);
std::map<uint32_t, StreamStatisticianImpl*> statisticians_

View File

@ -203,19 +203,19 @@ void RTCPReceiver::IncomingPacket(rtc::ArrayView<const uint8_t> packet) {
// This method is only used by test and legacy code, so we should be able to
// remove it soon.
int64_t RTCPReceiver::LastReceivedReportBlockMs() const {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
return last_received_rb_.IsFinite() ? last_received_rb_.ms() : 0;
}
void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
// New SSRC reset old reports.
last_received_sr_ntp_.Reset();
remote_ssrc_ = ssrc;
}
uint32_t RTCPReceiver::RemoteSSRC() const {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
return remote_ssrc_;
}
@ -224,7 +224,7 @@ int32_t RTCPReceiver::RTT(uint32_t remote_ssrc,
int64_t* avg_rtt_ms,
int64_t* min_rtt_ms,
int64_t* max_rtt_ms) const {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
auto it = received_report_blocks_.find(main_ssrc_);
if (it == received_report_blocks_.end())
@ -257,13 +257,13 @@ int32_t RTCPReceiver::RTT(uint32_t remote_ssrc,
}
void RTCPReceiver::SetRtcpXrRrtrStatus(bool enable) {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
xr_rrtr_status_ = enable;
}
bool RTCPReceiver::GetAndResetXrRrRtt(int64_t* rtt_ms) {
RTC_DCHECK(rtt_ms);
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
if (xr_rr_rtt_ms_ == 0) {
return false;
}
@ -282,7 +282,7 @@ absl::optional<TimeDelta> RTCPReceiver::OnPeriodicRttUpdate(
if (sending) {
// Check if we've received a report block within the last kRttUpdateInterval
// amount of time.
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
if (last_received_rb_.IsInfinite() || last_received_rb_ > newer_than) {
// Stow away the report block for the main ssrc. We'll use the associated
// data map to look up each sender and check the last_rtt_ms().
@ -331,7 +331,7 @@ bool RTCPReceiver::NTP(uint32_t* received_ntp_secs,
uint32_t* rtcp_arrival_time_secs,
uint32_t* rtcp_arrival_time_frac,
uint32_t* rtcp_timestamp) const {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
if (!last_received_sr_ntp_.Valid())
return false;
@ -356,7 +356,7 @@ bool RTCPReceiver::NTP(uint32_t* received_ntp_secs,
std::vector<rtcp::ReceiveTimeInfo>
RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
const size_t last_xr_rtis_size = std::min(
received_rrtrs_.size(), rtcp::ExtendedReports::kMaxNumberOfDlrrItems);
@ -381,7 +381,7 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() {
int32_t RTCPReceiver::StatisticsReceived(
std::vector<RTCPReportBlock>* receive_blocks) const {
RTC_DCHECK(receive_blocks);
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
for (const auto& reports_per_receiver : received_report_blocks_)
for (const auto& report : reports_per_receiver.second)
receive_blocks->push_back(report.second.report_block());
@ -390,7 +390,7 @@ int32_t RTCPReceiver::StatisticsReceived(
std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
std::vector<ReportBlockData> result;
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
for (const auto& reports_per_receiver : received_report_blocks_)
for (const auto& report : reports_per_receiver.second)
result.push_back(report.second);
@ -399,7 +399,7 @@ std::vector<ReportBlockData> RTCPReceiver::GetLatestReportBlockData() const {
bool RTCPReceiver::ParseCompoundPacket(rtc::ArrayView<const uint8_t> packet,
PacketInformation* packet_information) {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
CommonHeader rtcp_block;
for (const uint8_t* next_block = packet.begin(); next_block != packet.end();
@ -654,17 +654,17 @@ RTCPReceiver::TmmbrInformation* RTCPReceiver::GetTmmbrInformation(
// the methods and require that access to the locked variables only happens on
// the worker thread and thus no locking is needed.
bool RTCPReceiver::RtcpRrTimeout() {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
return RtcpRrTimeoutLocked(clock_->CurrentTime());
}
bool RTCPReceiver::RtcpRrSequenceNumberTimeout() {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
return RtcpRrSequenceNumberTimeoutLocked(clock_->CurrentTime());
}
bool RTCPReceiver::UpdateTmmbrTimers() {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
int64_t now_ms = clock_->TimeInMilliseconds();
int64_t timeout_ms = now_ms - kTmmbrTimeoutIntervalMs;
@ -701,7 +701,7 @@ bool RTCPReceiver::UpdateTmmbrTimers() {
}
std::vector<rtcp::TmmbItem> RTCPReceiver::BoundingSet(bool* tmmbr_owner) {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
TmmbrInformation* tmmbr_info = GetTmmbrInformation(remote_ssrc_);
if (!tmmbr_info)
return std::vector<rtcp::TmmbItem>();
@ -1062,7 +1062,7 @@ void RTCPReceiver::TriggerCallbacksFromRtcpPacket(
std::set<uint32_t> registered_ssrcs;
{
// We don't want to hold this critsect when triggering the callbacks below.
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
local_ssrc = main_ssrc_;
registered_ssrcs = registered_ssrcs_;
}
@ -1178,7 +1178,7 @@ int32_t RTCPReceiver::CNAME(uint32_t remoteSSRC,
char cName[RTCP_CNAME_SIZE]) const {
RTC_DCHECK(cName);
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
auto received_cname_it = received_cnames_.find(remoteSSRC);
if (received_cname_it == received_cnames_.end())
return -1;
@ -1189,7 +1189,7 @@ int32_t RTCPReceiver::CNAME(uint32_t remoteSSRC,
}
std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() {
rtc::CritScope lock(&rtcp_receiver_lock_);
MutexLock lock(&rtcp_receiver_lock_);
std::vector<rtcp::TmmbItem> candidates;
int64_t now_ms = clock_->TimeInMilliseconds();

View File

@ -24,7 +24,7 @@
#include "modules/rtp_rtcp/source/rtcp_nack_stats.h"
#include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/ntp_time.h"
@ -235,7 +235,7 @@ class RTCPReceiver final {
VideoBitrateAllocationObserver* const bitrate_allocation_observer_;
const TimeDelta report_interval_;
rtc::CriticalSection rtcp_receiver_lock_;
mutable Mutex rtcp_receiver_lock_;
uint32_t remote_ssrc_ RTC_GUARDED_BY(rtcp_receiver_lock_);
// Received sender report.

View File

@ -93,7 +93,7 @@ RtpPacketHistory::~RtpPacketHistory() {}
void RtpPacketHistory::SetStorePacketsStatus(StorageMode mode,
size_t number_to_store) {
RTC_DCHECK_LE(number_to_store, kMaxCapacity);
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode != StorageMode::kDisabled && mode_ != StorageMode::kDisabled) {
RTC_LOG(LS_WARNING) << "Purging packet history in order to re-set status.";
}
@ -103,12 +103,12 @@ void RtpPacketHistory::SetStorePacketsStatus(StorageMode mode,
}
RtpPacketHistory::StorageMode RtpPacketHistory::GetStorageMode() const {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
return mode_;
}
void RtpPacketHistory::SetRtt(int64_t rtt_ms) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
RTC_DCHECK_GE(rtt_ms, 0);
rtt_ms_ = rtt_ms;
// If storage is not disabled, packets will be removed after a timeout
@ -122,7 +122,7 @@ void RtpPacketHistory::SetRtt(int64_t rtt_ms) {
void RtpPacketHistory::PutRtpPacket(std::unique_ptr<RtpPacketToSend> packet,
absl::optional<int64_t> send_time_ms) {
RTC_DCHECK(packet);
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
int64_t now_ms = clock_->TimeInMilliseconds();
if (mode_ == StorageMode::kDisabled) {
return;
@ -170,7 +170,7 @@ void RtpPacketHistory::PutRtpPacket(std::unique_ptr<RtpPacketToSend> packet,
std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPacketAndSetSendTime(
uint16_t sequence_number) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return nullptr;
}
@ -210,7 +210,7 @@ std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPacketAndMarkAsPending(
uint16_t sequence_number,
rtc::FunctionView<std::unique_ptr<RtpPacketToSend>(const RtpPacketToSend&)>
encapsulate) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return nullptr;
}
@ -241,7 +241,7 @@ std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPacketAndMarkAsPending(
}
void RtpPacketHistory::MarkPacketAsSent(uint16_t sequence_number) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return;
}
@ -263,7 +263,7 @@ void RtpPacketHistory::MarkPacketAsSent(uint16_t sequence_number) {
absl::optional<RtpPacketHistory::PacketState> RtpPacketHistory::GetPacketState(
uint16_t sequence_number) const {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return absl::nullopt;
}
@ -311,7 +311,7 @@ std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPayloadPaddingPacket() {
std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPayloadPaddingPacket(
rtc::FunctionView<std::unique_ptr<RtpPacketToSend>(const RtpPacketToSend&)>
encapsulate) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return nullptr;
}
@ -357,7 +357,7 @@ std::unique_ptr<RtpPacketToSend> RtpPacketHistory::GetPayloadPaddingPacket(
void RtpPacketHistory::CullAcknowledgedPackets(
rtc::ArrayView<const uint16_t> sequence_numbers) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
for (uint16_t sequence_number : sequence_numbers) {
int packet_index = GetPacketIndex(sequence_number);
if (packet_index < 0 ||
@ -369,7 +369,7 @@ void RtpPacketHistory::CullAcknowledgedPackets(
}
bool RtpPacketHistory::SetPendingTransmission(uint16_t sequence_number) {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
if (mode_ == StorageMode::kDisabled) {
return false;
}
@ -384,7 +384,7 @@ bool RtpPacketHistory::SetPendingTransmission(uint16_t sequence_number) {
}
void RtpPacketHistory::Clear() {
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
Reset();
}

View File

@ -20,7 +20,7 @@
#include "api/function_view.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -193,7 +193,7 @@ class RtpPacketHistory {
Clock* const clock_;
const bool enable_padding_prio_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
size_t number_to_store_ RTC_GUARDED_BY(lock_);
StorageMode mode_ RTC_GUARDED_BY(lock_);
int64_t rtt_ms_ RTC_GUARDED_BY(lock_);

View File

@ -223,13 +223,13 @@ rtc::ArrayView<const RtpExtensionSize> RTPSender::AudioExtensionSizes() {
}
void RTPSender::SetExtmapAllowMixed(bool extmap_allow_mixed) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
rtp_header_extension_map_.SetExtmapAllowMixed(extmap_allow_mixed);
}
int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
uint8_t id) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
bool registered = rtp_header_extension_map_.RegisterByType(id, type);
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
UpdateHeaderSizes();
@ -237,7 +237,7 @@ int32_t RTPSender::RegisterRtpHeaderExtension(RTPExtensionType type,
}
bool RTPSender::RegisterRtpHeaderExtension(absl::string_view uri, int id) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
bool registered = rtp_header_extension_map_.RegisterByUri(id, uri);
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
UpdateHeaderSizes();
@ -245,12 +245,12 @@ bool RTPSender::RegisterRtpHeaderExtension(absl::string_view uri, int id) {
}
bool RTPSender::IsRtpHeaderExtensionRegistered(RTPExtensionType type) const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return rtp_header_extension_map_.IsRegistered(type);
}
int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
rtp_header_extension_map_.Deregister(type);
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
UpdateHeaderSizes();
@ -258,7 +258,7 @@ int32_t RTPSender::DeregisterRtpHeaderExtension(RTPExtensionType type) {
}
void RTPSender::DeregisterRtpHeaderExtension(absl::string_view uri) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
rtp_header_extension_map_.Deregister(uri);
supports_bwe_extension_ = HasBweExtension(rtp_header_extension_map_);
UpdateHeaderSizes();
@ -267,7 +267,7 @@ void RTPSender::DeregisterRtpHeaderExtension(absl::string_view uri) {
void RTPSender::SetMaxRtpPacketSize(size_t max_packet_size) {
RTC_DCHECK_GE(max_packet_size, 100);
RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
max_packet_size_ = max_packet_size;
}
@ -276,18 +276,18 @@ size_t RTPSender::MaxRtpPacketSize() const {
}
void RTPSender::SetRtxStatus(int mode) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
rtx_ = mode;
}
int RTPSender::RtxStatus() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return rtx_;
}
void RTPSender::SetRtxPayloadType(int payload_type,
int associated_payload_type) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
RTC_DCHECK_LE(payload_type, 127);
RTC_DCHECK_LE(associated_payload_type, 127);
if (payload_type < 0) {
@ -346,7 +346,7 @@ int32_t RTPSender::ReSendPacket(uint16_t packet_id) {
}
void RTPSender::OnReceivedAckOnSsrc(int64_t extended_highest_sequence_number) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
bool update_required = !ssrc_has_acked_;
ssrc_has_acked_ = true;
if (update_required) {
@ -356,7 +356,7 @@ void RTPSender::OnReceivedAckOnSsrc(int64_t extended_highest_sequence_number) {
void RTPSender::OnReceivedAckOnRtxSsrc(
int64_t extended_highest_sequence_number) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
rtx_ssrc_has_acked_ = true;
}
@ -376,12 +376,12 @@ void RTPSender::OnReceivedNack(
}
bool RTPSender::SupportsPadding() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return sending_media_ && supports_bwe_extension_;
}
bool RTPSender::SupportsRtxPayloadPadding() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return sending_media_ && supports_bwe_extension_ &&
(rtx_ & kRtxRedundantPayloads);
}
@ -423,7 +423,7 @@ std::vector<std::unique_ptr<RtpPacketToSend>> RTPSender::GeneratePadding(
}
}
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
if (!sending_media_) {
return {};
}
@ -546,24 +546,24 @@ void RTPSender::EnqueuePackets(
}
size_t RTPSender::FecOrPaddingPacketMaxRtpHeaderLength() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return max_padding_fec_packet_header_;
}
size_t RTPSender::ExpectedPerPacketOverhead() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return max_media_packet_header_;
}
uint16_t RTPSender::AllocateSequenceNumber(uint16_t packets_to_send) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
uint16_t first_allocated_sequence_number = sequence_number_;
sequence_number_ += packets_to_send;
return first_allocated_sequence_number;
}
std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
// TODO(danilchap): Find better motivator and value for extra capacity.
// RtpPacketizer might slightly miscalulate needed size,
// SRTP may benefit from extra space in the buffer and do encryption in place
@ -605,7 +605,7 @@ std::unique_ptr<RtpPacketToSend> RTPSender::AllocatePacket() const {
}
bool RTPSender::AssignSequenceNumber(RtpPacketToSend* packet) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
if (!sending_media_)
return false;
RTC_DCHECK(packet->Ssrc() == ssrc_);
@ -624,12 +624,12 @@ bool RTPSender::AssignSequenceNumber(RtpPacketToSend* packet) {
}
void RTPSender::SetSendingMediaStatus(bool enabled) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
sending_media_ = enabled;
}
bool RTPSender::SendingMedia() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return sending_media_;
}
@ -638,18 +638,18 @@ bool RTPSender::IsAudioConfigured() const {
}
void RTPSender::SetTimestampOffset(uint32_t timestamp) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
timestamp_offset_ = timestamp;
}
uint32_t RTPSender::TimestampOffset() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return timestamp_offset_;
}
void RTPSender::SetRid(const std::string& rid) {
// RID is used in simulcast scenario when multiple layers share the same mid.
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
RTC_DCHECK_LE(rid.length(), RtpStreamId::kMaxValueSizeBytes);
rid_ = rid;
UpdateHeaderSizes();
@ -657,7 +657,7 @@ void RTPSender::SetRid(const std::string& rid) {
void RTPSender::SetMid(const std::string& mid) {
// This is configured via the API.
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
RTC_DCHECK_LE(mid.length(), RtpMid::kMaxValueSizeBytes);
mid_ = mid;
UpdateHeaderSizes();
@ -665,7 +665,7 @@ void RTPSender::SetMid(const std::string& mid) {
void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize);
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
csrcs_ = csrcs;
UpdateHeaderSizes();
}
@ -673,7 +673,7 @@ void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
void RTPSender::SetSequenceNumber(uint16_t seq) {
bool updated_sequence_number = false;
{
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
sequence_number_forced_ = true;
if (sequence_number_ != seq) {
updated_sequence_number = true;
@ -689,7 +689,7 @@ void RTPSender::SetSequenceNumber(uint16_t seq) {
}
uint16_t RTPSender::SequenceNumber() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return sequence_number_;
}
@ -747,7 +747,7 @@ std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
// Add original RTP header.
{
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
if (!sending_media_)
return nullptr;
@ -813,7 +813,7 @@ std::unique_ptr<RtpPacketToSend> RTPSender::BuildRtxPacket(
}
void RTPSender::SetRtpState(const RtpState& rtp_state) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
sequence_number_ = rtp_state.sequence_number;
sequence_number_forced_ = true;
timestamp_offset_ = rtp_state.start_timestamp;
@ -825,7 +825,7 @@ void RTPSender::SetRtpState(const RtpState& rtp_state) {
}
RtpState RTPSender::GetRtpState() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
RtpState state;
state.sequence_number = sequence_number_;
@ -838,13 +838,13 @@ RtpState RTPSender::GetRtpState() const {
}
void RTPSender::SetRtxRtpState(const RtpState& rtp_state) {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
sequence_number_rtx_ = rtp_state.sequence_number;
rtx_ssrc_has_acked_ = rtp_state.ssrc_has_acked;
}
RtpState RTPSender::GetRtxRtpState() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
RtpState state;
state.sequence_number = sequence_number_rtx_;
@ -855,7 +855,7 @@ RtpState RTPSender::GetRtxRtpState() const {
}
int64_t RTPSender::LastTimestampTimeMs() const {
rtc::CritScope lock(&send_critsect_);
MutexLock lock(&send_mutex_);
return last_timestamp_time_ms_;
}

View File

@ -30,10 +30,10 @@
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/deprecation.h"
#include "rtc_base/random.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
namespace webrtc {
@ -51,127 +51,124 @@ class RTPSender {
~RTPSender();
void SetSendingMediaStatus(bool enabled) RTC_LOCKS_EXCLUDED(send_critsect_);
bool SendingMedia() const RTC_LOCKS_EXCLUDED(send_critsect_);
bool IsAudioConfigured() const RTC_LOCKS_EXCLUDED(send_critsect_);
void SetSendingMediaStatus(bool enabled) RTC_LOCKS_EXCLUDED(send_mutex_);
bool SendingMedia() const RTC_LOCKS_EXCLUDED(send_mutex_);
bool IsAudioConfigured() const RTC_LOCKS_EXCLUDED(send_mutex_);
uint32_t TimestampOffset() const RTC_LOCKS_EXCLUDED(send_critsect_);
void SetTimestampOffset(uint32_t timestamp)
RTC_LOCKS_EXCLUDED(send_critsect_);
uint32_t TimestampOffset() const RTC_LOCKS_EXCLUDED(send_mutex_);
void SetTimestampOffset(uint32_t timestamp) RTC_LOCKS_EXCLUDED(send_mutex_);
void SetRid(const std::string& rid) RTC_LOCKS_EXCLUDED(send_critsect_);
void SetRid(const std::string& rid) RTC_LOCKS_EXCLUDED(send_mutex_);
void SetMid(const std::string& mid) RTC_LOCKS_EXCLUDED(send_critsect_);
void SetMid(const std::string& mid) RTC_LOCKS_EXCLUDED(send_mutex_);
uint16_t SequenceNumber() const RTC_LOCKS_EXCLUDED(send_critsect_);
void SetSequenceNumber(uint16_t seq) RTC_LOCKS_EXCLUDED(send_critsect_);
uint16_t SequenceNumber() const RTC_LOCKS_EXCLUDED(send_mutex_);
void SetSequenceNumber(uint16_t seq) RTC_LOCKS_EXCLUDED(send_mutex_);
void SetCsrcs(const std::vector<uint32_t>& csrcs)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
void SetMaxRtpPacketSize(size_t max_packet_size)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
void SetExtmapAllowMixed(bool extmap_allow_mixed)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// RTP header extension
int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
bool RegisterRtpHeaderExtension(absl::string_view uri, int id)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
bool IsRtpHeaderExtensionRegistered(RTPExtensionType type) const
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
int32_t DeregisterRtpHeaderExtension(RTPExtensionType type)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
void DeregisterRtpHeaderExtension(absl::string_view uri)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
bool SupportsPadding() const RTC_LOCKS_EXCLUDED(send_critsect_);
bool SupportsRtxPayloadPadding() const RTC_LOCKS_EXCLUDED(send_critsect_);
bool SupportsPadding() const RTC_LOCKS_EXCLUDED(send_mutex_);
bool SupportsRtxPayloadPadding() const RTC_LOCKS_EXCLUDED(send_mutex_);
std::vector<std::unique_ptr<RtpPacketToSend>> GeneratePadding(
size_t target_size_bytes,
bool media_has_been_sent) RTC_LOCKS_EXCLUDED(send_critsect_);
bool media_has_been_sent) RTC_LOCKS_EXCLUDED(send_mutex_);
// NACK.
void OnReceivedNack(const std::vector<uint16_t>& nack_sequence_numbers,
int64_t avg_rtt) RTC_LOCKS_EXCLUDED(send_critsect_);
int64_t avg_rtt) RTC_LOCKS_EXCLUDED(send_mutex_);
int32_t ReSendPacket(uint16_t packet_id) RTC_LOCKS_EXCLUDED(send_critsect_);
int32_t ReSendPacket(uint16_t packet_id) RTC_LOCKS_EXCLUDED(send_mutex_);
// ACK.
void OnReceivedAckOnSsrc(int64_t extended_highest_sequence_number)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
void OnReceivedAckOnRtxSsrc(int64_t extended_highest_sequence_number)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// RTX.
void SetRtxStatus(int mode) RTC_LOCKS_EXCLUDED(send_critsect_);
int RtxStatus() const RTC_LOCKS_EXCLUDED(send_critsect_);
absl::optional<uint32_t> RtxSsrc() const RTC_LOCKS_EXCLUDED(send_critsect_) {
void SetRtxStatus(int mode) RTC_LOCKS_EXCLUDED(send_mutex_);
int RtxStatus() const RTC_LOCKS_EXCLUDED(send_mutex_);
absl::optional<uint32_t> RtxSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return rtx_ssrc_;
}
void SetRtxPayloadType(int payload_type, int associated_payload_type)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Size info for header extensions used by FEC packets.
static rtc::ArrayView<const RtpExtensionSize> FecExtensionSizes()
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Size info for header extensions used by video packets.
static rtc::ArrayView<const RtpExtensionSize> VideoExtensionSizes()
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Size info for header extensions used by audio packets.
static rtc::ArrayView<const RtpExtensionSize> AudioExtensionSizes()
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Create empty packet, fills ssrc, csrcs and reserve place for header
// extensions RtpSender updates before sending.
std::unique_ptr<RtpPacketToSend> AllocatePacket() const
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Allocate sequence number for provided packet.
// Save packet's fields to generate padding that doesn't break media stream.
// Return false if sending was turned off.
bool AssignSequenceNumber(RtpPacketToSend* packet)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Maximum header overhead per fec/padding packet.
size_t FecOrPaddingPacketMaxRtpHeaderLength() const
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Expected header overhead per media packet.
size_t ExpectedPerPacketOverhead() const RTC_LOCKS_EXCLUDED(send_critsect_);
size_t ExpectedPerPacketOverhead() const RTC_LOCKS_EXCLUDED(send_mutex_);
uint16_t AllocateSequenceNumber(uint16_t packets_to_send)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Including RTP headers.
size_t MaxRtpPacketSize() const RTC_LOCKS_EXCLUDED(send_critsect_);
size_t MaxRtpPacketSize() const RTC_LOCKS_EXCLUDED(send_mutex_);
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_critsect_) { return ssrc_; }
uint32_t SSRC() const RTC_LOCKS_EXCLUDED(send_mutex_) { return ssrc_; }
absl::optional<uint32_t> FlexfecSsrc() const
RTC_LOCKS_EXCLUDED(send_critsect_) {
absl::optional<uint32_t> FlexfecSsrc() const RTC_LOCKS_EXCLUDED(send_mutex_) {
return flexfec_ssrc_;
}
// Sends packet to |transport_| or to the pacer, depending on configuration.
// TODO(bugs.webrtc.org/XXX): Remove in favor of EnqueuePackets().
bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
// Pass a set of packets to RtpPacketSender instance, for paced or immediate
// sending to the network.
void EnqueuePackets(std::vector<std::unique_ptr<RtpPacketToSend>> packets)
RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
void SetRtpState(const RtpState& rtp_state)
RTC_LOCKS_EXCLUDED(send_critsect_);
RtpState GetRtpState() const RTC_LOCKS_EXCLUDED(send_critsect_);
void SetRtpState(const RtpState& rtp_state) RTC_LOCKS_EXCLUDED(send_mutex_);
RtpState GetRtpState() const RTC_LOCKS_EXCLUDED(send_mutex_);
void SetRtxRtpState(const RtpState& rtp_state)
RTC_LOCKS_EXCLUDED(send_critsect_);
RtpState GetRtxRtpState() const RTC_LOCKS_EXCLUDED(send_critsect_);
RTC_LOCKS_EXCLUDED(send_mutex_);
RtpState GetRtxRtpState() const RTC_LOCKS_EXCLUDED(send_mutex_);
int64_t LastTimestampTimeMs() const RTC_LOCKS_EXCLUDED(send_critsect_);
int64_t LastTimestampTimeMs() const RTC_LOCKS_EXCLUDED(send_mutex_);
private:
std::unique_ptr<RtpPacketToSend> BuildRtxPacket(
@ -179,10 +176,10 @@ class RTPSender {
bool IsFecPacket(const RtpPacketToSend& packet) const;
void UpdateHeaderSizes() RTC_EXCLUSIVE_LOCKS_REQUIRED(send_critsect_);
void UpdateHeaderSizes() RTC_EXCLUSIVE_LOCKS_REQUIRED(send_mutex_);
Clock* const clock_;
Random random_ RTC_GUARDED_BY(send_critsect_);
Random random_ RTC_GUARDED_BY(send_mutex_);
const bool audio_configured_;
@ -196,42 +193,41 @@ class RTPSender {
RtpPacketHistory* const packet_history_;
RtpPacketSender* const paced_sender_;
rtc::CriticalSection send_critsect_;
mutable Mutex send_mutex_;
bool sending_media_ RTC_GUARDED_BY(send_critsect_);
bool sending_media_ RTC_GUARDED_BY(send_mutex_);
size_t max_packet_size_;
int8_t last_payload_type_ RTC_GUARDED_BY(send_critsect_);
int8_t last_payload_type_ RTC_GUARDED_BY(send_mutex_);
RtpHeaderExtensionMap rtp_header_extension_map_
RTC_GUARDED_BY(send_critsect_);
size_t max_media_packet_header_ RTC_GUARDED_BY(send_critsect_);
size_t max_padding_fec_packet_header_ RTC_GUARDED_BY(send_critsect_);
RtpHeaderExtensionMap rtp_header_extension_map_ RTC_GUARDED_BY(send_mutex_);
size_t max_media_packet_header_ RTC_GUARDED_BY(send_mutex_);
size_t max_padding_fec_packet_header_ RTC_GUARDED_BY(send_mutex_);
// RTP variables
uint32_t timestamp_offset_ RTC_GUARDED_BY(send_critsect_);
bool sequence_number_forced_ RTC_GUARDED_BY(send_critsect_);
uint16_t sequence_number_ RTC_GUARDED_BY(send_critsect_);
uint16_t sequence_number_rtx_ RTC_GUARDED_BY(send_critsect_);
uint32_t timestamp_offset_ RTC_GUARDED_BY(send_mutex_);
bool sequence_number_forced_ RTC_GUARDED_BY(send_mutex_);
uint16_t sequence_number_ RTC_GUARDED_BY(send_mutex_);
uint16_t sequence_number_rtx_ RTC_GUARDED_BY(send_mutex_);
// RID value to send in the RID or RepairedRID header extension.
std::string rid_ RTC_GUARDED_BY(send_critsect_);
std::string rid_ RTC_GUARDED_BY(send_mutex_);
// MID value to send in the MID header extension.
std::string mid_ RTC_GUARDED_BY(send_critsect_);
std::string mid_ RTC_GUARDED_BY(send_mutex_);
// Should we send MID/RID even when ACKed? (see below).
const bool always_send_mid_and_rid_;
// Track if any ACK has been received on the SSRC and RTX SSRC to indicate
// when to stop sending the MID and RID header extensions.
bool ssrc_has_acked_ RTC_GUARDED_BY(send_critsect_);
bool rtx_ssrc_has_acked_ RTC_GUARDED_BY(send_critsect_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(send_critsect_);
int64_t capture_time_ms_ RTC_GUARDED_BY(send_critsect_);
int64_t last_timestamp_time_ms_ RTC_GUARDED_BY(send_critsect_);
bool last_packet_marker_bit_ RTC_GUARDED_BY(send_critsect_);
std::vector<uint32_t> csrcs_ RTC_GUARDED_BY(send_critsect_);
int rtx_ RTC_GUARDED_BY(send_critsect_);
bool ssrc_has_acked_ RTC_GUARDED_BY(send_mutex_);
bool rtx_ssrc_has_acked_ RTC_GUARDED_BY(send_mutex_);
uint32_t last_rtp_timestamp_ RTC_GUARDED_BY(send_mutex_);
int64_t capture_time_ms_ RTC_GUARDED_BY(send_mutex_);
int64_t last_timestamp_time_ms_ RTC_GUARDED_BY(send_mutex_);
bool last_packet_marker_bit_ RTC_GUARDED_BY(send_mutex_);
std::vector<uint32_t> csrcs_ RTC_GUARDED_BY(send_mutex_);
int rtx_ RTC_GUARDED_BY(send_mutex_);
// Mapping rtx_payload_type_map_[associated] = rtx.
std::map<int8_t, int8_t> rtx_payload_type_map_ RTC_GUARDED_BY(send_critsect_);
bool supports_bwe_extension_ RTC_GUARDED_BY(send_critsect_);
std::map<int8_t, int8_t> rtx_payload_type_map_ RTC_GUARDED_BY(send_mutex_);
bool supports_bwe_extension_ RTC_GUARDED_BY(send_mutex_);
RateLimiter* const retransmission_rate_limiter_;

View File

@ -66,7 +66,7 @@ int32_t RTPSenderAudio::RegisterAudioPayload(absl::string_view payload_name,
const size_t channels,
const uint32_t rate) {
if (absl::EqualsIgnoreCase(payload_name, "cn")) {
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
// we can have multiple CNG payload types
switch (frequency) {
case 8000:
@ -85,14 +85,14 @@ int32_t RTPSenderAudio::RegisterAudioPayload(absl::string_view payload_name,
return -1;
}
} else if (absl::EqualsIgnoreCase(payload_name, "telephone-event")) {
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
// Don't add it to the list
// we dont want to allow send with a DTMF payloadtype
dtmf_payload_type_ = payload_type;
dtmf_payload_freq_ = frequency;
return 0;
} else if (payload_name == "audio") {
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
encoder_rtp_timestamp_frequency_ = frequency;
return 0;
}
@ -100,7 +100,7 @@ int32_t RTPSenderAudio::RegisterAudioPayload(absl::string_view payload_name,
}
bool RTPSenderAudio::MarkerBit(AudioFrameType frame_type, int8_t payload_type) {
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
// for audio true for first packet in a speech burst
bool marker_bit = false;
if (last_payload_type_ != payload_type) {
@ -174,7 +174,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type,
uint32_t dtmf_payload_freq = 0;
absl::optional<uint32_t> encoder_rtp_timestamp_frequency;
{
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
audio_level_dbov = audio_level_dbov_;
dtmf_payload_freq = dtmf_payload_freq_;
encoder_rtp_timestamp_frequency = encoder_rtp_timestamp_frequency_;
@ -296,7 +296,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type,
return false;
{
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
last_payload_type_ = payload_type;
}
TRACE_EVENT_ASYNC_END2("webrtc", "Audio", rtp_timestamp, "timestamp",
@ -316,7 +316,7 @@ int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dbov) {
if (level_dbov > 127) {
return -1;
}
rtc::CritScope cs(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
audio_level_dbov_ = level_dbov;
return 0;
}
@ -327,7 +327,7 @@ int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key,
uint8_t level) {
DtmfQueue::Event event;
{
rtc::CritScope lock(&send_audio_critsect_);
MutexLock lock(&send_audio_mutex_);
if (dtmf_payload_type_ < 0) {
// TelephoneEvent payloadtype not configured
return -1;

View File

@ -22,8 +22,8 @@
#include "modules/rtp_rtcp/source/dtmf_queue.h"
#include "modules/rtp_rtcp/source/rtp_sender.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/one_time_event.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
@ -74,13 +74,13 @@ class RTPSenderAudio {
Clock* const clock_ = nullptr;
RTPSender* const rtp_sender_ = nullptr;
rtc::CriticalSection send_audio_critsect_;
Mutex send_audio_mutex_;
// DTMF.
bool dtmf_event_is_on_ = false;
bool dtmf_event_first_packet_sent_ = false;
int8_t dtmf_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
uint32_t dtmf_payload_freq_ RTC_GUARDED_BY(send_audio_critsect_) = 8000;
int8_t dtmf_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
uint32_t dtmf_payload_freq_ RTC_GUARDED_BY(send_audio_mutex_) = 8000;
uint32_t dtmf_timestamp_ = 0;
uint32_t dtmf_length_samples_ = 0;
int64_t dtmf_time_last_sent_ = 0;
@ -89,20 +89,20 @@ class RTPSenderAudio {
DtmfQueue dtmf_queue_;
// VAD detection, used for marker bit.
bool inband_vad_active_ RTC_GUARDED_BY(send_audio_critsect_) = false;
int8_t cngnb_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
int8_t cngwb_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
int8_t cngswb_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
int8_t cngfb_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
int8_t last_payload_type_ RTC_GUARDED_BY(send_audio_critsect_) = -1;
bool inband_vad_active_ RTC_GUARDED_BY(send_audio_mutex_) = false;
int8_t cngnb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
int8_t cngwb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
int8_t cngswb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
int8_t cngfb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
int8_t last_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
// Audio level indication.
// (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/)
uint8_t audio_level_dbov_ RTC_GUARDED_BY(send_audio_critsect_) = 0;
uint8_t audio_level_dbov_ RTC_GUARDED_BY(send_audio_mutex_) = 0;
OneTimeEvent first_packet_sent_;
absl::optional<uint32_t> encoder_rtp_timestamp_frequency_
RTC_GUARDED_BY(send_audio_critsect_);
RTC_GUARDED_BY(send_audio_mutex_);
AbsoluteCaptureTimeSender absolute_capture_time_sender_;

View File

@ -178,7 +178,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
absl::optional<std::pair<FecProtectionParams, FecProtectionParams>>
new_fec_params;
{
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
new_fec_params.swap(pending_fec_params_);
}
if (new_fec_params) {
@ -236,7 +236,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
PacketOptions options;
{
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
options.included_in_allocation = force_part_of_allocation_;
}
@ -295,7 +295,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet,
}
RtpSendRates RtpSenderEgress::GetSendRates() const {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
const int64_t now_ms = clock_->TimeInMilliseconds();
return GetSendRatesLocked(now_ms);
}
@ -314,14 +314,14 @@ void RtpSenderEgress::GetDataCounters(StreamDataCounters* rtp_stats,
StreamDataCounters* rtx_stats) const {
// TODO(bugs.webrtc.org/11581): make sure rtx_rtp_stats_ and rtp_stats_ are
// only touched on the worker thread.
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
*rtp_stats = rtp_stats_;
*rtx_stats = rtx_rtp_stats_;
}
void RtpSenderEgress::ForceIncludeSendPacketsInAllocation(
bool part_of_allocation) {
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
force_part_of_allocation_ = part_of_allocation;
}
@ -369,7 +369,7 @@ void RtpSenderEgress::SetFecProtectionParameters(
const FecProtectionParams& key_params) {
// TODO(sprang): Post task to pacer queue instead, one pacer is fully
// migrated to a task queue.
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
pending_fec_params_.emplace(delta_params, key_params);
}
@ -430,7 +430,7 @@ void RtpSenderEgress::UpdateDelayStatistics(int64_t capture_time_ms,
int max_delay_ms = 0;
uint64_t total_packet_send_delay_ms = 0;
{
rtc::CritScope cs(&lock_);
MutexLock lock(&lock_);
// Compute the max and average of the recent capture-to-send delays.
// The time complexity of the current approach depends on the distribution
// of the delay values. This could be done more efficiently.
@ -547,7 +547,7 @@ void RtpSenderEgress::UpdateRtpStats(int64_t now_ms,
// worker thread.
RtpSendRates send_rates;
{
rtc::CritScope lock(&lock_);
MutexLock lock(&lock_);
// TODO(bugs.webrtc.org/11581): make sure rtx_rtp_stats_ and rtp_stats_ are
// only touched on the worker thread.

View File

@ -27,8 +27,8 @@
#include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_interface.h"
#include "modules/rtp_rtcp/source/rtp_sequence_number_map.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/task_utils/pending_task_safety_flag.h"
#include "rtc_base/task_utils/repeating_task.h"
@ -149,7 +149,7 @@ class RtpSenderEgress {
StreamDataCountersCallback* const rtp_stats_callback_;
BitrateStatisticsObserver* const bitrate_callback_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
bool media_has_been_sent_ RTC_GUARDED_BY(pacer_checker_);
bool force_part_of_allocation_ RTC_GUARDED_BY(lock_);
uint32_t timestamp_offset_ RTC_GUARDED_BY(worker_queue_);

View File

@ -175,7 +175,7 @@ void RTPSenderVideo::LogAndSendToNetwork(
#endif
{
rtc::CritScope cs(&stats_crit_);
MutexLock lock(&stats_mutex_);
size_t packetized_payload_size = 0;
for (const auto& packet : packets) {
if (*packet->packet_type() == RtpPacketMediaType::kVideo) {
@ -693,12 +693,12 @@ bool RTPSenderVideo::SendEncodedImage(
}
uint32_t RTPSenderVideo::VideoBitrateSent() const {
rtc::CritScope cs(&stats_crit_);
MutexLock lock(&stats_mutex_);
return video_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0);
}
uint32_t RTPSenderVideo::PacketizationOverheadBps() const {
rtc::CritScope cs(&stats_crit_);
MutexLock lock(&stats_mutex_);
return packetization_overhead_bitrate_.Rate(clock_->TimeInMilliseconds())
.value_or(0);
}
@ -710,7 +710,7 @@ bool RTPSenderVideo::AllowRetransmission(
if (retransmission_settings == kRetransmitOff)
return false;
rtc::CritScope cs(&stats_crit_);
MutexLock lock(&stats_mutex_);
// Media packet storage.
if ((retransmission_settings & kConditionallyRetransmitHigherLayers) &&
UpdateConditionalRetransmit(temporal_id,

View File

@ -33,10 +33,10 @@
#include "modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h"
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "modules/rtp_rtcp/source/video_fec_generator.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/one_time_event.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/thread_annotations.h"
@ -162,7 +162,7 @@ class RTPSenderVideo {
bool UpdateConditionalRetransmit(uint8_t temporal_id,
int64_t expected_retransmission_time_ms)
RTC_EXCLUSIVE_LOCKS_REQUIRED(stats_crit_);
RTC_EXCLUSIVE_LOCKS_REQUIRED(stats_mutex_);
void MaybeUpdateCurrentPlayoutDelay(const RTPVideoHeader& header)
RTC_EXCLUSIVE_LOCKS_REQUIRED(send_checker_);
@ -188,20 +188,20 @@ class RTPSenderVideo {
bool playout_delay_pending_;
// Should never be held when calling out of this class.
rtc::CriticalSection crit_;
Mutex mutex_;
const absl::optional<int> red_payload_type_;
VideoFecGenerator* const fec_generator_;
absl::optional<VideoFecGenerator::FecType> fec_type_;
const size_t fec_overhead_bytes_; // Per packet max FEC overhead.
rtc::CriticalSection stats_crit_;
mutable Mutex stats_mutex_;
// Bitrate used for video payload and RTP headers.
RateStatistics video_bitrate_ RTC_GUARDED_BY(stats_crit_);
RateStatistics packetization_overhead_bitrate_ RTC_GUARDED_BY(stats_crit_);
RateStatistics video_bitrate_ RTC_GUARDED_BY(stats_mutex_);
RateStatistics packetization_overhead_bitrate_ RTC_GUARDED_BY(stats_mutex_);
std::map<int, TemporalLayerStats> frame_stats_by_temporal_layer_
RTC_GUARDED_BY(stats_crit_);
RTC_GUARDED_BY(stats_mutex_);
OneTimeEvent first_frame_sent_;

View File

@ -145,7 +145,7 @@ bool RTPSenderVideoFrameTransformerDelegate::TransformFrame(
void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame(
std::unique_ptr<TransformableFrameInterface> frame) {
rtc::CritScope lock(&sender_lock_);
MutexLock lock(&sender_lock_);
// The encoder queue gets destroyed after the sender; as long as the sender is
// alive, it's safe to post.
@ -161,7 +161,7 @@ void RTPSenderVideoFrameTransformerDelegate::OnTransformedFrame(
void RTPSenderVideoFrameTransformerDelegate::SendVideo(
std::unique_ptr<TransformableFrameInterface> transformed_frame) const {
RTC_CHECK(encoder_queue_->IsCurrent());
rtc::CritScope lock(&sender_lock_);
MutexLock lock(&sender_lock_);
if (!sender_)
return;
auto* transformed_video_frame =
@ -179,7 +179,7 @@ void RTPSenderVideoFrameTransformerDelegate::SendVideo(
void RTPSenderVideoFrameTransformerDelegate::SetVideoStructureUnderLock(
const FrameDependencyStructure* video_structure) {
rtc::CritScope lock(&sender_lock_);
MutexLock lock(&sender_lock_);
RTC_CHECK(sender_);
sender_->SetVideoStructureUnderLock(video_structure);
}
@ -188,7 +188,7 @@ void RTPSenderVideoFrameTransformerDelegate::Reset() {
frame_transformer_->UnregisterTransformedFrameSinkCallback(ssrc_);
frame_transformer_ = nullptr;
{
rtc::CritScope lock(&sender_lock_);
MutexLock lock(&sender_lock_);
sender_ = nullptr;
}
}

View File

@ -16,7 +16,7 @@
#include "api/frame_transformer_interface.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/task_queue_base.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -65,7 +65,7 @@ class RTPSenderVideoFrameTransformerDelegate : public TransformedFrameCallback {
~RTPSenderVideoFrameTransformerDelegate() override = default;
private:
rtc::CriticalSection sender_lock_;
mutable Mutex sender_lock_;
RTPSenderVideo* sender_ RTC_GUARDED_BY(sender_lock_);
rtc::scoped_refptr<FrameTransformerInterface> frame_transformer_;
const uint32_t ssrc_;

View File

@ -25,7 +25,7 @@ void SourceTracker::OnFrameDelivered(const RtpPacketInfos& packet_infos) {
}
int64_t now_ms = clock_->TimeInMilliseconds();
rtc::CritScope lock_scope(&lock_);
MutexLock lock_scope(&lock_);
for (const auto& packet_info : packet_infos) {
for (uint32_t csrc : packet_info.csrcs()) {
@ -54,7 +54,7 @@ std::vector<RtpSource> SourceTracker::GetSources() const {
std::vector<RtpSource> sources;
int64_t now_ms = clock_->TimeInMilliseconds();
rtc::CritScope lock_scope(&lock_);
MutexLock lock_scope(&lock_);
PruneEntries(now_ms);

View File

@ -20,7 +20,7 @@
#include "absl/types/optional.h"
#include "api/rtp_packet_infos.h"
#include "api/transport/rtp/rtp_source.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/clock.h"
@ -116,7 +116,7 @@ class SourceTracker {
void PruneEntries(int64_t now_ms) const RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_);
Clock* const clock_;
rtc::CriticalSection lock_;
mutable Mutex lock_;
// Entries are stored in reverse chronological order (i.e. with the most
// recently updated entries appearing first). Mutability is needed for timeout

View File

@ -22,7 +22,7 @@
#include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/checks.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -103,7 +103,7 @@ void UlpfecGenerator::SetProtectionParameters(
RTC_DCHECK_LE(key_params.fec_rate, 255);
// Store the new params and apply them for the next set of FEC packets being
// produced.
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
pending_params_.emplace(delta_params, key_params);
}
@ -112,7 +112,7 @@ void UlpfecGenerator::AddPacketAndGenerateFec(const RtpPacketToSend& packet) {
RTC_DCHECK(generated_fec_packets_.empty());
if (media_packets_.empty()) {
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
if (pending_params_) {
current_params_ = *pending_params_;
pending_params_.reset();
@ -237,14 +237,14 @@ std::vector<std::unique_ptr<RtpPacketToSend>> UlpfecGenerator::GetFecPackets() {
ResetState();
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
fec_bitrate_.Update(total_fec_size_bytes, clock_->TimeInMilliseconds());
return fec_packets;
}
DataRate UlpfecGenerator::CurrentFecRate() const {
rtc::CritScope cs(&crit_);
MutexLock lock(&mutex_);
return DataRate::BitsPerSec(
fec_bitrate_.Rate(clock_->TimeInMilliseconds()).value_or(0));
}

View File

@ -21,9 +21,9 @@
#include "modules/include/module_fec_types.h"
#include "modules/rtp_rtcp/source/forward_error_correction.h"
#include "modules/rtp_rtcp/source/video_fec_generator.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -112,9 +112,9 @@ class UlpfecGenerator : public VideoFecGenerator {
Params current_params_ RTC_GUARDED_BY(race_checker_);
bool keyframe_in_process_ RTC_GUARDED_BY(race_checker_);
rtc::CriticalSection crit_;
absl::optional<Params> pending_params_ RTC_GUARDED_BY(crit_);
RateStatistics fec_bitrate_ RTC_GUARDED_BY(crit_);
mutable Mutex mutex_;
absl::optional<Params> pending_params_ RTC_GUARDED_BY(mutex_);
RateStatistics fec_bitrate_ RTC_GUARDED_BY(mutex_);
};
} // namespace webrtc

View File

@ -42,7 +42,7 @@ UlpfecReceiverImpl::~UlpfecReceiverImpl() {
}
FecPacketCounter UlpfecReceiverImpl::GetPacketCounter() const {
rtc::CritScope cs(&crit_sect_);
MutexLock lock(&mutex_);
return packet_counter_;
}
@ -87,7 +87,7 @@ bool UlpfecReceiverImpl::AddReceivedRedPacket(
"packet size; dropping.";
return false;
}
rtc::CritScope cs(&crit_sect_);
MutexLock lock(&mutex_);
static constexpr uint8_t kRedHeaderLength = 1;
@ -150,7 +150,7 @@ bool UlpfecReceiverImpl::AddReceivedRedPacket(
// TODO(nisse): Drop always-zero return value.
int32_t UlpfecReceiverImpl::ProcessReceivedFec() {
crit_sect_.Enter();
mutex_.Lock();
// If we iterate over |received_packets_| and it contains a packet that cause
// us to recurse back to this function (for example a RED packet encapsulating
@ -167,10 +167,10 @@ int32_t UlpfecReceiverImpl::ProcessReceivedFec() {
// Send received media packet to VCM.
if (!received_packet->is_fec) {
ForwardErrorCorrection::Packet* packet = received_packet->pkt;
crit_sect_.Leave();
mutex_.Unlock();
recovered_packet_callback_->OnRecoveredPacket(packet->data.data(),
packet->data.size());
crit_sect_.Enter();
mutex_.Lock();
// Create a packet with the buffer to modify it.
RtpPacketReceived rtp_packet;
const uint8_t* const original_data = packet->data.cdata();
@ -207,13 +207,13 @@ int32_t UlpfecReceiverImpl::ProcessReceivedFec() {
// Set this flag first; in case the recovered packet carries a RED
// header, OnRecoveredPacket will recurse back here.
recovered_packet->returned = true;
crit_sect_.Leave();
mutex_.Unlock();
recovered_packet_callback_->OnRecoveredPacket(packet->data.data(),
packet->data.size());
crit_sect_.Enter();
mutex_.Lock();
}
crit_sect_.Leave();
mutex_.Unlock();
return 0;
}

View File

@ -22,7 +22,7 @@
#include "modules/rtp_rtcp/include/ulpfec_receiver.h"
#include "modules/rtp_rtcp/source/forward_error_correction.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/critical_section.h"
#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@ -44,7 +44,7 @@ class UlpfecReceiverImpl : public UlpfecReceiver {
const uint32_t ssrc_;
const RtpHeaderExtensionMap extensions_;
rtc::CriticalSection crit_sect_;
mutable Mutex mutex_;
RecoveredPacketReceiver* recovered_packet_callback_;
std::unique_ptr<ForwardErrorCorrection> fec_;
// TODO(nisse): The AddReceivedRedPacket method adds one or two packets to