Fixit: Migrate uses of BuiltinVideo{Encoder,Decoder}Factory to Video{Encoder,Decoder}FactoryTemplate.

Bug: webrtc:13573
Change-Id: Id1b0d841869d514ba0c609caf82659d5cdc19c0f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299640
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39738}
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index 7e8f473..ad02233 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -197,9 +197,17 @@
       "../api/task_queue:default_task_queue_factory",
       "../api/task_queue:task_queue",
       "../api/video:builtin_video_bitrate_allocator_factory",
-      "../api/video_codecs:builtin_video_decoder_factory",
-      "../api/video_codecs:builtin_video_encoder_factory",
       "../api/video_codecs:video_codecs_api",
+      "..//api/video_codecs:video_decoder_factory_template",
+      "..//api/video_codecs:video_decoder_factory_template_dav1d_adapter",
+      "..//api/video_codecs:video_decoder_factory_template_libvpx_vp8_adapter",
+      "..//api/video_codecs:video_decoder_factory_template_libvpx_vp9_adapter",
+      "..//api/video_codecs:video_decoder_factory_template_open_h264_adapter",
+      "..//api/video_codecs:video_encoder_factory_template",
+      "..//api/video_codecs:video_encoder_factory_template_libaom_av1_adapter",
+      "..//api/video_codecs:video_encoder_factory_template_libvpx_vp8_adapter",
+      "..//api/video_codecs:video_encoder_factory_template_libvpx_vp9_adapter",
+      "..//api/video_codecs:video_encoder_factory_template_open_h264_adapter",
       "../call",
       "../call:call_interfaces",
       "../call:fake_network",
diff --git a/rtc_tools/rtp_generator/rtp_generator.cc b/rtc_tools/rtp_generator/rtp_generator.cc
index e1a2cb3..90af82a 100644
--- a/rtc_tools/rtp_generator/rtp_generator.cc
+++ b/rtc_tools/rtp_generator/rtp_generator.cc
@@ -16,9 +16,16 @@
 
 #include "api/task_queue/default_task_queue_factory.h"
 #include "api/test/create_frame_generator.h"
-#include "api/video_codecs/builtin_video_decoder_factory.h"
-#include "api/video_codecs/builtin_video_encoder_factory.h"
+#include "api/video_codecs/video_decoder_factory_template.h"
+#include "api/video_codecs/video_decoder_factory_template_dav1d_adapter.h"
+#include "api/video_codecs/video_decoder_factory_template_libvpx_vp8_adapter.h"
+#include "api/video_codecs/video_decoder_factory_template_libvpx_vp9_adapter.h"
 #include "api/video_codecs/video_encoder.h"
+#include "api/video_codecs/video_encoder_factory.h"
+#include "api/video_codecs/video_encoder_factory_template.h"
+#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
+#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
+#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
 #include "media/base/media_constants.h"
 #include "rtc_base/strings/json.h"
 #include "rtc_base/system/file_wrapper.h"
@@ -164,8 +171,16 @@
 
 RtpGenerator::RtpGenerator(const RtpGeneratorOptions& options)
     : options_(options),
-      video_encoder_factory_(CreateBuiltinVideoEncoderFactory()),
-      video_decoder_factory_(CreateBuiltinVideoDecoderFactory()),
+      video_encoder_factory_(
+          std::make_unique<webrtc::VideoEncoderFactoryTemplate<
+              webrtc::LibvpxVp8EncoderTemplateAdapter,
+              webrtc::LibvpxVp9EncoderTemplateAdapter,
+              webrtc::LibaomAv1EncoderTemplateAdapter>>()),
+      video_decoder_factory_(
+          std::make_unique<webrtc::VideoDecoderFactoryTemplate<
+              webrtc::LibvpxVp8DecoderTemplateAdapter,
+              webrtc::LibvpxVp9DecoderTemplateAdapter,
+              webrtc::Dav1dDecoderTemplateAdapter>>()),
       video_bitrate_allocator_factory_(
           CreateBuiltinVideoBitrateAllocatorFactory()),
       event_log_(std::make_unique<RtcEventLogNull>()),