Add factory function for legacy VideoCoding that takes Environment

That forces external field trials, thus VideoCoding will be able to remove dependency on the global field trials string through FieldTrialBasedConfig class.

Bug: webrtc:10335
Change-Id: I6d22a7d20a4433801a0086b0863cda78e91f4f60
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/347646
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42092}
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index 69cca17..15face2 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -333,6 +333,7 @@
     "../../api:rtp_headers",
     "../../api:rtp_packet_info",
     "../../api:sequence_checker",
+    "../../api/environment",
     "../../api/transport:field_trial_based_config",
     "../../api/units:timestamp",
     "../../api/video:encoded_image",
diff --git a/modules/video_coding/include/video_coding.h b/modules/video_coding/include/video_coding.h
index ee9326d..ad0f591 100644
--- a/modules/video_coding/include/video_coding.h
+++ b/modules/video_coding/include/video_coding.h
@@ -11,6 +11,9 @@
 #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
 #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
 
+#include <memory>
+
+#include "api/environment/environment.h"
 #include "api/field_trials_view.h"
 #include "api/video/video_frame.h"
 #include "api/video_codecs/video_decoder.h"
@@ -27,10 +30,11 @@
 
 class VideoCodingModule {
  public:
-  // DEPRECATED.
-  static VideoCodingModule* Create(
+  [[deprecated]] static VideoCodingModule* Create(
       Clock* clock,
       const FieldTrialsView* field_trials = nullptr);
+  [[deprecated]] static std::unique_ptr<VideoCodingModule> CreateDeprecated(
+      const Environment& env);
 
   virtual ~VideoCodingModule() = default;
 
diff --git a/modules/video_coding/video_coding_impl.cc b/modules/video_coding/video_coding_impl.cc
index 2eaecd5..888ea60 100644
--- a/modules/video_coding/video_coding_impl.cc
+++ b/modules/video_coding/video_coding_impl.cc
@@ -251,4 +251,10 @@
   return new VideoCodingModuleImpl(clock, field_trials);
 }
 
+std::unique_ptr<VideoCodingModule> VideoCodingModule::CreateDeprecated(
+    const Environment& env) {
+  return std::make_unique<VideoCodingModuleImpl>(&env.clock(),
+                                                 &env.field_trials());
+}
+
 }  // namespace webrtc