Bug 1806510 - Vendor libwebrtc from 9e09a1f327

Upstream commit: https://webrtc.googlesource.com/src/+/9e09a1f327018143723c330069b51b16613a6f11
    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:
Dan Baker 2023-01-09 15:09:08 -07:00
Родитель 0873e6093b
Коммит 93855f65c8
56 изменённых файлов: 214 добавлений и 320 удалений

3
third_party/libwebrtc/README.moz-ff-commit поставляемый
Просмотреть файл

@ -17694,3 +17694,6 @@ c1e7080e51
# MOZ_LIBWEBRTC_SRC=/Users/danielbaker/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
b190ca9e70
# MOZ_LIBWEBRTC_SRC=/Users/danielbaker/moz-libwebrtc MOZ_LIBWEBRTC_COMMIT=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
# base of lastest vendoring
9e09a1f327

2
third_party/libwebrtc/README.mozilla поставляемый
Просмотреть файл

@ -11818,3 +11818,5 @@ libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 202
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T22:06:18.262167.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T22:07:22.257515.
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/moz-libwebrtc --commit mozpatches libwebrtc
libwebrtc updated from /Users/danielbaker/moz-libwebrtc commit mozpatches on 2023-01-09T22:09:01.481248.

1
third_party/libwebrtc/audio/voip/BUILD.gn поставляемый
Просмотреть файл

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

Просмотреть файл

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

2
third_party/libwebrtc/call/BUILD.gn поставляемый
Просмотреть файл

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

1
third_party/libwebrtc/call/call.cc поставляемый
Просмотреть файл

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

1
third_party/libwebrtc/call/degraded_call.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

16
third_party/libwebrtc/pc/BUILD.gn поставляемый
Просмотреть файл

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

Просмотреть файл

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

11
third_party/libwebrtc/pc/channel.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

7
third_party/libwebrtc/pc/dtmf_sender.cc поставляемый
Просмотреть файл

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

4
third_party/libwebrtc/pc/dtmf_sender.h поставляемый
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

89
third_party/libwebrtc/pc/peer_connection.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

40
third_party/libwebrtc/pc/rtp_sender.cc поставляемый
Просмотреть файл

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

80
third_party/libwebrtc/pc/rtp_transceiver.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

4
third_party/libwebrtc/pc/sctp_transport.cc поставляемый
Просмотреть файл

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

65
third_party/libwebrtc/pc/sdp_offer_answer.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

3
third_party/libwebrtc/pc/video_track.cc поставляемый
Просмотреть файл

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

2
third_party/libwebrtc/rtc_base/BUILD.gn поставляемый
Просмотреть файл

@ -1558,7 +1558,6 @@ if (rtc_include_tests) {
":checks",
":gunit_helpers",
":ip_address",
":location",
":logging",
":macromagic",
":net_helpers",
@ -1647,7 +1646,6 @@ if (rtc_include_tests) {
":gunit_helpers",
":histogram_percentile_counter",
":ip_address",
":location",
":logging",
":macromagic",
":mod_ops",

Просмотреть файл

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

2
third_party/libwebrtc/rtc_base/network.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

1
third_party/libwebrtc/rtc_base/stream.cc поставляемый
Просмотреть файл

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

Просмотреть файл

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

1
third_party/libwebrtc/rtc_base/task_queue.h поставляемый
Просмотреть файл

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

3
third_party/libwebrtc/rtc_base/thread.h поставляемый
Просмотреть файл

@ -349,7 +349,8 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
// Deprecated, use `BlockingCall` instead.
template <typename ReturnT>
ReturnT Invoke(const Location& posted_from, FunctionView<ReturnT()> functor) {
[[deprecated]] ReturnT Invoke(const Location& /*posted_from*/,
FunctionView<ReturnT()> functor) {
return BlockingCall(functor);
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

2
third_party/libwebrtc/video/BUILD.gn поставляемый
Просмотреть файл

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

1
third_party/libwebrtc/video/call_stats2.cc поставляемый
Просмотреть файл

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

Просмотреть файл

@ -595,7 +595,7 @@ VideoReceiveStreamInterface::Stats ReceiveStatisticsProxy::GetStats() const {
RTC_DCHECK_RUN_ON(&main_thread_);
// Like VideoReceiveStreamInterface::GetStats, called on the worker thread
// from StatsCollector::ExtractMediaInfo via worker_thread()->Invoke().
// from StatsCollector::ExtractMediaInfo via worker_thread()->BlockingCall().
// WebRtcVideoChannel::GetStats(), GetVideoReceiverInfo.
// Get current frame rates here, as only updating them on new frames prevents

Просмотреть файл

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

Просмотреть файл

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