Replace Thread::Invoke with Thread::BlockingCall
BlockingCall doesn't take rtc::Location parameter and thus most of the dependencies on location can be removed
Bug: webrtc:11318
Change-Id: I91a17e342dd9a9e3e2c8f7fbe267474c98a8d0e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274620
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38045}
diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc
index b42e439..aa640f3 100644
--- a/pc/rtp_sender.cc
+++ b/pc/rtp_sender.cc
@@ -24,7 +24,6 @@
#include "pc/legacy_stats_collector_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/helpers.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/trace_event.h"
@@ -125,9 +124,8 @@
frame_encryptor_ = std::move(frame_encryptor);
// Special Case: Set the frame encryptor to any value on any existing channel.
if (media_channel_ && ssrc_ && !stopped_) {
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
- media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_);
- });
+ worker_thread_->BlockingCall(
+ [&] { media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_); });
}
}
@@ -142,7 +140,7 @@
void RtpSenderBase::SetEncoderSelectorOnChannel() {
RTC_DCHECK_RUN_ON(signaling_thread_);
if (media_channel_ && ssrc_ && !stopped_) {
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
media_channel_->SetEncoderSelector(ssrc_, encoder_selector_.get());
});
}
@@ -162,7 +160,7 @@
if (!media_channel_ || !ssrc_) {
return init_parameters_;
}
- return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] {
+ return worker_thread_->BlockingCall([&] {
RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_);
RemoveEncodingLayers(disabled_rids_, &result.encodings);
return result;
@@ -177,7 +175,7 @@
if (!media_channel_ || !ssrc_) {
return init_parameters_;
}
- return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] {
+ return worker_thread_->BlockingCall([&] {
RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_);
return result;
});
@@ -208,7 +206,7 @@
}
return result;
}
- return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] {
+ return worker_thread_->BlockingCall([&] {
RtpParameters rtp_parameters = parameters;
if (!disabled_rids_.empty()) {
// Need to add the inactive layers.
@@ -239,7 +237,7 @@
}
return result;
}
- return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] {
+ return worker_thread_->BlockingCall([&] {
RtpParameters rtp_parameters = parameters;
return media_channel_->SetRtpSendParameters(ssrc_, rtp_parameters);
});
@@ -345,7 +343,7 @@
}
if (!init_parameters_.encodings.empty() ||
init_parameters_.degradation_preference.has_value()) {
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
RTC_DCHECK(media_channel_);
// Get the current parameters, which are constructed from the SDP.
// The number of layers in the SDP is currently authoritative to support
@@ -454,7 +452,7 @@
RTC_DCHECK_RUN_ON(signaling_thread_);
frame_transformer_ = std::move(frame_transformer);
if (media_channel_ && ssrc_ && !stopped_) {
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
media_channel_->SetEncoderToPacketizerFrameTransformer(
ssrc_, frame_transformer_);
});
@@ -526,8 +524,8 @@
RTC_LOG(LS_ERROR) << "CanInsertDtmf: Sender does not have SSRC.";
return false;
}
- return worker_thread_->Invoke<bool>(
- RTC_FROM_HERE, [&] { return voice_media_channel()->CanInsertDtmf(); });
+ return worker_thread_->BlockingCall(
+ [&] { return voice_media_channel()->CanInsertDtmf(); });
}
bool AudioRtpSender::InsertDtmf(int code, int duration) {
@@ -539,9 +537,8 @@
RTC_LOG(LS_ERROR) << "InsertDtmf: Sender does not have SSRC.";
return false;
}
- bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
- return voice_media_channel()->InsertDtmf(ssrc_, code, duration);
- });
+ bool success = worker_thread_->BlockingCall(
+ [&] { return voice_media_channel()->InsertDtmf(ssrc_, code, duration); });
if (!success) {
RTC_LOG(LS_ERROR) << "Failed to insert DTMF to channel.";
}
@@ -610,7 +607,7 @@
// `track_->enabled()` hops to the signaling thread, so call it before we hop
// to the worker thread or else it will deadlock.
bool track_enabled = track_->enabled();
- bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
+ bool success = worker_thread_->BlockingCall([&] {
return voice_media_channel()->SetAudioSend(ssrc_, track_enabled, &options,
sink_adapter_.get());
});
@@ -628,7 +625,7 @@
return;
}
cricket::AudioOptions options;
- bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
+ bool success = worker_thread_->BlockingCall([&] {
return voice_media_channel()->SetAudioSend(ssrc_, false, &options, nullptr);
});
if (!success) {
@@ -704,7 +701,7 @@
options.is_screencast = true;
break;
}
- bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
+ bool success = worker_thread_->BlockingCall([&] {
return video_media_channel()->SetVideoSend(ssrc_, &options,
video_track().get());
});
@@ -722,9 +719,8 @@
// Allow SetVideoSend to fail since `enable` is false and `source` is null.
// This the normal case when the underlying media channel has already been
// deleted.
- worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] {
- return video_media_channel()->SetVideoSend(ssrc_, nullptr, nullptr);
- });
+ worker_thread_->BlockingCall(
+ [&] { video_media_channel()->SetVideoSend(ssrc_, nullptr, nullptr); });
}
} // namespace webrtc