Expose TaskQueueFactory for webrtc::Call in peer connection api

making a step for GlobalTaskQueueFactory to be optional way
to provide TaskQueueFactory

Bug: webrtc:10284
Change-Id: Ife838b3691c256820973118bc5b3cb372dea09cf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130488
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27423}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 1a193d9..0d26945 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -144,6 +144,7 @@
     ":scoped_refptr",
     "audio:audio_mixer_api",
     "audio_codecs:audio_codecs_api",
+    "task_queue",
     "transport:bitrate_settings",
     "transport:network_control",
     "transport/media:audio_interfaces",
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index b925fe8..661c5aa 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -91,6 +91,7 @@
 #include "api/set_remote_description_observer_interface.h"
 #include "api/stats/rtc_stats_collector_callback.h"
 #include "api/stats_types.h"
+#include "api/task_queue/task_queue_factory.h"
 #include "api/transport/bitrate_settings.h"
 #include "api/transport/network_control.h"
 #include "api/turn_customizer.h"
@@ -1242,6 +1243,7 @@
   rtc::Thread* network_thread = nullptr;
   rtc::Thread* worker_thread = nullptr;
   rtc::Thread* signaling_thread = nullptr;
+  std::unique_ptr<TaskQueueFactory> task_queue_factory;
   std::unique_ptr<cricket::MediaEngineInterface> media_engine;
   std::unique_ptr<CallFactoryInterface> call_factory;
   std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory;
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 1df3f63..1089621 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -198,6 +198,7 @@
     "../api:libjingle_peerconnection_api",
     "../api:rtc_stats_api",
     "../api:scoped_refptr",
+    "../api/task_queue",
     "../api/video:video_frame",
     "../api/video_codecs:video_codecs_api",
     "../call:call_interfaces",
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index 4c89120..dd403ed 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -106,6 +106,7 @@
       network_thread_(dependencies.network_thread),
       worker_thread_(dependencies.worker_thread),
       signaling_thread_(dependencies.signaling_thread),
+      task_queue_factory_(std::move(dependencies.task_queue_factory)),
       media_engine_(std::move(dependencies.media_engine)),
       call_factory_(std::move(dependencies.call_factory)),
       event_log_factory_(std::move(dependencies.event_log_factory)),
@@ -386,6 +387,7 @@
   call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
 
   call_config.fec_controller_factory = fec_controller_factory_.get();
+  call_config.task_queue_factory = task_queue_factory_.get();
 
   if (field_trial::IsEnabled("WebRTC-Bwe-InjectedCongestionController")) {
     RTC_LOG(LS_INFO) << "Using injected network controller factory";
diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h
index 0ea309b..fd9db27 100644
--- a/pc/peer_connection_factory.h
+++ b/pc/peer_connection_factory.h
@@ -113,6 +113,7 @@
   rtc::Thread* signaling_thread_;
   std::unique_ptr<rtc::Thread> owned_network_thread_;
   std::unique_ptr<rtc::Thread> owned_worker_thread_;
+  const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
   Options options_;
   std::unique_ptr<cricket::ChannelManager> channel_manager_;
   std::unique_ptr<rtc::BasicNetworkManager> default_network_manager_;