Add support for setting a custom NetEqFactory in PeerConnection level tests.

This allows running Peerconnection level tests with a custom NetEqFactory.

Bug: webrtc:11005
Change-Id: If3063cf61a6274a137e4ab74f9ec2665425f21ae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161307
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30028}
diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h
index d2b69a7..0d87804 100644
--- a/api/test/peerconnection_quality_test_fixture.h
+++ b/api/test/peerconnection_quality_test_fixture.h
@@ -299,6 +299,9 @@
     // Set the audio stream for the call from this peer. If this method won't
     // be invoked, this peer will send no audio.
     virtual PeerConfigurer* SetAudioConfig(AudioConfig config) = 0;
+    // Set a custom NetEqFactory to be used in the call.
+    virtual PeerConfigurer* SetNetEqFactory(
+        std::unique_ptr<NetEqFactory> neteq_factory) = 0;
     // If is set, an RTCEventLog will be saved in that location and it will be
     // available for further analysis.
     virtual PeerConfigurer* SetRtcEventLogPath(std::string path) = 0;
diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h
index 3f18a9e..570380e 100644
--- a/test/pc/e2e/peer_connection_quality_test.h
+++ b/test/pc/e2e/peer_connection_quality_test.h
@@ -136,6 +136,11 @@
     params_->audio_config = std::move(config);
     return this;
   }
+  PeerConfigurer* SetNetEqFactory(
+      std::unique_ptr<NetEqFactory> neteq_factory) override {
+    components_->pcf_dependencies->neteq_factory = std::move(neteq_factory);
+    return this;
+  }
   PeerConfigurer* SetRtcEventLogPath(std::string path) override {
     params_->rtc_event_log_path = std::move(path);
     return this;
diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h
index 765f5a8..9d9558b 100644
--- a/test/pc/e2e/peer_connection_quality_test_params.h
+++ b/test/pc/e2e/peer_connection_quality_test_params.h
@@ -48,6 +48,7 @@
   std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
   std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
   std::unique_ptr<MediaTransportFactory> media_transport_factory;
+  std::unique_ptr<NetEqFactory> neteq_factory;
 
   // Will be passed to MediaEngineInterface, that will be used in
   // PeerConnectionFactory.
diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc
index 4874725..b5c74f1 100644
--- a/test/pc/e2e/test_peer.cc
+++ b/test/pc/e2e/test_peer.cc
@@ -162,6 +162,9 @@
       pcf_deps.media_transport_factory =
           std::move(pcf_dependencies->media_transport_factory);
     }
+    if (pcf_dependencies->neteq_factory != nullptr) {
+      pcf_deps.neteq_factory = std::move(pcf_dependencies->neteq_factory);
+    }
 
     return pcf_deps;
   }