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/audio/voip/BUILD.gn b/audio/voip/BUILD.gn
index a70d1c3..1b8c29e 100644
--- a/audio/voip/BUILD.gn
+++ b/audio/voip/BUILD.gn
@@ -46,7 +46,6 @@
"../../modules/rtp_rtcp",
"../../modules/rtp_rtcp:rtp_rtcp_format",
"../../rtc_base:criticalsection",
- "../../rtc_base:location",
"../../rtc_base:logging",
"../../rtc_base:refcount",
]
diff --git a/audio/voip/audio_channel.cc b/audio/voip/audio_channel.cc
index 4650d19..a70e33e 100644
--- a/audio/voip/audio_channel.cc
+++ b/audio/voip/audio_channel.cc
@@ -17,7 +17,6 @@
#include "api/task_queue/task_queue_factory.h"
#include "modules/rtp_rtcp/include/receive_statistics.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
namespace webrtc {
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 2e24e32..36f42d8 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -209,7 +209,6 @@
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:race_checker",
@@ -318,7 +317,6 @@
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rate_limiter",
diff --git a/call/call.cc b/call/call.cc
index 959d028..ae796cf 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -52,7 +52,6 @@
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/video_coding/fec_controller_default.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/no_unique_address.h"
diff --git a/call/degraded_call.cc b/call/degraded_call.cc
index bc3f587..8c3da57 100644
--- a/call/degraded_call.cc
+++ b/call/degraded_call.cc
@@ -14,7 +14,6 @@
#include <utility>
#include "absl/strings/string_view.h"
-#include "rtc_base/location.h"
namespace webrtc {
diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc
index 9e00078..db8b7e7 100644
--- a/call/flexfec_receive_stream_impl.cc
+++ b/call/flexfec_receive_stream_impl.cc
@@ -24,7 +24,6 @@
#include "modules/rtp_rtcp/include/receive_statistics.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/clock.h"
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc
index a7e2f69..0e4f8d8 100644
--- a/call/rtp_video_sender.cc
+++ b/call/rtp_video_sender.cc
@@ -28,7 +28,6 @@
#include "modules/rtp_rtcp/source/rtp_sender.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/trace_event.h"
diff --git a/examples/androidvoip/jni/android_voip_client.cc b/examples/androidvoip/jni/android_voip_client.cc
index 9f17ed0..cf07e87 100644
--- a/examples/androidvoip/jni/android_voip_client.cc
+++ b/examples/androidvoip/jni/android_voip_client.cc
@@ -135,7 +135,7 @@
// Due to consistent thread requirement on
// modules/audio_device/android/audio_device_template.h,
// code is invoked in the context of voip_thread_.
- voip_thread_->Invoke<void>(RTC_FROM_HERE, [this, &config] {
+ voip_thread_->BlockingCall([this, &config] {
RTC_DCHECK_RUN_ON(voip_thread_.get());
supported_codecs_ = config.encoder_factory->GetSupportedEncoders();
@@ -145,7 +145,7 @@
}
AndroidVoipClient::~AndroidVoipClient() {
- voip_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
+ voip_thread_->BlockingCall([this] {
RTC_DCHECK_RUN_ON(voip_thread_.get());
JavaVM* jvm = nullptr;
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index 5ce38a3..5f3556a 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -46,7 +46,6 @@
"../../logging:rtc_event_pacing",
"../../rtc_base:checks",
"../../rtc_base:event_tracer",
- "../../rtc_base:location",
"../../rtc_base:logging",
"../../rtc_base:macromagic",
"../../rtc_base:rtc_numerics",
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index e69fb86..031db70 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -381,7 +381,6 @@
"../../modules/rtp_rtcp:rtp_video_header",
"../../rtc_base:checks",
"../../rtc_base:event_tracer",
- "../../rtc_base:location",
"../../rtc_base:logging",
"../../rtc_base:macromagic",
"../../rtc_base:one_time_event",
@@ -1220,7 +1219,6 @@
"../../rtc_base",
"../../rtc_base:checks",
"../../rtc_base:histogram_percentile_counter",
- "../../rtc_base:location",
"../../rtc_base:platform_thread",
"../../rtc_base:random",
"../../rtc_base:refcount",
diff --git a/modules/video_coding/jitter_buffer_unittest.cc b/modules/video_coding/jitter_buffer_unittest.cc
index 930eca5..cc791fe 100644
--- a/modules/video_coding/jitter_buffer_unittest.cc
+++ b/modules/video_coding/jitter_buffer_unittest.cc
@@ -21,7 +21,6 @@
#include "modules/video_coding/media_opt_util.h"
#include "modules/video_coding/packet.h"
#include "modules/video_coding/test/stream_generator.h"
-#include "rtc_base/location.h"
#include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h"
#include "test/gmock.h"
diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc
index 51d74c9..38b70f8 100644
--- a/modules/video_coding/video_receiver.cc
+++ b/modules/video_coding/video_receiver.cc
@@ -30,7 +30,6 @@
#include "modules/video_coding/timing/timing.h"
#include "modules/video_coding/video_coding_impl.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/one_time_event.h"
#include "rtc_base/trace_event.h"
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index e99fc01..46bf22d 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -87,7 +87,6 @@
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:socket",
@@ -294,7 +293,6 @@
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:threading",
@@ -482,7 +480,6 @@
"../p2p:rtc_p2p",
"../rtc_base",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:threading",
@@ -854,7 +851,6 @@
"../media:rtc_media_base",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rtc_base",
@@ -935,7 +931,6 @@
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:copy_on_write_buffer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:threading",
@@ -1021,7 +1016,6 @@
"../rtc_base:checks",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:network_constants",
"../rtc_base:refcount",
@@ -1107,7 +1101,6 @@
"../rtc_base",
"../rtc_base:checks",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rtc_operations_chain",
@@ -1209,7 +1202,6 @@
"../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:network_constants",
@@ -1294,7 +1286,6 @@
"../rtc_base:checks",
"../rtc_base:event_tracer",
"../rtc_base:ip_address",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:network_constants",
@@ -1484,7 +1475,6 @@
"../pc:session_description",
"../pc:video_track",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rtc_base",
@@ -1561,7 +1551,6 @@
"../api/video:video_bitrate_allocator_factory",
"../media:rtc_media_base",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:threading",
@@ -1693,7 +1682,6 @@
"../media:rtc_media_base",
"../rtc_base",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:macromagic",
"../rtc_base:threading",
"../rtc_base/system:no_unique_address",
@@ -1732,7 +1720,6 @@
"../media:rtc_media_base",
"../rtc_base",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:threading",
@@ -1795,7 +1782,6 @@
"../media:rtc_media_base",
"../rtc_base",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:macromagic",
"../rtc_base:threading",
"../rtc_base/system:no_unique_address",
@@ -1877,7 +1863,6 @@
"../media:rtc_media_base",
"../rtc_base:checks",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:rtc_base",
@@ -1932,7 +1917,6 @@
"../api/task_queue:pending_task_safety_flag",
"../api/units:time_delta",
"../rtc_base:checks",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:refcount",
diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc
index e58b74e..0dbdf0b 100644
--- a/pc/audio_rtp_receiver.cc
+++ b/pc/audio_rtp_receiver.cc
@@ -20,7 +20,6 @@
#include "pc/audio_track.h"
#include "pc/media_stream_track_proxy.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
namespace webrtc {
@@ -101,7 +100,7 @@
RTC_DCHECK_LE(volume, 10);
bool track_enabled = track_->internal()->enabled();
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() {
+ worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_);
// Update the cached_volume_ even when stopped, to allow clients to set
// the volume before starting/restarting, eg see crbug.com/1272566.
@@ -168,7 +167,7 @@
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
bool enabled = track_->internal()->enabled();
MediaSourceInterface::SourceState state = source_->state();
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() {
+ worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_);
RestartMediaChannel_w(std::move(ssrc), enabled, state);
});
diff --git a/pc/channel.cc b/pc/channel.cc
index 0777314..0e2345b 100644
--- a/pc/channel.cc
+++ b/pc/channel.cc
@@ -29,7 +29,6 @@
#include "pc/rtp_media_utils.h"
#include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_route.h"
#include "rtc_base/strings/string_format.h"
@@ -269,8 +268,8 @@
// network thread. At the moment there's a workaround for inconsistent state
// between the worker and network thread because of this (see
// OnDemuxerCriteriaUpdatePending elsewhere in this file) and
- // SetPayloadTypeDemuxingEnabled_w has an Invoke over to the network thread
- // to apply state updates.
+ // SetPayloadTypeDemuxingEnabled_w has a BlockingCall over to the network
+ // thread to apply state updates.
RTC_DCHECK_RUN_ON(worker_thread());
TRACE_EVENT0("webrtc", "BaseChannel::SetPayloadTypeDemuxingEnabled");
return SetPayloadTypeDemuxingEnabled_w(enabled);
@@ -461,7 +460,7 @@
if (update_demuxer)
media_channel()->OnDemuxerCriteriaUpdatePending();
- bool success = network_thread()->Invoke<bool>(RTC_FROM_HERE, [&]() mutable {
+ bool success = network_thread()->BlockingCall([&]() mutable {
RTC_DCHECK_RUN_ON(network_thread());
// NOTE: This doesn't take the BUNDLE case in account meaning the RTP header
// extension maps are not merged when BUNDLE is enabled. This is fine
@@ -491,8 +490,8 @@
media_channel_->OnDemuxerCriteriaUpdatePending();
// Copy demuxer criteria, since they're a worker-thread variable
// and we want to pass them to the network thread
- bool ret = network_thread_->Invoke<bool>(
- RTC_FROM_HERE, [this, demuxer_criteria = demuxer_criteria_] {
+ bool ret = network_thread_->BlockingCall(
+ [this, demuxer_criteria = demuxer_criteria_] {
RTC_DCHECK_RUN_ON(network_thread());
if (!rtp_transport_) {
// Transport was disconnected before attempting to update the
diff --git a/pc/connection_context.cc b/pc/connection_context.cc
index 13c598a..ec6f21c 100644
--- a/pc/connection_context.cc
+++ b/pc/connection_context.cc
@@ -167,13 +167,13 @@
if (media_engine_) {
// TODO(tommi): Change VoiceEngine to do ctor time initialization so that
// this isn't necessary.
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { media_engine_->Init(); });
+ worker_thread_->BlockingCall([&] { media_engine_->Init(); });
}
}
ConnectionContext::~ConnectionContext() {
RTC_DCHECK_RUN_ON(signaling_thread_);
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(worker_thread());
// While `media_engine_` is const throughout the ConnectionContext's
// lifetime, it requires destruction to happen on the worker thread. Instead
diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc
index b655b53..36f11fe 100644
--- a/pc/data_channel_controller.cc
+++ b/pc/data_channel_controller.cc
@@ -16,7 +16,6 @@
#include "api/rtc_error.h"
#include "pc/peer_connection_internal.h"
#include "pc/sctp_utils.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
namespace webrtc {
@@ -81,7 +80,7 @@
void DataChannelController::AddSctpDataStream(int sid) {
if (data_channel_transport()) {
- network_thread()->Invoke<void>(RTC_FROM_HERE, [this, sid] {
+ network_thread()->BlockingCall([this, sid] {
if (data_channel_transport()) {
data_channel_transport()->OpenChannel(sid);
}
@@ -91,7 +90,7 @@
void DataChannelController::RemoveSctpDataStream(int sid) {
if (data_channel_transport()) {
- network_thread()->Invoke<void>(RTC_FROM_HERE, [this, sid] {
+ network_thread()->BlockingCall([this, sid] {
if (data_channel_transport()) {
data_channel_transport()->CloseChannel(sid);
}
@@ -382,15 +381,14 @@
const rtc::CopyOnWriteBuffer& payload,
cricket::SendDataResult* result) {
// TODO(bugs.webrtc.org/11547): Expect method to be called on the network
- // thread instead. Remove the Invoke() below and move assocated state to
+ // thread instead. Remove the BlockingCall() below and move assocated state to
// the network thread.
RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(data_channel_transport());
- RTCError error = network_thread()->Invoke<RTCError>(
- RTC_FROM_HERE, [this, sid, params, payload] {
- return data_channel_transport()->SendData(sid, params, payload);
- });
+ RTCError error = network_thread()->BlockingCall([this, sid, params, payload] {
+ return data_channel_transport()->SendData(sid, params, payload);
+ });
if (error.ok()) {
*result = cricket::SendDataResult::SDR_SUCCESS;
diff --git a/pc/dtmf_sender.cc b/pc/dtmf_sender.cc
index c3bd4b6..45a4a58 100644
--- a/pc/dtmf_sender.cc
+++ b/pc/dtmf_sender.cc
@@ -142,7 +142,7 @@
}
safety_flag_ = PendingTaskSafetyFlag::Create();
// Kick off a new DTMF task.
- QueueInsertDtmf(RTC_FROM_HERE, 1 /*ms*/);
+ QueueInsertDtmf(1 /*ms*/);
return true;
}
@@ -166,8 +166,7 @@
return comma_delay_;
}
-void DtmfSender::QueueInsertDtmf(const rtc::Location& posted_from,
- uint32_t delay_ms) {
+void DtmfSender::QueueInsertDtmf(uint32_t delay_ms) {
signaling_thread_->PostDelayedHighPrecisionTask(
SafeTask(safety_flag_,
[this] {
@@ -232,7 +231,7 @@
tones_.erase(0, first_tone_pos + 1);
// Continue with the next tone.
- QueueInsertDtmf(RTC_FROM_HERE, tone_gap);
+ QueueInsertDtmf(tone_gap);
}
void DtmfSender::StopSending() {
diff --git a/pc/dtmf_sender.h b/pc/dtmf_sender.h
index c295f03..c99c7be 100644
--- a/pc/dtmf_sender.h
+++ b/pc/dtmf_sender.h
@@ -21,7 +21,6 @@
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/task_queue/task_queue_base.h"
#include "pc/proxy.h"
-#include "rtc_base/location.h"
#include "rtc_base/ref_count.h"
#include "rtc_base/thread_annotations.h"
@@ -77,8 +76,7 @@
private:
DtmfSender();
- void QueueInsertDtmf(const rtc::Location& posted_from, uint32_t delay_ms)
- RTC_RUN_ON(signaling_thread_);
+ void QueueInsertDtmf(uint32_t delay_ms) RTC_RUN_ON(signaling_thread_);
// The DTMF sending task.
void DoInsertDtmf() RTC_RUN_ON(signaling_thread_);
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index 7b44574..95ab799 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -29,7 +29,6 @@
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
#include "rtc_base/trace_event.h"
@@ -77,8 +76,8 @@
const cricket::SessionDescription* description) {
TRACE_EVENT0("webrtc", "JsepTransportController::SetLocalDescription");
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<RTCError>(
- RTC_FROM_HERE, [=] { return SetLocalDescription(type, description); });
+ return network_thread_->BlockingCall(
+ [=] { return SetLocalDescription(type, description); });
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -98,8 +97,8 @@
const cricket::SessionDescription* description) {
TRACE_EVENT0("webrtc", "JsepTransportController::SetRemoteDescription");
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<RTCError>(
- RTC_FROM_HERE, [=] { return SetRemoteDescription(type, description); });
+ return network_thread_->BlockingCall(
+ [=] { return SetRemoteDescription(type, description); });
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -199,8 +198,7 @@
// thread during negotiations, potentially multiple times.
// WebRtcSessionDescriptionFactory::InternalCreateAnswer is one example.
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<absl::optional<rtc::SSLRole>>(
- RTC_FROM_HERE, [&] { return GetDtlsRole(mid); });
+ return network_thread_->BlockingCall([&] { return GetDtlsRole(mid); });
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -215,8 +213,8 @@
bool JsepTransportController::SetLocalCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<bool>(
- RTC_FROM_HERE, [&] { return SetLocalCertificate(certificate); });
+ return network_thread_->BlockingCall(
+ [&] { return SetLocalCertificate(certificate); });
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -274,8 +272,7 @@
void JsepTransportController::MaybeStartGathering() {
if (!network_thread_->IsCurrent()) {
- network_thread_->Invoke<void>(RTC_FROM_HERE,
- [&] { MaybeStartGathering(); });
+ network_thread_->BlockingCall([&] { MaybeStartGathering(); });
return;
}
@@ -301,8 +298,8 @@
RTCError JsepTransportController::RemoveRemoteCandidates(
const cricket::Candidates& candidates) {
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<RTCError>(
- RTC_FROM_HERE, [&] { return RemoveRemoteCandidates(candidates); });
+ return network_thread_->BlockingCall(
+ [&] { return RemoveRemoteCandidates(candidates); });
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -361,9 +358,8 @@
void JsepTransportController::SetActiveResetSrtpParams(
bool active_reset_srtp_params) {
if (!network_thread_->IsCurrent()) {
- network_thread_->Invoke<void>(RTC_FROM_HERE, [=] {
- SetActiveResetSrtpParams(active_reset_srtp_params);
- });
+ network_thread_->BlockingCall(
+ [=] { SetActiveResetSrtpParams(active_reset_srtp_params); });
return;
}
RTC_DCHECK_RUN_ON(network_thread_);
@@ -378,8 +374,7 @@
RTCError JsepTransportController::RollbackTransports() {
if (!network_thread_->IsCurrent()) {
- return network_thread_->Invoke<RTCError>(
- RTC_FROM_HERE, [=] { return RollbackTransports(); });
+ return network_thread_->BlockingCall([=] { return RollbackTransports(); });
}
RTC_DCHECK_RUN_ON(network_thread_);
bundles_.Rollback();
diff --git a/pc/legacy_stats_collector.cc b/pc/legacy_stats_collector.cc
index 393e0ef..b710bc1 100644
--- a/pc/legacy_stats_collector.cc
+++ b/pc/legacy_stats_collector.cc
@@ -46,7 +46,6 @@
#include "pc/transport_stats.h"
#include "rtc_base/checks.h"
#include "rtc_base/ip_address.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/socket_address.h"
@@ -861,9 +860,9 @@
SessionStats stats;
auto transceivers = pc_->GetTransceiversInternal();
- pc_->network_thread()->Invoke<void>(
- RTC_FROM_HERE, [&, sctp_transport_name = pc_->sctp_transport_name(),
- sctp_mid = pc_->sctp_mid()]() mutable {
+ pc_->network_thread()->BlockingCall(
+ [&, sctp_transport_name = pc_->sctp_transport_name(),
+ sctp_mid = pc_->sctp_mid()]() mutable {
stats = ExtractSessionInfo_n(
transceivers, std::move(sctp_transport_name), std::move(sctp_mid));
});
@@ -1049,7 +1048,7 @@
}
if (!video_media_channels.empty()) {
- pc_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&] {
+ pc_->worker_thread()->BlockingCall([&] {
for (const auto& channel : video_media_channels) {
channel->FillBitrateInfo(&bwe_info);
}
@@ -1200,7 +1199,7 @@
}
}
- pc_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&] {
+ pc_->worker_thread()->BlockingCall([&] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
// Populate `receiver_track_id_by_ssrc` for the gatherers.
int i = 0;
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 1c0e695..517669d 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -52,7 +52,6 @@
#include "pc/webrtc_session_description_factory.h"
#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network.h"
@@ -525,7 +524,7 @@
data_channel_controller_(this),
message_handler_(signaling_thread()),
weak_factory_(this) {
- worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_ = PendingTaskSafetyFlag::Create();
if (!call_)
@@ -569,7 +568,7 @@
// port_allocator_ and transport_controller_ live on the network thread and
// should be destroyed there.
transport_controller_copy_ = nullptr;
- network_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ network_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(network_thread());
TeardownDataChannelTransport_n();
transport_controller_.reset();
@@ -579,7 +578,7 @@
});
// call_ and event_log_ must be destroyed on the worker thread.
- worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive();
call_.reset();
@@ -618,7 +617,7 @@
// Network thread initialization.
transport_controller_copy_ =
- network_thread()->Invoke<JsepTransportController*>(RTC_FROM_HERE, [&] {
+ network_thread()->BlockingCall([&] {
RTC_DCHECK_RUN_ON(network_thread());
network_thread_safety_ = PendingTaskSafetyFlag::Create();
InitializePortAllocatorResult pa_result = InitializePortAllocator_n(
@@ -940,13 +939,12 @@
// TODO(bugs.webrtc.org/9987): Avoid the thread jump.
// This might be done by caching the value on the signaling thread.
RTC_DCHECK_RUN_ON(signaling_thread());
- return network_thread()->Invoke<RtpTransportInternal*>(
- RTC_FROM_HERE, [this, &mid] {
- RTC_DCHECK_RUN_ON(network_thread());
- auto rtp_transport = transport_controller_->GetRtpTransport(mid);
- RTC_DCHECK(rtp_transport);
- return rtp_transport;
- });
+ return network_thread()->BlockingCall([this, &mid] {
+ RTC_DCHECK_RUN_ON(network_thread());
+ auto rtp_transport = transport_controller_->GetRtpTransport(mid);
+ RTC_DCHECK(rtp_transport);
+ return rtp_transport;
+ });
}
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
@@ -1556,8 +1554,7 @@
// Apply part of the configuration on the network thread. In theory this
// shouldn't fail.
- if (!network_thread()->Invoke<bool>(
- RTC_FROM_HERE,
+ if (!network_thread()->BlockingCall(
[this, needs_ice_restart, &ice_config, &stun_servers, &turn_servers,
&modified_config, has_local_description] {
RTC_DCHECK_RUN_ON(network_thread());
@@ -1583,8 +1580,8 @@
if (configuration_.active_reset_srtp_params !=
modified_config.active_reset_srtp_params) {
- // TODO(tommi): merge invokes
- network_thread()->Invoke<void>(RTC_FROM_HERE, [this, &modified_config] {
+ // TODO(tommi): merge BlockingCalls
+ network_thread()->BlockingCall([this, &modified_config] {
RTC_DCHECK_RUN_ON(network_thread());
transport_controller_->SetActiveResetSrtpParams(
modified_config.active_reset_srtp_params);
@@ -1603,8 +1600,7 @@
video_channel->media_channel()));
}
- worker_thread()->Invoke<void>(
- RTC_FROM_HERE,
+ worker_thread()->BlockingCall(
[channels = std::move(channels),
allow_codec_switching = *modified_config.allow_codec_switching]() {
for (auto* ch : channels)
@@ -1643,8 +1639,7 @@
RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) {
if (!worker_thread()->IsCurrent()) {
- return worker_thread()->Invoke<RTCError>(
- RTC_FROM_HERE, [&]() { return SetBitrate(bitrate); });
+ return worker_thread()->BlockingCall([&]() { return SetBitrate(bitrate); });
}
RTC_DCHECK_RUN_ON(worker_thread());
@@ -1685,8 +1680,8 @@
void PeerConnection::SetAudioPlayout(bool playout) {
if (!worker_thread()->IsCurrent()) {
- worker_thread()->Invoke<void>(
- RTC_FROM_HERE, [this, playout] { SetAudioPlayout(playout); });
+ worker_thread()->BlockingCall(
+ [this, playout] { SetAudioPlayout(playout); });
return;
}
auto audio_state = context_->media_engine()->voice().GetAudioState();
@@ -1695,8 +1690,8 @@
void PeerConnection::SetAudioRecording(bool recording) {
if (!worker_thread()->IsCurrent()) {
- worker_thread()->Invoke<void>(
- RTC_FROM_HERE, [this, recording] { SetAudioRecording(recording); });
+ worker_thread()->BlockingCall(
+ [this, recording] { SetAudioRecording(recording); });
return;
}
auto audio_state = context_->media_engine()->voice().GetAudioState();
@@ -1706,9 +1701,8 @@
void PeerConnection::AddAdaptationResource(
rtc::scoped_refptr<Resource> resource) {
if (!worker_thread()->IsCurrent()) {
- return worker_thread()->Invoke<void>(RTC_FROM_HERE, [this, resource]() {
- return AddAdaptationResource(resource);
- });
+ return worker_thread()->BlockingCall(
+ [this, resource]() { return AddAdaptationResource(resource); });
}
RTC_DCHECK_RUN_ON(worker_thread());
if (!call_) {
@@ -1724,8 +1718,7 @@
bool PeerConnection::StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) {
- return worker_thread()->Invoke<bool>(
- RTC_FROM_HERE,
+ return worker_thread()->BlockingCall(
[this, output = std::move(output), output_period_ms]() mutable {
return StartRtcEventLog_w(std::move(output), output_period_ms);
});
@@ -1741,7 +1734,7 @@
}
void PeerConnection::StopRtcEventLog() {
- worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] { StopRtcEventLog_w(); });
+ worker_thread()->BlockingCall([this] { StopRtcEventLog_w(); });
}
rtc::scoped_refptr<DtlsTransportInterface>
@@ -1755,11 +1748,10 @@
RTC_DCHECK_RUN_ON(signaling_thread());
// TODO(bugs.webrtc.org/9987): Avoid the thread jump.
// This might be done by caching the value on the signaling thread.
- return network_thread()->Invoke<rtc::scoped_refptr<DtlsTransport>>(
- RTC_FROM_HERE, [this, mid]() {
- RTC_DCHECK_RUN_ON(network_thread());
- return transport_controller_->LookupDtlsTransportByMid(mid);
- });
+ return network_thread()->BlockingCall([this, mid]() {
+ RTC_DCHECK_RUN_ON(network_thread());
+ return transport_controller_->LookupDtlsTransportByMid(mid);
+ });
}
rtc::scoped_refptr<SctpTransportInterface> PeerConnection::GetSctpTransport()
@@ -1856,7 +1848,7 @@
rtp_manager_->Close();
}
- network_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ network_thread()->BlockingCall([this] {
// Data channels will already have been unset via the DestroyAllChannels()
// call above, which triggers a call to TeardownDataChannelTransport_n().
// TODO(tommi): ^^ That's not exactly optimal since this is yet another
@@ -1870,7 +1862,7 @@
}
});
- worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive();
call_.reset();
@@ -2225,11 +2217,10 @@
absl::optional<rtc::SSLRole> dtls_role;
if (sctp_mid_s_) {
- dtls_role = network_thread()->Invoke<absl::optional<rtc::SSLRole>>(
- RTC_FROM_HERE, [this] {
- RTC_DCHECK_RUN_ON(network_thread());
- return transport_controller_->GetDtlsRole(*sctp_mid_n_);
- });
+ dtls_role = network_thread()->BlockingCall([this] {
+ RTC_DCHECK_RUN_ON(network_thread());
+ return transport_controller_->GetDtlsRole(*sctp_mid_n_);
+ });
if (!dtls_role && sdp_handler_->is_caller().has_value()) {
// This works fine if we are the offerer, but can be a mistake if
// we are the answerer and the remote offer is ACTIVE. In that
@@ -2259,11 +2250,10 @@
return false;
}
- auto dtls_role = network_thread()->Invoke<absl::optional<rtc::SSLRole>>(
- RTC_FROM_HERE, [this, content_name]() {
- RTC_DCHECK_RUN_ON(network_thread());
- return transport_controller_->GetDtlsRole(content_name);
- });
+ auto dtls_role = network_thread()->BlockingCall([this, content_name]() {
+ RTC_DCHECK_RUN_ON(network_thread());
+ return transport_controller_->GetDtlsRole(content_name);
+ });
if (dtls_role) {
*role = *dtls_role;
return true;
@@ -2360,7 +2350,7 @@
}
bool PeerConnection::NeedsIceRestart(const std::string& content_name) const {
- return network_thread()->Invoke<bool>(RTC_FROM_HERE, [this, &content_name] {
+ return network_thread()->BlockingCall([this, &content_name] {
RTC_DCHECK_RUN_ON(network_thread());
return transport_controller_->NeedsIceRestart(content_name);
});
@@ -2489,8 +2479,7 @@
Call::Stats PeerConnection::GetCallStats() {
if (!worker_thread()->IsCurrent()) {
- return worker_thread()->Invoke<Call::Stats>(
- RTC_FROM_HERE, [this] { return GetCallStats(); });
+ return worker_thread()->BlockingCall([this] { return GetCallStats(); });
}
RTC_DCHECK_RUN_ON(worker_thread());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index 6460a90..cec909f 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -46,7 +46,6 @@
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/experiments/field_trial_units.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/rtc_certificate_generator.h"
@@ -60,12 +59,9 @@
// The PeerConnectionFactory must be created on the signaling thread.
if (dependencies.signaling_thread &&
!dependencies.signaling_thread->IsCurrent()) {
- return dependencies.signaling_thread
- ->Invoke<rtc::scoped_refptr<PeerConnectionFactoryInterface>>(
- RTC_FROM_HERE, [&dependencies] {
- return CreateModularPeerConnectionFactory(
- std::move(dependencies));
- });
+ return dependencies.signaling_thread->BlockingCall([&dependencies] {
+ return CreateModularPeerConnectionFactory(std::move(dependencies));
+ });
}
auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
@@ -238,13 +234,12 @@
dependencies.allocator->SetVpnList(configuration.vpn_list);
std::unique_ptr<RtcEventLog> event_log =
- worker_thread()->Invoke<std::unique_ptr<RtcEventLog>>(
- RTC_FROM_HERE, [this] { return CreateRtcEventLog_w(); });
+ worker_thread()->BlockingCall([this] { return CreateRtcEventLog_w(); });
const FieldTrialsView* trials =
dependencies.trials ? dependencies.trials.get() : &field_trials();
- std::unique_ptr<Call> call = worker_thread()->Invoke<std::unique_ptr<Call>>(
- RTC_FROM_HERE, [this, &event_log, trials] {
+ std::unique_ptr<Call> call =
+ worker_thread()->BlockingCall([this, &event_log, trials] {
return CreateCall_w(event_log.get(), *trials);
});
diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc
index 15e72c4..c27533a 100644
--- a/pc/rtc_stats_collector.cc
+++ b/pc/rtc_stats_collector.cc
@@ -50,7 +50,6 @@
#include "pc/webrtc_sdp.h"
#include "rtc_base/checks.h"
#include "rtc_base/ip_address.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/network_constants.h"
#include "rtc_base/rtc_certificate.h"
@@ -2316,9 +2315,9 @@
auto transceivers = pc_->GetTransceiversInternal();
// TODO(tommi): See if we can avoid synchronously blocking the signaling
- // thread while we do this (or avoid the Invoke at all).
- network_thread_->Invoke<void>(RTC_FROM_HERE, [this, &transceivers,
- &voice_stats, &video_stats] {
+ // thread while we do this (or avoid the BlockingCall at all).
+ network_thread_->BlockingCall([this, &transceivers, &voice_stats,
+ &video_stats] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
for (const auto& transceiver_proxy : transceivers) {
@@ -2363,7 +2362,7 @@
// well as GetCallStats(). At the same time we construct the
// TrackMediaInfoMaps, which also needs info from the worker thread. This
// minimizes the number of thread jumps.
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
for (auto& pair : voice_stats) {
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
diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc
index 44a96d4..db49468 100644
--- a/pc/rtp_transceiver.cc
+++ b/pc/rtp_transceiver.cc
@@ -28,7 +28,6 @@
#include "pc/rtp_media_utils.h"
#include "pc/session_description.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
@@ -185,57 +184,42 @@
// TODO(bugs.webrtc.org/11992): Remove this workaround after updates in
// PeerConnection and add the expectation that we're already on the right
// thread.
- new_channel =
- context()
- ->worker_thread()
- ->Invoke<std::unique_ptr<cricket::VoiceChannel>>(
- RTC_FROM_HERE, [&]() -> std::unique_ptr<cricket::VoiceChannel> {
- RTC_DCHECK_RUN_ON(context()->worker_thread());
+ context()->worker_thread()->BlockingCall([&] {
+ RTC_DCHECK_RUN_ON(context()->worker_thread());
- cricket::VoiceMediaChannel* media_channel =
- media_engine()->voice().CreateMediaChannel(
- call_ptr, media_config, audio_options,
- crypto_options);
- if (!media_channel) {
- return nullptr;
- }
+ cricket::VoiceMediaChannel* media_channel =
+ media_engine()->voice().CreateMediaChannel(
+ call_ptr, media_config, audio_options, crypto_options);
+ if (!media_channel) {
+ return;
+ }
- auto voice_channel = std::make_unique<cricket::VoiceChannel>(
- context()->worker_thread(), context()->network_thread(),
- context()->signaling_thread(),
- absl::WrapUnique(media_channel), mid, srtp_required,
- crypto_options, context()->ssrc_generator());
-
- return voice_channel;
- });
+ new_channel = std::make_unique<cricket::VoiceChannel>(
+ context()->worker_thread(), context()->network_thread(),
+ context()->signaling_thread(), absl::WrapUnique(media_channel), mid,
+ srtp_required, crypto_options, context()->ssrc_generator());
+ });
} else {
RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO, media_type());
// TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to
// the worker thread. We shouldn't be using the `call_ptr_` hack here but
// simply be on the worker thread and use `call_` (update upstream code).
- new_channel =
- context()
- ->worker_thread()
- ->Invoke<std::unique_ptr<cricket::VideoChannel>>(
- RTC_FROM_HERE, [&]() -> std::unique_ptr<cricket::VideoChannel> {
- RTC_DCHECK_RUN_ON(context()->worker_thread());
- cricket::VideoMediaChannel* media_channel =
- media_engine()->video().CreateMediaChannel(
- call_ptr, media_config, video_options, crypto_options,
- video_bitrate_allocator_factory);
- if (!media_channel) {
- return nullptr;
- }
+ context()->worker_thread()->BlockingCall([&] {
+ RTC_DCHECK_RUN_ON(context()->worker_thread());
+ cricket::VideoMediaChannel* media_channel =
+ media_engine()->video().CreateMediaChannel(
+ call_ptr, media_config, video_options, crypto_options,
+ video_bitrate_allocator_factory);
+ if (!media_channel) {
+ return;
+ }
- auto video_channel = std::make_unique<cricket::VideoChannel>(
- context()->worker_thread(), context()->network_thread(),
- context()->signaling_thread(),
- absl::WrapUnique(media_channel), mid, srtp_required,
- crypto_options, context()->ssrc_generator());
-
- return video_channel;
- });
+ new_channel = std::make_unique<cricket::VideoChannel>(
+ context()->worker_thread(), context()->network_thread(),
+ context()->signaling_thread(), absl::WrapUnique(media_channel), mid,
+ srtp_required, crypto_options, context()->ssrc_generator());
+ });
}
if (!new_channel) {
// TODO(hta): Must be a better way
@@ -274,7 +258,7 @@
// Similarly, if the channel() accessor is limited to the network thread, that
// helps with keeping the channel implementation requirements being met and
// avoids synchronization for accessing the pointer or network related state.
- context()->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() {
+ context()->network_thread()->BlockingCall([&]() {
if (channel_) {
channel_->SetFirstPacketReceivedCallback(nullptr);
channel_->SetRtpTransport(nullptr);
@@ -310,7 +294,7 @@
}
std::unique_ptr<cricket::ChannelInterface> channel_to_delete;
- context()->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() {
+ context()->network_thread()->BlockingCall([&]() {
if (channel_) {
channel_->SetFirstPacketReceivedCallback(nullptr);
channel_->SetRtpTransport(nullptr);
@@ -331,7 +315,7 @@
if (!channel_to_delete && senders_.empty() && receivers_.empty()) {
return;
}
- context()->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() {
+ context()->worker_thread()->BlockingCall([&]() {
// Push down the new media_channel, if any, otherwise clear it.
auto* media_channel = channel_ ? channel_->media_channel() : nullptr;
for (const auto& sender : senders_) {
@@ -399,7 +383,7 @@
}
(*it)->internal()->Stop();
- context()->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() {
+ context()->worker_thread()->BlockingCall([&]() {
// `Stop()` will clear the receiver's pointer to the media channel.
(*it)->internal()->SetMediaChannel(nullptr);
});
@@ -533,7 +517,7 @@
for (const auto& receiver : receivers_)
receiver->internal()->Stop();
- context()->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() {
+ context()->worker_thread()->BlockingCall([&]() {
// 5 Stop receiving media with receiver.
for (const auto& receiver : receivers_)
receiver->internal()->SetMediaChannel(nullptr);
diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc
index a5e0d76..0591bcc 100644
--- a/pc/sctp_data_channel.cc
+++ b/pc/sctp_data_channel.cc
@@ -20,7 +20,6 @@
#include "pc/proxy.h"
#include "pc/sctp_utils.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/system/unused.h"
#include "rtc_base/thread.h"
diff --git a/pc/sctp_transport.cc b/pc/sctp_transport.cc
index f411883..eabaa04 100644
--- a/pc/sctp_transport.cc
+++ b/pc/sctp_transport.cc
@@ -17,7 +17,6 @@
#include "api/dtls_transport_interface.h"
#include "api/sequence_checker.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
namespace webrtc {
@@ -50,8 +49,7 @@
// expected thread. Chromium currently calls this method from
// TransceiverStateSurfacer.
if (!owner_thread_->IsCurrent()) {
- return owner_thread_->Invoke<SctpTransportInformation>(
- RTC_FROM_HERE, [this] { return Information(); });
+ return owner_thread_->BlockingCall([this] { return Information(); });
}
RTC_DCHECK_RUN_ON(owner_thread_);
return info_;
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc
index 9a5023c..35e65e0 100644
--- a/pc/sdp_offer_answer.cc
+++ b/pc/sdp_offer_answer.cc
@@ -55,7 +55,6 @@
#include "pc/usage_pattern.h"
#include "pc/webrtc_session_description_factory.h"
#include "rtc_base/helpers.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_stream_adapter.h"
@@ -691,13 +690,12 @@
JsepTransportController* controller,
const std::string& mid) {
// TODO(tommi): Can we post this (and associated operations where this
- // function is called) to the network thread and avoid this Invoke?
+ // function is called) to the network thread and avoid this BlockingCall?
// We might be able to simplify a few things if we set the transport on
// the network thread and then update the implementation to check that
// the set_ and relevant get methods are always called on the network
// thread (we'll need to update proxy maps).
- return network_thread->Invoke<rtc::scoped_refptr<webrtc::DtlsTransport>>(
- RTC_FROM_HERE,
+ return network_thread->BlockingCall(
[controller, &mid] { return controller->LookupDtlsTransportByMid(mid); });
}
@@ -1813,7 +1811,7 @@
ReportSimulcastApiVersion(kSimulcastVersionApplyRemoteDescription,
*session_desc);
- // NOTE: This will perform an Invoke() to the network thread.
+ // NOTE: This will perform a BlockingCall() to the network thread.
return transport_controller_s()->SetRemoteDescription(sdp_type, session_desc);
}
@@ -2200,8 +2198,8 @@
// TODO(deadbeef): We already had to hop to the network thread for
// MaybeStartGathering...
- context_->network_thread()->Invoke<void>(
- RTC_FROM_HERE, [this] { port_allocator()->DiscardCandidatePool(); });
+ context_->network_thread()->BlockingCall(
+ [this] { port_allocator()->DiscardCandidatePool(); });
// Make UMA notes about what was agreed to.
ReportNegotiatedSdpSemantics(*local_description());
}
@@ -2404,8 +2402,8 @@
if (was_answer) {
// TODO(deadbeef): We already had to hop to the network thread for
// MaybeStartGathering...
- context_->network_thread()->Invoke<void>(
- RTC_FROM_HERE, [this] { port_allocator()->DiscardCandidatePool(); });
+ context_->network_thread()->BlockingCall(
+ [this] { port_allocator()->DiscardCandidatePool(); });
// Make UMA notes about what was agreed to.
ReportNegotiatedSdpSemantics(*remote_description());
}
@@ -3831,8 +3829,7 @@
session_options->rtcp_cname = rtcp_cname_;
session_options->crypto_options = pc_->GetCryptoOptions();
session_options->pooled_ice_credentials =
- context_->network_thread()->Invoke<std::vector<cricket::IceParameters>>(
- RTC_FROM_HERE,
+ context_->network_thread()->BlockingCall(
[this] { return port_allocator()->GetPooledIceCredentials(); });
session_options->offer_extmap_allow_mixed =
pc_->configuration()->offer_extmap_allow_mixed;
@@ -4095,8 +4092,7 @@
session_options->rtcp_cname = rtcp_cname_;
session_options->crypto_options = pc_->GetCryptoOptions();
session_options->pooled_ice_credentials =
- context_->network_thread()->Invoke<std::vector<cricket::IceParameters>>(
- RTC_FROM_HERE,
+ context_->network_thread()->BlockingCall(
[this] { return port_allocator()->GetPooledIceCredentials(); });
}
@@ -4525,8 +4521,8 @@
RTC_DCHECK(sdesc);
if (ConfiguredForMedia()) {
- // Note: This will perform an Invoke over to the worker thread, which we'll
- // also do in a loop below.
+ // Note: This will perform a BlockingCall over to the worker thread, which
+ // we'll also do in a loop below.
if (!UpdatePayloadTypeDemuxingState(source, bundle_groups_by_mid)) {
// Note that this is never expected to fail, since RtpDemuxer doesn't
// return an error when changing payload type demux criteria, which is all
@@ -4570,7 +4566,7 @@
for (const auto& entry : channels) {
std::string error;
bool success =
- context_->worker_thread()->Invoke<bool>(RTC_FROM_HERE, [&]() {
+ context_->worker_thread()->BlockingCall([&]() {
return (source == cricket::CS_LOCAL)
? entry.first->SetLocalContent(entry.second, type, error)
: entry.first->SetRemoteContent(entry.second, type,
@@ -4918,7 +4914,7 @@
bool SdpOfferAnswerHandler::CreateDataChannel(const std::string& mid) {
RTC_DCHECK_RUN_ON(signaling_thread());
- if (!context_->network_thread()->Invoke<bool>(RTC_FROM_HERE, [this, &mid] {
+ if (!context_->network_thread()->BlockingCall([this, &mid] {
RTC_DCHECK_RUN_ON(context_->network_thread());
return pc_->SetupDataChannelTransport_n(mid);
})) {
@@ -4940,7 +4936,7 @@
if (has_sctp)
data_channel_controller()->OnTransportChannelClosed(error);
- context_->network_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ context_->network_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(context_->network_thread());
pc_->TeardownDataChannelTransport_n();
});
@@ -5174,7 +5170,7 @@
pt_demuxing_has_been_used_video_;
// Gather all updates ahead of time so that all channels can be updated in a
- // single Invoke; necessary due to thread guards.
+ // single BlockingCall; necessary due to thread guards.
std::vector<std::pair<bool, cricket::ChannelInterface*>> channels_to_update;
for (const auto& transceiver : transceivers()->ListInternal()) {
cricket::ChannelInterface* channel = transceiver->channel();
@@ -5226,22 +5222,21 @@
return true;
}
- // TODO(bugs.webrtc.org/11993): This Invoke() will also invoke on the network
- // thread for every demuxer sink that needs to be updated. The demuxer state
- // needs to be fully (and only) managed on the network thread and once that's
- // the case, there's no need to stop by on the worker. Ideally we could also
- // do this without blocking.
- return context_->worker_thread()->Invoke<bool>(
- RTC_FROM_HERE, [&channels_to_update]() {
- for (const auto& it : channels_to_update) {
- if (!it.second->SetPayloadTypeDemuxingEnabled(it.first)) {
- // Note that the state has already been irrevocably changed at this
- // point. Is it useful to stop the loop?
- return false;
- }
- }
- return true;
- });
+ // TODO(bugs.webrtc.org/11993): This BlockingCall() will also block on the
+ // network thread for every demuxer sink that needs to be updated. The demuxer
+ // state needs to be fully (and only) managed on the network thread and once
+ // that's the case, there's no need to stop by on the worker. Ideally we could
+ // also do this without blocking.
+ return context_->worker_thread()->BlockingCall([&channels_to_update]() {
+ for (const auto& it : channels_to_update) {
+ if (!it.second->SetPayloadTypeDemuxingEnabled(it.first)) {
+ // Note that the state has already been irrevocably changed at this
+ // point. Is it useful to stop the loop?
+ return false;
+ }
+ }
+ return true;
+ });
}
bool SdpOfferAnswerHandler::ConfiguredForMedia() const {
diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc
index d6272e7..e01a33f 100644
--- a/pc/video_rtp_receiver.cc
+++ b/pc/video_rtp_receiver.cc
@@ -19,7 +19,6 @@
#include "api/video/recordable_encoded_frame.h"
#include "pc/video_track.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
namespace webrtc {
@@ -117,7 +116,7 @@
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
MediaSourceInterface::SourceState state = source_->state();
// TODO(tommi): Can we restart the media channel without blocking?
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(worker_thread_);
RestartMediaChannel_w(std::move(ssrc), state);
});
@@ -316,7 +315,7 @@
RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
RTC_DCHECK(media_channel);
MediaSourceInterface::SourceState state = source_->state();
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ worker_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(worker_thread_);
SetMediaChannel_w(media_channel);
RestartMediaChannel_w(std::move(ssrc), state);
diff --git a/pc/video_track.cc b/pc/video_track.cc
index c979995..0bf8687 100644
--- a/pc/video_track.cc
+++ b/pc/video_track.cc
@@ -16,7 +16,6 @@
#include "api/notifier.h"
#include "api/sequence_checker.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
namespace webrtc {
@@ -95,7 +94,7 @@
bool ret = MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
- worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() {
+ worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_);
enabled_w_ = enable;
for (auto& sink_pair : sink_pairs()) {
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index c3e4be9..12676a0 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -1492,7 +1492,6 @@
":checks",
":gunit_helpers",
":ip_address",
- ":location",
":logging",
":macromagic",
":net_helpers",
@@ -1581,7 +1580,6 @@
":gunit_helpers",
":histogram_percentile_counter",
":ip_address",
- ":location",
":logging",
":macromagic",
":mod_ops",
diff --git a/rtc_base/fake_mdns_responder.h b/rtc_base/fake_mdns_responder.h
index 8be6f1c..706c11b 100644
--- a/rtc_base/fake_mdns_responder.h
+++ b/rtc_base/fake_mdns_responder.h
@@ -17,7 +17,6 @@
#include "absl/strings/string_view.h"
#include "rtc_base/ip_address.h"
-#include "rtc_base/location.h"
#include "rtc_base/mdns_responder_interface.h"
#include "rtc_base/thread.h"
diff --git a/rtc_base/network.cc b/rtc_base/network.cc
index 673a113..ce77cbc 100644
--- a/rtc_base/network.cc
+++ b/rtc_base/network.cc
@@ -1253,7 +1253,7 @@
if (thread_ == nullptr) {
vpn_ = vpn;
} else {
- thread_->Invoke<void>(RTC_FROM_HERE, [this, vpn] { vpn_ = vpn; });
+ thread_->BlockingCall([this, vpn] { vpn_ = vpn; });
}
}
diff --git a/rtc_base/rtc_certificate_generator.cc b/rtc_base/rtc_certificate_generator.cc
index 739890e..bdd90f2 100644
--- a/rtc_base/rtc_certificate_generator.cc
+++ b/rtc_base/rtc_certificate_generator.cc
@@ -17,7 +17,6 @@
#include <utility>
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/message_handler.h"
#include "rtc_base/ssl_identity.h"
diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc
index 2ac5634..ea6407a 100644
--- a/rtc_base/socket_unittest.cc
+++ b/rtc_base/socket_unittest.cc
@@ -23,7 +23,6 @@
#include "rtc_base/async_udp_socket.h"
#include "rtc_base/buffer.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/socket_address.h"
@@ -730,7 +729,7 @@
// Shouldn't signal when blocked in a thread Send, where process_io is false.
std::unique_ptr<Thread> thread(Thread::CreateWithSocketServer());
thread->Start();
- thread->Invoke<void>(RTC_FROM_HERE, [] { Thread::SleepMs(500); });
+ thread->BlockingCall([] { Thread::SleepMs(500); });
EXPECT_FALSE(sink.Check(accepted.get(), SSE_READ));
// But should signal when process_io is true.
diff --git a/rtc_base/stream.cc b/rtc_base/stream.cc
index 30c7678..e1aab8c 100644
--- a/rtc_base/stream.cc
+++ b/rtc_base/stream.cc
@@ -16,7 +16,6 @@
#include <string>
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/thread.h"
namespace rtc {
diff --git a/rtc_base/synchronization/BUILD.gn b/rtc_base/synchronization/BUILD.gn
index 5890e75..5f2b04e 100644
--- a/rtc_base/synchronization/BUILD.gn
+++ b/rtc_base/synchronization/BUILD.gn
@@ -86,7 +86,6 @@
":yield",
":yield_policy",
"..:checks",
- "..:location",
"..:macromagic",
"..:platform_thread",
"..:rtc_base",
diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h
index 0ef0ffe..cae9534 100644
--- a/rtc_base/task_queue.h
+++ b/rtc_base/task_queue.h
@@ -90,7 +90,6 @@
// Returns non-owning pointer to the task queue implementation.
webrtc::TaskQueueBase* Get() { return impl_; }
- // TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
void PostTask(absl::AnyInvocable<void() &&> task) {
impl_->PostTask(std::move(task));
}
diff --git a/rtc_base/thread.h b/rtc_base/thread.h
index ad286a8..435aff6 100644
--- a/rtc_base/thread.h
+++ b/rtc_base/thread.h
@@ -349,7 +349,8 @@
// Deprecated, use `BlockingCall` instead.
template <typename ReturnT>
- ReturnT Invoke(const Location& posted_from, FunctionView<ReturnT()> functor) {
+ [[deprecated]] ReturnT Invoke(const Location& /*posted_from*/,
+ FunctionView<ReturnT()> functor) {
return BlockingCall(functor);
}
diff --git a/rtc_base/time_utils_unittest.cc b/rtc_base/time_utils_unittest.cc
index 7e72c5f..2c73b0f 100644
--- a/rtc_base/time_utils_unittest.cc
+++ b/rtc_base/time_utils_unittest.cc
@@ -16,7 +16,6 @@
#include "rtc_base/event.h"
#include "rtc_base/fake_clock.h"
#include "rtc_base/helpers.h"
-#include "rtc_base/location.h"
#include "rtc_base/message_handler.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
diff --git a/rtc_tools/network_tester/test_controller.cc b/rtc_tools/network_tester/test_controller.cc
index 4ba43cc..6fe83fd 100644
--- a/rtc_tools/network_tester/test_controller.cc
+++ b/rtc_tools/network_tester/test_controller.cc
@@ -38,7 +38,7 @@
send_data_.fill(42);
packet_sender_thread_->SetName("PacketSender", nullptr);
packet_sender_thread_->Start();
- packet_sender_thread_->Invoke<void>(RTC_FROM_HERE, [&] {
+ packet_sender_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(packet_sender_thread_.get());
udp_socket_ =
std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket(
@@ -49,8 +49,8 @@
TestController::~TestController() {
RTC_DCHECK_RUN_ON(&test_controller_thread_checker_);
- packet_sender_thread_->Invoke<void>(
- RTC_FROM_HERE, [this]() { task_safety_flag_->SetNotAlive(); });
+ packet_sender_thread_->BlockingCall(
+ [this]() { task_safety_flag_->SetNotAlive(); });
}
void TestController::SendConnectTo(const std::string& hostname, int port) {
diff --git a/sdk/android/src/jni/pc/peer_connection.cc b/sdk/android/src/jni/pc/peer_connection.cc
index 502763a..03321a5 100644
--- a/sdk/android/src/jni/pc/peer_connection.cc
+++ b/sdk/android/src/jni/pc/peer_connection.cc
@@ -516,7 +516,7 @@
// must do this odd dance.
std::string sdp;
std::string type;
- pc->signaling_thread()->Invoke<void>(RTC_FROM_HERE, [pc, &sdp, &type] {
+ pc->signaling_thread()->BlockingCall([pc, &sdp, &type] {
const SessionDescriptionInterface* desc = pc->local_description();
if (desc) {
RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
@@ -535,7 +535,7 @@
// must do this odd dance.
std::string sdp;
std::string type;
- pc->signaling_thread()->Invoke<void>(RTC_FROM_HERE, [pc, &sdp, &type] {
+ pc->signaling_thread()->BlockingCall([pc, &sdp, &type] {
const SessionDescriptionInterface* desc = pc->remote_description();
if (desc) {
RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
diff --git a/sdk/objc/api/peerconnection/RTCMediaStream.mm b/sdk/objc/api/peerconnection/RTCMediaStream.mm
index beb4a7a..0018dd6 100644
--- a/sdk/objc/api/peerconnection/RTCMediaStream.mm
+++ b/sdk/objc/api/peerconnection/RTCMediaStream.mm
@@ -36,16 +36,14 @@
- (NSArray<RTC_OBJC_TYPE(RTCAudioTrack) *> *)audioTracks {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<NSArray<RTC_OBJC_TYPE(RTCAudioTrack) *> *>(
- RTC_FROM_HERE, [self]() { return self.audioTracks; });
+ return _signalingThread->BlockingCall([self]() { return self.audioTracks; });
}
return [_audioTracks copy];
}
- (NSArray<RTC_OBJC_TYPE(RTCVideoTrack) *> *)videoTracks {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<NSArray<RTC_OBJC_TYPE(RTCVideoTrack) *> *>(
- RTC_FROM_HERE, [self]() { return self.videoTracks; });
+ return _signalingThread->BlockingCall([self]() { return self.videoTracks; });
}
return [_videoTracks copy];
}
@@ -56,8 +54,8 @@
- (void)addAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<void>(
- RTC_FROM_HERE, [audioTrack, self]() { return [self addAudioTrack:audioTrack]; });
+ return _signalingThread->BlockingCall(
+ [audioTrack, self]() { return [self addAudioTrack:audioTrack]; });
}
if (_nativeMediaStream->AddTrack(audioTrack.nativeAudioTrack)) {
[_audioTracks addObject:audioTrack];
@@ -66,8 +64,8 @@
- (void)addVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<void>(
- RTC_FROM_HERE, [videoTrack, self]() { return [self addVideoTrack:videoTrack]; });
+ return _signalingThread->BlockingCall(
+ [videoTrack, self]() { return [self addVideoTrack:videoTrack]; });
}
if (_nativeMediaStream->AddTrack(videoTrack.nativeVideoTrack)) {
[_videoTracks addObject:videoTrack];
@@ -76,8 +74,8 @@
- (void)removeAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<void>(
- RTC_FROM_HERE, [audioTrack, self]() { return [self removeAudioTrack:audioTrack]; });
+ return _signalingThread->BlockingCall(
+ [audioTrack, self]() { return [self removeAudioTrack:audioTrack]; });
}
NSUInteger index = [_audioTracks indexOfObjectIdenticalTo:audioTrack];
if (index == NSNotFound) {
@@ -91,8 +89,8 @@
- (void)removeVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack {
if (!_signalingThread->IsCurrent()) {
- return _signalingThread->Invoke<void>(
- RTC_FROM_HERE, [videoTrack, self]() { return [self removeVideoTrack:videoTrack]; });
+ return _signalingThread->BlockingCall(
+ [videoTrack, self]() { return [self removeVideoTrack:videoTrack]; });
}
NSUInteger index = [_videoTracks indexOfObjectIdenticalTo:videoTrack];
if (index == NSNotFound) {
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm
index f4db472..df99030 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm
+++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm
@@ -392,26 +392,22 @@
- (RTC_OBJC_TYPE(RTCSessionDescription) *)localDescription {
// It's only safe to operate on SessionDescriptionInterface on the signaling thread.
- return _peerConnection->signaling_thread()->Invoke<RTC_OBJC_TYPE(RTCSessionDescription) *>(
- RTC_FROM_HERE, [self] {
- const webrtc::SessionDescriptionInterface *description =
- _peerConnection->local_description();
- return description ?
- [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
- nil;
- });
+ return _peerConnection->signaling_thread()->BlockingCall([self] {
+ const webrtc::SessionDescriptionInterface *description = _peerConnection->local_description();
+ return description ?
+ [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
+ nil;
+ });
}
- (RTC_OBJC_TYPE(RTCSessionDescription) *)remoteDescription {
// It's only safe to operate on SessionDescriptionInterface on the signaling thread.
- return _peerConnection->signaling_thread()->Invoke<RTC_OBJC_TYPE(RTCSessionDescription) *>(
- RTC_FROM_HERE, [self] {
- const webrtc::SessionDescriptionInterface *description =
- _peerConnection->remote_description();
- return description ?
- [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
- nil;
- });
+ return _peerConnection->signaling_thread()->BlockingCall([self] {
+ const webrtc::SessionDescriptionInterface *description = _peerConnection->remote_description();
+ return description ?
+ [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
+ nil;
+ });
}
- (RTCSignalingState)signalingState {
diff --git a/sdk/objc/api/peerconnection/RTCVideoTrack.mm b/sdk/objc/api/peerconnection/RTCVideoTrack.mm
index fb015c6..d4862e3 100644
--- a/sdk/objc/api/peerconnection/RTCVideoTrack.mm
+++ b/sdk/objc/api/peerconnection/RTCVideoTrack.mm
@@ -72,7 +72,7 @@
- (void)addRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer {
if (!_workerThread->IsCurrent()) {
- _workerThread->Invoke<void>(RTC_FROM_HERE, [renderer, self] { [self addRenderer:renderer]; });
+ _workerThread->BlockingCall([renderer, self] { [self addRenderer:renderer]; });
return;
}
@@ -93,8 +93,7 @@
- (void)removeRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer {
if (!_workerThread->IsCurrent()) {
- _workerThread->Invoke<void>(RTC_FROM_HERE,
- [renderer, self] { [self removeRenderer:renderer]; });
+ _workerThread->BlockingCall([renderer, self] { [self removeRenderer:renderer]; });
return;
}
__block NSUInteger indexToRemove = NSNotFound;
diff --git a/sdk/objc/native/src/objc_audio_device_delegate.mm b/sdk/objc/native/src/objc_audio_device_delegate.mm
index b7bb4e4..156d632 100644
--- a/sdk/objc/native/src/objc_audio_device_delegate.mm
+++ b/sdk/objc/native/src/objc_audio_device_delegate.mm
@@ -178,7 +178,7 @@
block();
}
} else {
- thread->Invoke<void>(RTC_FROM_HERE, [block] {
+ thread->BlockingCall([block] {
@autoreleasepool {
block();
}
diff --git a/test/time_controller/BUILD.gn b/test/time_controller/BUILD.gn
index c810eae..8f552a8 100644
--- a/test/time_controller/BUILD.gn
+++ b/test/time_controller/BUILD.gn
@@ -60,7 +60,6 @@
"../../api:time_controller",
"../../api/units:time_delta",
"../../rtc_base",
- "../../rtc_base:location",
"../../rtc_base:macromagic",
"../../rtc_base:rtc_event",
"../../rtc_base:rtc_task_queue",
diff --git a/test/time_controller/time_controller_conformance_test.cc b/test/time_controller/time_controller_conformance_test.cc
index 4b03be3..300dd91 100644
--- a/test/time_controller/time_controller_conformance_test.cc
+++ b/test/time_controller/time_controller_conformance_test.cc
@@ -14,7 +14,6 @@
#include "api/test/time_controller.h"
#include "api/units/time_delta.h"
#include "rtc_base/event.h"
-#include "rtc_base/location.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
@@ -121,7 +120,7 @@
// posted/invoked.
ExecutionOrderKeeper execution_order;
thread->PostTask([&]() { execution_order.Executed(1); });
- thread->Invoke<void>(RTC_FROM_HERE, [&]() { execution_order.Executed(2); });
+ thread->BlockingCall([&]() { execution_order.Executed(2); });
time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));
// Destroy `thread` before `execution_order` to be sure `execution_order`
@@ -140,7 +139,7 @@
ExecutionOrderKeeper execution_order;
thread->PostTask([&]() {
thread->PostTask([&]() { execution_order.Executed(2); });
- thread->Invoke<void>(RTC_FROM_HERE, [&]() { execution_order.Executed(1); });
+ thread->BlockingCall([&]() { execution_order.Executed(1); });
});
time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));
diff --git a/video/BUILD.gn b/video/BUILD.gn
index f0c0add..82bd9e4 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -106,7 +106,6 @@
"../rtc_base:checks",
"../rtc_base:event_tracer",
"../rtc_base:histogram_percentile_counter",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:mod_ops",
@@ -405,7 +404,6 @@
"../rtc_base:checks",
"../rtc_base:criticalsection",
"../rtc_base:event_tracer",
- "../rtc_base:location",
"../rtc_base:logging",
"../rtc_base:macromagic",
"../rtc_base:race_checker",
diff --git a/video/call_stats2.cc b/video/call_stats2.cc
index 95a4e99..ef575d2 100644
--- a/video/call_stats2.cc
+++ b/video/call_stats2.cc
@@ -16,7 +16,6 @@
#include "absl/algorithm/container.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "system_wrappers/include/metrics.h"
namespace webrtc {
diff --git a/video/receive_statistics_proxy2.cc b/video/receive_statistics_proxy2.cc
index 073b1a6..a3a7bca 100644
--- a/video/receive_statistics_proxy2.cc
+++ b/video/receive_statistics_proxy2.cc
@@ -594,7 +594,7 @@
RTC_DCHECK_RUN_ON(&main_thread_);
// Like VideoReceiveStreamInterface::GetStats, called on the worker thread
- // from StatsCollector::ExtractMediaInfo via worker_thread()->Invoke().
+ // from StatsCollector::ExtractMediaInfo via worker_thread()->BlockingCall().
// WebRtcVideoChannel::GetStats(), GetVideoReceiverInfo.
// Get current frame rates here, as only updating them on new frames prevents
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc
index d2ba1b6..4748257 100644
--- a/video/rtp_video_stream_receiver2.cc
+++ b/video/rtp_video_stream_receiver2.cc
@@ -42,7 +42,6 @@
#include "modules/video_coding/nack_requester.h"
#include "modules/video_coding/packet_buffer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/metrics.h"
diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc
index bde8881..8bf8ce2 100644
--- a/video/video_stream_encoder.cc
+++ b/video/video_stream_encoder.cc
@@ -42,7 +42,6 @@
#include "rtc_base/experiments/alr_experiment.h"
#include "rtc_base/experiments/encoder_info_settings.h"
#include "rtc_base/experiments/rate_control_settings.h"
-#include "rtc_base/location.h"
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/no_unique_address.h"