Provide Environment when creating VideoEncoder in test code

Bug: webrtc:15860
Change-Id: I8c79ff58619716842e02f33e78a0529c631494e6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342280
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41884}
diff --git a/video/end_to_end_tests/multi_codec_receive_tests.cc b/video/end_to_end_tests/multi_codec_receive_tests.cc
index 56fce60..4027b60 100644
--- a/video/end_to_end_tests/multi_codec_receive_tests.cc
+++ b/video/end_to_end_tests/multi_codec_receive_tests.cc
@@ -199,7 +199,8 @@
   EXPECT_TRUE(!configs.empty());
 
   test::FunctionVideoEncoderFactory encoder_factory(
-      [](const SdpVideoFormat& format) -> std::unique_ptr<VideoEncoder> {
+      [](const Environment& env,
+         const SdpVideoFormat& format) -> std::unique_ptr<VideoEncoder> {
         if (format.name == "VP8") {
           return VP8Encoder::Create();
         }
diff --git a/video/quality_scaling_tests.cc b/video/quality_scaling_tests.cc
index edd186d..26ef919 100644
--- a/video/quality_scaling_tests.cc
+++ b/video/quality_scaling_tests.cc
@@ -87,7 +87,8 @@
                   bool expect_scaling)
       : SendTest(expect_scaling ? kTimeout * 4 : kTimeout),
         encoder_factory_(
-            [](const SdpVideoFormat& format) -> std::unique_ptr<VideoEncoder> {
+            [](const Environment& env,
+               const SdpVideoFormat& format) -> std::unique_ptr<VideoEncoder> {
               if (format.name == "VP8")
                 return VP8Encoder::Create();
               if (format.name == "VP9")
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index 4e17b4e..551cd34 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -312,6 +312,7 @@
 }
 
 std::unique_ptr<VideoEncoder> VideoQualityTest::CreateVideoEncoder(
+    const Environment& env,
     const SdpVideoFormat& format,
     VideoAnalyzer* analyzer) {
   std::unique_ptr<VideoEncoder> encoder;
@@ -321,7 +322,7 @@
   } else if (format.name == "FakeCodec") {
     encoder = webrtc::FakeVideoEncoderFactory::CreateVideoEncoder();
   } else {
-    encoder = encoder_factory_->CreateVideoEncoder(format);
+    encoder = encoder_factory_->Create(env, format);
   }
 
   std::vector<FileWrapper> encoded_frame_dump_files;
@@ -372,12 +373,13 @@
           [this](const Environment& env, const SdpVideoFormat& format) {
             return this->CreateVideoDecoder(env, format);
           }),
-      video_encoder_factory_([this](const SdpVideoFormat& format) {
-        return this->CreateVideoEncoder(format, nullptr);
-      }),
+      video_encoder_factory_(
+          [this](const Environment& env, const SdpVideoFormat& format) {
+            return this->CreateVideoEncoder(env, format, nullptr);
+          }),
       video_encoder_factory_with_analyzer_(
-          [this](const SdpVideoFormat& format) {
-            return this->CreateVideoEncoder(format, analyzer_.get());
+          [this](const Environment& env, const SdpVideoFormat& format) {
+            return this->CreateVideoEncoder(env, format, analyzer_.get());
           }),
       video_bitrate_allocator_factory_(
           CreateBuiltinVideoBitrateAllocatorFactory()),
diff --git a/video/video_quality_test.h b/video/video_quality_test.h
index c5e63dd..508a7ac 100644
--- a/video/video_quality_test.h
+++ b/video/video_quality_test.h
@@ -82,7 +82,8 @@
   std::unique_ptr<VideoDecoder> CreateVideoDecoder(
       const Environment& env,
       const SdpVideoFormat& format);
-  std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
+  std::unique_ptr<VideoEncoder> CreateVideoEncoder(const Environment& env,
+                                                   const SdpVideoFormat& format,
                                                    VideoAnalyzer* analyzer);
   void SetupVideo(Transport* send_transport, Transport* recv_transport);
   void SetupThumbnails(Transport* send_transport, Transport* recv_transport);