Stop using GlobalTaskQueueFactory in video unittests

instead use DefaultTaskQueueFactory directly

Bug: webrtc:10284
Change-Id: I58ae120cf185553d0145d7feb365deca90a93bc5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132401
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27610}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 5dc9670..b647472 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -369,7 +369,7 @@
       "../api:rtp_headers",
       "../api:transport_api",
       "../api/audio_codecs:builtin_audio_decoder_factory",
-      "../api/task_queue:global_task_queue_factory",
+      "../api/task_queue:default_task_queue_factory",
       "../api/video:video_frame",
       "../audio",
       "../logging:rtc_event_log_api",
diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc
index 0b0b3fe..9416173 100644
--- a/call/rtp_video_sender_unittest.cc
+++ b/call/rtp_video_sender_unittest.cc
@@ -12,7 +12,7 @@
 #include <string>
 
 #include "absl/memory/memory.h"
-#include "api/task_queue/global_task_queue_factory.h"
+#include "api/task_queue/default_task_queue_factory.h"
 #include "call/rtp_transport_controller_send.h"
 #include "call/rtp_video_sender.h"
 #include "modules/video_coding/fec_controller_default.h"
@@ -80,13 +80,14 @@
       : clock_(1000000),
         config_(&transport_),
         send_delay_stats_(&clock_),
+        task_queue_factory_(CreateDefaultTaskQueueFactory()),
         transport_controller_(&clock_,
                               &event_log_,
                               nullptr,
                               nullptr,
                               bitrate_config_,
                               ProcessThread::Create("PacerThread"),
-                              &GlobalTaskQueueFactory()),
+                              task_queue_factory_.get()),
         process_thread_(ProcessThread::Create("test_thread")),
         call_stats_(&clock_, process_thread_.get()),
         stats_proxy_(&clock_,
@@ -127,6 +128,7 @@
   VideoSendStream::Config config_;
   SendDelayStats send_delay_stats_;
   BitrateConstraints bitrate_config_;
+  const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
   RtpTransportControllerSend transport_controller_;
   std::unique_ptr<ProcessThread> process_thread_;
   CallStats call_stats_;
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 907a96d..584a9e7 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -517,7 +517,6 @@
       "../api:scoped_refptr",
       "../api:simulated_network_api",
       "../api/task_queue:default_task_queue_factory",
-      "../api/task_queue:global_task_queue_factory",
       "../api/test/video:function_video_factory",
       "../api/units:data_rate",
       "../api/video:builtin_video_bitrate_allocator_factory",
diff --git a/video/video_receive_stream_unittest.cc b/video/video_receive_stream_unittest.cc
index ad5d477..2d29ef7 100644
--- a/video/video_receive_stream_unittest.cc
+++ b/video/video_receive_stream_unittest.cc
@@ -14,7 +14,7 @@
 #include "test/gmock.h"
 #include "test/gtest.h"
 
-#include "api/task_queue/global_task_queue_factory.h"
+#include "api/task_queue/default_task_queue_factory.h"
 #include "api/video_codecs/video_decoder.h"
 #include "call/rtp_stream_receiver_controller.h"
 #include "media/base/fake_video_renderer.h"
@@ -73,6 +73,7 @@
  public:
   VideoReceiveStreamTest()
       : process_thread_(ProcessThread::Create("TestThread")),
+        task_queue_factory_(CreateDefaultTaskQueueFactory()),
         config_(&mock_transport_),
         call_stats_(Clock::GetRealTimeClock(), process_thread_.get()),
         h264_decoder_factory_(&mock_h264_video_decoder_),
@@ -100,13 +101,14 @@
     timing_ = new VCMTiming(clock);
 
     video_receive_stream_.reset(new webrtc::internal::VideoReceiveStream(
-        &GlobalTaskQueueFactory(), &rtp_stream_receiver_controller_,
+        task_queue_factory_.get(), &rtp_stream_receiver_controller_,
         kDefaultNumCpuCores, &packet_router_, config_.Copy(),
         process_thread_.get(), &call_stats_, clock, timing_));
   }
 
  protected:
   std::unique_ptr<ProcessThread> process_thread_;
+  const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
   VideoReceiveStream::Config config_;
   CallStats call_stats_;
   MockVideoDecoder mock_h264_video_decoder_;
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 23480e7..3242064 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -12,9 +12,10 @@
 
 #include <algorithm>
 #include <limits>
+#include <memory>
 #include <utility>
 
-#include "api/task_queue/global_task_queue_factory.h"
+#include "api/task_queue/default_task_queue_factory.h"
 #include "api/video/builtin_video_bitrate_allocator_factory.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_bitrate_allocation.h"
@@ -99,7 +100,8 @@
 class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
  public:
   VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy,
-                              const VideoStreamEncoderSettings& settings)
+                              const VideoStreamEncoderSettings& settings,
+                              TaskQueueFactory* task_queue_factory)
       : VideoStreamEncoder(Clock::GetRealTimeClock(),
                            1 /* number_of_cores */,
                            stats_proxy,
@@ -107,7 +109,7 @@
                            std::unique_ptr<OveruseFrameDetector>(
                                overuse_detector_proxy_ =
                                    new CpuOveruseDetectorProxy(stats_proxy)),
-                           &GlobalTaskQueueFactory()) {}
+                           task_queue_factory) {}
 
   void PostTaskAndWait(bool down, AdaptReason reason) {
     rtc::Event event;
@@ -288,6 +290,7 @@
         codec_width_(320),
         codec_height_(240),
         max_framerate_(kDefaultFramerate),
+        task_queue_factory_(CreateDefaultTaskQueueFactory()),
         fake_encoder_(),
         encoder_factory_(&fake_encoder_),
         bitrate_allocator_factory_(CreateBuiltinVideoBitrateAllocatorFactory()),
@@ -326,7 +329,8 @@
     if (video_stream_encoder_)
       video_stream_encoder_->Stop();
     video_stream_encoder_.reset(new VideoStreamEncoderUnderTest(
-        stats_proxy_.get(), video_send_config_.encoder_settings));
+        stats_proxy_.get(), video_send_config_.encoder_settings,
+        task_queue_factory_.get()));
     video_stream_encoder_->SetSink(&sink_, false /* rotation_applied */);
     video_stream_encoder_->SetSource(
         &video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
@@ -902,6 +906,7 @@
   int codec_width_;
   int codec_height_;
   int max_framerate_;
+  const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
   TestEncoder fake_encoder_;
   test::VideoEncoderProxyFactory encoder_factory_;
   std::unique_ptr<VideoBitrateAllocatorFactory> bitrate_allocator_factory_;