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}
This commit is contained in:
Danil Chapovalov 2022-09-08 18:38:10 +02:00 committed by WebRTC LUCI CQ
parent b190ca9e70
commit 9e09a1f327
54 changed files with 209 additions and 320 deletions

View file

@ -46,7 +46,6 @@ rtc_library("audio_channel") {
"../../modules/rtp_rtcp", "../../modules/rtp_rtcp",
"../../modules/rtp_rtcp:rtp_rtcp_format", "../../modules/rtp_rtcp:rtp_rtcp_format",
"../../rtc_base:criticalsection", "../../rtc_base:criticalsection",
"../../rtc_base:location",
"../../rtc_base:logging", "../../rtc_base:logging",
"../../rtc_base:refcount", "../../rtc_base:refcount",
] ]

View file

@ -17,7 +17,6 @@
#include "api/task_queue/task_queue_factory.h" #include "api/task_queue/task_queue_factory.h"
#include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/receive_statistics.h"
#include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h" #include "modules/rtp_rtcp/source/rtp_rtcp_impl2.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
namespace webrtc { namespace webrtc {

View file

@ -209,7 +209,6 @@ rtc_library("rtp_sender") {
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:race_checker", "../rtc_base:race_checker",
@ -318,7 +317,6 @@ rtc_library("call") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rate_limiter", "../rtc_base:rate_limiter",

View file

@ -52,7 +52,6 @@
#include "modules/rtp_rtcp/source/rtp_util.h" #include "modules/rtp_rtcp/source/rtp_util.h"
#include "modules/video_coding/fec_controller_default.h" #include "modules/video_coding/fec_controller_default.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/no_unique_address.h" #include "rtc_base/system/no_unique_address.h"

View file

@ -14,7 +14,6 @@
#include <utility> #include <utility>
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "rtc_base/location.h"
namespace webrtc { namespace webrtc {

View file

@ -24,7 +24,6 @@
#include "modules/rtp_rtcp/include/receive_statistics.h" #include "modules/rtp_rtcp/include/receive_statistics.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/clock.h" #include "system_wrappers/include/clock.h"

View file

@ -28,7 +28,6 @@
#include "modules/rtp_rtcp/source/rtp_sender.h" #include "modules/rtp_rtcp/source/rtp_sender.h"
#include "modules/video_coding/include/video_codec_interface.h" #include "modules/video_coding/include/video_codec_interface.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/task_queue.h" #include "rtc_base/task_queue.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"

View file

@ -135,7 +135,7 @@ void AndroidVoipClient::Init(
// Due to consistent thread requirement on // Due to consistent thread requirement on
// modules/audio_device/android/audio_device_template.h, // modules/audio_device/android/audio_device_template.h,
// code is invoked in the context of voip_thread_. // 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()); RTC_DCHECK_RUN_ON(voip_thread_.get());
supported_codecs_ = config.encoder_factory->GetSupportedEncoders(); supported_codecs_ = config.encoder_factory->GetSupportedEncoders();
@ -145,7 +145,7 @@ void AndroidVoipClient::Init(
} }
AndroidVoipClient::~AndroidVoipClient() { AndroidVoipClient::~AndroidVoipClient() {
voip_thread_->Invoke<void>(RTC_FROM_HERE, [this] { voip_thread_->BlockingCall([this] {
RTC_DCHECK_RUN_ON(voip_thread_.get()); RTC_DCHECK_RUN_ON(voip_thread_.get());
JavaVM* jvm = nullptr; JavaVM* jvm = nullptr;

View file

@ -46,7 +46,6 @@ rtc_library("pacing") {
"../../logging:rtc_event_pacing", "../../logging:rtc_event_pacing",
"../../rtc_base:checks", "../../rtc_base:checks",
"../../rtc_base:event_tracer", "../../rtc_base:event_tracer",
"../../rtc_base:location",
"../../rtc_base:logging", "../../rtc_base:logging",
"../../rtc_base:macromagic", "../../rtc_base:macromagic",
"../../rtc_base:rtc_numerics", "../../rtc_base:rtc_numerics",

View file

@ -381,7 +381,6 @@ rtc_library("video_coding_legacy") {
"../../modules/rtp_rtcp:rtp_video_header", "../../modules/rtp_rtcp:rtp_video_header",
"../../rtc_base:checks", "../../rtc_base:checks",
"../../rtc_base:event_tracer", "../../rtc_base:event_tracer",
"../../rtc_base:location",
"../../rtc_base:logging", "../../rtc_base:logging",
"../../rtc_base:macromagic", "../../rtc_base:macromagic",
"../../rtc_base:one_time_event", "../../rtc_base:one_time_event",
@ -1220,7 +1219,6 @@ if (rtc_include_tests) {
"../../rtc_base", "../../rtc_base",
"../../rtc_base:checks", "../../rtc_base:checks",
"../../rtc_base:histogram_percentile_counter", "../../rtc_base:histogram_percentile_counter",
"../../rtc_base:location",
"../../rtc_base:platform_thread", "../../rtc_base:platform_thread",
"../../rtc_base:random", "../../rtc_base:random",
"../../rtc_base:refcount", "../../rtc_base:refcount",

View file

@ -21,7 +21,6 @@
#include "modules/video_coding/media_opt_util.h" #include "modules/video_coding/media_opt_util.h"
#include "modules/video_coding/packet.h" #include "modules/video_coding/packet.h"
#include "modules/video_coding/test/stream_generator.h" #include "modules/video_coding/test/stream_generator.h"
#include "rtc_base/location.h"
#include "system_wrappers/include/clock.h" #include "system_wrappers/include/clock.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
#include "test/gmock.h" #include "test/gmock.h"

View file

@ -30,7 +30,6 @@
#include "modules/video_coding/timing/timing.h" #include "modules/video_coding/timing/timing.h"
#include "modules/video_coding/video_coding_impl.h" #include "modules/video_coding/video_coding_impl.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/one_time_event.h" #include "rtc_base/one_time_event.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"

View file

@ -87,7 +87,6 @@ rtc_source_set("channel") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:socket", "../rtc_base:socket",
@ -294,7 +293,6 @@ rtc_source_set("jsep_transport_controller") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
@ -482,7 +480,6 @@ rtc_source_set("sctp_transport") {
"../p2p:rtc_p2p", "../p2p:rtc_p2p",
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
@ -854,7 +851,6 @@ rtc_library("sctp_data_channel") {
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
@ -935,7 +931,6 @@ rtc_source_set("data_channel_controller") {
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
@ -1021,7 +1016,6 @@ rtc_source_set("rtc_stats_collector") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:ip_address", "../rtc_base:ip_address",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:network_constants", "../rtc_base:network_constants",
"../rtc_base:refcount", "../rtc_base:refcount",
@ -1107,7 +1101,6 @@ rtc_source_set("sdp_offer_answer") {
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rtc_operations_chain", "../rtc_base:rtc_operations_chain",
@ -1209,7 +1202,6 @@ rtc_source_set("peer_connection") {
"../rtc_base:copy_on_write_buffer", "../rtc_base:copy_on_write_buffer",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:ip_address", "../rtc_base:ip_address",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:network_constants", "../rtc_base:network_constants",
@ -1294,7 +1286,6 @@ rtc_source_set("legacy_stats_collector") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:ip_address", "../rtc_base:ip_address",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:network_constants", "../rtc_base:network_constants",
@ -1484,7 +1475,6 @@ rtc_source_set("peer_connection_factory") {
"../pc:session_description", "../pc:session_description",
"../pc:video_track", "../pc:video_track",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
@ -1561,7 +1551,6 @@ rtc_library("rtp_transceiver") {
"../api/video:video_bitrate_allocator_factory", "../api/video:video_bitrate_allocator_factory",
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
@ -1693,7 +1682,6 @@ rtc_library("audio_rtp_receiver") {
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
"../rtc_base/system:no_unique_address", "../rtc_base/system:no_unique_address",
@ -1732,7 +1720,6 @@ rtc_library("video_rtp_receiver") {
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
@ -1795,7 +1782,6 @@ rtc_library("video_track") {
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base", "../rtc_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:threading", "../rtc_base:threading",
"../rtc_base/system:no_unique_address", "../rtc_base/system:no_unique_address",
@ -1877,7 +1863,6 @@ rtc_library("rtp_sender") {
"../media:rtc_media_base", "../media:rtc_media_base",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
@ -1932,7 +1917,6 @@ rtc_library("dtmf_sender") {
"../api/task_queue:pending_task_safety_flag", "../api/task_queue:pending_task_safety_flag",
"../api/units:time_delta", "../api/units:time_delta",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:refcount", "../rtc_base:refcount",

View file

@ -20,7 +20,6 @@
#include "pc/audio_track.h" #include "pc/audio_track.h"
#include "pc/media_stream_track_proxy.h" #include "pc/media_stream_track_proxy.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
namespace webrtc { namespace webrtc {
@ -101,7 +100,7 @@ void AudioRtpReceiver::OnSetVolume(double volume) {
RTC_DCHECK_LE(volume, 10); RTC_DCHECK_LE(volume, 10);
bool track_enabled = track_->internal()->enabled(); bool track_enabled = track_->internal()->enabled();
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() { worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
// Update the cached_volume_ even when stopped, to allow clients to set // Update the cached_volume_ even when stopped, to allow clients to set
// the volume before starting/restarting, eg see crbug.com/1272566. // the volume before starting/restarting, eg see crbug.com/1272566.
@ -168,7 +167,7 @@ void AudioRtpReceiver::RestartMediaChannel(absl::optional<uint32_t> ssrc) {
RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
bool enabled = track_->internal()->enabled(); bool enabled = track_->internal()->enabled();
MediaSourceInterface::SourceState state = source_->state(); MediaSourceInterface::SourceState state = source_->state();
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() { worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
RestartMediaChannel_w(std::move(ssrc), enabled, state); RestartMediaChannel_w(std::move(ssrc), enabled, state);
}); });

View file

@ -29,7 +29,6 @@
#include "pc/rtp_media_utils.h" #include "pc/rtp_media_utils.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/copy_on_write_buffer.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/network_route.h" #include "rtc_base/network_route.h"
#include "rtc_base/strings/string_format.h" #include "rtc_base/strings/string_format.h"
@ -269,8 +268,8 @@ bool BaseChannel::SetPayloadTypeDemuxingEnabled(bool enabled) {
// network thread. At the moment there's a workaround for inconsistent state // network thread. At the moment there's a workaround for inconsistent state
// between the worker and network thread because of this (see // between the worker and network thread because of this (see
// OnDemuxerCriteriaUpdatePending elsewhere in this file) and // OnDemuxerCriteriaUpdatePending elsewhere in this file) and
// SetPayloadTypeDemuxingEnabled_w has an Invoke over to the network thread // SetPayloadTypeDemuxingEnabled_w has a BlockingCall over to the network
// to apply state updates. // thread to apply state updates.
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
TRACE_EVENT0("webrtc", "BaseChannel::SetPayloadTypeDemuxingEnabled"); TRACE_EVENT0("webrtc", "BaseChannel::SetPayloadTypeDemuxingEnabled");
return SetPayloadTypeDemuxingEnabled_w(enabled); return SetPayloadTypeDemuxingEnabled_w(enabled);
@ -461,7 +460,7 @@ bool BaseChannel::MaybeUpdateDemuxerAndRtpExtensions_w(
if (update_demuxer) if (update_demuxer)
media_channel()->OnDemuxerCriteriaUpdatePending(); 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()); RTC_DCHECK_RUN_ON(network_thread());
// NOTE: This doesn't take the BUNDLE case in account meaning the RTP header // 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 // extension maps are not merged when BUNDLE is enabled. This is fine
@ -491,8 +490,8 @@ bool BaseChannel::RegisterRtpDemuxerSink_w() {
media_channel_->OnDemuxerCriteriaUpdatePending(); media_channel_->OnDemuxerCriteriaUpdatePending();
// Copy demuxer criteria, since they're a worker-thread variable // Copy demuxer criteria, since they're a worker-thread variable
// and we want to pass them to the network thread // and we want to pass them to the network thread
bool ret = network_thread_->Invoke<bool>( bool ret = network_thread_->BlockingCall(
RTC_FROM_HERE, [this, demuxer_criteria = demuxer_criteria_] { [this, demuxer_criteria = demuxer_criteria_] {
RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK_RUN_ON(network_thread());
if (!rtp_transport_) { if (!rtp_transport_) {
// Transport was disconnected before attempting to update the // Transport was disconnected before attempting to update the

View file

@ -167,13 +167,13 @@ ConnectionContext::ConnectionContext(
if (media_engine_) { if (media_engine_) {
// TODO(tommi): Change VoiceEngine to do ctor time initialization so that // TODO(tommi): Change VoiceEngine to do ctor time initialization so that
// this isn't necessary. // this isn't necessary.
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { media_engine_->Init(); }); worker_thread_->BlockingCall([&] { media_engine_->Init(); });
} }
} }
ConnectionContext::~ConnectionContext() { ConnectionContext::~ConnectionContext() {
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
// While `media_engine_` is const throughout the ConnectionContext's // While `media_engine_` is const throughout the ConnectionContext's
// lifetime, it requires destruction to happen on the worker thread. Instead // lifetime, it requires destruction to happen on the worker thread. Instead

View file

@ -16,7 +16,6 @@
#include "api/rtc_error.h" #include "api/rtc_error.h"
#include "pc/peer_connection_internal.h" #include "pc/peer_connection_internal.h"
#include "pc/sctp_utils.h" #include "pc/sctp_utils.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
namespace webrtc { namespace webrtc {
@ -81,7 +80,7 @@ void DataChannelController::DisconnectDataChannel(
void DataChannelController::AddSctpDataStream(int sid) { void DataChannelController::AddSctpDataStream(int sid) {
if (data_channel_transport()) { if (data_channel_transport()) {
network_thread()->Invoke<void>(RTC_FROM_HERE, [this, sid] { network_thread()->BlockingCall([this, sid] {
if (data_channel_transport()) { if (data_channel_transport()) {
data_channel_transport()->OpenChannel(sid); data_channel_transport()->OpenChannel(sid);
} }
@ -91,7 +90,7 @@ void DataChannelController::AddSctpDataStream(int sid) {
void DataChannelController::RemoveSctpDataStream(int sid) { void DataChannelController::RemoveSctpDataStream(int sid) {
if (data_channel_transport()) { if (data_channel_transport()) {
network_thread()->Invoke<void>(RTC_FROM_HERE, [this, sid] { network_thread()->BlockingCall([this, sid] {
if (data_channel_transport()) { if (data_channel_transport()) {
data_channel_transport()->CloseChannel(sid); data_channel_transport()->CloseChannel(sid);
} }
@ -382,15 +381,14 @@ bool DataChannelController::DataChannelSendData(
const rtc::CopyOnWriteBuffer& payload, const rtc::CopyOnWriteBuffer& payload,
cricket::SendDataResult* result) { cricket::SendDataResult* result) {
// TODO(bugs.webrtc.org/11547): Expect method to be called on the network // 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. // the network thread.
RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK_RUN_ON(signaling_thread());
RTC_DCHECK(data_channel_transport()); RTC_DCHECK(data_channel_transport());
RTCError error = network_thread()->Invoke<RTCError>( RTCError error = network_thread()->BlockingCall([this, sid, params, payload] {
RTC_FROM_HERE, [this, sid, params, payload] { return data_channel_transport()->SendData(sid, params, payload);
return data_channel_transport()->SendData(sid, params, payload); });
});
if (error.ok()) { if (error.ok()) {
*result = cricket::SendDataResult::SDR_SUCCESS; *result = cricket::SendDataResult::SDR_SUCCESS;

View file

@ -142,7 +142,7 @@ bool DtmfSender::InsertDtmf(const std::string& tones,
} }
safety_flag_ = PendingTaskSafetyFlag::Create(); safety_flag_ = PendingTaskSafetyFlag::Create();
// Kick off a new DTMF task. // Kick off a new DTMF task.
QueueInsertDtmf(RTC_FROM_HERE, 1 /*ms*/); QueueInsertDtmf(1 /*ms*/);
return true; return true;
} }
@ -166,8 +166,7 @@ int DtmfSender::comma_delay() const {
return comma_delay_; return comma_delay_;
} }
void DtmfSender::QueueInsertDtmf(const rtc::Location& posted_from, void DtmfSender::QueueInsertDtmf(uint32_t delay_ms) {
uint32_t delay_ms) {
signaling_thread_->PostDelayedHighPrecisionTask( signaling_thread_->PostDelayedHighPrecisionTask(
SafeTask(safety_flag_, SafeTask(safety_flag_,
[this] { [this] {
@ -232,7 +231,7 @@ void DtmfSender::DoInsertDtmf() {
tones_.erase(0, first_tone_pos + 1); tones_.erase(0, first_tone_pos + 1);
// Continue with the next tone. // Continue with the next tone.
QueueInsertDtmf(RTC_FROM_HERE, tone_gap); QueueInsertDtmf(tone_gap);
} }
void DtmfSender::StopSending() { void DtmfSender::StopSending() {

View file

@ -21,7 +21,6 @@
#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/pending_task_safety_flag.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "pc/proxy.h" #include "pc/proxy.h"
#include "rtc_base/location.h"
#include "rtc_base/ref_count.h" #include "rtc_base/ref_count.h"
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
@ -77,8 +76,7 @@ class DtmfSender : public DtmfSenderInterface {
private: private:
DtmfSender(); DtmfSender();
void QueueInsertDtmf(const rtc::Location& posted_from, uint32_t delay_ms) void QueueInsertDtmf(uint32_t delay_ms) RTC_RUN_ON(signaling_thread_);
RTC_RUN_ON(signaling_thread_);
// The DTMF sending task. // The DTMF sending task.
void DoInsertDtmf() RTC_RUN_ON(signaling_thread_); void DoInsertDtmf() RTC_RUN_ON(signaling_thread_);

View file

@ -29,7 +29,6 @@
#include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_constants.h"
#include "p2p/base/port.h" #include "p2p/base/port.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"
@ -77,8 +76,8 @@ RTCError JsepTransportController::SetLocalDescription(
const cricket::SessionDescription* description) { const cricket::SessionDescription* description) {
TRACE_EVENT0("webrtc", "JsepTransportController::SetLocalDescription"); TRACE_EVENT0("webrtc", "JsepTransportController::SetLocalDescription");
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>( return network_thread_->BlockingCall(
RTC_FROM_HERE, [=] { return SetLocalDescription(type, description); }); [=] { return SetLocalDescription(type, description); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -98,8 +97,8 @@ RTCError JsepTransportController::SetRemoteDescription(
const cricket::SessionDescription* description) { const cricket::SessionDescription* description) {
TRACE_EVENT0("webrtc", "JsepTransportController::SetRemoteDescription"); TRACE_EVENT0("webrtc", "JsepTransportController::SetRemoteDescription");
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>( return network_thread_->BlockingCall(
RTC_FROM_HERE, [=] { return SetRemoteDescription(type, description); }); [=] { return SetRemoteDescription(type, description); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -199,8 +198,7 @@ absl::optional<rtc::SSLRole> JsepTransportController::GetDtlsRole(
// thread during negotiations, potentially multiple times. // thread during negotiations, potentially multiple times.
// WebRtcSessionDescriptionFactory::InternalCreateAnswer is one example. // WebRtcSessionDescriptionFactory::InternalCreateAnswer is one example.
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<absl::optional<rtc::SSLRole>>( return network_thread_->BlockingCall([&] { return GetDtlsRole(mid); });
RTC_FROM_HERE, [&] { return GetDtlsRole(mid); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -215,8 +213,8 @@ absl::optional<rtc::SSLRole> JsepTransportController::GetDtlsRole(
bool JsepTransportController::SetLocalCertificate( bool JsepTransportController::SetLocalCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<bool>( return network_thread_->BlockingCall(
RTC_FROM_HERE, [&] { return SetLocalCertificate(certificate); }); [&] { return SetLocalCertificate(certificate); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -274,8 +272,7 @@ JsepTransportController::GetRemoteSSLCertChain(
void JsepTransportController::MaybeStartGathering() { void JsepTransportController::MaybeStartGathering() {
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
network_thread_->Invoke<void>(RTC_FROM_HERE, network_thread_->BlockingCall([&] { MaybeStartGathering(); });
[&] { MaybeStartGathering(); });
return; return;
} }
@ -301,8 +298,8 @@ RTCError JsepTransportController::AddRemoteCandidates(
RTCError JsepTransportController::RemoveRemoteCandidates( RTCError JsepTransportController::RemoveRemoteCandidates(
const cricket::Candidates& candidates) { const cricket::Candidates& candidates) {
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>( return network_thread_->BlockingCall(
RTC_FROM_HERE, [&] { return RemoveRemoteCandidates(candidates); }); [&] { return RemoveRemoteCandidates(candidates); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -361,9 +358,8 @@ bool JsepTransportController::GetStats(const std::string& transport_name,
void JsepTransportController::SetActiveResetSrtpParams( void JsepTransportController::SetActiveResetSrtpParams(
bool active_reset_srtp_params) { bool active_reset_srtp_params) {
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
network_thread_->Invoke<void>(RTC_FROM_HERE, [=] { network_thread_->BlockingCall(
SetActiveResetSrtpParams(active_reset_srtp_params); [=] { SetActiveResetSrtpParams(active_reset_srtp_params); });
});
return; return;
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
@ -378,8 +374,7 @@ void JsepTransportController::SetActiveResetSrtpParams(
RTCError JsepTransportController::RollbackTransports() { RTCError JsepTransportController::RollbackTransports() {
if (!network_thread_->IsCurrent()) { if (!network_thread_->IsCurrent()) {
return network_thread_->Invoke<RTCError>( return network_thread_->BlockingCall([=] { return RollbackTransports(); });
RTC_FROM_HERE, [=] { return RollbackTransports(); });
} }
RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK_RUN_ON(network_thread_);
bundles_.Rollback(); bundles_.Rollback();

View file

@ -46,7 +46,6 @@
#include "pc/transport_stats.h" #include "pc/transport_stats.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/ip_address.h" #include "rtc_base/ip_address.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate.h" #include "rtc_base/rtc_certificate.h"
#include "rtc_base/socket_address.h" #include "rtc_base/socket_address.h"
@ -861,9 +860,9 @@ std::map<std::string, std::string> LegacyStatsCollector::ExtractSessionInfo() {
SessionStats stats; SessionStats stats;
auto transceivers = pc_->GetTransceiversInternal(); auto transceivers = pc_->GetTransceiversInternal();
pc_->network_thread()->Invoke<void>( pc_->network_thread()->BlockingCall(
RTC_FROM_HERE, [&, sctp_transport_name = pc_->sctp_transport_name(), [&, sctp_transport_name = pc_->sctp_transport_name(),
sctp_mid = pc_->sctp_mid()]() mutable { sctp_mid = pc_->sctp_mid()]() mutable {
stats = ExtractSessionInfo_n( stats = ExtractSessionInfo_n(
transceivers, std::move(sctp_transport_name), std::move(sctp_mid)); transceivers, std::move(sctp_transport_name), std::move(sctp_mid));
}); });
@ -1049,7 +1048,7 @@ void LegacyStatsCollector::ExtractBweInfo() {
} }
if (!video_media_channels.empty()) { if (!video_media_channels.empty()) {
pc_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&] { pc_->worker_thread()->BlockingCall([&] {
for (const auto& channel : video_media_channels) { for (const auto& channel : video_media_channels) {
channel->FillBitrateInfo(&bwe_info); channel->FillBitrateInfo(&bwe_info);
} }
@ -1200,7 +1199,7 @@ void LegacyStatsCollector::ExtractMediaInfo(
} }
} }
pc_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&] { pc_->worker_thread()->BlockingCall([&] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
// Populate `receiver_track_id_by_ssrc` for the gatherers. // Populate `receiver_track_id_by_ssrc` for the gatherers.
int i = 0; int i = 0;

View file

@ -52,7 +52,6 @@
#include "pc/webrtc_session_description_factory.h" #include "pc/webrtc_session_description_factory.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h" #include "rtc_base/ip_address.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/net_helper.h" #include "rtc_base/net_helper.h"
#include "rtc_base/network.h" #include "rtc_base/network.h"
@ -525,7 +524,7 @@ PeerConnection::PeerConnection(
data_channel_controller_(this), data_channel_controller_(this),
message_handler_(signaling_thread()), message_handler_(signaling_thread()),
weak_factory_(this) { weak_factory_(this) {
worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] { worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_ = PendingTaskSafetyFlag::Create(); worker_thread_safety_ = PendingTaskSafetyFlag::Create();
if (!call_) if (!call_)
@ -569,7 +568,7 @@ PeerConnection::~PeerConnection() {
// port_allocator_ and transport_controller_ live on the network thread and // port_allocator_ and transport_controller_ live on the network thread and
// should be destroyed there. // should be destroyed there.
transport_controller_copy_ = nullptr; transport_controller_copy_ = nullptr;
network_thread()->Invoke<void>(RTC_FROM_HERE, [this] { network_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK_RUN_ON(network_thread());
TeardownDataChannelTransport_n(); TeardownDataChannelTransport_n();
transport_controller_.reset(); transport_controller_.reset();
@ -579,7 +578,7 @@ PeerConnection::~PeerConnection() {
}); });
// call_ and event_log_ must be destroyed on the worker thread. // 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()); RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive(); worker_thread_safety_->SetNotAlive();
call_.reset(); call_.reset();
@ -618,7 +617,7 @@ RTCError PeerConnection::Initialize(
// Network thread initialization. // Network thread initialization.
transport_controller_copy_ = transport_controller_copy_ =
network_thread()->Invoke<JsepTransportController*>(RTC_FROM_HERE, [&] { network_thread()->BlockingCall([&] {
RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK_RUN_ON(network_thread());
network_thread_safety_ = PendingTaskSafetyFlag::Create(); network_thread_safety_ = PendingTaskSafetyFlag::Create();
InitializePortAllocatorResult pa_result = InitializePortAllocator_n( InitializePortAllocatorResult pa_result = InitializePortAllocator_n(
@ -940,13 +939,12 @@ RtpTransportInternal* PeerConnection::GetRtpTransport(const std::string& mid) {
// TODO(bugs.webrtc.org/9987): Avoid the thread jump. // TODO(bugs.webrtc.org/9987): Avoid the thread jump.
// This might be done by caching the value on the signaling thread. // This might be done by caching the value on the signaling thread.
RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK_RUN_ON(signaling_thread());
return network_thread()->Invoke<RtpTransportInternal*>( return network_thread()->BlockingCall([this, &mid] {
RTC_FROM_HERE, [this, &mid] { RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK_RUN_ON(network_thread()); auto rtp_transport = transport_controller_->GetRtpTransport(mid);
auto rtp_transport = transport_controller_->GetRtpTransport(mid); RTC_DCHECK(rtp_transport);
RTC_DCHECK(rtp_transport); return rtp_transport;
return rtp_transport; });
});
} }
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
@ -1556,8 +1554,7 @@ RTCError PeerConnection::SetConfiguration(
// Apply part of the configuration on the network thread. In theory this // Apply part of the configuration on the network thread. In theory this
// shouldn't fail. // shouldn't fail.
if (!network_thread()->Invoke<bool>( if (!network_thread()->BlockingCall(
RTC_FROM_HERE,
[this, needs_ice_restart, &ice_config, &stun_servers, &turn_servers, [this, needs_ice_restart, &ice_config, &stun_servers, &turn_servers,
&modified_config, has_local_description] { &modified_config, has_local_description] {
RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK_RUN_ON(network_thread());
@ -1583,8 +1580,8 @@ RTCError PeerConnection::SetConfiguration(
if (configuration_.active_reset_srtp_params != if (configuration_.active_reset_srtp_params !=
modified_config.active_reset_srtp_params) { modified_config.active_reset_srtp_params) {
// TODO(tommi): merge invokes // TODO(tommi): merge BlockingCalls
network_thread()->Invoke<void>(RTC_FROM_HERE, [this, &modified_config] { network_thread()->BlockingCall([this, &modified_config] {
RTC_DCHECK_RUN_ON(network_thread()); RTC_DCHECK_RUN_ON(network_thread());
transport_controller_->SetActiveResetSrtpParams( transport_controller_->SetActiveResetSrtpParams(
modified_config.active_reset_srtp_params); modified_config.active_reset_srtp_params);
@ -1603,8 +1600,7 @@ RTCError PeerConnection::SetConfiguration(
video_channel->media_channel())); video_channel->media_channel()));
} }
worker_thread()->Invoke<void>( worker_thread()->BlockingCall(
RTC_FROM_HERE,
[channels = std::move(channels), [channels = std::move(channels),
allow_codec_switching = *modified_config.allow_codec_switching]() { allow_codec_switching = *modified_config.allow_codec_switching]() {
for (auto* ch : channels) for (auto* ch : channels)
@ -1643,8 +1639,7 @@ bool PeerConnection::RemoveIceCandidates(
RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) { RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) {
if (!worker_thread()->IsCurrent()) { if (!worker_thread()->IsCurrent()) {
return worker_thread()->Invoke<RTCError>( return worker_thread()->BlockingCall([&]() { return SetBitrate(bitrate); });
RTC_FROM_HERE, [&]() { return SetBitrate(bitrate); });
} }
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
@ -1685,8 +1680,8 @@ RTCError PeerConnection::SetBitrate(const BitrateSettings& bitrate) {
void PeerConnection::SetAudioPlayout(bool playout) { void PeerConnection::SetAudioPlayout(bool playout) {
if (!worker_thread()->IsCurrent()) { if (!worker_thread()->IsCurrent()) {
worker_thread()->Invoke<void>( worker_thread()->BlockingCall(
RTC_FROM_HERE, [this, playout] { SetAudioPlayout(playout); }); [this, playout] { SetAudioPlayout(playout); });
return; return;
} }
auto audio_state = context_->media_engine()->voice().GetAudioState(); auto audio_state = context_->media_engine()->voice().GetAudioState();
@ -1695,8 +1690,8 @@ void PeerConnection::SetAudioPlayout(bool playout) {
void PeerConnection::SetAudioRecording(bool recording) { void PeerConnection::SetAudioRecording(bool recording) {
if (!worker_thread()->IsCurrent()) { if (!worker_thread()->IsCurrent()) {
worker_thread()->Invoke<void>( worker_thread()->BlockingCall(
RTC_FROM_HERE, [this, recording] { SetAudioRecording(recording); }); [this, recording] { SetAudioRecording(recording); });
return; return;
} }
auto audio_state = context_->media_engine()->voice().GetAudioState(); auto audio_state = context_->media_engine()->voice().GetAudioState();
@ -1706,9 +1701,8 @@ void PeerConnection::SetAudioRecording(bool recording) {
void PeerConnection::AddAdaptationResource( void PeerConnection::AddAdaptationResource(
rtc::scoped_refptr<Resource> resource) { rtc::scoped_refptr<Resource> resource) {
if (!worker_thread()->IsCurrent()) { if (!worker_thread()->IsCurrent()) {
return worker_thread()->Invoke<void>(RTC_FROM_HERE, [this, resource]() { return worker_thread()->BlockingCall(
return AddAdaptationResource(resource); [this, resource]() { return AddAdaptationResource(resource); });
});
} }
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
if (!call_) { if (!call_) {
@ -1724,8 +1718,7 @@ bool PeerConnection::ConfiguredForMedia() const {
bool PeerConnection::StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, bool PeerConnection::StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) { int64_t output_period_ms) {
return worker_thread()->Invoke<bool>( return worker_thread()->BlockingCall(
RTC_FROM_HERE,
[this, output = std::move(output), output_period_ms]() mutable { [this, output = std::move(output), output_period_ms]() mutable {
return StartRtcEventLog_w(std::move(output), output_period_ms); return StartRtcEventLog_w(std::move(output), output_period_ms);
}); });
@ -1741,7 +1734,7 @@ bool PeerConnection::StartRtcEventLog(
} }
void PeerConnection::StopRtcEventLog() { void PeerConnection::StopRtcEventLog() {
worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] { StopRtcEventLog_w(); }); worker_thread()->BlockingCall([this] { StopRtcEventLog_w(); });
} }
rtc::scoped_refptr<DtlsTransportInterface> rtc::scoped_refptr<DtlsTransportInterface>
@ -1755,11 +1748,10 @@ PeerConnection::LookupDtlsTransportByMidInternal(const std::string& mid) {
RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK_RUN_ON(signaling_thread());
// TODO(bugs.webrtc.org/9987): Avoid the thread jump. // TODO(bugs.webrtc.org/9987): Avoid the thread jump.
// This might be done by caching the value on the signaling thread. // This might be done by caching the value on the signaling thread.
return network_thread()->Invoke<rtc::scoped_refptr<DtlsTransport>>( return network_thread()->BlockingCall([this, mid]() {
RTC_FROM_HERE, [this, mid]() { RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK_RUN_ON(network_thread()); return transport_controller_->LookupDtlsTransportByMid(mid);
return transport_controller_->LookupDtlsTransportByMid(mid); });
});
} }
rtc::scoped_refptr<SctpTransportInterface> PeerConnection::GetSctpTransport() rtc::scoped_refptr<SctpTransportInterface> PeerConnection::GetSctpTransport()
@ -1856,7 +1848,7 @@ void PeerConnection::Close() {
rtp_manager_->Close(); 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() // Data channels will already have been unset via the DestroyAllChannels()
// call above, which triggers a call to TeardownDataChannelTransport_n(). // call above, which triggers a call to TeardownDataChannelTransport_n().
// TODO(tommi): ^^ That's not exactly optimal since this is yet another // TODO(tommi): ^^ That's not exactly optimal since this is yet another
@ -1870,7 +1862,7 @@ void PeerConnection::Close() {
} }
}); });
worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] { worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive(); worker_thread_safety_->SetNotAlive();
call_.reset(); call_.reset();
@ -2225,11 +2217,10 @@ bool PeerConnection::GetSctpSslRole(rtc::SSLRole* role) {
absl::optional<rtc::SSLRole> dtls_role; absl::optional<rtc::SSLRole> dtls_role;
if (sctp_mid_s_) { if (sctp_mid_s_) {
dtls_role = network_thread()->Invoke<absl::optional<rtc::SSLRole>>( dtls_role = network_thread()->BlockingCall([this] {
RTC_FROM_HERE, [this] { RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK_RUN_ON(network_thread()); return transport_controller_->GetDtlsRole(*sctp_mid_n_);
return transport_controller_->GetDtlsRole(*sctp_mid_n_); });
});
if (!dtls_role && sdp_handler_->is_caller().has_value()) { if (!dtls_role && sdp_handler_->is_caller().has_value()) {
// This works fine if we are the offerer, but can be a mistake if // 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 // we are the answerer and the remote offer is ACTIVE. In that
@ -2259,11 +2250,10 @@ bool PeerConnection::GetSslRole(const std::string& content_name,
return false; return false;
} }
auto dtls_role = network_thread()->Invoke<absl::optional<rtc::SSLRole>>( auto dtls_role = network_thread()->BlockingCall([this, content_name]() {
RTC_FROM_HERE, [this, content_name]() { RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK_RUN_ON(network_thread()); return transport_controller_->GetDtlsRole(content_name);
return transport_controller_->GetDtlsRole(content_name); });
});
if (dtls_role) { if (dtls_role) {
*role = *dtls_role; *role = *dtls_role;
return true; return true;
@ -2360,7 +2350,7 @@ bool PeerConnection::IceRestartPending(const std::string& content_name) const {
} }
bool PeerConnection::NeedsIceRestart(const std::string& content_name) const { 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()); RTC_DCHECK_RUN_ON(network_thread());
return transport_controller_->NeedsIceRestart(content_name); return transport_controller_->NeedsIceRestart(content_name);
}); });
@ -2489,8 +2479,7 @@ bool PeerConnection::GetLocalCandidateMediaIndex(
Call::Stats PeerConnection::GetCallStats() { Call::Stats PeerConnection::GetCallStats() {
if (!worker_thread()->IsCurrent()) { if (!worker_thread()->IsCurrent()) {
return worker_thread()->Invoke<Call::Stats>( return worker_thread()->BlockingCall([this] { return GetCallStats(); });
RTC_FROM_HERE, [this] { return GetCallStats(); });
} }
RTC_DCHECK_RUN_ON(worker_thread()); RTC_DCHECK_RUN_ON(worker_thread());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;

View file

@ -46,7 +46,6 @@
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/experiments/field_trial_units.h" #include "rtc_base/experiments/field_trial_units.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_conversions.h"
#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/rtc_certificate_generator.h"
@ -60,12 +59,9 @@ CreateModularPeerConnectionFactory(
// The PeerConnectionFactory must be created on the signaling thread. // The PeerConnectionFactory must be created on the signaling thread.
if (dependencies.signaling_thread && if (dependencies.signaling_thread &&
!dependencies.signaling_thread->IsCurrent()) { !dependencies.signaling_thread->IsCurrent()) {
return dependencies.signaling_thread return dependencies.signaling_thread->BlockingCall([&dependencies] {
->Invoke<rtc::scoped_refptr<PeerConnectionFactoryInterface>>( return CreateModularPeerConnectionFactory(std::move(dependencies));
RTC_FROM_HERE, [&dependencies] { });
return CreateModularPeerConnectionFactory(
std::move(dependencies));
});
} }
auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies)); auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
@ -238,13 +234,12 @@ PeerConnectionFactory::CreatePeerConnectionOrError(
dependencies.allocator->SetVpnList(configuration.vpn_list); dependencies.allocator->SetVpnList(configuration.vpn_list);
std::unique_ptr<RtcEventLog> event_log = std::unique_ptr<RtcEventLog> event_log =
worker_thread()->Invoke<std::unique_ptr<RtcEventLog>>( worker_thread()->BlockingCall([this] { return CreateRtcEventLog_w(); });
RTC_FROM_HERE, [this] { return CreateRtcEventLog_w(); });
const FieldTrialsView* trials = const FieldTrialsView* trials =
dependencies.trials ? dependencies.trials.get() : &field_trials(); dependencies.trials ? dependencies.trials.get() : &field_trials();
std::unique_ptr<Call> call = worker_thread()->Invoke<std::unique_ptr<Call>>( std::unique_ptr<Call> call =
RTC_FROM_HERE, [this, &event_log, trials] { worker_thread()->BlockingCall([this, &event_log, trials] {
return CreateCall_w(event_log.get(), *trials); return CreateCall_w(event_log.get(), *trials);
}); });

View file

@ -50,7 +50,6 @@
#include "pc/webrtc_sdp.h" #include "pc/webrtc_sdp.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/ip_address.h" #include "rtc_base/ip_address.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/network_constants.h" #include "rtc_base/network_constants.h"
#include "rtc_base/rtc_certificate.h" #include "rtc_base/rtc_certificate.h"
@ -2316,9 +2315,9 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() {
auto transceivers = pc_->GetTransceiversInternal(); auto transceivers = pc_->GetTransceiversInternal();
// TODO(tommi): See if we can avoid synchronously blocking the signaling // TODO(tommi): See if we can avoid synchronously blocking the signaling
// thread while we do this (or avoid the Invoke at all). // thread while we do this (or avoid the BlockingCall at all).
network_thread_->Invoke<void>(RTC_FROM_HERE, [this, &transceivers, network_thread_->BlockingCall([this, &transceivers, &voice_stats,
&voice_stats, &video_stats] { &video_stats] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
for (const auto& transceiver_proxy : transceivers) { for (const auto& transceiver_proxy : transceivers) {
@ -2363,7 +2362,7 @@ void RTCStatsCollector::PrepareTransceiverStatsInfosAndCallStats_s_w_n() {
// well as GetCallStats(). At the same time we construct the // well as GetCallStats(). At the same time we construct the
// TrackMediaInfoMaps, which also needs info from the worker thread. This // TrackMediaInfoMaps, which also needs info from the worker thread. This
// minimizes the number of thread jumps. // minimizes the number of thread jumps.
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
for (auto& pair : voice_stats) { for (auto& pair : voice_stats) {

View file

@ -24,7 +24,6 @@
#include "pc/legacy_stats_collector_interface.h" #include "pc/legacy_stats_collector_interface.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/trace_event.h" #include "rtc_base/trace_event.h"
@ -125,9 +124,8 @@ void RtpSenderBase::SetFrameEncryptor(
frame_encryptor_ = std::move(frame_encryptor); frame_encryptor_ = std::move(frame_encryptor);
// Special Case: Set the frame encryptor to any value on any existing channel. // Special Case: Set the frame encryptor to any value on any existing channel.
if (media_channel_ && ssrc_ && !stopped_) { if (media_channel_ && ssrc_ && !stopped_) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall(
media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_); [&] { media_channel_->SetFrameEncryptor(ssrc_, frame_encryptor_); });
});
} }
} }
@ -142,7 +140,7 @@ void RtpSenderBase::SetEncoderSelector(
void RtpSenderBase::SetEncoderSelectorOnChannel() { void RtpSenderBase::SetEncoderSelectorOnChannel() {
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
if (media_channel_ && ssrc_ && !stopped_) { if (media_channel_ && ssrc_ && !stopped_) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
media_channel_->SetEncoderSelector(ssrc_, encoder_selector_.get()); media_channel_->SetEncoderSelector(ssrc_, encoder_selector_.get());
}); });
} }
@ -162,7 +160,7 @@ RtpParameters RtpSenderBase::GetParametersInternal() const {
if (!media_channel_ || !ssrc_) { if (!media_channel_ || !ssrc_) {
return init_parameters_; return init_parameters_;
} }
return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] { return worker_thread_->BlockingCall([&] {
RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_); RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_);
RemoveEncodingLayers(disabled_rids_, &result.encodings); RemoveEncodingLayers(disabled_rids_, &result.encodings);
return result; return result;
@ -177,7 +175,7 @@ RtpParameters RtpSenderBase::GetParametersInternalWithAllLayers() const {
if (!media_channel_ || !ssrc_) { if (!media_channel_ || !ssrc_) {
return init_parameters_; return init_parameters_;
} }
return worker_thread_->Invoke<RtpParameters>(RTC_FROM_HERE, [&] { return worker_thread_->BlockingCall([&] {
RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_); RtpParameters result = media_channel_->GetRtpSendParameters(ssrc_);
return result; return result;
}); });
@ -208,7 +206,7 @@ RTCError RtpSenderBase::SetParametersInternal(const RtpParameters& parameters) {
} }
return result; return result;
} }
return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] { return worker_thread_->BlockingCall([&] {
RtpParameters rtp_parameters = parameters; RtpParameters rtp_parameters = parameters;
if (!disabled_rids_.empty()) { if (!disabled_rids_.empty()) {
// Need to add the inactive layers. // Need to add the inactive layers.
@ -239,7 +237,7 @@ RTCError RtpSenderBase::SetParametersInternalWithAllLayers(
} }
return result; return result;
} }
return worker_thread_->Invoke<RTCError>(RTC_FROM_HERE, [&] { return worker_thread_->BlockingCall([&] {
RtpParameters rtp_parameters = parameters; RtpParameters rtp_parameters = parameters;
return media_channel_->SetRtpSendParameters(ssrc_, rtp_parameters); return media_channel_->SetRtpSendParameters(ssrc_, rtp_parameters);
}); });
@ -345,7 +343,7 @@ void RtpSenderBase::SetSsrc(uint32_t ssrc) {
} }
if (!init_parameters_.encodings.empty() || if (!init_parameters_.encodings.empty() ||
init_parameters_.degradation_preference.has_value()) { init_parameters_.degradation_preference.has_value()) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
RTC_DCHECK(media_channel_); RTC_DCHECK(media_channel_);
// Get the current parameters, which are constructed from the SDP. // Get the current parameters, which are constructed from the SDP.
// The number of layers in the SDP is currently authoritative to support // The number of layers in the SDP is currently authoritative to support
@ -454,7 +452,7 @@ void RtpSenderBase::SetEncoderToPacketizerFrameTransformer(
RTC_DCHECK_RUN_ON(signaling_thread_); RTC_DCHECK_RUN_ON(signaling_thread_);
frame_transformer_ = std::move(frame_transformer); frame_transformer_ = std::move(frame_transformer);
if (media_channel_ && ssrc_ && !stopped_) { if (media_channel_ && ssrc_ && !stopped_) {
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
media_channel_->SetEncoderToPacketizerFrameTransformer( media_channel_->SetEncoderToPacketizerFrameTransformer(
ssrc_, frame_transformer_); ssrc_, frame_transformer_);
}); });
@ -526,8 +524,8 @@ bool AudioRtpSender::CanInsertDtmf() {
RTC_LOG(LS_ERROR) << "CanInsertDtmf: Sender does not have SSRC."; RTC_LOG(LS_ERROR) << "CanInsertDtmf: Sender does not have SSRC.";
return false; return false;
} }
return worker_thread_->Invoke<bool>( return worker_thread_->BlockingCall(
RTC_FROM_HERE, [&] { return voice_media_channel()->CanInsertDtmf(); }); [&] { return voice_media_channel()->CanInsertDtmf(); });
} }
bool AudioRtpSender::InsertDtmf(int code, int duration) { bool AudioRtpSender::InsertDtmf(int code, int duration) {
@ -539,9 +537,8 @@ bool AudioRtpSender::InsertDtmf(int code, int duration) {
RTC_LOG(LS_ERROR) << "InsertDtmf: Sender does not have SSRC."; RTC_LOG(LS_ERROR) << "InsertDtmf: Sender does not have SSRC.";
return false; return false;
} }
bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { bool success = worker_thread_->BlockingCall(
return voice_media_channel()->InsertDtmf(ssrc_, code, duration); [&] { return voice_media_channel()->InsertDtmf(ssrc_, code, duration); });
});
if (!success) { if (!success) {
RTC_LOG(LS_ERROR) << "Failed to insert DTMF to channel."; RTC_LOG(LS_ERROR) << "Failed to insert DTMF to channel.";
} }
@ -610,7 +607,7 @@ void AudioRtpSender::SetSend() {
// `track_->enabled()` hops to the signaling thread, so call it before we hop // `track_->enabled()` hops to the signaling thread, so call it before we hop
// to the worker thread or else it will deadlock. // to the worker thread or else it will deadlock.
bool track_enabled = track_->enabled(); 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, return voice_media_channel()->SetAudioSend(ssrc_, track_enabled, &options,
sink_adapter_.get()); sink_adapter_.get());
}); });
@ -628,7 +625,7 @@ void AudioRtpSender::ClearSend() {
return; return;
} }
cricket::AudioOptions options; 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); return voice_media_channel()->SetAudioSend(ssrc_, false, &options, nullptr);
}); });
if (!success) { if (!success) {
@ -704,7 +701,7 @@ void VideoRtpSender::SetSend() {
options.is_screencast = true; options.is_screencast = true;
break; break;
} }
bool success = worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { bool success = worker_thread_->BlockingCall([&] {
return video_media_channel()->SetVideoSend(ssrc_, &options, return video_media_channel()->SetVideoSend(ssrc_, &options,
video_track().get()); video_track().get());
}); });
@ -722,9 +719,8 @@ void VideoRtpSender::ClearSend() {
// Allow SetVideoSend to fail since `enable` is false and `source` is null. // Allow SetVideoSend to fail since `enable` is false and `source` is null.
// This the normal case when the underlying media channel has already been // This the normal case when the underlying media channel has already been
// deleted. // deleted.
worker_thread_->Invoke<bool>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall(
return video_media_channel()->SetVideoSend(ssrc_, nullptr, nullptr); [&] { video_media_channel()->SetVideoSend(ssrc_, nullptr, nullptr); });
});
} }
} // namespace webrtc } // namespace webrtc

View file

@ -28,7 +28,6 @@
#include "pc/rtp_media_utils.h" #include "pc/rtp_media_utils.h"
#include "pc/session_description.h" #include "pc/session_description.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
@ -185,57 +184,42 @@ RTCError RtpTransceiver::CreateChannel(
// TODO(bugs.webrtc.org/11992): Remove this workaround after updates in // TODO(bugs.webrtc.org/11992): Remove this workaround after updates in
// PeerConnection and add the expectation that we're already on the right // PeerConnection and add the expectation that we're already on the right
// thread. // thread.
new_channel = context()->worker_thread()->BlockingCall([&] {
context() RTC_DCHECK_RUN_ON(context()->worker_thread());
->worker_thread()
->Invoke<std::unique_ptr<cricket::VoiceChannel>>(
RTC_FROM_HERE, [&]() -> std::unique_ptr<cricket::VoiceChannel> {
RTC_DCHECK_RUN_ON(context()->worker_thread());
cricket::VoiceMediaChannel* media_channel = cricket::VoiceMediaChannel* media_channel =
media_engine()->voice().CreateMediaChannel( media_engine()->voice().CreateMediaChannel(
call_ptr, media_config, audio_options, call_ptr, media_config, audio_options, crypto_options);
crypto_options); if (!media_channel) {
if (!media_channel) { return;
return nullptr; }
}
auto voice_channel = std::make_unique<cricket::VoiceChannel>( new_channel = std::make_unique<cricket::VoiceChannel>(
context()->worker_thread(), context()->network_thread(), context()->worker_thread(), context()->network_thread(),
context()->signaling_thread(), context()->signaling_thread(), absl::WrapUnique(media_channel), mid,
absl::WrapUnique(media_channel), mid, srtp_required, srtp_required, crypto_options, context()->ssrc_generator());
crypto_options, context()->ssrc_generator()); });
return voice_channel;
});
} else { } else {
RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO, media_type()); RTC_DCHECK_EQ(cricket::MEDIA_TYPE_VIDEO, media_type());
// TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to // TODO(bugs.webrtc.org/11992): CreateVideoChannel internally switches to
// the worker thread. We shouldn't be using the `call_ptr_` hack here but // 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). // simply be on the worker thread and use `call_` (update upstream code).
new_channel = context()->worker_thread()->BlockingCall([&] {
context() RTC_DCHECK_RUN_ON(context()->worker_thread());
->worker_thread() cricket::VideoMediaChannel* media_channel =
->Invoke<std::unique_ptr<cricket::VideoChannel>>( media_engine()->video().CreateMediaChannel(
RTC_FROM_HERE, [&]() -> std::unique_ptr<cricket::VideoChannel> { call_ptr, media_config, video_options, crypto_options,
RTC_DCHECK_RUN_ON(context()->worker_thread()); video_bitrate_allocator_factory);
cricket::VideoMediaChannel* media_channel = if (!media_channel) {
media_engine()->video().CreateMediaChannel( return;
call_ptr, media_config, video_options, crypto_options, }
video_bitrate_allocator_factory);
if (!media_channel) {
return nullptr;
}
auto video_channel = std::make_unique<cricket::VideoChannel>( new_channel = std::make_unique<cricket::VideoChannel>(
context()->worker_thread(), context()->network_thread(), context()->worker_thread(), context()->network_thread(),
context()->signaling_thread(), context()->signaling_thread(), absl::WrapUnique(media_channel), mid,
absl::WrapUnique(media_channel), mid, srtp_required, srtp_required, crypto_options, context()->ssrc_generator());
crypto_options, context()->ssrc_generator()); });
return video_channel;
});
} }
if (!new_channel) { if (!new_channel) {
// TODO(hta): Must be a better way // TODO(hta): Must be a better way
@ -274,7 +258,7 @@ void RtpTransceiver::SetChannel(
// Similarly, if the channel() accessor is limited to the network thread, that // Similarly, if the channel() accessor is limited to the network thread, that
// helps with keeping the channel implementation requirements being met and // helps with keeping the channel implementation requirements being met and
// avoids synchronization for accessing the pointer or network related state. // avoids synchronization for accessing the pointer or network related state.
context()->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { context()->network_thread()->BlockingCall([&]() {
if (channel_) { if (channel_) {
channel_->SetFirstPacketReceivedCallback(nullptr); channel_->SetFirstPacketReceivedCallback(nullptr);
channel_->SetRtpTransport(nullptr); channel_->SetRtpTransport(nullptr);
@ -310,7 +294,7 @@ void RtpTransceiver::ClearChannel() {
} }
std::unique_ptr<cricket::ChannelInterface> channel_to_delete; std::unique_ptr<cricket::ChannelInterface> channel_to_delete;
context()->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { context()->network_thread()->BlockingCall([&]() {
if (channel_) { if (channel_) {
channel_->SetFirstPacketReceivedCallback(nullptr); channel_->SetFirstPacketReceivedCallback(nullptr);
channel_->SetRtpTransport(nullptr); channel_->SetRtpTransport(nullptr);
@ -331,7 +315,7 @@ void RtpTransceiver::PushNewMediaChannelAndDeleteChannel(
if (!channel_to_delete && senders_.empty() && receivers_.empty()) { if (!channel_to_delete && senders_.empty() && receivers_.empty()) {
return; return;
} }
context()->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { context()->worker_thread()->BlockingCall([&]() {
// Push down the new media_channel, if any, otherwise clear it. // Push down the new media_channel, if any, otherwise clear it.
auto* media_channel = channel_ ? channel_->media_channel() : nullptr; auto* media_channel = channel_ ? channel_->media_channel() : nullptr;
for (const auto& sender : senders_) { for (const auto& sender : senders_) {
@ -399,7 +383,7 @@ bool RtpTransceiver::RemoveReceiver(RtpReceiverInterface* receiver) {
} }
(*it)->internal()->Stop(); (*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. // `Stop()` will clear the receiver's pointer to the media channel.
(*it)->internal()->SetMediaChannel(nullptr); (*it)->internal()->SetMediaChannel(nullptr);
}); });
@ -533,7 +517,7 @@ void RtpTransceiver::StopSendingAndReceiving() {
for (const auto& receiver : receivers_) for (const auto& receiver : receivers_)
receiver->internal()->Stop(); receiver->internal()->Stop();
context()->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { context()->worker_thread()->BlockingCall([&]() {
// 5 Stop receiving media with receiver. // 5 Stop receiving media with receiver.
for (const auto& receiver : receivers_) for (const auto& receiver : receivers_)
receiver->internal()->SetMediaChannel(nullptr); receiver->internal()->SetMediaChannel(nullptr);

View file

@ -20,7 +20,6 @@
#include "pc/proxy.h" #include "pc/proxy.h"
#include "pc/sctp_utils.h" #include "pc/sctp_utils.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/system/unused.h" #include "rtc_base/system/unused.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"

View file

@ -17,7 +17,6 @@
#include "api/dtls_transport_interface.h" #include "api/dtls_transport_interface.h"
#include "api/sequence_checker.h" #include "api/sequence_checker.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
namespace webrtc { namespace webrtc {
@ -50,8 +49,7 @@ SctpTransportInformation SctpTransport::Information() const {
// expected thread. Chromium currently calls this method from // expected thread. Chromium currently calls this method from
// TransceiverStateSurfacer. // TransceiverStateSurfacer.
if (!owner_thread_->IsCurrent()) { if (!owner_thread_->IsCurrent()) {
return owner_thread_->Invoke<SctpTransportInformation>( return owner_thread_->BlockingCall([this] { return Information(); });
RTC_FROM_HERE, [this] { return Information(); });
} }
RTC_DCHECK_RUN_ON(owner_thread_); RTC_DCHECK_RUN_ON(owner_thread_);
return info_; return info_;

View file

@ -55,7 +55,6 @@
#include "pc/usage_pattern.h" #include "pc/usage_pattern.h"
#include "pc/webrtc_session_description_factory.h" #include "pc/webrtc_session_description_factory.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/rtc_certificate.h" #include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/ssl_stream_adapter.h"
@ -691,13 +690,12 @@ rtc::scoped_refptr<webrtc::DtlsTransport> LookupDtlsTransportByMid(
JsepTransportController* controller, JsepTransportController* controller,
const std::string& mid) { const std::string& mid) {
// TODO(tommi): Can we post this (and associated operations where this // 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 // 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 network thread and then update the implementation to check that
// the set_ and relevant get methods are always called on the network // the set_ and relevant get methods are always called on the network
// thread (we'll need to update proxy maps). // thread (we'll need to update proxy maps).
return network_thread->Invoke<rtc::scoped_refptr<webrtc::DtlsTransport>>( return network_thread->BlockingCall(
RTC_FROM_HERE,
[controller, &mid] { return controller->LookupDtlsTransportByMid(mid); }); [controller, &mid] { return controller->LookupDtlsTransportByMid(mid); });
} }
@ -1813,7 +1811,7 @@ RTCError SdpOfferAnswerHandler::ReplaceRemoteDescription(
ReportSimulcastApiVersion(kSimulcastVersionApplyRemoteDescription, ReportSimulcastApiVersion(kSimulcastVersionApplyRemoteDescription,
*session_desc); *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); return transport_controller_s()->SetRemoteDescription(sdp_type, session_desc);
} }
@ -2200,8 +2198,8 @@ void SdpOfferAnswerHandler::DoSetLocalDescription(
// TODO(deadbeef): We already had to hop to the network thread for // TODO(deadbeef): We already had to hop to the network thread for
// MaybeStartGathering... // MaybeStartGathering...
context_->network_thread()->Invoke<void>( context_->network_thread()->BlockingCall(
RTC_FROM_HERE, [this] { port_allocator()->DiscardCandidatePool(); }); [this] { port_allocator()->DiscardCandidatePool(); });
// Make UMA notes about what was agreed to. // Make UMA notes about what was agreed to.
ReportNegotiatedSdpSemantics(*local_description()); ReportNegotiatedSdpSemantics(*local_description());
} }
@ -2404,8 +2402,8 @@ void SdpOfferAnswerHandler::SetRemoteDescriptionPostProcess(bool was_answer) {
if (was_answer) { if (was_answer) {
// TODO(deadbeef): We already had to hop to the network thread for // TODO(deadbeef): We already had to hop to the network thread for
// MaybeStartGathering... // MaybeStartGathering...
context_->network_thread()->Invoke<void>( context_->network_thread()->BlockingCall(
RTC_FROM_HERE, [this] { port_allocator()->DiscardCandidatePool(); }); [this] { port_allocator()->DiscardCandidatePool(); });
// Make UMA notes about what was agreed to. // Make UMA notes about what was agreed to.
ReportNegotiatedSdpSemantics(*remote_description()); ReportNegotiatedSdpSemantics(*remote_description());
} }
@ -3831,8 +3829,7 @@ void SdpOfferAnswerHandler::GetOptionsForOffer(
session_options->rtcp_cname = rtcp_cname_; session_options->rtcp_cname = rtcp_cname_;
session_options->crypto_options = pc_->GetCryptoOptions(); session_options->crypto_options = pc_->GetCryptoOptions();
session_options->pooled_ice_credentials = session_options->pooled_ice_credentials =
context_->network_thread()->Invoke<std::vector<cricket::IceParameters>>( context_->network_thread()->BlockingCall(
RTC_FROM_HERE,
[this] { return port_allocator()->GetPooledIceCredentials(); }); [this] { return port_allocator()->GetPooledIceCredentials(); });
session_options->offer_extmap_allow_mixed = session_options->offer_extmap_allow_mixed =
pc_->configuration()->offer_extmap_allow_mixed; pc_->configuration()->offer_extmap_allow_mixed;
@ -4095,8 +4092,7 @@ void SdpOfferAnswerHandler::GetOptionsForAnswer(
session_options->rtcp_cname = rtcp_cname_; session_options->rtcp_cname = rtcp_cname_;
session_options->crypto_options = pc_->GetCryptoOptions(); session_options->crypto_options = pc_->GetCryptoOptions();
session_options->pooled_ice_credentials = session_options->pooled_ice_credentials =
context_->network_thread()->Invoke<std::vector<cricket::IceParameters>>( context_->network_thread()->BlockingCall(
RTC_FROM_HERE,
[this] { return port_allocator()->GetPooledIceCredentials(); }); [this] { return port_allocator()->GetPooledIceCredentials(); });
} }
@ -4525,8 +4521,8 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription(
RTC_DCHECK(sdesc); RTC_DCHECK(sdesc);
if (ConfiguredForMedia()) { if (ConfiguredForMedia()) {
// Note: This will perform an Invoke over to the worker thread, which we'll // Note: This will perform a BlockingCall over to the worker thread, which
// also do in a loop below. // we'll also do in a loop below.
if (!UpdatePayloadTypeDemuxingState(source, bundle_groups_by_mid)) { if (!UpdatePayloadTypeDemuxingState(source, bundle_groups_by_mid)) {
// Note that this is never expected to fail, since RtpDemuxer doesn't // Note that this is never expected to fail, since RtpDemuxer doesn't
// return an error when changing payload type demux criteria, which is all // return an error when changing payload type demux criteria, which is all
@ -4570,7 +4566,7 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription(
for (const auto& entry : channels) { for (const auto& entry : channels) {
std::string error; std::string error;
bool success = bool success =
context_->worker_thread()->Invoke<bool>(RTC_FROM_HERE, [&]() { context_->worker_thread()->BlockingCall([&]() {
return (source == cricket::CS_LOCAL) return (source == cricket::CS_LOCAL)
? entry.first->SetLocalContent(entry.second, type, error) ? entry.first->SetLocalContent(entry.second, type, error)
: entry.first->SetRemoteContent(entry.second, type, : entry.first->SetRemoteContent(entry.second, type,
@ -4918,7 +4914,7 @@ RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) {
bool SdpOfferAnswerHandler::CreateDataChannel(const std::string& mid) { bool SdpOfferAnswerHandler::CreateDataChannel(const std::string& mid) {
RTC_DCHECK_RUN_ON(signaling_thread()); 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()); RTC_DCHECK_RUN_ON(context_->network_thread());
return pc_->SetupDataChannelTransport_n(mid); return pc_->SetupDataChannelTransport_n(mid);
})) { })) {
@ -4940,7 +4936,7 @@ void SdpOfferAnswerHandler::DestroyDataChannelTransport(RTCError error) {
if (has_sctp) if (has_sctp)
data_channel_controller()->OnTransportChannelClosed(error); 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()); RTC_DCHECK_RUN_ON(context_->network_thread());
pc_->TeardownDataChannelTransport_n(); pc_->TeardownDataChannelTransport_n();
}); });
@ -5174,7 +5170,7 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState(
pt_demuxing_has_been_used_video_; pt_demuxing_has_been_used_video_;
// Gather all updates ahead of time so that all channels can be updated in a // 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; std::vector<std::pair<bool, cricket::ChannelInterface*>> channels_to_update;
for (const auto& transceiver : transceivers()->ListInternal()) { for (const auto& transceiver : transceivers()->ListInternal()) {
cricket::ChannelInterface* channel = transceiver->channel(); cricket::ChannelInterface* channel = transceiver->channel();
@ -5226,22 +5222,21 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState(
return true; return true;
} }
// TODO(bugs.webrtc.org/11993): This Invoke() will also invoke on the network // TODO(bugs.webrtc.org/11993): This BlockingCall() will also block on the
// thread for every demuxer sink that needs to be updated. The demuxer state // network thread for every demuxer sink that needs to be updated. The demuxer
// needs to be fully (and only) managed on the network thread and once that's // state needs to be fully (and only) managed on the network thread and once
// the case, there's no need to stop by on the worker. Ideally we could also // that's the case, there's no need to stop by on the worker. Ideally we could
// do this without blocking. // also do this without blocking.
return context_->worker_thread()->Invoke<bool>( return context_->worker_thread()->BlockingCall([&channels_to_update]() {
RTC_FROM_HERE, [&channels_to_update]() { for (const auto& it : channels_to_update) {
for (const auto& it : channels_to_update) { if (!it.second->SetPayloadTypeDemuxingEnabled(it.first)) {
if (!it.second->SetPayloadTypeDemuxingEnabled(it.first)) { // Note that the state has already been irrevocably changed at this
// Note that the state has already been irrevocably changed at this // point. Is it useful to stop the loop?
// point. Is it useful to stop the loop? return false;
return false; }
} }
} return true;
return true; });
});
} }
bool SdpOfferAnswerHandler::ConfiguredForMedia() const { bool SdpOfferAnswerHandler::ConfiguredForMedia() const {

View file

@ -19,7 +19,6 @@
#include "api/video/recordable_encoded_frame.h" #include "api/video/recordable_encoded_frame.h"
#include "pc/video_track.h" #include "pc/video_track.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
namespace webrtc { namespace webrtc {
@ -117,7 +116,7 @@ void VideoRtpReceiver::RestartMediaChannel(absl::optional<uint32_t> ssrc) {
RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
MediaSourceInterface::SourceState state = source_->state(); MediaSourceInterface::SourceState state = source_->state();
// TODO(tommi): Can we restart the media channel without blocking? // 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_); RTC_DCHECK_RUN_ON(worker_thread_);
RestartMediaChannel_w(std::move(ssrc), state); RestartMediaChannel_w(std::move(ssrc), state);
}); });
@ -316,7 +315,7 @@ void VideoRtpReceiver::SetupMediaChannel(absl::optional<uint32_t> ssrc,
RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RTC_DCHECK_RUN_ON(&signaling_thread_checker_);
RTC_DCHECK(media_channel); RTC_DCHECK(media_channel);
MediaSourceInterface::SourceState state = source_->state(); MediaSourceInterface::SourceState state = source_->state();
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&] { worker_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
SetMediaChannel_w(media_channel); SetMediaChannel_w(media_channel);
RestartMediaChannel_w(std::move(ssrc), state); RestartMediaChannel_w(std::move(ssrc), state);

View file

@ -16,7 +16,6 @@
#include "api/notifier.h" #include "api/notifier.h"
#include "api/sequence_checker.h" #include "api/sequence_checker.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
namespace webrtc { namespace webrtc {
@ -95,7 +94,7 @@ bool VideoTrack::set_enabled(bool enable) {
bool ret = MediaStreamTrack<VideoTrackInterface>::set_enabled(enable); bool ret = MediaStreamTrack<VideoTrackInterface>::set_enabled(enable);
worker_thread_->Invoke<void>(RTC_FROM_HERE, [&]() { worker_thread_->BlockingCall([&]() {
RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK_RUN_ON(worker_thread_);
enabled_w_ = enable; enabled_w_ = enable;
for (auto& sink_pair : sink_pairs()) { for (auto& sink_pair : sink_pairs()) {

View file

@ -1492,7 +1492,6 @@ if (rtc_include_tests) {
":checks", ":checks",
":gunit_helpers", ":gunit_helpers",
":ip_address", ":ip_address",
":location",
":logging", ":logging",
":macromagic", ":macromagic",
":net_helpers", ":net_helpers",
@ -1581,7 +1580,6 @@ if (rtc_include_tests) {
":gunit_helpers", ":gunit_helpers",
":histogram_percentile_counter", ":histogram_percentile_counter",
":ip_address", ":ip_address",
":location",
":logging", ":logging",
":macromagic", ":macromagic",
":mod_ops", ":mod_ops",

View file

@ -17,7 +17,6 @@
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "rtc_base/ip_address.h" #include "rtc_base/ip_address.h"
#include "rtc_base/location.h"
#include "rtc_base/mdns_responder_interface.h" #include "rtc_base/mdns_responder_interface.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"

View file

@ -1253,7 +1253,7 @@ void BasicNetworkManager::set_vpn_list(const std::vector<NetworkMask>& vpn) {
if (thread_ == nullptr) { if (thread_ == nullptr) {
vpn_ = vpn; vpn_ = vpn;
} else { } else {
thread_->Invoke<void>(RTC_FROM_HERE, [this, vpn] { vpn_ = vpn; }); thread_->BlockingCall([this, vpn] { vpn_ = vpn; });
} }
} }

View file

@ -17,7 +17,6 @@
#include <utility> #include <utility>
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/message_handler.h" #include "rtc_base/message_handler.h"
#include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_identity.h"

View file

@ -23,7 +23,6 @@
#include "rtc_base/async_udp_socket.h" #include "rtc_base/async_udp_socket.h"
#include "rtc_base/buffer.h" #include "rtc_base/buffer.h"
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/net_helpers.h" #include "rtc_base/net_helpers.h"
#include "rtc_base/socket_address.h" #include "rtc_base/socket_address.h"
@ -730,7 +729,7 @@ void SocketTest::SocketServerWaitInternal(const IPAddress& loopback) {
// Shouldn't signal when blocked in a thread Send, where process_io is false. // Shouldn't signal when blocked in a thread Send, where process_io is false.
std::unique_ptr<Thread> thread(Thread::CreateWithSocketServer()); std::unique_ptr<Thread> thread(Thread::CreateWithSocketServer());
thread->Start(); thread->Start();
thread->Invoke<void>(RTC_FROM_HERE, [] { Thread::SleepMs(500); }); thread->BlockingCall([] { Thread::SleepMs(500); });
EXPECT_FALSE(sink.Check(accepted.get(), SSE_READ)); EXPECT_FALSE(sink.Check(accepted.get(), SSE_READ));
// But should signal when process_io is true. // But should signal when process_io is true.

View file

@ -16,7 +16,6 @@
#include <string> #include <string>
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
namespace rtc { namespace rtc {

View file

@ -86,7 +86,6 @@ if (rtc_include_tests) {
":yield", ":yield",
":yield_policy", ":yield_policy",
"..:checks", "..:checks",
"..:location",
"..:macromagic", "..:macromagic",
"..:platform_thread", "..:platform_thread",
"..:rtc_base", "..:rtc_base",

View file

@ -90,7 +90,6 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
// Returns non-owning pointer to the task queue implementation. // Returns non-owning pointer to the task queue implementation.
webrtc::TaskQueueBase* Get() { return impl_; } webrtc::TaskQueueBase* Get() { return impl_; }
// TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
void PostTask(absl::AnyInvocable<void() &&> task) { void PostTask(absl::AnyInvocable<void() &&> task) {
impl_->PostTask(std::move(task)); impl_->PostTask(std::move(task));
} }

View file

@ -349,7 +349,8 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
// Deprecated, use `BlockingCall` instead. // Deprecated, use `BlockingCall` instead.
template <typename ReturnT> 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); return BlockingCall(functor);
} }

View file

@ -16,7 +16,6 @@
#include "rtc_base/event.h" #include "rtc_base/event.h"
#include "rtc_base/fake_clock.h" #include "rtc_base/fake_clock.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
#include "rtc_base/location.h"
#include "rtc_base/message_handler.h" #include "rtc_base/message_handler.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gtest.h" #include "test/gtest.h"

View file

@ -38,7 +38,7 @@ TestController::TestController(int min_port,
send_data_.fill(42); send_data_.fill(42);
packet_sender_thread_->SetName("PacketSender", nullptr); packet_sender_thread_->SetName("PacketSender", nullptr);
packet_sender_thread_->Start(); packet_sender_thread_->Start();
packet_sender_thread_->Invoke<void>(RTC_FROM_HERE, [&] { packet_sender_thread_->BlockingCall([&] {
RTC_DCHECK_RUN_ON(packet_sender_thread_.get()); RTC_DCHECK_RUN_ON(packet_sender_thread_.get());
udp_socket_ = udp_socket_ =
std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket(
@ -49,8 +49,8 @@ TestController::TestController(int min_port,
TestController::~TestController() { TestController::~TestController() {
RTC_DCHECK_RUN_ON(&test_controller_thread_checker_); RTC_DCHECK_RUN_ON(&test_controller_thread_checker_);
packet_sender_thread_->Invoke<void>( packet_sender_thread_->BlockingCall(
RTC_FROM_HERE, [this]() { task_safety_flag_->SetNotAlive(); }); [this]() { task_safety_flag_->SetNotAlive(); });
} }
void TestController::SendConnectTo(const std::string& hostname, int port) { void TestController::SendConnectTo(const std::string& hostname, int port) {

View file

@ -516,7 +516,7 @@ static ScopedJavaLocalRef<jobject> JNI_PeerConnection_GetLocalDescription(
// must do this odd dance. // must do this odd dance.
std::string sdp; std::string sdp;
std::string type; 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(); const SessionDescriptionInterface* desc = pc->local_description();
if (desc) { if (desc) {
RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp; RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;
@ -535,7 +535,7 @@ static ScopedJavaLocalRef<jobject> JNI_PeerConnection_GetRemoteDescription(
// must do this odd dance. // must do this odd dance.
std::string sdp; std::string sdp;
std::string type; 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(); const SessionDescriptionInterface* desc = pc->remote_description();
if (desc) { if (desc) {
RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp; RTC_CHECK(desc->ToString(&sdp)) << "got so far: " << sdp;

View file

@ -36,16 +36,14 @@
- (NSArray<RTC_OBJC_TYPE(RTCAudioTrack) *> *)audioTracks { - (NSArray<RTC_OBJC_TYPE(RTCAudioTrack) *> *)audioTracks {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<NSArray<RTC_OBJC_TYPE(RTCAudioTrack) *> *>( return _signalingThread->BlockingCall([self]() { return self.audioTracks; });
RTC_FROM_HERE, [self]() { return self.audioTracks; });
} }
return [_audioTracks copy]; return [_audioTracks copy];
} }
- (NSArray<RTC_OBJC_TYPE(RTCVideoTrack) *> *)videoTracks { - (NSArray<RTC_OBJC_TYPE(RTCVideoTrack) *> *)videoTracks {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<NSArray<RTC_OBJC_TYPE(RTCVideoTrack) *> *>( return _signalingThread->BlockingCall([self]() { return self.videoTracks; });
RTC_FROM_HERE, [self]() { return self.videoTracks; });
} }
return [_videoTracks copy]; return [_videoTracks copy];
} }
@ -56,8 +54,8 @@
- (void)addAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack { - (void)addAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<void>( return _signalingThread->BlockingCall(
RTC_FROM_HERE, [audioTrack, self]() { return [self addAudioTrack:audioTrack]; }); [audioTrack, self]() { return [self addAudioTrack:audioTrack]; });
} }
if (_nativeMediaStream->AddTrack(audioTrack.nativeAudioTrack)) { if (_nativeMediaStream->AddTrack(audioTrack.nativeAudioTrack)) {
[_audioTracks addObject:audioTrack]; [_audioTracks addObject:audioTrack];
@ -66,8 +64,8 @@
- (void)addVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack { - (void)addVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<void>( return _signalingThread->BlockingCall(
RTC_FROM_HERE, [videoTrack, self]() { return [self addVideoTrack:videoTrack]; }); [videoTrack, self]() { return [self addVideoTrack:videoTrack]; });
} }
if (_nativeMediaStream->AddTrack(videoTrack.nativeVideoTrack)) { if (_nativeMediaStream->AddTrack(videoTrack.nativeVideoTrack)) {
[_videoTracks addObject:videoTrack]; [_videoTracks addObject:videoTrack];
@ -76,8 +74,8 @@
- (void)removeAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack { - (void)removeAudioTrack:(RTC_OBJC_TYPE(RTCAudioTrack) *)audioTrack {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<void>( return _signalingThread->BlockingCall(
RTC_FROM_HERE, [audioTrack, self]() { return [self removeAudioTrack:audioTrack]; }); [audioTrack, self]() { return [self removeAudioTrack:audioTrack]; });
} }
NSUInteger index = [_audioTracks indexOfObjectIdenticalTo:audioTrack]; NSUInteger index = [_audioTracks indexOfObjectIdenticalTo:audioTrack];
if (index == NSNotFound) { if (index == NSNotFound) {
@ -91,8 +89,8 @@
- (void)removeVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack { - (void)removeVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)videoTrack {
if (!_signalingThread->IsCurrent()) { if (!_signalingThread->IsCurrent()) {
return _signalingThread->Invoke<void>( return _signalingThread->BlockingCall(
RTC_FROM_HERE, [videoTrack, self]() { return [self removeVideoTrack:videoTrack]; }); [videoTrack, self]() { return [self removeVideoTrack:videoTrack]; });
} }
NSUInteger index = [_videoTracks indexOfObjectIdenticalTo:videoTrack]; NSUInteger index = [_videoTracks indexOfObjectIdenticalTo:videoTrack];
if (index == NSNotFound) { if (index == NSNotFound) {

View file

@ -392,26 +392,22 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
- (RTC_OBJC_TYPE(RTCSessionDescription) *)localDescription { - (RTC_OBJC_TYPE(RTCSessionDescription) *)localDescription {
// It's only safe to operate on SessionDescriptionInterface on the signaling thread. // It's only safe to operate on SessionDescriptionInterface on the signaling thread.
return _peerConnection->signaling_thread()->Invoke<RTC_OBJC_TYPE(RTCSessionDescription) *>( return _peerConnection->signaling_thread()->BlockingCall([self] {
RTC_FROM_HERE, [self] { const webrtc::SessionDescriptionInterface *description = _peerConnection->local_description();
const webrtc::SessionDescriptionInterface *description = return description ?
_peerConnection->local_description(); [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
return description ? nil;
[[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] : });
nil;
});
} }
- (RTC_OBJC_TYPE(RTCSessionDescription) *)remoteDescription { - (RTC_OBJC_TYPE(RTCSessionDescription) *)remoteDescription {
// It's only safe to operate on SessionDescriptionInterface on the signaling thread. // It's only safe to operate on SessionDescriptionInterface on the signaling thread.
return _peerConnection->signaling_thread()->Invoke<RTC_OBJC_TYPE(RTCSessionDescription) *>( return _peerConnection->signaling_thread()->BlockingCall([self] {
RTC_FROM_HERE, [self] { const webrtc::SessionDescriptionInterface *description = _peerConnection->remote_description();
const webrtc::SessionDescriptionInterface *description = return description ?
_peerConnection->remote_description(); [[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] :
return description ? nil;
[[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:description] : });
nil;
});
} }
- (RTCSignalingState)signalingState { - (RTCSignalingState)signalingState {

View file

@ -72,7 +72,7 @@
- (void)addRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer { - (void)addRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer {
if (!_workerThread->IsCurrent()) { if (!_workerThread->IsCurrent()) {
_workerThread->Invoke<void>(RTC_FROM_HERE, [renderer, self] { [self addRenderer:renderer]; }); _workerThread->BlockingCall([renderer, self] { [self addRenderer:renderer]; });
return; return;
} }
@ -93,8 +93,7 @@
- (void)removeRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer { - (void)removeRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)renderer {
if (!_workerThread->IsCurrent()) { if (!_workerThread->IsCurrent()) {
_workerThread->Invoke<void>(RTC_FROM_HERE, _workerThread->BlockingCall([renderer, self] { [self removeRenderer:renderer]; });
[renderer, self] { [self removeRenderer:renderer]; });
return; return;
} }
__block NSUInteger indexToRemove = NSNotFound; __block NSUInteger indexToRemove = NSNotFound;

View file

@ -178,7 +178,7 @@ class AudioDeviceDelegateImpl final : public rtc::RefCountedNonVirtual<AudioDevi
block(); block();
} }
} else { } else {
thread->Invoke<void>(RTC_FROM_HERE, [block] { thread->BlockingCall([block] {
@autoreleasepool { @autoreleasepool {
block(); block();
} }

View file

@ -60,7 +60,6 @@ if (rtc_include_tests) {
"../../api:time_controller", "../../api:time_controller",
"../../api/units:time_delta", "../../api/units:time_delta",
"../../rtc_base", "../../rtc_base",
"../../rtc_base:location",
"../../rtc_base:macromagic", "../../rtc_base:macromagic",
"../../rtc_base:rtc_event", "../../rtc_base:rtc_event",
"../../rtc_base:rtc_task_queue", "../../rtc_base:rtc_task_queue",

View file

@ -14,7 +14,6 @@
#include "api/test/time_controller.h" #include "api/test/time_controller.h"
#include "api/units/time_delta.h" #include "api/units/time_delta.h"
#include "rtc_base/event.h" #include "rtc_base/event.h"
#include "rtc_base/location.h"
#include "rtc_base/synchronization/mutex.h" #include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
@ -121,7 +120,7 @@ TEST_P(SimulatedRealTimeControllerConformanceTest, ThreadPostInvokeOrderTest) {
// posted/invoked. // posted/invoked.
ExecutionOrderKeeper execution_order; ExecutionOrderKeeper execution_order;
thread->PostTask([&]() { execution_order.Executed(1); }); 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)); time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2})); EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));
// Destroy `thread` before `execution_order` to be sure `execution_order` // Destroy `thread` before `execution_order` to be sure `execution_order`
@ -140,7 +139,7 @@ TEST_P(SimulatedRealTimeControllerConformanceTest,
ExecutionOrderKeeper execution_order; ExecutionOrderKeeper execution_order;
thread->PostTask([&]() { thread->PostTask([&]() {
thread->PostTask([&]() { execution_order.Executed(2); }); 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)); time_controller->AdvanceTime(TimeDelta::Millis(100));
EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2})); EXPECT_THAT(execution_order.order(), ElementsAreArray({1, 2}));

View file

@ -106,7 +106,6 @@ rtc_library("video") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:histogram_percentile_counter", "../rtc_base:histogram_percentile_counter",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:mod_ops", "../rtc_base:mod_ops",
@ -405,7 +404,6 @@ rtc_library("video_stream_encoder_impl") {
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:criticalsection", "../rtc_base:criticalsection",
"../rtc_base:event_tracer", "../rtc_base:event_tracer",
"../rtc_base:location",
"../rtc_base:logging", "../rtc_base:logging",
"../rtc_base:macromagic", "../rtc_base:macromagic",
"../rtc_base:race_checker", "../rtc_base:race_checker",

View file

@ -16,7 +16,6 @@
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
namespace webrtc { namespace webrtc {

View file

@ -594,7 +594,7 @@ VideoReceiveStreamInterface::Stats ReceiveStatisticsProxy::GetStats() const {
RTC_DCHECK_RUN_ON(&main_thread_); RTC_DCHECK_RUN_ON(&main_thread_);
// Like VideoReceiveStreamInterface::GetStats, called on the worker 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. // WebRtcVideoChannel::GetStats(), GetVideoReceiverInfo.
// Get current frame rates here, as only updating them on new frames prevents // Get current frame rates here, as only updating them on new frames prevents

View file

@ -42,7 +42,6 @@
#include "modules/video_coding/nack_requester.h" #include "modules/video_coding/nack_requester.h"
#include "modules/video_coding/packet_buffer.h" #include "modules/video_coding/packet_buffer.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"

View file

@ -42,7 +42,6 @@
#include "rtc_base/experiments/alr_experiment.h" #include "rtc_base/experiments/alr_experiment.h"
#include "rtc_base/experiments/encoder_info_settings.h" #include "rtc_base/experiments/encoder_info_settings.h"
#include "rtc_base/experiments/rate_control_settings.h" #include "rtc_base/experiments/rate_control_settings.h"
#include "rtc_base/location.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/no_unique_address.h" #include "rtc_base/system/no_unique_address.h"