Migrate call/ to webrtc::Mutex.
Bug: webrtc:11567
Change-Id: Iab7142c77bc0c1a026cf5121b756094e05bccefe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176742
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31636}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 5f7c603..eb71a33 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -183,6 +183,7 @@
"../rtc_base:rate_limiter",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_task_queue",
+ "../rtc_base/synchronization:mutex",
"../rtc_base/task_utils:repeating_task",
]
absl_deps = [
@@ -341,6 +342,7 @@
"../api/units:timestamp",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
+ "../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
]
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
@@ -369,6 +371,7 @@
"../modules/utility",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
+ "../rtc_base/synchronization:mutex",
"../rtc_base/synchronization:sequence_checker",
"../system_wrappers",
]
@@ -434,6 +437,7 @@
"../rtc_base:rate_limiter",
"../rtc_base:rtc_base_approved",
"../rtc_base:task_queue_for_test",
+ "../rtc_base/synchronization:mutex",
"../system_wrappers",
"../test:audio_codec_mocks",
"../test:direct_transport",
@@ -493,6 +497,7 @@
"../rtc_base:rtc_base_approved",
"../rtc_base:task_queue_for_test",
"../rtc_base:task_queue_for_test",
+ "../rtc_base/synchronization:mutex",
"../rtc_base/task_utils:repeating_task",
"../system_wrappers",
"../system_wrappers:metrics",
diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn
index 084b7bd..6aa82e5 100644
--- a/call/adaptation/BUILD.gn
+++ b/call/adaptation/BUILD.gn
@@ -49,6 +49,7 @@
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base/experiments:balanced_degradation_settings",
+ "../../rtc_base/synchronization:mutex",
"../../rtc_base/synchronization:sequence_checker",
"../../rtc_base/task_utils:to_queued_task",
]
@@ -85,6 +86,7 @@
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:task_queue_for_test",
+ "../../rtc_base/synchronization:mutex",
"../../test:field_trial",
"../../test:rtc_expect_death",
"../../test:test_support",
diff --git a/call/adaptation/broadcast_resource_listener.cc b/call/adaptation/broadcast_resource_listener.cc
index 2a4d8ca..59bd1e0 100644
--- a/call/adaptation/broadcast_resource_listener.cc
+++ b/call/adaptation/broadcast_resource_listener.cc
@@ -15,8 +15,8 @@
#include <utility>
#include "rtc_base/checks.h"
-#include "rtc_base/critical_section.h"
#include "rtc_base/ref_counted_object.h"
+#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -29,7 +29,7 @@
// The parent is letting us know we have a usage neasurement.
void OnResourceUsageStateMeasured(ResourceUsageState usage_state) {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
if (!listener_)
return;
listener_->OnResourceUsageStateMeasured(this, usage_state);
@@ -38,14 +38,14 @@
// Resource implementation.
std::string Name() const override { return name_; }
void SetResourceListener(ResourceListener* listener) override {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
RTC_DCHECK(!listener_ || !listener);
listener_ = listener;
}
private:
const std::string name_;
- rtc::CriticalSection lock_;
+ Mutex lock_;
ResourceListener* listener_ RTC_GUARDED_BY(lock_) = nullptr;
};
@@ -64,14 +64,14 @@
}
void BroadcastResourceListener::StartListening() {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
RTC_DCHECK(!is_listening_);
source_resource_->SetResourceListener(this);
is_listening_ = true;
}
void BroadcastResourceListener::StopListening() {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
RTC_DCHECK(is_listening_);
RTC_DCHECK(adapters_.empty());
source_resource_->SetResourceListener(nullptr);
@@ -80,7 +80,7 @@
rtc::scoped_refptr<Resource>
BroadcastResourceListener::CreateAdapterResource() {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
RTC_DCHECK(is_listening_);
rtc::scoped_refptr<AdapterResource> adapter =
new rtc::RefCountedObject<AdapterResource>(source_resource_->Name() +
@@ -91,7 +91,7 @@
void BroadcastResourceListener::RemoveAdapterResource(
rtc::scoped_refptr<Resource> resource) {
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
auto it = std::find(adapters_.begin(), adapters_.end(), resource);
RTC_DCHECK(it != adapters_.end());
adapters_.erase(it);
@@ -100,7 +100,7 @@
std::vector<rtc::scoped_refptr<Resource>>
BroadcastResourceListener::GetAdapterResources() {
std::vector<rtc::scoped_refptr<Resource>> resources;
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
for (const auto& adapter : adapters_) {
resources.push_back(adapter);
}
@@ -111,7 +111,7 @@
rtc::scoped_refptr<Resource> resource,
ResourceUsageState usage_state) {
RTC_DCHECK_EQ(resource, source_resource_);
- rtc::CritScope crit(&lock_);
+ MutexLock lock(&lock_);
for (const auto& adapter : adapters_) {
adapter->OnResourceUsageStateMeasured(usage_state);
}
diff --git a/call/adaptation/broadcast_resource_listener.h b/call/adaptation/broadcast_resource_listener.h
index f0d035d..2c5a5c7 100644
--- a/call/adaptation/broadcast_resource_listener.h
+++ b/call/adaptation/broadcast_resource_listener.h
@@ -15,7 +15,7 @@
#include "api/adaptation/resource.h"
#include "api/scoped_refptr.h"
-#include "rtc_base/critical_section.h"
+#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -62,7 +62,7 @@
friend class AdapterResource;
const rtc::scoped_refptr<Resource> source_resource_;
- rtc::CriticalSection lock_;
+ Mutex lock_;
bool is_listening_ RTC_GUARDED_BY(lock_);
// The AdapterResource unregisters itself prior to destruction, guaranteeing
// that these pointers are safe to use.
diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc
index 4e0f885..e7298d6 100644
--- a/call/adaptation/resource_adaptation_processor_unittest.cc
+++ b/call/adaptation/resource_adaptation_processor_unittest.cc
@@ -20,9 +20,9 @@
#include "call/adaptation/test/fake_resource.h"
#include "call/adaptation/video_source_restrictions.h"
#include "call/adaptation/video_stream_input_state_provider.h"
-#include "rtc_base/critical_section.h"
#include "rtc_base/event.h"
#include "rtc_base/gunit.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/task_queue_for_test.h"
#include "test/gtest.h"
diff --git a/call/adaptation/video_stream_input_state_provider.cc b/call/adaptation/video_stream_input_state_provider.cc
index 4ecf858..3c0a7e3 100644
--- a/call/adaptation/video_stream_input_state_provider.cc
+++ b/call/adaptation/video_stream_input_state_provider.cc
@@ -19,19 +19,19 @@
VideoStreamInputStateProvider::~VideoStreamInputStateProvider() {}
void VideoStreamInputStateProvider::OnHasInputChanged(bool has_input) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
input_state_.set_has_input(has_input);
}
void VideoStreamInputStateProvider::OnFrameSizeObserved(int frame_size_pixels) {
RTC_DCHECK_GT(frame_size_pixels, 0);
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
input_state_.set_frame_size_pixels(frame_size_pixels);
}
void VideoStreamInputStateProvider::OnEncoderSettingsChanged(
EncoderSettings encoder_settings) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
input_state_.set_video_codec_type(
encoder_settings.encoder_config().codec_type);
input_state_.set_min_pixels_per_frame(
@@ -41,7 +41,7 @@
VideoStreamInputState VideoStreamInputStateProvider::InputState() {
// GetInputFrameRate() is thread-safe.
int input_fps = frame_rate_provider_->GetInputFrameRate();
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
input_state_.set_frames_per_second(input_fps);
return input_state_;
}
diff --git a/call/adaptation/video_stream_input_state_provider.h b/call/adaptation/video_stream_input_state_provider.h
index a20ac17..f4a3e0b 100644
--- a/call/adaptation/video_stream_input_state_provider.h
+++ b/call/adaptation/video_stream_input_state_provider.h
@@ -14,7 +14,7 @@
#include "api/video/video_stream_encoder_observer.h"
#include "call/adaptation/encoder_settings.h"
#include "call/adaptation/video_stream_input_state.h"
-#include "rtc_base/critical_section.h"
+#include "rtc_base/synchronization/mutex.h"
namespace webrtc {
@@ -31,9 +31,9 @@
virtual VideoStreamInputState InputState();
private:
- mutable rtc::CriticalSection crit_;
+ Mutex mutex_;
VideoStreamEncoderObserver* const frame_rate_provider_;
- VideoStreamInputState input_state_ RTC_GUARDED_BY(crit_);
+ VideoStreamInputState input_state_ RTC_GUARDED_BY(mutex_);
};
} // namespace webrtc
diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc
index 50da12b..cd052dc 100644
--- a/call/bitrate_estimator_tests.cc
+++ b/call/bitrate_estimator_tests.cc
@@ -19,6 +19,7 @@
#include "rtc_base/checks.h"
#include "rtc_base/event.h"
#include "rtc_base/logging.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/thread_annotations.h"
#include "test/call_test.h"
@@ -49,7 +50,7 @@
class Callback : public rtc::LogSink {
public:
void OnLogMessage(const std::string& message) override {
- rtc::CritScope lock(&crit_sect_);
+ MutexLock lock(&mutex_);
// Ignore log lines that are due to missing AST extensions, these are
// logged when we switch back from AST to TOF until the wrapping bitrate
// estimator gives up on using AST.
@@ -78,15 +79,15 @@
bool Wait() { return done_.Wait(test::CallTest::kDefaultTimeoutMs); }
void PushExpectedLogLine(const std::string& expected_log_line) {
- rtc::CritScope lock(&crit_sect_);
+ MutexLock lock(&mutex_);
expected_log_lines_.push_back(expected_log_line);
}
private:
typedef std::list<std::string> Strings;
- rtc::CriticalSection crit_sect_;
- Strings received_log_lines_ RTC_GUARDED_BY(crit_sect_);
- Strings expected_log_lines_ RTC_GUARDED_BY(crit_sect_);
+ Mutex mutex_;
+ Strings received_log_lines_ RTC_GUARDED_BY(mutex_);
+ Strings expected_log_lines_ RTC_GUARDED_BY(mutex_);
rtc::Event done_;
};
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index 123be7d..9214ae5 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -29,6 +29,7 @@
#include "modules/audio_mixer/audio_mixer_impl.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "rtc_base/checks.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
@@ -409,7 +410,7 @@
}
void OnFrame(const VideoFrame& video_frame) override {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
if (video_frame.ntp_time_ms() <= 0) {
// Haven't got enough RTCP SR in order to calculate the capture ntp
// time.
@@ -445,7 +446,7 @@
}
Action OnSendRtp(const uint8_t* packet, size_t length) override {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
RtpPacket rtp_packet;
EXPECT_TRUE(rtp_packet.Parse(packet, length));
@@ -488,7 +489,7 @@
time_offset_ms_list_, "ms", true);
}
- rtc::CriticalSection crit_;
+ Mutex mutex_;
const BuiltInNetworkBehaviorConfig net_config_;
Clock* const clock_;
int threshold_ms_;
@@ -499,7 +500,7 @@
bool rtp_start_timestamp_set_;
uint32_t rtp_start_timestamp_;
typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList;
- FrameCaptureTimeList capture_time_list_ RTC_GUARDED_BY(&crit_);
+ FrameCaptureTimeList capture_time_list_ RTC_GUARDED_BY(&mutex_);
std::vector<double> time_offset_ms_list_;
} test(net_config, threshold_ms, start_time_ms, run_time_ms);
diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc
index 8844700..324a7bd 100644
--- a/call/fake_network_pipe.cc
+++ b/call/fake_network_pipe.cc
@@ -122,17 +122,17 @@
}
void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
receiver_ = receiver;
}
void FakeNetworkPipe::AddActiveTransport(Transport* transport) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
active_transports_[transport]++;
}
void FakeNetworkPipe::RemoveActiveTransport(Transport* transport) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
auto it = active_transports_.find(transport);
RTC_CHECK(it != active_transports_.end());
if (--(it->second) == 0) {
@@ -186,7 +186,7 @@
}
void FakeNetworkPipe::SetClockOffset(int64_t offset_ms) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
clock_offset_ms_ = offset_ms;
}
@@ -198,7 +198,7 @@
bool is_rtcp,
MediaType media_type,
absl::optional<int64_t> packet_time_us) {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
int64_t time_now_us = clock_->TimeInMicroseconds();
return EnqueuePacket(NetworkPacket(std::move(packet), time_now_us,
time_now_us, options, is_rtcp, media_type,
@@ -209,7 +209,7 @@
absl::optional<PacketOptions> options,
bool is_rtcp,
Transport* transport) {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
int64_t time_now_us = clock_->TimeInMicroseconds();
return EnqueuePacket(NetworkPacket(std::move(packet), time_now_us,
time_now_us, options, is_rtcp,
@@ -233,7 +233,7 @@
}
float FakeNetworkPipe::PercentageLoss() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
if (sent_packets_ == 0)
return 0;
@@ -242,7 +242,7 @@
}
int FakeNetworkPipe::AverageDelay() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
if (sent_packets_ == 0)
return 0;
@@ -251,12 +251,12 @@
}
size_t FakeNetworkPipe::DroppedPackets() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
return dropped_packets_;
}
size_t FakeNetworkPipe::SentPackets() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
return sent_packets_;
}
@@ -264,7 +264,7 @@
int64_t time_now_us;
std::queue<NetworkPacket> packets_to_deliver;
{
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
time_now_us = clock_->TimeInMicroseconds();
if (time_now_us - last_log_time_us_ > kLogIntervalMs * 1000) {
int64_t queueing_delay_us = 0;
@@ -318,7 +318,7 @@
}
}
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
while (!packets_to_deliver.empty()) {
NetworkPacket packet = std::move(packets_to_deliver.front());
packets_to_deliver.pop();
@@ -354,7 +354,7 @@
}
absl::optional<int64_t> FakeNetworkPipe::TimeUntilNextProcess() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
absl::optional<int64_t> delivery_us = network_behavior_->NextDeliveryTimeUs();
if (delivery_us) {
int64_t delay_us = *delivery_us - clock_->TimeInMicroseconds();
@@ -364,17 +364,17 @@
}
bool FakeNetworkPipe::HasReceiver() const {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
return receiver_ != nullptr;
}
void FakeNetworkPipe::DeliverPacketWithLock(NetworkPacket* packet) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
DeliverNetworkPacket(packet);
}
void FakeNetworkPipe::ResetStats() {
- rtc::CritScope crit(&process_lock_);
+ MutexLock lock(&process_lock_);
dropped_packets_ = 0;
sent_packets_ = 0;
total_packet_delay_us_ = 0;
diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h
index 24340a2..1e5bb51 100644
--- a/call/fake_network_pipe.h
+++ b/call/fake_network_pipe.h
@@ -24,7 +24,7 @@
#include "call/call.h"
#include "call/simulated_packet_receiver.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 {
@@ -204,14 +204,14 @@
Clock* const clock_;
// |config_lock| guards the mostly constant things like the callbacks.
- rtc::CriticalSection config_lock_;
+ mutable Mutex config_lock_;
const std::unique_ptr<NetworkBehaviorInterface> network_behavior_;
PacketReceiver* receiver_ RTC_GUARDED_BY(config_lock_);
Transport* const global_transport_;
// |process_lock| guards the data structures involved in delay and loss
// processes, such as the packet queues.
- rtc::CriticalSection process_lock_;
+ Mutex process_lock_;
// Packets are added at the back of the deque, this makes the deque ordered
// by increasing send time. The common case when removing packets from the
// deque is removing early packets, which will be close to the front of the
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index 854a18a..3217b3c 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -467,7 +467,7 @@
}
void RtpVideoSender::SetActive(bool active) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
if (active_ == active)
return;
const std::vector<bool> active_modules(rtp_streams_.size(), active);
@@ -475,7 +475,7 @@
}
void RtpVideoSender::SetActiveModules(const std::vector<bool> active_modules) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
return SetActiveModulesLocked(active_modules);
}
@@ -495,7 +495,7 @@
}
bool RtpVideoSender::IsActive() {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
return IsActiveLocked();
}
@@ -509,7 +509,7 @@
const RTPFragmentationHeader* fragmentation) {
fec_controller_->UpdateWithEncodedData(encoded_image.size(),
encoded_image._frameType);
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
RTC_DCHECK(!rtp_streams_.empty());
if (!active_)
return Result(Result::ERROR_SEND_FAILED);
@@ -583,7 +583,7 @@
void RtpVideoSender::OnBitrateAllocationUpdated(
const VideoBitrateAllocation& bitrate) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
if (IsActiveLocked()) {
if (rtp_streams_.size() == 1) {
// If spatial scalability is enabled, it is covered by a single stream.
@@ -726,7 +726,7 @@
std::map<uint32_t, RtpPayloadState> RtpVideoSender::GetRtpPayloadStates()
const {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
std::map<uint32_t, RtpPayloadState> payload_states;
for (const auto& param : params_) {
payload_states[param.ssrc()] = param.state();
@@ -737,7 +737,7 @@
void RtpVideoSender::OnTransportOverheadChanged(
size_t transport_overhead_bytes_per_packet) {
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet;
size_t max_rtp_packet_size =
@@ -751,7 +751,7 @@
void RtpVideoSender::OnBitrateUpdated(BitrateAllocationUpdate update,
int framerate) {
// Substract overhead from bitrate.
- rtc::CritScope lock(&crit_);
+ MutexLock lock(&mutex_);
size_t num_active_streams = 0;
size_t overhead_bytes_per_packet = 0;
for (const auto& stream : rtp_streams_) {
@@ -880,14 +880,14 @@
}
void RtpVideoSender::SetFecAllowed(bool fec_allowed) {
- rtc::CritScope cs(&crit_);
+ MutexLock lock(&mutex_);
fec_allowed_ = fec_allowed;
}
void RtpVideoSender::OnPacketFeedbackVector(
std::vector<StreamPacketInfo> packet_feedback_vector) {
if (fec_controller_->UseLossVectorMask()) {
- rtc::CritScope cs(&crit_);
+ MutexLock lock(&mutex_);
for (const StreamPacketInfo& packet : packet_feedback_vector) {
loss_mask_vector_.push_back(!packet.received);
}
diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h
index e364729..876f6e9 100644
--- a/call/rtp_video_sender.h
+++ b/call/rtp_video_sender.h
@@ -36,8 +36,8 @@
#include "modules/rtp_rtcp/source/rtp_video_header.h"
#include "modules/utility/include/process_thread.h"
#include "rtc_base/constructor_magic.h"
-#include "rtc_base/critical_section.h"
#include "rtc_base/rate_limiter.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
@@ -97,27 +97,27 @@
// TODO(perkj): Replace the use of |module_process_thread| with a TaskQueue,
// maybe |worker_queue|.
void RegisterProcessThread(ProcessThread* module_process_thread)
- RTC_LOCKS_EXCLUDED(crit_) override;
- void DeRegisterProcessThread() RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
+ void DeRegisterProcessThread() RTC_LOCKS_EXCLUDED(mutex_) override;
// RtpVideoSender will only route packets if being active, all packets will be
// dropped otherwise.
- void SetActive(bool active) RTC_LOCKS_EXCLUDED(crit_) override;
+ void SetActive(bool active) RTC_LOCKS_EXCLUDED(mutex_) override;
// Sets the sending status of the rtp modules and appropriately sets the
// payload router to active if any rtp modules are active.
void SetActiveModules(const std::vector<bool> active_modules)
- RTC_LOCKS_EXCLUDED(crit_) override;
- bool IsActive() RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
+ bool IsActive() RTC_LOCKS_EXCLUDED(mutex_) override;
void OnNetworkAvailability(bool network_available)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
std::map<uint32_t, RtpState> GetRtpStates() const
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
void DeliverRtcp(const uint8_t* packet, size_t length)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
// Implements webrtc::VCMProtectionCallback.
int ProtectionRequest(const FecProtectionParams* delta_params,
@@ -125,10 +125,10 @@
uint32_t* sent_video_rate_bps,
uint32_t* sent_nack_rate_bps,
uint32_t* sent_fec_rate_bps)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
// Implements FecControllerOverride.
- void SetFecAllowed(bool fec_allowed) RTC_LOCKS_EXCLUDED(crit_) override;
+ void SetFecAllowed(bool fec_allowed) RTC_LOCKS_EXCLUDED(mutex_) override;
// Implements EncodedImageCallback.
// Returns 0 if the packet was routed / sent, -1 otherwise.
@@ -136,35 +136,35 @@
const EncodedImage& encoded_image,
const CodecSpecificInfo* codec_specific_info,
const RTPFragmentationHeader* fragmentation)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
void OnBitrateAllocationUpdated(const VideoBitrateAllocation& bitrate)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
void OnTransportOverheadChanged(size_t transport_overhead_bytes_per_packet)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
void OnBitrateUpdated(BitrateAllocationUpdate update, int framerate)
- RTC_LOCKS_EXCLUDED(crit_) override;
- uint32_t GetPayloadBitrateBps() const RTC_LOCKS_EXCLUDED(crit_) override;
- uint32_t GetProtectionBitrateBps() const RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
+ uint32_t GetPayloadBitrateBps() const RTC_LOCKS_EXCLUDED(mutex_) override;
+ uint32_t GetProtectionBitrateBps() const RTC_LOCKS_EXCLUDED(mutex_) override;
void SetEncodingData(size_t width, size_t height, size_t num_temporal_layers)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos(
uint32_t ssrc,
rtc::ArrayView<const uint16_t> sequence_numbers) const
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
// From StreamFeedbackObserver.
void OnPacketFeedbackVector(
std::vector<StreamPacketInfo> packet_feedback_vector)
- RTC_LOCKS_EXCLUDED(crit_) override;
+ RTC_LOCKS_EXCLUDED(mutex_) override;
private:
- bool IsActiveLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ bool IsActiveLocked() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
void SetActiveModulesLocked(const std::vector<bool> active_modules)
- RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
- void UpdateModuleSendingState() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
+ void UpdateModuleSendingState() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
void ConfigureProtection();
void ConfigureSsrcs();
void ConfigureRids();
@@ -178,17 +178,17 @@
const bool has_packet_feedback_;
const bool use_deferred_fec_;
- // TODO(holmer): Remove crit_ once RtpVideoSender runs on the
+ // TODO(holmer): Remove mutex_ once RtpVideoSender runs on the
// transport task queue.
- rtc::CriticalSection crit_;
- bool active_ RTC_GUARDED_BY(crit_);
+ mutable Mutex mutex_;
+ bool active_ RTC_GUARDED_BY(mutex_);
ProcessThread* module_process_thread_;
rtc::ThreadChecker module_process_thread_checker_;
std::map<uint32_t, RtpState> suspended_ssrcs_;
const std::unique_ptr<FecController> fec_controller_;
- bool fec_allowed_ RTC_GUARDED_BY(crit_);
+ bool fec_allowed_ RTC_GUARDED_BY(mutex_);
// Rtp modules are assumed to be sorted in simulcast index order.
const std::vector<webrtc_internal_rtp_video_sender::RtpStreamSender>
@@ -202,15 +202,15 @@
// rewrite the frame id), therefore |shared_frame_id| has to live in a place
// where we are aware of all the different streams.
int64_t shared_frame_id_ = 0;
- std::vector<RtpPayloadParams> params_ RTC_GUARDED_BY(crit_);
+ std::vector<RtpPayloadParams> params_ RTC_GUARDED_BY(mutex_);
- size_t transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(crit_);
+ size_t transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(mutex_);
uint32_t protection_bitrate_bps_;
uint32_t encoder_target_rate_bps_;
- std::vector<bool> loss_mask_vector_ RTC_GUARDED_BY(crit_);
+ std::vector<bool> loss_mask_vector_ RTC_GUARDED_BY(mutex_);
- std::vector<FrameCounts> frame_counts_ RTC_GUARDED_BY(crit_);
+ std::vector<FrameCounts> frame_counts_ RTC_GUARDED_BY(mutex_);
FrameCountObserver* const frame_count_observer_;
// Effectively const map from SSRC to RtpRtcp, for all media SSRCs.
diff --git a/call/simulated_network.cc b/call/simulated_network.cc
index b298fdb..2ed9140 100644
--- a/call/simulated_network.cc
+++ b/call/simulated_network.cc
@@ -87,7 +87,7 @@
SimulatedNetwork::~SimulatedNetwork() = default;
void SimulatedNetwork::SetConfig(const Config& config) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
config_state_.config = config; // Shallow copy of the struct.
double prob_loss = config.loss_percent / 100.0;
if (config_state_.config.avg_burst_loss_length == -1) {
@@ -113,12 +113,12 @@
void SimulatedNetwork::UpdateConfig(
std::function<void(BuiltInNetworkBehaviorConfig*)> config_modifier) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
config_modifier(&config_state_.config);
}
void SimulatedNetwork::PauseTransmissionUntil(int64_t until_us) {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
config_state_.pause_transmission_until_us = until_us;
}
@@ -260,7 +260,7 @@
}
SimulatedNetwork::ConfigState SimulatedNetwork::GetConfigState() const {
- rtc::CritScope crit(&config_lock_);
+ MutexLock lock(&config_lock_);
return config_state_;
}
diff --git a/call/simulated_network.h b/call/simulated_network.h
index 2ff90ec..b53ecc0 100644
--- a/call/simulated_network.h
+++ b/call/simulated_network.h
@@ -20,9 +20,9 @@
#include "api/test/simulated_network.h"
#include "api/units/data_size.h"
#include "api/units/timestamp.h"
-#include "rtc_base/critical_section.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/random.h"
+#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
@@ -96,7 +96,7 @@
RTC_RUN_ON(&process_checker_);
ConfigState GetConfigState() const;
- rtc::CriticalSection config_lock_;
+ mutable Mutex config_lock_;
// |process_checker_| guards the data structures involved in delay and loss
// processes, such as the packet queues.