Reland "Enable using a custom NetEqFactory in simulations"

This is a reland of 2a11b2451a4068746fa0c55fa210efd4a15e4423
There are no changes compared to the first attempt.

Original change's description:
> Enable using a custom NetEqFactory in simulations
>
> Bug: webrtc:11005
> Change-Id: I8a15f77953cbd3c29a75c7cfc77f926b138994b9
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165580
> Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30286}

TBR=kwiberg

Bug: webrtc:11005
Change-Id: I4aa377e05916bd23f8f63aece9d0e27731c80d3e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166465
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30319}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 45f555c..f0b5eeb 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -678,6 +678,7 @@
         ":neteq_simulator_api",
         "../modules/audio_coding:neteq_test_factory",
         "../rtc_base:checks",
+        "neteq:neteq_api",
         "//third_party/abseil-cpp/absl/flags:flag",
         "//third_party/abseil-cpp/absl/flags:parse",
         "//third_party/abseil-cpp/absl/strings",
diff --git a/api/test/neteq_simulator_factory.cc b/api/test/neteq_simulator_factory.cc
index 9a751a4..b4917f4 100644
--- a/api/test/neteq_simulator_factory.cc
+++ b/api/test/neteq_simulator_factory.cc
@@ -50,7 +50,8 @@
   config.max_nr_packets_in_buffer =
       absl::GetFlag(FLAGS_max_nr_packets_in_buffer);
   config.output_audio_filename = output_audio_filename;
-  return factory_->InitializeTestFromFile(args[1], config);
+  return factory_->InitializeTestFromFile(/*input_file_name=*/args[1],
+                                          /*factory=*/nullptr, config);
 }
 
 std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulatorFromFile(
@@ -63,8 +64,8 @@
   config.initial_dummy_packets = simulation_config.initial_dummy_packets;
   config.skip_get_audio_events = simulation_config.skip_get_audio_events;
   config.field_trial_string = simulation_config.field_trial_string;
-  return factory_->InitializeTestFromFile(std::string(event_log_filename),
-                                          config);
+  return factory_->InitializeTestFromFile(
+      std::string(event_log_filename), simulation_config.neteq_factory, config);
 }
 
 std::unique_ptr<NetEqSimulator>
@@ -79,7 +80,8 @@
   config.skip_get_audio_events = simulation_config.skip_get_audio_events;
   config.field_trial_string = simulation_config.field_trial_string;
   return factory_->InitializeTestFromString(
-      std::string(event_log_file_contents), config);
+      std::string(event_log_file_contents), simulation_config.neteq_factory,
+      config);
 }
 
 }  // namespace test
diff --git a/api/test/neteq_simulator_factory.h b/api/test/neteq_simulator_factory.h
index 3c0cbe0..af747f6 100644
--- a/api/test/neteq_simulator_factory.h
+++ b/api/test/neteq_simulator_factory.h
@@ -15,6 +15,7 @@
 #include <string>
 
 #include "absl/strings/string_view.h"
+#include "api/neteq/neteq_factory.h"
 #include "api/test/neteq_simulator.h"
 
 namespace webrtc {
@@ -40,6 +41,8 @@
     int skip_get_audio_events = 0;
     // A WebRTC field trial string to be used during the simulation.
     std::string field_trial_string;
+    // A custom NetEqFactory can be used.
+    NetEqFactory* neteq_factory = nullptr;
   };
   // This function takes the same arguments as the neteq_rtpplay utility.
   std::unique_ptr<NetEqSimulator> CreateSimulator(int argc, char* argv[]);