Deprecate VP8Decoder::Create

Migrate remaining usages inside webrtc (all are test only) to CreateVp8Decoder

Bug: webrtc:15791
Change-Id: I6a8317a8761953208ba746ac785fa1606217e6f5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340300
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41792}
diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc
index 3ee3465..4abda03 100644
--- a/media/engine/simulcast_encoder_adapter_unittest.cc
+++ b/media/engine/simulcast_encoder_adapter_unittest.cc
@@ -14,6 +14,7 @@
 #include <memory>
 #include <vector>
 
+#include "api/environment/environment.h"
 #include "api/field_trials_view.h"
 #include "api/test/create_simulcast_test_fixture.h"
 #include "api/test/simulcast_test_fixture.h"
@@ -62,7 +63,9 @@
           });
   std::unique_ptr<VideoDecoderFactory> decoder_factory =
       std::make_unique<FunctionVideoDecoderFactory>(
-          []() { return VP8Decoder::Create(); });
+          [](const Environment& env, const SdpVideoFormat& format) {
+            return CreateVp8Decoder(env);
+          });
   return CreateSimulcastTestFixture(std::move(encoder_factory),
                                     std::move(decoder_factory),
                                     SdpVideoFormat(cricket::kVp8CodecName));
diff --git a/modules/video_coding/codecs/vp8/include/vp8.h b/modules/video_coding/codecs/vp8/include/vp8.h
index 45b7cee..b03200a 100644
--- a/modules/video_coding/codecs/vp8/include/vp8.h
+++ b/modules/video_coding/codecs/vp8/include/vp8.h
@@ -41,11 +41,10 @@
   static std::unique_ptr<VideoEncoder> Create(Settings settings);
 };
 
-// TODO: bugs.webrtc.org/15791 - Deprecate and delete in favor of the
-// CreateVp8Decoder function.
+// TODO: bugs.webrtc.org/15791 - Delete in favor of the CreateVp8Decoder below.
 class VP8Decoder {
  public:
-  static std::unique_ptr<VideoDecoder> Create();
+  [[deprecated]] static std::unique_ptr<VideoDecoder> Create();
 };
 
 std::unique_ptr<VideoDecoder> CreateVp8Decoder(const Environment& env);
diff --git a/test/BUILD.gn b/test/BUILD.gn
index ed5dc51..d9f2b92 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -53,6 +53,7 @@
     "../api:frame_generator_api",
     "../api:scoped_refptr",
     "../api:sequence_checker",
+    "../api/environment:environment_factory",
     "../api/video:encoded_image",
     "../api/video:video_frame",
     "../api/video:video_frame_i010",
diff --git a/test/testsupport/ivf_video_frame_generator.cc b/test/testsupport/ivf_video_frame_generator.cc
index 0dec113..d2ce215 100644
--- a/test/testsupport/ivf_video_frame_generator.cc
+++ b/test/testsupport/ivf_video_frame_generator.cc
@@ -12,6 +12,7 @@
 
 #include <limits>
 
+#include "api/environment/environment_factory.h"
 #include "api/video/encoded_image.h"
 #include "api/video/i420_buffer.h"
 #include "api/video_codecs/video_codec.h"
@@ -137,7 +138,9 @@
 std::unique_ptr<VideoDecoder> IvfVideoFrameGenerator::CreateVideoDecoder(
     VideoCodecType codec_type) {
   if (codec_type == VideoCodecType::kVideoCodecVP8) {
-    return VP8Decoder::Create();
+    // Use a default environment for the VP8 decoder while there is no use case
+    // for a propagated environment in this test utility IvfVideoFrameGenerator.
+    return CreateVp8Decoder(CreateEnvironment());
   }
   if (codec_type == VideoCodecType::kVideoCodecVP9) {
     return VP9Decoder::Create();
diff --git a/video/end_to_end_tests/codec_tests.cc b/video/end_to_end_tests/codec_tests.cc
index e9ec7d5..f9f3a41 100644
--- a/video/end_to_end_tests/codec_tests.cc
+++ b/video/end_to_end_tests/codec_tests.cc
@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "absl/types/optional.h"
+#include "api/environment/environment.h"
 #include "api/test/video/function_video_encoder_factory.h"
 #include "api/video/color_space.h"
 #include "api/video/video_rotation.h"
@@ -126,7 +127,9 @@
   test::FunctionVideoEncoderFactory encoder_factory(
       []() { return VP8Encoder::Create(); });
   test::FunctionVideoDecoderFactory decoder_factory(
-      []() { return VP8Decoder::Create(); });
+      [](const Environment& env, const SdpVideoFormat& format) {
+        return CreateVp8Decoder(env);
+      });
   CodecObserver test(5, kVideoRotation_0, absl::nullopt, "VP8",
                      &encoder_factory, &decoder_factory);
   RunBaseTest(&test);
@@ -136,7 +139,9 @@
   test::FunctionVideoEncoderFactory encoder_factory(
       []() { return VP8Encoder::Create(); });
   test::FunctionVideoDecoderFactory decoder_factory(
-      []() { return VP8Decoder::Create(); });
+      [](const Environment& env, const SdpVideoFormat& format) {
+        return CreateVp8Decoder(env);
+      });
   CodecObserver test(5, kVideoRotation_90, absl::nullopt, "VP8",
                      &encoder_factory, &decoder_factory);
   RunBaseTest(&test);
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 e236af0..56fce60 100644
--- a/video/end_to_end_tests/multi_codec_receive_tests.cc
+++ b/video/end_to_end_tests/multi_codec_receive_tests.cc
@@ -216,7 +216,7 @@
       [](const Environment& env,
          const SdpVideoFormat& format) -> std::unique_ptr<VideoDecoder> {
         if (format.name == "VP8") {
-          return VP8Decoder::Create();
+          return CreateVp8Decoder(env);
         }
         if (format.name == "VP9") {
           return VP9Decoder::Create();