diff --git a/call/call.cc b/call/call.cc index dd2a1261fd..f20f4b5c41 100644 --- a/call/call.cc +++ b/call/call.cc @@ -325,7 +325,7 @@ class Call final : public webrtc::Call, Clock* const clock_; TaskQueueFactory* const task_queue_factory_; TaskQueueBase* const worker_thread_; - RTC_NO_UNIQUE_ADDRESS SequenceChecker network_thread_; + TaskQueueBase* const network_thread_; const int num_cpu_cores_; const rtc::scoped_refptr module_process_thread_; @@ -602,6 +602,10 @@ Call::Call(Clock* clock, : clock_(clock), task_queue_factory_(task_queue_factory), worker_thread_(GetCurrentTaskQueueOrThread()), + // If |network_task_queue_| was set to nullptr, network related calls + // must be made on |worker_thread_| (i.e. they're one and the same). + network_thread_(config.network_task_queue_ ? config.network_task_queue_ + : worker_thread_), num_cpu_cores_(CpuInfo::DetectNumberOfCores()), module_process_thread_(std::move(module_process_thread)), call_stats_(new CallStats(clock_, worker_thread_)), @@ -628,10 +632,9 @@ Call::Call(Clock* clock, transport_send_(std::move(transport_send)) { RTC_DCHECK(config.event_log != nullptr); RTC_DCHECK(config.trials != nullptr); + RTC_DCHECK(network_thread_); RTC_DCHECK(worker_thread_->IsCurrent()); - network_thread_.Detach(); - // Do not remove this call; it is here to convince the compiler that the // WebRTC source timestamp string needs to be in the final binary. LoadWebRTCVersionInRegister(); @@ -768,7 +771,6 @@ void Call::UpdateReceiveHistograms() { } PacketReceiver* Call::Receiver() { - RTC_DCHECK_RUN_ON(worker_thread_); return this; } @@ -1429,7 +1431,7 @@ void Call::DeliverPacketAsync(MediaType media_type, rtc::CopyOnWriteBuffer packet, int64_t packet_time_us, PacketCallback callback) { - RTC_DCHECK_RUN_ON(&network_thread_); + RTC_DCHECK_RUN_ON(network_thread_); TaskQueueBase* network_thread = rtc::Thread::Current(); RTC_DCHECK(network_thread); diff --git a/call/call_config.cc b/call/call_config.cc index b149c889ea..8b3c91222e 100644 --- a/call/call_config.cc +++ b/call/call_config.cc @@ -14,7 +14,9 @@ namespace webrtc { -CallConfig::CallConfig(RtcEventLog* event_log) : event_log(event_log) { +CallConfig::CallConfig(RtcEventLog* event_log, + TaskQueueBase* network_task_queue /* = nullptr*/) + : event_log(event_log), network_task_queue_(network_task_queue) { RTC_DCHECK(event_log); } diff --git a/call/call_config.h b/call/call_config.h index 205f7a48bb..95dad36002 100644 --- a/call/call_config.h +++ b/call/call_config.h @@ -26,7 +26,11 @@ class AudioProcessing; class RtcEventLog; struct CallConfig { - explicit CallConfig(RtcEventLog* event_log); + // If |network_task_queue| is set to nullptr, Call will assume that network + // related callbacks will be made on the same TQ as the Call instance was + // constructed on. + explicit CallConfig(RtcEventLog* event_log, + TaskQueueBase* network_task_queue = nullptr); CallConfig(const CallConfig&); ~CallConfig(); @@ -42,7 +46,7 @@ struct CallConfig { // RtcEventLog to use for this call. Required. // Use webrtc::RtcEventLog::CreateNull() for a null implementation. - RtcEventLog* event_log = nullptr; + RtcEventLog* const event_log = nullptr; // FecController to use for this call. FecControllerFactoryInterface* fec_controller_factory = nullptr; @@ -63,6 +67,8 @@ struct CallConfig { // Key-value mapping of internal configurations to apply, // e.g. field trials. const WebRtcKeyValueConfig* trials = nullptr; + + TaskQueueBase* const network_task_queue_ = nullptr; }; } // namespace webrtc diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index 0048992e6b..c65b2f5fca 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -313,7 +313,7 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( RtcEventLog* event_log) { RTC_DCHECK_RUN_ON(worker_thread()); - webrtc::Call::Config call_config(event_log); + webrtc::Call::Config call_config(event_log, network_thread()); if (!channel_manager()->media_engine() || !context_->call_factory()) { return nullptr; }