From 98aa44859b1f3414e5376106e1a1735d720e177b Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 20 Mar 2019 12:30:52 +0100 Subject: [PATCH] Move Params, InjectableComponents and classes around on the top level Bug: webrtc:10138 Change-Id: I3ee489c5558f9acad30587dc774ed240e115640e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128608 Reviewed-by: Mirko Bonadei Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#27210} --- test/pc/e2e/BUILD.gn | 21 ++++ .../api/peerconnection_quality_test_fixture.h | 78 ------------ test/pc/e2e/peer_connection_quality_test.h | 8 +- .../e2e/peer_connection_quality_test_params.h | 114 ++++++++++++++++++ test/pc/e2e/test_peer.cc | 7 -- test/pc/e2e/test_peer.h | 4 +- 6 files changed, 137 insertions(+), 95 deletions(-) create mode 100644 test/pc/e2e/peer_connection_quality_test_params.h diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 0be2e4e435..3c3a6645cd 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -41,6 +41,25 @@ if (rtc_include_tests) { } } +rtc_source_set("peer_connection_quality_test_params") { + visibility = [ "*" ] + sources = [ + "peer_connection_quality_test_params.h", + ] + + deps = [ + "../../../api:callfactory_api", + "../../../api:fec_controller_api", + "../../../api:libjingle_peerconnection_api", + "../../../api/transport:network_control", + "../../../api/video_codecs:video_codecs_api", + "../../../logging:rtc_event_log_api", + "../../../rtc_base:rtc_base", + "api:peer_connection_quality_test_fixture_api", + "//third_party/abseil-cpp/absl/memory:memory", + ] +} + rtc_source_set("encoded_image_data_injector_api") { visibility = [ "*" ] sources = [ @@ -167,6 +186,7 @@ if (rtc_include_tests) { "test_peer.h", ] deps = [ + ":peer_connection_quality_test_params", ":video_quality_analyzer_injection_helper", "../../../api:array_view", "../../../api:scoped_refptr", @@ -203,6 +223,7 @@ if (rtc_include_tests) { deps = [ ":default_audio_quality_analyzer", ":default_video_quality_analyzer", + ":peer_connection_quality_test_params", ":single_process_encoded_image_data_injector", ":stats_poller", ":test_peer", diff --git a/test/pc/e2e/api/peerconnection_quality_test_fixture.h b/test/pc/e2e/api/peerconnection_quality_test_fixture.h index 86381512f1..6afaf093c2 100644 --- a/test/pc/e2e/api/peerconnection_quality_test_fixture.h +++ b/test/pc/e2e/api/peerconnection_quality_test_fixture.h @@ -41,69 +41,6 @@ namespace webrtc_pc_e2e { // TODO(titovartem) move to API when it will be stabilized. class PeerConnectionE2EQualityTestFixture { public: - // Contains most part from PeerConnectionFactoryDependencies. Also all fields - // are optional and defaults will be provided by fixture implementation if - // any will be omitted. - // - // Separate class was introduced to clarify which components can be - // overridden. For example worker and signaling threads will be provided by - // fixture implementation. The same is applicable to the media engine. So user - // can override only some parts of media engine like video encoder/decoder - // factories. - struct PeerConnectionFactoryComponents { - std::unique_ptr call_factory; - std::unique_ptr event_log_factory; - std::unique_ptr fec_controller_factory; - std::unique_ptr - network_controller_factory; - std::unique_ptr media_transport_factory; - - // Will be passed to MediaEngineInterface, that will be used in - // PeerConnectionFactory. - std::unique_ptr video_encoder_factory; - std::unique_ptr video_decoder_factory; - }; - - // Contains most parts from PeerConnectionDependencies. Also all fields are - // optional and defaults will be provided by fixture implementation if any - // will be omitted. - // - // Separate class was introduced to clarify which components can be - // overridden. For example observer, which is required to - // PeerConnectionDependencies, will be provided by fixture implementation, - // so client can't inject its own. Also only network manager can be overridden - // inside port allocator. - struct PeerConnectionComponents { - PeerConnectionComponents(rtc::NetworkManager* network_manager) - : network_manager(network_manager) { - RTC_CHECK(network_manager); - } - - rtc::NetworkManager* const network_manager; - std::unique_ptr async_resolver_factory; - std::unique_ptr cert_generator; - std::unique_ptr tls_cert_verifier; - }; - - // Contains all components, that can be overridden in peer connection. Also - // has a network thread, that will be used to communicate with another peers. - struct InjectableComponents { - explicit InjectableComponents(rtc::Thread* network_thread, - rtc::NetworkManager* network_manager) - : network_thread(network_thread), - pcf_dependencies( - absl::make_unique()), - pc_dependencies( - absl::make_unique(network_manager)) { - RTC_CHECK(network_thread); - } - - rtc::Thread* const network_thread; - - std::unique_ptr pcf_dependencies; - std::unique_ptr pc_dependencies; - }; - // Contains screen share video stream properties. struct ScreenShareConfig { // If true, slides will be generated programmatically. @@ -185,21 +122,6 @@ class PeerConnectionE2EQualityTestFixture { cricket::AudioOptions audio_options; }; - // Contains information about call media streams (up to 1 audio stream and - // unlimited amount of video streams) and rtc configuration, that will be used - // to set up peer connection. - struct Params { - // If |video_configs| is empty - no video should be added to the test call. - std::vector video_configs; - // If |audio_config| is set audio stream will be configured - absl::optional audio_config; - // If |rtc_event_log_path| is set, an RTCEventLog will be saved in that - // location and it will be available for further analysis. - absl::optional rtc_event_log_path; - - PeerConnectionInterface::RTCConfiguration rtc_configuration; - }; - // This class is used to fully configure one peer inside the call. class PeerConfigurer { public: diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index ea20fa267c..54cdea51db 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -28,6 +28,7 @@ #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h" #include "test/pc/e2e/api/audio_quality_analyzer_interface.h" #include "test/pc/e2e/api/peerconnection_quality_test_fixture.h" +#include "test/pc/e2e/peer_connection_quality_test_params.h" #include "test/pc/e2e/test_peer.h" #include "test/testsupport/video_frame_writer.h" @@ -37,10 +38,6 @@ namespace webrtc_pc_e2e { class PeerConfigurerImpl final : public PeerConnectionE2EQualityTestFixture::PeerConfigurer { public: - using Params = PeerConnectionE2EQualityTestFixture::Params; - using InjectableComponents = - PeerConnectionE2EQualityTestFixture::InjectableComponents; - PeerConfigurerImpl(rtc::Thread* network_thread, rtc::NetworkManager* network_manager) : components_(absl::make_unique(network_thread, @@ -147,9 +144,6 @@ class PeerConfigurerImpl final class PeerConnectionE2EQualityTest : public PeerConnectionE2EQualityTestFixture { public: - using Params = PeerConnectionE2EQualityTestFixture::Params; - using InjectableComponents = - PeerConnectionE2EQualityTestFixture::InjectableComponents; using VideoGeneratorType = PeerConnectionE2EQualityTestFixture::VideoGeneratorType; using RunParams = PeerConnectionE2EQualityTestFixture::RunParams; diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h new file mode 100644 index 0000000000..94cd917345 --- /dev/null +++ b/test/pc/e2e/peer_connection_quality_test_params.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#ifndef TEST_PC_E2E_PEER_CONNECTION_QUALITY_TEST_PARAMS_H_ +#define TEST_PC_E2E_PEER_CONNECTION_QUALITY_TEST_PARAMS_H_ + +#include +#include +#include + +#include "absl/memory/memory.h" +#include "api/async_resolver_factory.h" +#include "api/call/call_factory_interface.h" +#include "api/fec_controller.h" +#include "api/media_transport_interface.h" +#include "api/transport/network_control.h" +#include "api/video_codecs/video_decoder_factory.h" +#include "api/video_codecs/video_encoder_factory.h" +#include "logging/rtc_event_log/rtc_event_log_factory_interface.h" +#include "rtc_base/network.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/ssl_certificate.h" +#include "rtc_base/thread.h" +#include "test/pc/e2e/api/peerconnection_quality_test_fixture.h" + +namespace webrtc { +namespace webrtc_pc_e2e { + +// Contains most part from PeerConnectionFactoryDependencies. Also all fields +// are optional and defaults will be provided by fixture implementation if +// any will be omitted. +// +// Separate class was introduced to clarify which components can be +// overridden. For example worker and signaling threads will be provided by +// fixture implementation. The same is applicable to the media engine. So user +// can override only some parts of media engine like video encoder/decoder +// factories. +struct PeerConnectionFactoryComponents { + std::unique_ptr call_factory; + std::unique_ptr event_log_factory; + std::unique_ptr fec_controller_factory; + std::unique_ptr network_controller_factory; + std::unique_ptr media_transport_factory; + + // Will be passed to MediaEngineInterface, that will be used in + // PeerConnectionFactory. + std::unique_ptr video_encoder_factory; + std::unique_ptr video_decoder_factory; +}; + +// Contains most parts from PeerConnectionDependencies. Also all fields are +// optional and defaults will be provided by fixture implementation if any +// will be omitted. +// +// Separate class was introduced to clarify which components can be +// overridden. For example observer, which is required to +// PeerConnectionDependencies, will be provided by fixture implementation, +// so client can't inject its own. Also only network manager can be overridden +// inside port allocator. +struct PeerConnectionComponents { + explicit PeerConnectionComponents(rtc::NetworkManager* network_manager) + : network_manager(network_manager) { + RTC_CHECK(network_manager); + } + + rtc::NetworkManager* const network_manager; + std::unique_ptr async_resolver_factory; + std::unique_ptr cert_generator; + std::unique_ptr tls_cert_verifier; +}; + +// Contains all components, that can be overridden in peer connection. Also +// has a network thread, that will be used to communicate with another peers. +struct InjectableComponents { + explicit InjectableComponents(rtc::Thread* network_thread, + rtc::NetworkManager* network_manager) + : network_thread(network_thread), + pcf_dependencies(absl::make_unique()), + pc_dependencies( + absl::make_unique(network_manager)) { + RTC_CHECK(network_thread); + } + + rtc::Thread* const network_thread; + + std::unique_ptr pcf_dependencies; + std::unique_ptr pc_dependencies; +}; + +// Contains information about call media streams (up to 1 audio stream and +// unlimited amount of video streams) and rtc configuration, that will be used +// to set up peer connection. +struct Params { + // If |video_configs| is empty - no video should be added to the test call. + std::vector video_configs; + // If |audio_config| is set audio stream will be configured + absl::optional audio_config; + // If |rtc_event_log_path| is set, an RTCEventLog will be saved in that + // location and it will be available for further analysis. + absl::optional rtc_event_log_path; + + PeerConnectionInterface::RTCConfiguration rtc_configuration; +}; + +} // namespace webrtc_pc_e2e +} // namespace webrtc + +#endif // TEST_PC_E2E_PEER_CONNECTION_QUALITY_TEST_PARAMS_H_ diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc index 18736ea5ad..6491b94cb9 100644 --- a/test/pc/e2e/test_peer.cc +++ b/test/pc/e2e/test_peer.cc @@ -33,13 +33,6 @@ namespace { constexpr int16_t kGeneratedAudioMaxAmplitude = 32000; constexpr int kSamplingFrequencyInHz = 48000; -using Params = PeerConnectionE2EQualityTestFixture::Params; -using InjectableComponents = - PeerConnectionE2EQualityTestFixture::InjectableComponents; -using PeerConnectionFactoryComponents = - PeerConnectionE2EQualityTestFixture::PeerConnectionFactoryComponents; -using PeerConnectionComponents = - PeerConnectionE2EQualityTestFixture::PeerConnectionComponents; using AudioConfig = PeerConnectionE2EQualityTestFixture::AudioConfig; // Sets mandatory entities in injectable components like |pcf_dependencies| diff --git a/test/pc/e2e/test_peer.h b/test/pc/e2e/test_peer.h index fa2f8eb7ef..f87636f5a4 100644 --- a/test/pc/e2e/test_peer.h +++ b/test/pc/e2e/test_peer.h @@ -24,6 +24,7 @@ #include "rtc_base/thread.h" #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h" #include "test/pc/e2e/api/peerconnection_quality_test_fixture.h" +#include "test/pc/e2e/peer_connection_quality_test_params.h" namespace webrtc { namespace webrtc_pc_e2e { @@ -32,11 +33,8 @@ namespace webrtc_pc_e2e { class TestPeer final : public PeerConnectionWrapper { public: using PeerConnectionWrapper::PeerConnectionWrapper; - using Params = PeerConnectionE2EQualityTestFixture::Params; using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig; using AudioConfig = PeerConnectionE2EQualityTestFixture::AudioConfig; - using InjectableComponents = - PeerConnectionE2EQualityTestFixture::InjectableComponents; // Setups all components, that should be provided to WebRTC // PeerConnectionFactory and PeerConnection creation methods,