diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index ec3e41a4b4..7e1a4d3ac6 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -240,6 +240,7 @@ if (rtc_include_tests) { ] deps = [ ":echo_emulation", + ":peer_configurer", ":peer_connection_quality_test_params", ":test_peer", ":video_quality_analyzer_injection_helper", diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 7802468924..c109df61f2 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -160,23 +160,15 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { RTC_CHECK_EQ(peer_configurations_.size(), 2) << "Only peer to peer calls are allowed, please add 2 peers"; - std::unique_ptr alice_params = - peer_configurations_[0]->ReleaseParams(); - std::unique_ptr alice_components = - peer_configurations_[0]->ReleaseComponents(); - std::vector> - alice_video_generators = - peer_configurations_[0]->ReleaseVideoGenerators(); - std::unique_ptr bob_params = peer_configurations_[1]->ReleaseParams(); - std::unique_ptr bob_components = - peer_configurations_[1]->ReleaseComponents(); - std::vector> - bob_video_generators = peer_configurations_[1]->ReleaseVideoGenerators(); + std::unique_ptr alice_configurer = + std::move(peer_configurations_[0]); + std::unique_ptr bob_configurer = + std::move(peer_configurations_[1]); peer_configurations_.clear(); - for (size_t i = 0; i < bob_params->video_configs.size(); ++i) { + for (size_t i = 0; i < bob_configurer->params()->video_configs.size(); ++i) { // We support simulcast only from caller. - RTC_CHECK(!bob_params->video_configs[i].simulcast_config) + RTC_CHECK(!bob_configurer->params()->video_configs[i].simulcast_config) << "Only simulcast stream from first peer is supported"; } @@ -185,11 +177,11 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { // Print test summary RTC_LOG(INFO) << "Media quality test: Alice will make a call to Bob with media video=" - << !alice_params->video_configs.empty() - << "; audio=" << alice_params->audio_config.has_value() + << !alice_configurer->params()->video_configs.empty() + << "; audio=" << alice_configurer->params()->audio_config.has_value() << ". Bob will respond with media video=" - << !bob_params->video_configs.empty() - << "; audio=" << bob_params->audio_config.has_value(); + << !bob_configurer->params()->video_configs.empty() + << "; audio=" << bob_configurer->params()->audio_config.has_value(); const std::unique_ptr signaling_thread = rtc::Thread::Create(); signaling_thread->SetName(kSignalThreadName, nullptr); @@ -206,16 +198,17 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { // catch output of Alice's stream, Alice's output_dump_file_name should be // passed to Bob's TestPeer setup as audio output file name. absl::optional alice_remote_audio_config = - RemotePeerAudioConfig::Create(bob_params->audio_config); + RemotePeerAudioConfig::Create(bob_configurer->params()->audio_config); absl::optional bob_remote_audio_config = - RemotePeerAudioConfig::Create(alice_params->audio_config); + RemotePeerAudioConfig::Create(alice_configurer->params()->audio_config); // Copy Alice and Bob video configs to correctly pass them into lambdas. - std::vector alice_video_configs = alice_params->video_configs; - std::vector bob_video_configs = bob_params->video_configs; + std::vector alice_video_configs = + alice_configurer->params()->video_configs; + std::vector bob_video_configs = + bob_configurer->params()->video_configs; alice_ = TestPeerFactory::CreateTestPeer( - std::move(alice_components), std::move(alice_params), - std::move(alice_video_generators), + std::move(alice_configurer), std::make_unique( [this, bob_video_configs]( rtc::scoped_refptr transceiver) { @@ -226,8 +219,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { alice_remote_audio_config, run_params.video_encoder_bitrate_multiplier, run_params.echo_emulation_config, task_queue_.get()); bob_ = TestPeerFactory::CreateTestPeer( - std::move(bob_components), std::move(bob_params), - std::move(bob_video_generators), + std::move(bob_configurer), std::make_unique( [this, alice_video_configs]( rtc::scoped_refptr transceiver) { diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 4fc6578894..2b01d8dbb0 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -20,6 +20,7 @@ #include "modules/audio_processing/aec_dump/aec_dump_factory.h" #include "p2p/client/basic_port_allocator.h" #include "test/pc/e2e/echo/echo_emulation.h" +#include "test/pc/e2e/peer_configurer.h" #include "test/testsupport/copy_to_file_audio_capturer.h" namespace webrtc { @@ -326,5 +327,22 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( std::move(params), std::move(video_generators), audio_processing)); } +std::unique_ptr TestPeerFactory::CreateTestPeer( + std::unique_ptr configurer, + std::unique_ptr observer, + VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, + rtc::Thread* signaling_thread, + absl::optional remote_audio_config, + double bitrate_multiplier, + absl::optional + echo_emulation_config, + rtc::TaskQueue* task_queue) { + return CreateTestPeer( + configurer->ReleaseComponents(), configurer->ReleaseParams(), + configurer->ReleaseVideoGenerators(), std::move(observer), + video_analyzer_helper, signaling_thread, remote_audio_config, + bitrate_multiplier, echo_emulation_config, task_queue); +} + } // namespace webrtc_pc_e2e } // namespace webrtc diff --git a/test/pc/e2e/test_peer_factory.h b/test/pc/e2e/test_peer_factory.h index 155449eb2a..695acce888 100644 --- a/test/pc/e2e/test_peer_factory.h +++ b/test/pc/e2e/test_peer_factory.h @@ -21,6 +21,7 @@ #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/task_queue.h" #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h" +#include "test/pc/e2e/peer_configurer.h" #include "test/pc/e2e/peer_connection_quality_test_params.h" #include "test/pc/e2e/test_peer.h" @@ -63,6 +64,22 @@ class TestPeerFactory { absl::optional echo_emulation_config, rtc::TaskQueue* task_queue); + // Setups all components, that should be provided to WebRTC + // PeerConnectionFactory and PeerConnection creation methods, + // also will setup dependencies, that are required for media analyzers + // injection. + // + // |signaling_thread| will be provided by test fixture implementation. + static std::unique_ptr CreateTestPeer( + std::unique_ptr configurer, + std::unique_ptr observer, + VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, + rtc::Thread* signaling_thread, + absl::optional remote_audio_config, + double bitrate_multiplier, + absl::optional + echo_emulation_config, + rtc::TaskQueue* task_queue); }; } // namespace webrtc_pc_e2e