Partly migrate test/ to webrtc::Mutex.
This change migrates test/, except for subdirs - test/time_controller - test/pc/e2e Bug: webrtc:11567 Change-Id: Ib6f7c062f1c66caf7083fb4ec60727d66299dbeb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178819 Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31675}
This commit is contained in:
parent
059f4f74df
commit
a5a4be1118
@ -67,6 +67,7 @@ rtc_library("frame_generator_impl") {
|
||||
"../rtc_base:criticalsection",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:rtc_event",
|
||||
"../rtc_base/synchronization:mutex",
|
||||
"../rtc_base/synchronization:sequence_checker",
|
||||
"../rtc_base/system:file_wrapper",
|
||||
"../system_wrappers",
|
||||
@ -248,6 +249,7 @@ rtc_library("perf_test") {
|
||||
"../rtc_base:criticalsection",
|
||||
"../rtc_base:logging",
|
||||
"../rtc_base:rtc_numerics",
|
||||
"../rtc_base/synchronization:mutex",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
if (rtc_enable_protobuf) {
|
||||
@ -523,6 +525,7 @@ if (rtc_include_tests) {
|
||||
"../rtc_base:criticalsection",
|
||||
"../rtc_base:rtc_event",
|
||||
"../rtc_base:rtc_task_queue",
|
||||
"../rtc_base/synchronization:mutex",
|
||||
"../rtc_base/system:file_wrapper",
|
||||
"../rtc_base/task_utils:to_queued_task",
|
||||
"pc/e2e:e2e_unittests",
|
||||
@ -721,6 +724,7 @@ rtc_library("direct_transport") {
|
||||
"../call:simulated_packet_receiver",
|
||||
"../rtc_base:macromagic",
|
||||
"../rtc_base:timeutils",
|
||||
"../rtc_base/synchronization:mutex",
|
||||
"../rtc_base/synchronization:sequence_checker",
|
||||
"../rtc_base/task_utils:repeating_task",
|
||||
]
|
||||
|
||||
@ -83,7 +83,7 @@ void DirectTransport::SendPacket(const uint8_t* data, size_t length) {
|
||||
int64_t send_time_us = rtc::TimeMicros();
|
||||
fake_network_->DeliverPacket(media_type, rtc::CopyOnWriteBuffer(data, length),
|
||||
send_time_us);
|
||||
rtc::CritScope cs(&process_lock_);
|
||||
MutexLock lock(&process_lock_);
|
||||
if (!next_process_task_.Running())
|
||||
ProcessPackets();
|
||||
}
|
||||
@ -112,7 +112,7 @@ void DirectTransport::ProcessPackets() {
|
||||
if (auto delay_ms = fake_network_->TimeUntilNextProcess())
|
||||
return TimeDelta::Millis(*delay_ms);
|
||||
// Otherwise stop the task.
|
||||
rtc::CritScope cs(&process_lock_);
|
||||
MutexLock lock(&process_lock_);
|
||||
next_process_task_.Stop();
|
||||
// Since this task is stopped, return value doesn't matter.
|
||||
return TimeDelta::Zero();
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "call/call.h"
|
||||
#include "call/simulated_packet_receiver.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/synchronization/sequence_checker.h"
|
||||
#include "rtc_base/task_utils/repeating_task.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
@ -66,7 +67,7 @@ class DirectTransport : public Transport {
|
||||
|
||||
TaskQueueBase* const task_queue_;
|
||||
|
||||
rtc::CriticalSection process_lock_;
|
||||
Mutex process_lock_;
|
||||
RepeatingTaskHandle next_process_task_ RTC_GUARDED_BY(&process_lock_);
|
||||
|
||||
const Demuxer demuxer_;
|
||||
|
||||
@ -46,7 +46,7 @@ SquareGenerator::SquareGenerator(int width,
|
||||
}
|
||||
|
||||
void SquareGenerator::ChangeResolution(size_t width, size_t height) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
width_ = static_cast<int>(width);
|
||||
height_ = static_cast<int>(height);
|
||||
RTC_CHECK(width_ > 0);
|
||||
@ -65,7 +65,7 @@ rtc::scoped_refptr<I420Buffer> SquareGenerator::CreateI420Buffer(int width,
|
||||
}
|
||||
|
||||
FrameGeneratorInterface::VideoFrameData SquareGenerator::NextFrame() {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buffer = nullptr;
|
||||
switch (type_) {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
#include "api/video/video_source_interface.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/random.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -57,11 +57,11 @@ class SquareGenerator : public FrameGeneratorInterface {
|
||||
const uint8_t yuv_a_;
|
||||
};
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
Mutex mutex_;
|
||||
const OutputType type_;
|
||||
int width_ RTC_GUARDED_BY(&crit_);
|
||||
int height_ RTC_GUARDED_BY(&crit_);
|
||||
std::vector<std::unique_ptr<Square>> squares_ RTC_GUARDED_BY(&crit_);
|
||||
int width_ RTC_GUARDED_BY(&mutex_);
|
||||
int height_ RTC_GUARDED_BY(&mutex_);
|
||||
std::vector<std::unique_ptr<Square>> squares_ RTC_GUARDED_BY(&mutex_);
|
||||
};
|
||||
|
||||
class YuvFileGenerator : public FrameGeneratorInterface {
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/test/create_frame_generator.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
@ -150,13 +149,13 @@ std::unique_ptr<FrameGeneratorCapturer> FrameGeneratorCapturer::Create(
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::SetFakeRotation(VideoRotation rotation) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
fake_rotation_ = rotation;
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::SetFakeColorSpace(
|
||||
absl::optional<ColorSpace> color_space) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
fake_color_space_ = color_space;
|
||||
}
|
||||
|
||||
@ -176,7 +175,7 @@ bool FrameGeneratorCapturer::Init() {
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::InsertFrame() {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
if (sending_) {
|
||||
FrameGeneratorInterface::VideoFrameData frame_data =
|
||||
frame_generator_->NextFrame();
|
||||
@ -205,7 +204,7 @@ void FrameGeneratorCapturer::InsertFrame() {
|
||||
|
||||
void FrameGeneratorCapturer::Start() {
|
||||
{
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
sending_ = true;
|
||||
}
|
||||
if (!frame_task_.Running()) {
|
||||
@ -217,17 +216,17 @@ void FrameGeneratorCapturer::Start() {
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::Stop() {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
sending_ = false;
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::ChangeResolution(size_t width, size_t height) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
frame_generator_->ChangeResolution(width, height);
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::ChangeFramerate(int target_framerate) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
RTC_CHECK(target_capture_fps_ > 0);
|
||||
if (target_framerate > source_fps_)
|
||||
RTC_LOG(LS_WARNING) << "Target framerate clamped from " << target_framerate
|
||||
@ -245,7 +244,7 @@ void FrameGeneratorCapturer::ChangeFramerate(int target_framerate) {
|
||||
}
|
||||
|
||||
void FrameGeneratorCapturer::SetSinkWantsObserver(SinkWantsObserver* observer) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
RTC_DCHECK(!sink_wants_observer_);
|
||||
sink_wants_observer_ = observer;
|
||||
}
|
||||
@ -254,7 +253,7 @@ void FrameGeneratorCapturer::AddOrUpdateSink(
|
||||
rtc::VideoSinkInterface<VideoFrame>* sink,
|
||||
const rtc::VideoSinkWants& wants) {
|
||||
TestVideoCapturer::AddOrUpdateSink(sink, wants);
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
if (sink_wants_observer_) {
|
||||
// Tests need to observe unmodified sink wants.
|
||||
sink_wants_observer_->OnSinkWantsChanged(sink, wants);
|
||||
@ -266,7 +265,7 @@ void FrameGeneratorCapturer::RemoveSink(
|
||||
rtc::VideoSinkInterface<VideoFrame>* sink) {
|
||||
TestVideoCapturer::RemoveSink(sink);
|
||||
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
UpdateFps(GetSinkWants().max_framerate_fps);
|
||||
}
|
||||
|
||||
@ -284,7 +283,7 @@ void FrameGeneratorCapturer::ForceFrame() {
|
||||
}
|
||||
|
||||
int FrameGeneratorCapturer::GetCurrentConfiguredFramerate() {
|
||||
rtc::CritScope cs(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
if (wanted_fps_ && *wanted_fps_ < target_capture_fps_)
|
||||
return *wanted_fps_;
|
||||
return target_capture_fps_;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "api/task_queue/task_queue_factory.h"
|
||||
#include "api/test/frame_generator_interface.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/task_utils/repeating_task.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
@ -157,7 +157,7 @@ class FrameGeneratorCapturer : public TestVideoCapturer {
|
||||
bool sending_;
|
||||
SinkWantsObserver* sink_wants_observer_ RTC_GUARDED_BY(&lock_);
|
||||
|
||||
rtc::CriticalSection lock_;
|
||||
Mutex lock_;
|
||||
std::unique_ptr<FrameGeneratorInterface> frame_generator_;
|
||||
|
||||
int source_fps_ RTC_GUARDED_BY(&lock_);
|
||||
|
||||
@ -48,6 +48,7 @@ rtc_library("emulated_network") {
|
||||
"../../rtc_base:rtc_task_queue",
|
||||
"../../rtc_base:safe_minmax",
|
||||
"../../rtc_base:task_queue_for_test",
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../../rtc_base/synchronization:sequence_checker",
|
||||
"../../rtc_base/task_utils:repeating_task",
|
||||
"../../rtc_base/third_party/sigslot",
|
||||
|
||||
@ -280,7 +280,7 @@ EmulatedEndpointImpl* FakeNetworkSocketServer::GetEndpointNode(
|
||||
}
|
||||
|
||||
void FakeNetworkSocketServer::Unregister(FakeNetworkSocket* socket) {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
sockets_.erase(absl::c_find(sockets_, socket));
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ rtc::AsyncSocket* FakeNetworkSocketServer::CreateAsyncSocket(int family,
|
||||
RTC_DCHECK(thread_) << "must be attached to thread before creating sockets";
|
||||
FakeNetworkSocket* out = new FakeNetworkSocket(this, thread_);
|
||||
{
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
sockets_.push_back(out);
|
||||
}
|
||||
return out;
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
|
||||
#include "api/units/timestamp.h"
|
||||
#include "rtc_base/async_socket.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/socket_server.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "test/network/network_emulation.h"
|
||||
@ -58,7 +58,7 @@ class FakeNetworkSocketServer : public rtc::SocketServer,
|
||||
rtc::Event wakeup_;
|
||||
rtc::Thread* thread_ = nullptr;
|
||||
|
||||
rtc::CriticalSection lock_;
|
||||
Mutex lock_;
|
||||
std::vector<FakeNetworkSocket*> sockets_ RTC_GUARDED_BY(lock_);
|
||||
};
|
||||
|
||||
|
||||
@ -133,6 +133,7 @@ if (rtc_include_tests) {
|
||||
"../../rtc_base:rtc_task_queue",
|
||||
"../../rtc_base:safe_minmax",
|
||||
"../../rtc_base:task_queue_for_test",
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../../rtc_base/synchronization:sequence_checker",
|
||||
"../../rtc_base/task_utils:repeating_task",
|
||||
"../../system_wrappers",
|
||||
|
||||
@ -86,7 +86,7 @@ bool NetworkNodeTransport::SendRtp(const uint8_t* packet,
|
||||
sent_packet.info.packet_type = rtc::PacketType::kData;
|
||||
sender_call_->OnSentPacket(sent_packet);
|
||||
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
MutexLock lock(&mutex_);
|
||||
if (!endpoint_)
|
||||
return false;
|
||||
rtc::CopyOnWriteBuffer buffer(packet, length);
|
||||
@ -97,7 +97,7 @@ bool NetworkNodeTransport::SendRtp(const uint8_t* packet,
|
||||
|
||||
bool NetworkNodeTransport::SendRtcp(const uint8_t* packet, size_t length) {
|
||||
rtc::CopyOnWriteBuffer buffer(packet, length);
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
MutexLock lock(&mutex_);
|
||||
if (!endpoint_)
|
||||
return false;
|
||||
endpoint_->SendPacket(local_address_, remote_address_, buffer,
|
||||
@ -121,7 +121,7 @@ void NetworkNodeTransport::Connect(EmulatedEndpoint* endpoint,
|
||||
{
|
||||
// Only IPv4 address is supported.
|
||||
RTC_CHECK_EQ(receiver_address.family(), AF_INET);
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
MutexLock lock(&mutex_);
|
||||
endpoint_ = endpoint;
|
||||
local_address_ = rtc::SocketAddress(endpoint_->GetPeerLocalAddress(), 0);
|
||||
remote_address_ = receiver_address;
|
||||
@ -134,7 +134,7 @@ void NetworkNodeTransport::Connect(EmulatedEndpoint* endpoint,
|
||||
}
|
||||
|
||||
void NetworkNodeTransport::Disconnect() {
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
MutexLock lock(&mutex_);
|
||||
current_network_route_.connected = false;
|
||||
sender_call_->GetTransportControllerSend()->OnNetworkRouteChanged(
|
||||
kDummyTransportName, current_network_route_);
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "call/simulated_network.h"
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
#include "rtc_base/copy_on_write_buffer.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "test/network/network_emulation.h"
|
||||
#include "test/scenario/column_printer.h"
|
||||
@ -65,19 +66,19 @@ class NetworkNodeTransport : public Transport {
|
||||
void Disconnect();
|
||||
|
||||
DataSize packet_overhead() {
|
||||
rtc::CritScope crit(&crit_sect_);
|
||||
MutexLock lock(&mutex_);
|
||||
return packet_overhead_;
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::CriticalSection crit_sect_;
|
||||
Mutex mutex_;
|
||||
Clock* const sender_clock_;
|
||||
Call* const sender_call_;
|
||||
EmulatedEndpoint* endpoint_ RTC_GUARDED_BY(crit_sect_) = nullptr;
|
||||
rtc::SocketAddress local_address_ RTC_GUARDED_BY(crit_sect_);
|
||||
rtc::SocketAddress remote_address_ RTC_GUARDED_BY(crit_sect_);
|
||||
DataSize packet_overhead_ RTC_GUARDED_BY(crit_sect_) = DataSize::Zero();
|
||||
rtc::NetworkRoute current_network_route_ RTC_GUARDED_BY(crit_sect_);
|
||||
EmulatedEndpoint* endpoint_ RTC_GUARDED_BY(mutex_) = nullptr;
|
||||
rtc::SocketAddress local_address_ RTC_GUARDED_BY(mutex_);
|
||||
rtc::SocketAddress remote_address_ RTC_GUARDED_BY(mutex_);
|
||||
DataSize packet_overhead_ RTC_GUARDED_BY(mutex_) = DataSize::Zero();
|
||||
rtc::NetworkRoute current_network_route_ RTC_GUARDED_BY(mutex_);
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
||||
@ -373,7 +373,7 @@ SendVideoStream::SendVideoStream(CallClient* sender,
|
||||
case Encoder::Implementation::kFake:
|
||||
encoder_factory_ =
|
||||
std::make_unique<FunctionVideoEncoderFactory>([this]() {
|
||||
rtc::CritScope cs(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
std::unique_ptr<FakeEncoder> encoder;
|
||||
if (config_.encoder.codec == Codec::kVideoCodecVP8) {
|
||||
encoder = std::make_unique<test::FakeVp8Encoder>(sender_->clock_);
|
||||
@ -452,7 +452,7 @@ void SendVideoStream::Stop() {
|
||||
void SendVideoStream::UpdateConfig(
|
||||
std::function<void(VideoStreamConfig*)> modifier) {
|
||||
sender_->SendTask([&] {
|
||||
rtc::CritScope cs(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
VideoStreamConfig prior_config = config_;
|
||||
modifier(&config_);
|
||||
if (prior_config.encoder.fake.max_rate != config_.encoder.fake.max_rate) {
|
||||
@ -473,7 +473,7 @@ void SendVideoStream::UpdateConfig(
|
||||
|
||||
void SendVideoStream::UpdateActiveLayers(std::vector<bool> active_layers) {
|
||||
sender_->task_queue_.PostTask([=] {
|
||||
rtc::CritScope cs(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
if (config_.encoder.codec ==
|
||||
VideoStreamConfig::Encoder::Codec::kVideoCodecVP8) {
|
||||
send_stream_->UpdateActiveSimulcastLayers(active_layers);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "test/fake_encoder.h"
|
||||
#include "test/fake_videorenderer.h"
|
||||
#include "test/frame_generator_capturer.h"
|
||||
@ -53,14 +54,14 @@ class SendVideoStream {
|
||||
Transport* send_transport,
|
||||
VideoFrameMatcher* matcher);
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
Mutex mutex_;
|
||||
std::vector<uint32_t> ssrcs_;
|
||||
std::vector<uint32_t> rtx_ssrcs_;
|
||||
VideoSendStream* send_stream_ = nullptr;
|
||||
CallClient* const sender_;
|
||||
VideoStreamConfig config_ RTC_GUARDED_BY(crit_);
|
||||
VideoStreamConfig config_ RTC_GUARDED_BY(mutex_);
|
||||
std::unique_ptr<VideoEncoderFactory> encoder_factory_;
|
||||
std::vector<test::FakeEncoder*> fake_encoders_ RTC_GUARDED_BY(crit_);
|
||||
std::vector<test::FakeEncoder*> fake_encoders_ RTC_GUARDED_BY(mutex_);
|
||||
std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;
|
||||
std::unique_ptr<FrameGeneratorCapturer> video_capturer_;
|
||||
std::unique_ptr<ForwardingCapturedFrameTap> frame_tap_;
|
||||
|
||||
@ -84,7 +84,7 @@ void TestVideoCapturer::UpdateVideoAdapter() {
|
||||
}
|
||||
|
||||
VideoFrame TestVideoCapturer::MaybePreprocess(const VideoFrame& frame) {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
if (preprocessor_ != nullptr) {
|
||||
return preprocessor_->Preprocess(frame);
|
||||
} else {
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include "api/video/video_source_interface.h"
|
||||
#include "media/base/video_adapter.h"
|
||||
#include "media/base/video_broadcaster.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -38,7 +38,7 @@ class TestVideoCapturer : public rtc::VideoSourceInterface<VideoFrame> {
|
||||
const rtc::VideoSinkWants& wants) override;
|
||||
void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
|
||||
void SetFramePreprocessor(std::unique_ptr<FramePreprocessor> preprocessor) {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
preprocessor_ = std::move(preprocessor);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ class TestVideoCapturer : public rtc::VideoSourceInterface<VideoFrame> {
|
||||
void UpdateVideoAdapter();
|
||||
VideoFrame MaybePreprocess(const VideoFrame& frame);
|
||||
|
||||
rtc::CriticalSection lock_;
|
||||
Mutex lock_;
|
||||
std::unique_ptr<FramePreprocessor> preprocessor_ RTC_GUARDED_BY(lock_);
|
||||
rtc::VideoBroadcaster broadcaster_;
|
||||
cricket::VideoAdapter video_adapter_;
|
||||
|
||||
@ -53,7 +53,7 @@ IvfVideoFrameGenerator::IvfVideoFrameGenerator(const std::string& file_name)
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
}
|
||||
IvfVideoFrameGenerator::~IvfVideoFrameGenerator() {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
if (!file_reader_) {
|
||||
return;
|
||||
}
|
||||
@ -62,7 +62,7 @@ IvfVideoFrameGenerator::~IvfVideoFrameGenerator() {
|
||||
// Reset decoder to prevent it from async access to |this|.
|
||||
video_decoder_.reset();
|
||||
{
|
||||
rtc::CritScope frame_crit(&frame_decode_lock_);
|
||||
MutexLock frame_lock(&frame_decode_lock_);
|
||||
next_frame_ = absl::nullopt;
|
||||
// Set event in case another thread is waiting on it.
|
||||
next_frame_decoded_.Set();
|
||||
@ -70,7 +70,7 @@ IvfVideoFrameGenerator::~IvfVideoFrameGenerator() {
|
||||
}
|
||||
|
||||
FrameGeneratorInterface::VideoFrameData IvfVideoFrameGenerator::NextFrame() {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
next_frame_decoded_.Reset();
|
||||
RTC_CHECK(file_reader_);
|
||||
if (!file_reader_->HasMoreFrames()) {
|
||||
@ -86,7 +86,7 @@ FrameGeneratorInterface::VideoFrameData IvfVideoFrameGenerator::NextFrame() {
|
||||
RTC_CHECK(decoded) << "Failed to decode next frame in "
|
||||
<< kMaxNextFrameWaitTemeoutMs << "ms. Can't continue";
|
||||
|
||||
rtc::CritScope frame_crit(&frame_decode_lock_);
|
||||
MutexLock frame_lock(&frame_decode_lock_);
|
||||
rtc::scoped_refptr<VideoFrameBuffer> buffer =
|
||||
next_frame_->video_frame_buffer();
|
||||
if (width_ != static_cast<size_t>(buffer->width()) ||
|
||||
@ -102,7 +102,7 @@ FrameGeneratorInterface::VideoFrameData IvfVideoFrameGenerator::NextFrame() {
|
||||
}
|
||||
|
||||
void IvfVideoFrameGenerator::ChangeResolution(size_t width, size_t height) {
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
}
|
||||
@ -126,7 +126,7 @@ void IvfVideoFrameGenerator::DecodedCallback::Decoded(
|
||||
}
|
||||
|
||||
void IvfVideoFrameGenerator::OnFrameDecoded(const VideoFrame& decoded_frame) {
|
||||
rtc::CritScope crit(&frame_decode_lock_);
|
||||
MutexLock lock(&frame_decode_lock_);
|
||||
next_frame_ = decoded_frame;
|
||||
next_frame_decoded_.Set();
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
#include "modules/video_coding/utility/ivf_file_reader.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/synchronization/sequence_checker.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -71,11 +71,11 @@ class IvfVideoFrameGenerator : public FrameGeneratorInterface {
|
||||
// FrameGenerator is injected into PeerConnection via some scoped_ref object
|
||||
// and it can happen that the last pointer will be destroyed on the different
|
||||
// thread comparing to the one from which frames were read.
|
||||
rtc::CriticalSection lock_;
|
||||
Mutex lock_;
|
||||
// This lock is used to sync between sending and receiving frame from decoder.
|
||||
// We can't reuse |lock_| because then generator can be destroyed between
|
||||
// frame was sent to decoder and decoder callback was invoked.
|
||||
rtc::CriticalSection frame_decode_lock_;
|
||||
Mutex frame_decode_lock_;
|
||||
|
||||
rtc::Event next_frame_decoded_;
|
||||
absl::optional<VideoFrame> next_frame_ RTC_GUARDED_BY(frame_decode_lock_);
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9.h"
|
||||
#include "modules/video_coding/include/video_error_codes.h"
|
||||
#include "modules/video_coding/utility/ivf_file_writer.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/event.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/file_utils.h"
|
||||
@ -34,6 +33,8 @@
|
||||
|
||||
#if defined(WEBRTC_USE_H264)
|
||||
#include "modules/video_coding/codecs/h264/include/h264.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
@ -71,7 +72,7 @@ class IvfFileWriterEncodedCallback : public EncodedImageCallback {
|
||||
const RTPFragmentationHeader* fragmentation) override {
|
||||
EXPECT_TRUE(file_writer_->WriteFrame(encoded_image, video_codec_type_));
|
||||
|
||||
rtc::CritScope crit(&lock_);
|
||||
MutexLock lock(&lock_);
|
||||
received_frames_count_++;
|
||||
RTC_CHECK_LE(received_frames_count_, expected_frames_count_);
|
||||
if (received_frames_count_ == expected_frames_count_) {
|
||||
@ -89,7 +90,7 @@ class IvfFileWriterEncodedCallback : public EncodedImageCallback {
|
||||
const VideoCodecType video_codec_type_;
|
||||
const int expected_frames_count_;
|
||||
|
||||
rtc::CriticalSection lock_;
|
||||
Mutex lock_;
|
||||
int received_frames_count_ RTC_GUARDED_BY(lock_) = 0;
|
||||
rtc::Event expected_frames_count_received_;
|
||||
};
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "test/testsupport/perf_test_histogram_writer.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -60,7 +60,7 @@ class PlottableCounterPrinter {
|
||||
PlottableCounterPrinter() : output_(stdout) {}
|
||||
|
||||
void SetOutput(FILE* output) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
output_ = output;
|
||||
}
|
||||
|
||||
@ -68,14 +68,14 @@ class PlottableCounterPrinter {
|
||||
const std::string& trace_name,
|
||||
const webrtc::SamplesStatsCounter& counter,
|
||||
const std::string& units) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
plottable_counters_.push_back({graph_name, trace_name, counter, units});
|
||||
}
|
||||
|
||||
void Print(const std::vector<std::string>& desired_graphs_raw) const {
|
||||
std::set<std::string> desired_graphs(desired_graphs_raw.begin(),
|
||||
desired_graphs_raw.end());
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
for (auto& counter : plottable_counters_) {
|
||||
if (!desired_graphs.empty()) {
|
||||
auto it = desired_graphs.find(counter.graph_name);
|
||||
@ -108,9 +108,9 @@ class PlottableCounterPrinter {
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::CriticalSection crit_;
|
||||
std::vector<PlottableCounter> plottable_counters_ RTC_GUARDED_BY(&crit_);
|
||||
FILE* output_ RTC_GUARDED_BY(&crit_);
|
||||
mutable Mutex mutex_;
|
||||
std::vector<PlottableCounter> plottable_counters_ RTC_GUARDED_BY(&mutex_);
|
||||
FILE* output_ RTC_GUARDED_BY(&mutex_);
|
||||
};
|
||||
|
||||
PlottableCounterPrinter& GetPlottableCounterPrinter() {
|
||||
@ -123,7 +123,7 @@ class ResultsLinePrinter {
|
||||
ResultsLinePrinter() : output_(stdout) {}
|
||||
|
||||
void SetOutput(FILE* output) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
output_ = output;
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ class ResultsLinePrinter {
|
||||
const std::string& suffix,
|
||||
const std::string& units,
|
||||
bool important) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
// <*>RESULT <graph_name>: <trace_name>= <value> <units>
|
||||
// <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
|
||||
// <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
|
||||
@ -186,8 +186,8 @@ class ResultsLinePrinter {
|
||||
values.c_str(), suffix.c_str(), units.c_str());
|
||||
}
|
||||
|
||||
rtc::CriticalSection crit_;
|
||||
FILE* output_ RTC_GUARDED_BY(&crit_);
|
||||
Mutex mutex_;
|
||||
FILE* output_ RTC_GUARDED_BY(&mutex_);
|
||||
};
|
||||
|
||||
ResultsLinePrinter& GetResultsLinePrinter() {
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "rtc_base/critical_section.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "third_party/catapult/tracing/tracing/value/diagnostics/reserved_infos.h"
|
||||
#include "third_party/catapult/tracing/tracing/value/histogram.h"
|
||||
|
||||
@ -33,9 +33,9 @@ std::string AsJsonString(const std::string string) {
|
||||
|
||||
class PerfTestHistogramWriter : public PerfTestResultWriter {
|
||||
public:
|
||||
PerfTestHistogramWriter() : crit_() {}
|
||||
PerfTestHistogramWriter() : mutex_() {}
|
||||
void ClearResults() override {
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
histograms_.clear();
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ class PerfTestHistogramWriter : public PerfTestResultWriter {
|
||||
std::string Serialize() const override {
|
||||
proto::HistogramSet histogram_set;
|
||||
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
for (const auto& histogram : histograms_) {
|
||||
std::unique_ptr<proto::Histogram> proto = histogram.second->toProto();
|
||||
histogram_set.mutable_histograms()->AddAllocated(proto.release());
|
||||
@ -108,7 +108,7 @@ class PerfTestHistogramWriter : public PerfTestResultWriter {
|
||||
// parlance). There should be several histograms with the same measurement
|
||||
// if they're for different stories.
|
||||
std::string measurement_and_story = graph_name + trace_name;
|
||||
rtc::CritScope lock(&crit_);
|
||||
MutexLock lock(&mutex_);
|
||||
if (histograms_.count(measurement_and_story) == 0) {
|
||||
proto::UnitAndDirection unit = ParseUnit(units, improve_direction);
|
||||
std::unique_ptr<catapult::HistogramBuilder> builder =
|
||||
@ -182,9 +182,9 @@ class PerfTestHistogramWriter : public PerfTestResultWriter {
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::CriticalSection crit_;
|
||||
mutable Mutex mutex_;
|
||||
std::map<std::string, std::unique_ptr<catapult::HistogramBuilder>> histograms_
|
||||
RTC_GUARDED_BY(&crit_);
|
||||
RTC_GUARDED_BY(&mutex_);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user