From 389228d0f0cd6330da629f8bbcff76bc51db226c Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 4 Nov 2022 14:01:12 +0100 Subject: [PATCH] Remove PeerConfigurer interface. PeerConfigurerImpl is renamed to PeerConfigurer. Change-Id: Ie52c581126c21740536d42ff4831f0c4ed445ea4 Bug: webrtc:14627 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281883 Reviewed-by: Mirko Bonadei Reviewed-by: Artem Titov Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#38603} --- api/BUILD.gn | 1 + api/test/pclf/BUILD.gn | 5 - api/test/pclf/peer_configurer.cc | 254 +++--------------- api/test/pclf/peer_configurer.h | 133 +++------ .../peerconnection_quality_test_fixture.h | 123 +-------- test/pc/e2e/BUILD.gn | 27 +- test/pc/e2e/media/media_helper.cc | 3 +- test/pc/e2e/media/media_helper.h | 2 +- test/pc/e2e/peer_configurer.h | 9 + test/pc/e2e/peer_connection_quality_test.cc | 10 +- test/pc/e2e/peer_connection_quality_test.h | 3 +- test/pc/e2e/peer_params_preprocessor.cc | 217 +++++++++++++++ test/pc/e2e/peer_params_preprocessor.h | 52 ++++ test/pc/e2e/test_peer.cc | 3 +- test/pc/e2e/test_peer.h | 6 +- test/pc/e2e/test_peer_factory.cc | 4 +- test/pc/e2e/test_peer_factory.h | 3 +- 17 files changed, 399 insertions(+), 456 deletions(-) create mode 100644 test/pc/e2e/peer_params_preprocessor.cc create mode 100644 test/pc/e2e/peer_params_preprocessor.h diff --git a/api/BUILD.gn b/api/BUILD.gn index 7e78edd014..3360cfd1f9 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -539,6 +539,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { "task_queue", "test/pclf:media_configuration", "test/pclf:media_quality_test_params", + "test/pclf:peer_configurer", "test/video:video_frame_writer", "transport:network_control", "units:time_delta", diff --git a/api/test/pclf/BUILD.gn b/api/test/pclf/BUILD.gn index 218331541b..17cd758ea4 100644 --- a/api/test/pclf/BUILD.gn +++ b/api/test/pclf/BUILD.gn @@ -94,7 +94,6 @@ rtc_library("peer_configurer") { "../../../api:create_peer_connection_quality_test_frame_generator", "../../../api:fec_controller_api", "../../../api:packet_socket_factory", - "../../../api:peer_connection_quality_test_fixture_api", "../../../api:peer_network_dependencies", "../../../api/audio:audio_mixer_api", "../../../api/rtc_event_log", @@ -102,12 +101,8 @@ rtc_library("peer_configurer") { "../../../api/transport:network_control", "../../../api/video_codecs:video_codecs_api", "../../../modules/audio_processing:api", - "../../../modules/video_coding/svc:scalability_mode_util", - "../../../modules/video_coding/svc:scalability_structures", "../../../rtc_base", - "../../../rtc_base:macromagic", "../../../rtc_base:threading", - "../../../test:fileutils", ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc index 91235835d4..ead1b5db06 100644 --- a/api/test/pclf/peer_configurer.cc +++ b/api/test/pclf/peer_configurer.cc @@ -16,25 +16,11 @@ #include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_quality_test_params.h" #include "api/test/peer_network_dependencies.h" -#include "modules/video_coding/svc/create_scalability_structure.h" -#include "modules/video_coding/svc/scalability_mode_util.h" -#include "rtc_base/arraysize.h" -#include "test/testsupport/file_utils.h" namespace webrtc { namespace webrtc_pc_e2e { -namespace { -using PeerConfigurer = PeerConnectionE2EQualityTestFixture::PeerConfigurer; - -// List of default names of generic participants according to -// https://en.wikipedia.org/wiki/Alice_and_Bob -constexpr absl::string_view kDefaultNames[] = {"alice", "bob", "charlie", - "david", "erin", "frank"}; - -} // namespace - -PeerConfigurerImpl::PeerConfigurerImpl( +PeerConfigurer::PeerConfigurer( const PeerNetworkDependencies& network_dependencies) : components_(std::make_unique( network_dependencies.network_thread, @@ -43,175 +29,175 @@ PeerConfigurerImpl::PeerConfigurerImpl( params_(std::make_unique()), configurable_params_(std::make_unique()) {} -PeerConfigurer* PeerConfigurerImpl::SetName(absl::string_view name) { +PeerConfigurer* PeerConfigurer::SetName(absl::string_view name) { params_->name = std::string(name); return this; } -PeerConfigurer* PeerConfigurerImpl::SetTaskQueueFactory( +PeerConfigurer* PeerConfigurer::SetTaskQueueFactory( std::unique_ptr task_queue_factory) { components_->pcf_dependencies->task_queue_factory = std::move(task_queue_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetCallFactory( +PeerConfigurer* PeerConfigurer::SetCallFactory( std::unique_ptr call_factory) { components_->pcf_dependencies->call_factory = std::move(call_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetEventLogFactory( +PeerConfigurer* PeerConfigurer::SetEventLogFactory( std::unique_ptr event_log_factory) { components_->pcf_dependencies->event_log_factory = std::move(event_log_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetFecControllerFactory( +PeerConfigurer* PeerConfigurer::SetFecControllerFactory( std::unique_ptr fec_controller_factory) { components_->pcf_dependencies->fec_controller_factory = std::move(fec_controller_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetNetworkControllerFactory( +PeerConfigurer* PeerConfigurer::SetNetworkControllerFactory( std::unique_ptr network_controller_factory) { components_->pcf_dependencies->network_controller_factory = std::move(network_controller_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetVideoEncoderFactory( +PeerConfigurer* PeerConfigurer::SetVideoEncoderFactory( std::unique_ptr video_encoder_factory) { components_->pcf_dependencies->video_encoder_factory = std::move(video_encoder_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetVideoDecoderFactory( +PeerConfigurer* PeerConfigurer::SetVideoDecoderFactory( std::unique_ptr video_decoder_factory) { components_->pcf_dependencies->video_decoder_factory = std::move(video_decoder_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetAsyncResolverFactory( +PeerConfigurer* PeerConfigurer::SetAsyncResolverFactory( std::unique_ptr async_resolver_factory) { components_->pc_dependencies->async_resolver_factory = std::move(async_resolver_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetRTCCertificateGenerator( +PeerConfigurer* PeerConfigurer::SetRTCCertificateGenerator( std::unique_ptr cert_generator) { components_->pc_dependencies->cert_generator = std::move(cert_generator); return this; } -PeerConfigurer* PeerConfigurerImpl::SetSSLCertificateVerifier( +PeerConfigurer* PeerConfigurer::SetSSLCertificateVerifier( std::unique_ptr tls_cert_verifier) { components_->pc_dependencies->tls_cert_verifier = std::move(tls_cert_verifier); return this; } -PeerConfigurer* PeerConfigurerImpl::AddVideoConfig(VideoConfig config) { +PeerConfigurer* PeerConfigurer::AddVideoConfig(VideoConfig config) { video_sources_.push_back( CreateSquareFrameGenerator(config, /*type=*/absl::nullopt)); configurable_params_->video_configs.push_back(std::move(config)); return this; } -PeerConfigurer* PeerConfigurerImpl::AddVideoConfig( +PeerConfigurer* PeerConfigurer::AddVideoConfig( VideoConfig config, std::unique_ptr generator) { configurable_params_->video_configs.push_back(std::move(config)); video_sources_.push_back(std::move(generator)); return this; } -PeerConfigurer* PeerConfigurerImpl::AddVideoConfig(VideoConfig config, - CapturingDeviceIndex index) { +PeerConfigurer* PeerConfigurer::AddVideoConfig(VideoConfig config, + CapturingDeviceIndex index) { configurable_params_->video_configs.push_back(std::move(config)); video_sources_.push_back(index); return this; } -PeerConfigurer* PeerConfigurerImpl::SetVideoSubscription( +PeerConfigurer* PeerConfigurer::SetVideoSubscription( VideoSubscription subscription) { configurable_params_->video_subscription = std::move(subscription); return this; } -PeerConfigurer* PeerConfigurerImpl::SetAudioConfig(AudioConfig config) { +PeerConfigurer* PeerConfigurer::SetAudioConfig(AudioConfig config) { params_->audio_config = std::move(config); return this; } -PeerConfigurer* PeerConfigurerImpl::SetUseUlpFEC(bool value) { +PeerConfigurer* PeerConfigurer::SetUseUlpFEC(bool value) { params_->use_ulp_fec = value; return this; } -PeerConfigurer* PeerConfigurerImpl::SetUseFlexFEC(bool value) { +PeerConfigurer* PeerConfigurer::SetUseFlexFEC(bool value) { params_->use_flex_fec = value; return this; } -PeerConfigurer* PeerConfigurerImpl::SetVideoEncoderBitrateMultiplier( +PeerConfigurer* PeerConfigurer::SetVideoEncoderBitrateMultiplier( double multiplier) { params_->video_encoder_bitrate_multiplier = multiplier; return this; } -PeerConfigurer* PeerConfigurerImpl::SetNetEqFactory( +PeerConfigurer* PeerConfigurer::SetNetEqFactory( std::unique_ptr neteq_factory) { components_->pcf_dependencies->neteq_factory = std::move(neteq_factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetAudioProcessing( +PeerConfigurer* PeerConfigurer::SetAudioProcessing( rtc::scoped_refptr audio_processing) { components_->pcf_dependencies->audio_processing = audio_processing; return this; } -PeerConfigurer* PeerConfigurerImpl::SetAudioMixer( +PeerConfigurer* PeerConfigurer::SetAudioMixer( rtc::scoped_refptr audio_mixer) { components_->pcf_dependencies->audio_mixer = audio_mixer; return this; } -PeerConfigurer* PeerConfigurerImpl::SetUseNetworkThreadAsWorkerThread() { +PeerConfigurer* PeerConfigurer::SetUseNetworkThreadAsWorkerThread() { components_->worker_thread = components_->network_thread; return this; } -PeerConfigurer* PeerConfigurerImpl::SetRtcEventLogPath(std::string path) { +PeerConfigurer* PeerConfigurer::SetRtcEventLogPath(std::string path) { params_->rtc_event_log_path = std::move(path); return this; } -PeerConfigurer* PeerConfigurerImpl::SetAecDumpPath(std::string path) { +PeerConfigurer* PeerConfigurer::SetAecDumpPath(std::string path) { params_->aec_dump_path = std::move(path); return this; } -PeerConfigurer* PeerConfigurerImpl::SetRTCConfiguration( +PeerConfigurer* PeerConfigurer::SetRTCConfiguration( PeerConnectionInterface::RTCConfiguration configuration) { params_->rtc_configuration = std::move(configuration); return this; } -PeerConfigurer* PeerConfigurerImpl::SetRTCOfferAnswerOptions( +PeerConfigurer* PeerConfigurer::SetRTCOfferAnswerOptions( PeerConnectionInterface::RTCOfferAnswerOptions options) { params_->rtc_offer_answer_options = std::move(options); return this; } -PeerConfigurer* PeerConfigurerImpl::SetBitrateSettings( +PeerConfigurer* PeerConfigurer::SetBitrateSettings( BitrateSettings bitrate_settings) { params_->bitrate_settings = bitrate_settings; return this; } -PeerConfigurer* PeerConfigurerImpl::SetVideoCodecs( +PeerConfigurer* PeerConfigurer::SetVideoCodecs( std::vector video_codecs) { params_->video_codecs = std::move(video_codecs); return this; } -PeerConfigurer* PeerConfigurerImpl::SetIceTransportFactory( +PeerConfigurer* PeerConfigurer::SetIceTransportFactory( std::unique_ptr factory) { components_->pc_dependencies->ice_transport_factory = std::move(factory); return this; } -PeerConfigurer* PeerConfigurerImpl::SetPortAllocatorExtraFlags( +PeerConfigurer* PeerConfigurer::SetPortAllocatorExtraFlags( uint32_t extra_flags) { params_->port_allocator_extra_flags = extra_flags; return this; } -std::unique_ptr PeerConfigurerImpl::ReleaseComponents() { +std::unique_ptr PeerConfigurer::ReleaseComponents() { RTC_CHECK(components_); auto components = std::move(components_); components_ = nullptr; @@ -220,7 +206,7 @@ std::unique_ptr PeerConfigurerImpl::ReleaseComponents() { // Returns Params and transfer ownership to the caller. // Can be called once. -std::unique_ptr PeerConfigurerImpl::ReleaseParams() { +std::unique_ptr PeerConfigurer::ReleaseParams() { RTC_CHECK(params_); auto params = std::move(params_); params_ = nullptr; @@ -230,7 +216,7 @@ std::unique_ptr PeerConfigurerImpl::ReleaseParams() { // Returns ConfigurableParams and transfer ownership to the caller. // Can be called once. std::unique_ptr -PeerConfigurerImpl::ReleaseConfigurableParams() { +PeerConfigurer::ReleaseConfigurableParams() { RTC_CHECK(configurable_params_); auto configurable_params = std::move(configurable_params_); configurable_params_ = nullptr; @@ -239,177 +225,11 @@ PeerConfigurerImpl::ReleaseConfigurableParams() { // Returns video sources and transfer frame generators ownership to the // caller. Can be called once. -std::vector -PeerConfigurerImpl::ReleaseVideoSources() { +std::vector PeerConfigurer::ReleaseVideoSources() { auto video_sources = std::move(video_sources_); video_sources_.clear(); return video_sources; } -DefaultNamesProvider::DefaultNamesProvider( - absl::string_view prefix, - rtc::ArrayView default_names) - : prefix_(prefix), default_names_(default_names) {} - -void DefaultNamesProvider::MaybeSetName(absl::optional& name) { - if (name.has_value()) { - known_names_.insert(name.value()); - } else { - name = GenerateName(); - } -} - -std::string DefaultNamesProvider::GenerateName() { - std::string name; - do { - name = GenerateNameInternal(); - } while (!known_names_.insert(name).second); - return name; -} - -std::string DefaultNamesProvider::GenerateNameInternal() { - if (counter_ < default_names_.size()) { - return std::string(default_names_[counter_++]); - } - return prefix_ + std::to_string(counter_++); -} - -PeerParamsPreprocessor::PeerParamsPreprocessor() - : peer_names_provider_("peer_", kDefaultNames) {} - -void PeerParamsPreprocessor::SetDefaultValuesForMissingParams( - PeerConfigurerImpl& peer) { - Params* params = peer.params(); - ConfigurableParams* configurable_params = peer.configurable_params(); - peer_names_provider_.MaybeSetName(params->name); - DefaultNamesProvider video_stream_names_provider(*params->name + - "_auto_video_stream_label_"); - for (VideoConfig& config : configurable_params->video_configs) { - video_stream_names_provider.MaybeSetName(config.stream_label); - } - if (params->audio_config) { - DefaultNamesProvider audio_stream_names_provider( - *params->name + "_auto_audio_stream_label_"); - audio_stream_names_provider.MaybeSetName( - params->audio_config->stream_label); - } - - if (params->video_codecs.empty()) { - params->video_codecs.push_back(VideoCodecConfig(cricket::kVp8CodecName)); - } -} - -void PeerParamsPreprocessor::ValidateParams(const PeerConfigurerImpl& peer) { - const Params& p = peer.params(); - RTC_CHECK_GT(p.video_encoder_bitrate_multiplier, 0.0); - // Each peer should at least support 1 video codec. - RTC_CHECK_GE(p.video_codecs.size(), 1); - - { - RTC_CHECK(p.name); - bool inserted = peer_names_.insert(p.name.value()).second; - RTC_CHECK(inserted) << "Duplicate name=" << p.name.value(); - } - - // Validate that all video stream labels are unique and sync groups are - // valid. - for (const VideoConfig& video_config : - peer.configurable_params().video_configs) { - RTC_CHECK(video_config.stream_label); - bool inserted = - video_labels_.insert(video_config.stream_label.value()).second; - RTC_CHECK(inserted) << "Duplicate video_config.stream_label=" - << video_config.stream_label.value(); - - // TODO(bugs.webrtc.org/4762): remove this check after synchronization of - // more than two streams is supported. - if (video_config.sync_group.has_value()) { - bool sync_group_inserted = - video_sync_groups_.insert(video_config.sync_group.value()).second; - RTC_CHECK(sync_group_inserted) - << "Sync group shouldn't consist of more than two streams (one " - "video and one audio). Duplicate video_config.sync_group=" - << video_config.sync_group.value(); - } - - if (video_config.simulcast_config) { - if (!video_config.encoding_params.empty()) { - RTC_CHECK_EQ(video_config.simulcast_config->simulcast_streams_count, - video_config.encoding_params.size()) - << "|encoding_params| have to be specified for each simulcast " - << "stream in |video_config|."; - } - } else { - RTC_CHECK_LE(video_config.encoding_params.size(), 1) - << "|encoding_params| has multiple values but simulcast is not " - "enabled."; - } - - if (video_config.emulated_sfu_config) { - if (video_config.simulcast_config && - video_config.emulated_sfu_config->target_layer_index) { - RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, - video_config.simulcast_config->simulcast_streams_count); - } - if (!video_config.encoding_params.empty()) { - bool is_svc = false; - for (const auto& encoding_param : video_config.encoding_params) { - if (!encoding_param.scalability_mode) - continue; - - absl::optional scalability_mode = - ScalabilityModeFromString(*encoding_param.scalability_mode); - RTC_CHECK(scalability_mode) << "Unknown scalability_mode requested"; - - absl::optional - stream_layers_config = - ScalabilityStructureConfig(*scalability_mode); - is_svc |= stream_layers_config->num_spatial_layers > 1; - RTC_CHECK(stream_layers_config->num_spatial_layers == 1 || - video_config.encoding_params.size() == 1) - << "Can't enable SVC modes with multiple spatial layers (" - << stream_layers_config->num_spatial_layers - << " layers) or simulcast (" - << video_config.encoding_params.size() << " layers)"; - if (video_config.emulated_sfu_config->target_layer_index) { - RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, - stream_layers_config->num_spatial_layers); - } - } - if (!is_svc && video_config.emulated_sfu_config->target_layer_index) { - RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, - video_config.encoding_params.size()); - } - } - } - } - if (p.audio_config) { - bool inserted = - audio_labels_.insert(p.audio_config->stream_label.value()).second; - RTC_CHECK(inserted) << "Duplicate audio_config.stream_label=" - << p.audio_config->stream_label.value(); - // TODO(bugs.webrtc.org/4762): remove this check after synchronization of - // more than two streams is supported. - if (p.audio_config->sync_group.has_value()) { - bool sync_group_inserted = - audio_sync_groups_.insert(p.audio_config->sync_group.value()).second; - RTC_CHECK(sync_group_inserted) - << "Sync group shouldn't consist of more than two streams (one " - "video and one audio). Duplicate audio_config.sync_group=" - << p.audio_config->sync_group.value(); - } - // Check that if mode input file name specified only if mode is kFile. - if (p.audio_config.value().mode == AudioConfig::Mode::kGenerated) { - RTC_CHECK(!p.audio_config.value().input_file_name); - } - if (p.audio_config.value().mode == AudioConfig::Mode::kFile) { - RTC_CHECK(p.audio_config.value().input_file_name); - RTC_CHECK( - test::FileExists(p.audio_config.value().input_file_name.value())) - << p.audio_config.value().input_file_name.value() << " doesn't exist"; - } - } -} - } // namespace webrtc_pc_e2e } // namespace webrtc diff --git a/api/test/pclf/peer_configurer.h b/api/test/pclf/peer_configurer.h index e6fc2522f3..54f9402246 100644 --- a/api/test/pclf/peer_configurer.h +++ b/api/test/pclf/peer_configurer.h @@ -11,7 +11,6 @@ #define API_TEST_PCLF_PEER_CONFIGURER_H_ #include -#include #include #include #include @@ -27,7 +26,6 @@ #include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_quality_test_params.h" #include "api/test/peer_network_dependencies.h" -#include "api/test/peerconnection_quality_test_fixture.h" #include "api/transport/network_control.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" @@ -41,19 +39,17 @@ namespace webrtc { namespace webrtc_pc_e2e { // This class is used to fully configure one peer inside a call. -class PeerConfigurerImpl final - : public PeerConnectionE2EQualityTestFixture::PeerConfigurer { +class PeerConfigurer { public: using VideoSource = absl::variant, CapturingDeviceIndex>; - explicit PeerConfigurerImpl( - const PeerNetworkDependencies& network_dependencies); + explicit PeerConfigurer(const PeerNetworkDependencies& network_dependencies); - PeerConfigurerImpl(rtc::Thread* network_thread, - rtc::NetworkManager* network_manager, - rtc::PacketSocketFactory* packet_socket_factory) + PeerConfigurer(rtc::Thread* network_thread, + rtc::NetworkManager* network_manager, + rtc::PacketSocketFactory* packet_socket_factory) : components_( std::make_unique(network_thread, network_manager, @@ -64,113 +60,107 @@ class PeerConfigurerImpl final // Sets peer name that will be used to report metrics related to this peer. // If not set, some default name will be assigned. All names have to be // unique. - PeerConfigurer* SetName(absl::string_view name) override; + PeerConfigurer* SetName(absl::string_view name); // The parameters of the following 9 methods will be passed to the // PeerConnectionFactoryInterface implementation that will be created for // this peer. PeerConfigurer* SetTaskQueueFactory( - std::unique_ptr task_queue_factory) override; + std::unique_ptr task_queue_factory); PeerConfigurer* SetCallFactory( - std::unique_ptr call_factory) override; + std::unique_ptr call_factory); PeerConfigurer* SetEventLogFactory( - std::unique_ptr event_log_factory) override; + std::unique_ptr event_log_factory); PeerConfigurer* SetFecControllerFactory( - std::unique_ptr fec_controller_factory) - override; + std::unique_ptr fec_controller_factory); PeerConfigurer* SetNetworkControllerFactory( std::unique_ptr - network_controller_factory) override; + network_controller_factory); PeerConfigurer* SetVideoEncoderFactory( - std::unique_ptr video_encoder_factory) override; + std::unique_ptr video_encoder_factory); PeerConfigurer* SetVideoDecoderFactory( - std::unique_ptr video_decoder_factory) override; + std::unique_ptr video_decoder_factory); // Set a custom NetEqFactory to be used in the call. - PeerConfigurer* SetNetEqFactory( - std::unique_ptr neteq_factory) override; + PeerConfigurer* SetNetEqFactory(std::unique_ptr neteq_factory); PeerConfigurer* SetAudioProcessing( - rtc::scoped_refptr audio_processing) override; + rtc::scoped_refptr audio_processing); PeerConfigurer* SetAudioMixer( - rtc::scoped_refptr audio_mixer) override; + rtc::scoped_refptr audio_mixer); // Forces the Peerconnection to use the network thread as the worker thread. // Ie, worker thread and the network thread is the same thread. - PeerConfigurer* SetUseNetworkThreadAsWorkerThread() override; + PeerConfigurer* SetUseNetworkThreadAsWorkerThread(); // The parameters of the following 4 methods will be passed to the // PeerConnectionInterface implementation that will be created for this // peer. PeerConfigurer* SetAsyncResolverFactory( - std::unique_ptr async_resolver_factory) - override; + std::unique_ptr async_resolver_factory); PeerConfigurer* SetRTCCertificateGenerator( - std::unique_ptr cert_generator) - override; + std::unique_ptr cert_generator); PeerConfigurer* SetSSLCertificateVerifier( - std::unique_ptr tls_cert_verifier) override; + std::unique_ptr tls_cert_verifier); PeerConfigurer* SetIceTransportFactory( - std::unique_ptr factory) override; + std::unique_ptr factory); // Flags to set on `cricket::PortAllocator`. These flags will be added // to the default ones that are presented on the port allocator. // For possible values check p2p/base/port_allocator.h. - PeerConfigurer* SetPortAllocatorExtraFlags(uint32_t extra_flags) override; + PeerConfigurer* SetPortAllocatorExtraFlags(uint32_t extra_flags); // Add new video stream to the call that will be sent from this peer. // Default implementation of video frames generator will be used. - PeerConfigurer* AddVideoConfig(VideoConfig config) override; + PeerConfigurer* AddVideoConfig(VideoConfig config); // Add new video stream to the call that will be sent from this peer with // provided own implementation of video frames generator. PeerConfigurer* AddVideoConfig( VideoConfig config, - std::unique_ptr generator) override; + std::unique_ptr generator); // Add new video stream to the call that will be sent from this peer. // Capturing device with specified index will be used to get input video. - PeerConfigurer* AddVideoConfig( - VideoConfig config, - CapturingDeviceIndex capturing_device_index) override; + PeerConfigurer* AddVideoConfig(VideoConfig config, + CapturingDeviceIndex capturing_device_index); // Sets video subscription for the peer. By default subscription will // include all streams with `VideoSubscription::kSameAsSendStream` - // resolution. To override this behavior use this method. - PeerConfigurer* SetVideoSubscription(VideoSubscription subscription) override; + // resolution. To this behavior use this method. + PeerConfigurer* SetVideoSubscription(VideoSubscription subscription); // Set the list of video codecs used by the peer during the test. These // codecs will be negotiated in SDP during offer/answer exchange. The order // of these codecs during negotiation will be the same as in `video_codecs`. // Codecs have to be available in codecs list provided by peer connection to // be negotiated. If some of specified codecs won't be found, the test will // crash. - PeerConfigurer* SetVideoCodecs( - std::vector video_codecs) override; + PeerConfigurer* SetVideoCodecs(std::vector video_codecs); // Set the audio stream for the call from this peer. If this method won't // be invoked, this peer will send no audio. - PeerConfigurer* SetAudioConfig(AudioConfig config) override; + PeerConfigurer* SetAudioConfig(AudioConfig config); // Set if ULP FEC should be used or not. False by default. - PeerConfigurer* SetUseUlpFEC(bool value) override; + PeerConfigurer* SetUseUlpFEC(bool value); // Set if Flex FEC should be used or not. False by default. // Client also must enable `enable_flex_fec_support` in the `RunParams` to // be able to use this feature. - PeerConfigurer* SetUseFlexFEC(bool value) override; + PeerConfigurer* SetUseFlexFEC(bool value); // Specifies how much video encoder target bitrate should be different than // target bitrate, provided by WebRTC stack. Must be greater than 0. Can be // used to emulate overshooting of video encoders. This multiplier will // be applied for all video encoder on both sides for all layers. Bitrate // estimated by WebRTC stack will be multiplied by this multiplier and then // provided into VideoEncoder::SetRates(...). 1.0 by default. - PeerConfigurer* SetVideoEncoderBitrateMultiplier(double multiplier) override; + PeerConfigurer* SetVideoEncoderBitrateMultiplier(double multiplier); // If is set, an RTCEventLog will be saved in that location and it will be // available for further analysis. - PeerConfigurer* SetRtcEventLogPath(std::string path) override; + PeerConfigurer* SetRtcEventLogPath(std::string path); // If is set, an AEC dump will be saved in that location and it will be // available for further analysis. - PeerConfigurer* SetAecDumpPath(std::string path) override; + PeerConfigurer* SetAecDumpPath(std::string path); PeerConfigurer* SetRTCConfiguration( - PeerConnectionInterface::RTCConfiguration configuration) override; + PeerConnectionInterface::RTCConfiguration configuration); PeerConfigurer* SetRTCOfferAnswerOptions( - PeerConnectionInterface::RTCOfferAnswerOptions options) override; + PeerConnectionInterface::RTCOfferAnswerOptions options); // Set bitrate parameters on PeerConnection. This constraints will be // applied to all summed RTP streams for this peer. - PeerConfigurer* SetBitrateSettings(BitrateSettings bitrate_settings) override; + PeerConfigurer* SetBitrateSettings(BitrateSettings bitrate_settings); // Returns InjectableComponents and transfer ownership to the caller. // Can be called once. @@ -206,53 +196,6 @@ class PeerConfigurerImpl final std::vector video_sources_; }; -class DefaultNamesProvider { - public: - // Caller have to ensure that default names array will outlive names provider - // instance. - explicit DefaultNamesProvider( - absl::string_view prefix, - rtc::ArrayView default_names = {}); - - void MaybeSetName(absl::optional& name); - - private: - std::string GenerateName(); - - std::string GenerateNameInternal(); - - const std::string prefix_; - const rtc::ArrayView default_names_; - - std::set known_names_; - size_t counter_ = 0; -}; - -class PeerParamsPreprocessor { - public: - PeerParamsPreprocessor(); - - // Set missing params to default values if it is required: - // * Generate video stream labels if some of them are missing - // * Generate audio stream labels if some of them are missing - // * Set video source generation mode if it is not specified - // * Video codecs under test - void SetDefaultValuesForMissingParams(PeerConfigurerImpl& peer); - - // Validate peer's parameters, also ensure uniqueness of all video stream - // labels. - void ValidateParams(const PeerConfigurerImpl& peer); - - private: - DefaultNamesProvider peer_names_provider_; - - std::set peer_names_; - std::set video_labels_; - std::set audio_labels_; - std::set video_sync_groups_; - std::set audio_sync_groups_; -}; - } // namespace webrtc_pc_e2e } // namespace webrtc diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 9bf08239ac..d031bcd16f 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -38,6 +38,7 @@ #include "api/test/frame_generator_interface.h" #include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_quality_test_params.h" +#include "api/test/pclf/peer_configurer.h" #include "api/test/peer_network_dependencies.h" #include "api/test/simulated_network.h" #include "api/test/stats_observer_interface.h" @@ -76,127 +77,7 @@ class PeerConnectionE2EQualityTestFixture { using VideoSubscription = ::webrtc::webrtc_pc_e2e::VideoSubscription; using EchoEmulationConfig = ::webrtc::webrtc_pc_e2e::EchoEmulationConfig; using RunParams = ::webrtc::webrtc_pc_e2e::RunParams; - - // This class is used to fully configure one peer inside the call. - class PeerConfigurer { - public: - virtual ~PeerConfigurer() = default; - - // Sets peer name that will be used to report metrics related to this peer. - // If not set, some default name will be assigned. All names have to be - // unique. - virtual PeerConfigurer* SetName(absl::string_view name) = 0; - - // The parameters of the following 9 methods will be passed to the - // PeerConnectionFactoryInterface implementation that will be created for - // this peer. - virtual PeerConfigurer* SetTaskQueueFactory( - std::unique_ptr task_queue_factory) = 0; - virtual PeerConfigurer* SetCallFactory( - std::unique_ptr call_factory) = 0; - virtual PeerConfigurer* SetEventLogFactory( - std::unique_ptr event_log_factory) = 0; - virtual PeerConfigurer* SetFecControllerFactory( - std::unique_ptr - fec_controller_factory) = 0; - virtual PeerConfigurer* SetNetworkControllerFactory( - std::unique_ptr - network_controller_factory) = 0; - virtual PeerConfigurer* SetVideoEncoderFactory( - std::unique_ptr video_encoder_factory) = 0; - virtual PeerConfigurer* SetVideoDecoderFactory( - std::unique_ptr video_decoder_factory) = 0; - // Set a custom NetEqFactory to be used in the call. - virtual PeerConfigurer* SetNetEqFactory( - std::unique_ptr neteq_factory) = 0; - virtual PeerConfigurer* SetAudioProcessing( - rtc::scoped_refptr audio_processing) = 0; - virtual PeerConfigurer* SetAudioMixer( - rtc::scoped_refptr audio_mixer) = 0; - - // Forces the Peerconnection to use the network thread as the worker thread. - // Ie, worker thread and the network thread is the same thread. - virtual PeerConfigurer* SetUseNetworkThreadAsWorkerThread() = 0; - - // The parameters of the following 4 methods will be passed to the - // PeerConnectionInterface implementation that will be created for this - // peer. - virtual PeerConfigurer* SetAsyncResolverFactory( - std::unique_ptr - async_resolver_factory) = 0; - virtual PeerConfigurer* SetRTCCertificateGenerator( - std::unique_ptr - cert_generator) = 0; - virtual PeerConfigurer* SetSSLCertificateVerifier( - std::unique_ptr tls_cert_verifier) = 0; - virtual PeerConfigurer* SetIceTransportFactory( - std::unique_ptr factory) = 0; - // Flags to set on `cricket::PortAllocator`. These flags will be added - // to the default ones that are presented on the port allocator. - // For possible values check p2p/base/port_allocator.h. - virtual PeerConfigurer* SetPortAllocatorExtraFlags( - uint32_t extra_flags) = 0; - - // Add new video stream to the call that will be sent from this peer. - // Default implementation of video frames generator will be used. - virtual PeerConfigurer* AddVideoConfig(VideoConfig config) = 0; - // Add new video stream to the call that will be sent from this peer with - // provided own implementation of video frames generator. - virtual PeerConfigurer* AddVideoConfig( - VideoConfig config, - std::unique_ptr generator) = 0; - // Add new video stream to the call that will be sent from this peer. - // Capturing device with specified index will be used to get input video. - virtual PeerConfigurer* AddVideoConfig( - VideoConfig config, - CapturingDeviceIndex capturing_device_index) = 0; - // Sets video subscription for the peer. By default subscription will - // include all streams with `VideoSubscription::kSameAsSendStream` - // resolution. To override this behavior use this method. - virtual PeerConfigurer* SetVideoSubscription( - VideoSubscription subscription) = 0; - // Set the list of video codecs used by the peer during the test. These - // codecs will be negotiated in SDP during offer/answer exchange. The order - // of these codecs during negotiation will be the same as in `video_codecs`. - // Codecs have to be available in codecs list provided by peer connection to - // be negotiated. If some of specified codecs won't be found, the test will - // crash. - virtual PeerConfigurer* SetVideoCodecs( - std::vector video_codecs) = 0; - // 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 if ULP FEC should be used or not. False by default. - virtual PeerConfigurer* SetUseUlpFEC(bool value) = 0; - // Set if Flex FEC should be used or not. False by default. - // Client also must enable `enable_flex_fec_support` in the `RunParams` to - // be able to use this feature. - virtual PeerConfigurer* SetUseFlexFEC(bool value) = 0; - // Specifies how much video encoder target bitrate should be different than - // target bitrate, provided by WebRTC stack. Must be greater than 0. Can be - // used to emulate overshooting of video encoders. This multiplier will - // be applied for all video encoder on both sides for all layers. Bitrate - // estimated by WebRTC stack will be multiplied by this multiplier and then - // provided into VideoEncoder::SetRates(...). 1.0 by default. - virtual PeerConfigurer* SetVideoEncoderBitrateMultiplier( - double multiplier) = 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; - // If is set, an AEC dump will be saved in that location and it will be - // available for further analysis. - virtual PeerConfigurer* SetAecDumpPath(std::string path) = 0; - virtual PeerConfigurer* SetRTCConfiguration( - PeerConnectionInterface::RTCConfiguration configuration) = 0; - virtual PeerConfigurer* SetRTCOfferAnswerOptions( - PeerConnectionInterface::RTCOfferAnswerOptions options) = 0; - // Set bitrate parameters on PeerConnection. This constraints will be - // applied to all summed RTP streams for this peer. - virtual PeerConfigurer* SetBitrateSettings( - BitrateSettings bitrate_settings) = 0; - }; + using PeerConfigurer = ::webrtc::webrtc_pc_e2e::PeerConfigurer; // Represent an entity that will report quality metrics after test. class QualityMetricsReporter : public StatsObserverInterface { diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 92b8f9a531..27e1e71134 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -348,7 +348,6 @@ if (!build_with_chromium) { ":video_quality_analyzer_injection_helper", "../..:copy_to_file_audio_capturer", "../../../api:create_time_controller", - "../../../api:peer_connection_quality_test_fixture_api", "../../../api:time_controller", "../../../api/rtc_event_log:rtc_event_log_factory", "../../../api/task_queue:default_task_queue_factory", @@ -402,7 +401,30 @@ if (!build_with_chromium) { visibility = [ "*" ] testonly = true sources = [ "peer_configurer.h" ] - deps = [ "../../../api/test/pclf:peer_configurer" ] + deps = [ + ":peer_params_preprocessor", + "../../../api/test/pclf:peer_configurer", + ] + } + + rtc_library("peer_params_preprocessor") { + visibility = [ "*" ] + testonly = true + sources = [ + "peer_params_preprocessor.cc", + "peer_params_preprocessor.h", + ] + deps = [ + "../..:fileutils", + "../../../api:peer_network_dependencies", + "../../../api/test/pclf:media_configuration", + "../../../api/test/pclf:media_quality_test_params", + "../../../api/test/pclf:peer_configurer", + "../../../modules/video_coding/svc:scalability_mode_util", + "../../../modules/video_coding/svc:scalability_structures", + "../../../rtc_base:macromagic", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("test_activities_executor") { @@ -445,6 +467,7 @@ if (!build_with_chromium) { ":default_video_quality_analyzer", ":media_helper", ":metric_metadata_keys", + ":peer_params_preprocessor", ":sdp_changer", ":single_process_encoded_image_data_injector", ":stats_poller", diff --git a/test/pc/e2e/media/media_helper.cc b/test/pc/e2e/media/media_helper.cc index b4b317ac97..3f6d069429 100644 --- a/test/pc/e2e/media/media_helper.cc +++ b/test/pc/e2e/media/media_helper.cc @@ -16,6 +16,7 @@ #include "api/media_stream_interface.h" #include "api/test/create_frame_generator.h" #include "api/test/pclf/media_configuration.h" +#include "api/test/pclf/peer_configurer.h" #include "test/frame_generator_capturer.h" #include "test/platform_video_capturer.h" #include "test/testsupport/file_utils.h" @@ -96,7 +97,7 @@ MediaHelper::MaybeAddVideo(TestPeer* peer) { std::unique_ptr MediaHelper::CreateVideoCapturer( const VideoConfig& video_config, - PeerConfigurerImpl::VideoSource source, + PeerConfigurer::VideoSource source, std::unique_ptr frame_preprocessor) { CapturingDeviceIndex* capturing_device_index = diff --git a/test/pc/e2e/media/media_helper.h b/test/pc/e2e/media/media_helper.h index 9f0f1f79a1..2d163d009e 100644 --- a/test/pc/e2e/media/media_helper.h +++ b/test/pc/e2e/media/media_helper.h @@ -43,7 +43,7 @@ class MediaHelper { private: std::unique_ptr CreateVideoCapturer( const VideoConfig& video_config, - PeerConfigurerImpl::VideoSource source, + PeerConfigurer::VideoSource source, std::unique_ptr frame_preprocessor); diff --git a/test/pc/e2e/peer_configurer.h b/test/pc/e2e/peer_configurer.h index be8410b220..d4b2d2f12c 100644 --- a/test/pc/e2e/peer_configurer.h +++ b/test/pc/e2e/peer_configurer.h @@ -11,5 +11,14 @@ #define TEST_PC_E2E_PEER_CONFIGURER_H_ #include "api/test/pclf/peer_configurer.h" +#include "test/pc/e2e/peer_params_preprocessor.h" + +namespace webrtc { +namespace webrtc_pc_e2e { + +using PeerConfigurerImpl = ::webrtc::webrtc_pc_e2e::PeerConfigurer; + +} // namespace webrtc_pc_e2e +} // namespace webrtc #endif // TEST_PC_E2E_PEER_CONFIGURER_H_ diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index aa959f9227..90bc5c2d1f 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -23,6 +23,7 @@ #include "api/scoped_refptr.h" #include "api/test/metrics/metric.h" #include "api/test/pclf/media_configuration.h" +#include "api/test/pclf/peer_configurer.h" #include "api/test/time_controller.h" #include "api/test/video_quality_analyzer_interface.h" #include "pc/sdp_utils.h" @@ -40,6 +41,7 @@ #include "test/pc/e2e/analyzer/video/video_quality_metrics_reporter.h" #include "test/pc/e2e/cross_media_metrics_reporter.h" #include "test/pc/e2e/metric_metadata_keys.h" +#include "test/pc/e2e/peer_params_preprocessor.h" #include "test/pc/e2e/stats_poller.h" #include "test/pc/e2e/test_peer_factory.h" #include "test/testsupport/file_utils.h" @@ -108,7 +110,7 @@ class FixturePeerConnectionObserver : public MockPeerConnectionObserver { }; void ValidateP2PSimulcastParams( - const std::vector>& peers) { + const std::vector>& peers) { for (size_t i = 0; i < peers.size(); ++i) { Params* params = peers[i]->params(); ConfigurableParams* configurable_params = peers[i]->configurable_params(); @@ -197,7 +199,7 @@ PeerConnectionE2EQualityTest::PeerHandle* PeerConnectionE2EQualityTest::AddPeer( const PeerNetworkDependencies& network_dependencies, rtc::FunctionView configurer) { peer_configurations_.push_back( - std::make_unique(network_dependencies)); + std::make_unique(network_dependencies)); configurer(peer_configurations_.back().get()); peer_handles_.push_back(PeerHandleImpl()); return &peer_handles_.back(); @@ -213,9 +215,9 @@ 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_configurer = + std::unique_ptr alice_configurer = std::move(peer_configurations_[0]); - std::unique_ptr bob_configurer = + std::unique_ptr bob_configurer = std::move(peer_configurations_[1]); peer_configurations_.clear(); diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index 1cf03198b5..9ee59b7f9c 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -45,7 +45,6 @@ namespace webrtc_pc_e2e { class PeerConnectionE2EQualityTest : public PeerConnectionE2EQualityTestFixture { public: - using PeerConfigurer = PeerConnectionE2EQualityTestFixture::PeerConfigurer; using QualityMetricsReporter = PeerConnectionE2EQualityTestFixture::QualityMetricsReporter; @@ -124,7 +123,7 @@ class PeerConnectionE2EQualityTest std::unique_ptr executor_; test::MetricsLogger* const metrics_logger_; - std::vector> peer_configurations_; + std::vector> peer_configurations_; std::vector peer_handles_; std::unique_ptr alice_; diff --git a/test/pc/e2e/peer_params_preprocessor.cc b/test/pc/e2e/peer_params_preprocessor.cc new file mode 100644 index 0000000000..05372125d2 --- /dev/null +++ b/test/pc/e2e/peer_params_preprocessor.cc @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "test/pc/e2e/peer_params_preprocessor.h" + +#include +#include + +#include "absl/strings/string_view.h" +#include "api/test/pclf/media_configuration.h" +#include "api/test/pclf/media_quality_test_params.h" +#include "api/test/pclf/peer_configurer.h" +#include "api/test/peer_network_dependencies.h" +#include "modules/video_coding/svc/create_scalability_structure.h" +#include "modules/video_coding/svc/scalability_mode_util.h" +#include "rtc_base/arraysize.h" +#include "test/testsupport/file_utils.h" + +namespace webrtc { +namespace webrtc_pc_e2e { +namespace { + +// List of default names of generic participants according to +// https://en.wikipedia.org/wiki/Alice_and_Bob +constexpr absl::string_view kDefaultNames[] = {"alice", "bob", "charlie", + "david", "erin", "frank"}; + +} // namespace + +class PeerParamsPreprocessor::DefaultNamesProvider { + public: + // Caller have to ensure that default names array will outlive names provider + // instance. + explicit DefaultNamesProvider( + absl::string_view prefix, + rtc::ArrayView default_names = {}) + : prefix_(prefix), default_names_(default_names) {} + + void MaybeSetName(absl::optional& name) { + if (name.has_value()) { + known_names_.insert(name.value()); + } else { + name = GenerateName(); + } + } + + private: + std::string GenerateName() { + std::string name; + do { + name = GenerateNameInternal(); + } while (!known_names_.insert(name).second); + return name; + } + + std::string GenerateNameInternal() { + if (counter_ < default_names_.size()) { + return std::string(default_names_[counter_++]); + } + return prefix_ + std::to_string(counter_++); + } + + const std::string prefix_; + const rtc::ArrayView default_names_; + + std::set known_names_; + size_t counter_ = 0; +}; + +PeerParamsPreprocessor::PeerParamsPreprocessor() + : peer_names_provider_( + std::make_unique("peer_", kDefaultNames)) {} +PeerParamsPreprocessor::~PeerParamsPreprocessor() = default; + +void PeerParamsPreprocessor::SetDefaultValuesForMissingParams( + PeerConfigurer& peer) { + Params* params = peer.params(); + ConfigurableParams* configurable_params = peer.configurable_params(); + peer_names_provider_->MaybeSetName(params->name); + DefaultNamesProvider video_stream_names_provider(*params->name + + "_auto_video_stream_label_"); + for (VideoConfig& config : configurable_params->video_configs) { + video_stream_names_provider.MaybeSetName(config.stream_label); + } + if (params->audio_config) { + DefaultNamesProvider audio_stream_names_provider( + *params->name + "_auto_audio_stream_label_"); + audio_stream_names_provider.MaybeSetName( + params->audio_config->stream_label); + } + + if (params->video_codecs.empty()) { + params->video_codecs.push_back(VideoCodecConfig(cricket::kVp8CodecName)); + } +} + +void PeerParamsPreprocessor::ValidateParams(const PeerConfigurer& peer) { + const Params& p = peer.params(); + RTC_CHECK_GT(p.video_encoder_bitrate_multiplier, 0.0); + // Each peer should at least support 1 video codec. + RTC_CHECK_GE(p.video_codecs.size(), 1); + + { + RTC_CHECK(p.name); + bool inserted = peer_names_.insert(p.name.value()).second; + RTC_CHECK(inserted) << "Duplicate name=" << p.name.value(); + } + + // Validate that all video stream labels are unique and sync groups are + // valid. + for (const VideoConfig& video_config : + peer.configurable_params().video_configs) { + RTC_CHECK(video_config.stream_label); + bool inserted = + video_labels_.insert(video_config.stream_label.value()).second; + RTC_CHECK(inserted) << "Duplicate video_config.stream_label=" + << video_config.stream_label.value(); + + // TODO(bugs.webrtc.org/4762): remove this check after synchronization of + // more than two streams is supported. + if (video_config.sync_group.has_value()) { + bool sync_group_inserted = + video_sync_groups_.insert(video_config.sync_group.value()).second; + RTC_CHECK(sync_group_inserted) + << "Sync group shouldn't consist of more than two streams (one " + "video and one audio). Duplicate video_config.sync_group=" + << video_config.sync_group.value(); + } + + if (video_config.simulcast_config) { + if (!video_config.encoding_params.empty()) { + RTC_CHECK_EQ(video_config.simulcast_config->simulcast_streams_count, + video_config.encoding_params.size()) + << "|encoding_params| have to be specified for each simulcast " + << "stream in |video_config|."; + } + } else { + RTC_CHECK_LE(video_config.encoding_params.size(), 1) + << "|encoding_params| has multiple values but simulcast is not " + "enabled."; + } + + if (video_config.emulated_sfu_config) { + if (video_config.simulcast_config && + video_config.emulated_sfu_config->target_layer_index) { + RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, + video_config.simulcast_config->simulcast_streams_count); + } + if (!video_config.encoding_params.empty()) { + bool is_svc = false; + for (const auto& encoding_param : video_config.encoding_params) { + if (!encoding_param.scalability_mode) + continue; + + absl::optional scalability_mode = + ScalabilityModeFromString(*encoding_param.scalability_mode); + RTC_CHECK(scalability_mode) << "Unknown scalability_mode requested"; + + absl::optional + stream_layers_config = + ScalabilityStructureConfig(*scalability_mode); + is_svc |= stream_layers_config->num_spatial_layers > 1; + RTC_CHECK(stream_layers_config->num_spatial_layers == 1 || + video_config.encoding_params.size() == 1) + << "Can't enable SVC modes with multiple spatial layers (" + << stream_layers_config->num_spatial_layers + << " layers) or simulcast (" + << video_config.encoding_params.size() << " layers)"; + if (video_config.emulated_sfu_config->target_layer_index) { + RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, + stream_layers_config->num_spatial_layers); + } + } + if (!is_svc && video_config.emulated_sfu_config->target_layer_index) { + RTC_CHECK_LT(*video_config.emulated_sfu_config->target_layer_index, + video_config.encoding_params.size()); + } + } + } + } + if (p.audio_config) { + bool inserted = + audio_labels_.insert(p.audio_config->stream_label.value()).second; + RTC_CHECK(inserted) << "Duplicate audio_config.stream_label=" + << p.audio_config->stream_label.value(); + // TODO(bugs.webrtc.org/4762): remove this check after synchronization of + // more than two streams is supported. + if (p.audio_config->sync_group.has_value()) { + bool sync_group_inserted = + audio_sync_groups_.insert(p.audio_config->sync_group.value()).second; + RTC_CHECK(sync_group_inserted) + << "Sync group shouldn't consist of more than two streams (one " + "video and one audio). Duplicate audio_config.sync_group=" + << p.audio_config->sync_group.value(); + } + // Check that if mode input file name specified only if mode is kFile. + if (p.audio_config.value().mode == AudioConfig::Mode::kGenerated) { + RTC_CHECK(!p.audio_config.value().input_file_name); + } + if (p.audio_config.value().mode == AudioConfig::Mode::kFile) { + RTC_CHECK(p.audio_config.value().input_file_name); + RTC_CHECK( + test::FileExists(p.audio_config.value().input_file_name.value())) + << p.audio_config.value().input_file_name.value() << " doesn't exist"; + } + } +} + +} // namespace webrtc_pc_e2e +} // namespace webrtc diff --git a/test/pc/e2e/peer_params_preprocessor.h b/test/pc/e2e/peer_params_preprocessor.h new file mode 100644 index 0000000000..c222811546 --- /dev/null +++ b/test/pc/e2e/peer_params_preprocessor.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 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_PARAMS_PREPROCESSOR_H_ +#define TEST_PC_E2E_PEER_PARAMS_PREPROCESSOR_H_ + +#include +#include +#include + +#include "api/test/pclf/peer_configurer.h" + +namespace webrtc { +namespace webrtc_pc_e2e { + +class PeerParamsPreprocessor { + public: + PeerParamsPreprocessor(); + ~PeerParamsPreprocessor(); + + // Set missing params to default values if it is required: + // * Generate video stream labels if some of them are missing + // * Generate audio stream labels if some of them are missing + // * Set video source generation mode if it is not specified + // * Video codecs under test + void SetDefaultValuesForMissingParams(PeerConfigurer& peer); + + // Validate peer's parameters, also ensure uniqueness of all video stream + // labels. + void ValidateParams(const PeerConfigurer& peer); + + private: + class DefaultNamesProvider; + std::unique_ptr peer_names_provider_; + + std::set peer_names_; + std::set video_labels_; + std::set audio_labels_; + std::set video_sync_groups_; + std::set audio_sync_groups_; +}; + +} // namespace webrtc_pc_e2e +} // namespace webrtc + +#endif // TEST_PC_E2E_PEER_PARAMS_PREPROCESSOR_H_ diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc index 3e01c03f13..b3a9e1c164 100644 --- a/test/pc/e2e/test_peer.cc +++ b/test/pc/e2e/test_peer.cc @@ -16,6 +16,7 @@ #include "absl/strings/string_view.h" #include "api/scoped_refptr.h" #include "api/test/pclf/media_configuration.h" +#include "api/test/pclf/peer_configurer.h" #include "modules/audio_processing/include/audio_processing.h" namespace webrtc { @@ -132,7 +133,7 @@ TestPeer::TestPeer( std::unique_ptr observer, Params params, ConfigurableParams configurable_params, - std::vector video_sources, + std::vector video_sources, rtc::scoped_refptr audio_processing, std::unique_ptr worker_thread) : params_(std::move(params)), diff --git a/test/pc/e2e/test_peer.h b/test/pc/e2e/test_peer.h index dc4a699674..1088871817 100644 --- a/test/pc/e2e/test_peer.h +++ b/test/pc/e2e/test_peer.h @@ -49,7 +49,7 @@ class TestPeer final : public StatsProvider { void GetStats(RTCStatsCollectorCallback* callback) override; - PeerConfigurerImpl::VideoSource ReleaseVideoSource(size_t i) { + PeerConfigurer::VideoSource ReleaseVideoSource(size_t i) { RTC_CHECK(wrapper_) << "TestPeer is already closed"; return std::move(video_sources_[i]); } @@ -156,7 +156,7 @@ class TestPeer final : public StatsProvider { std::unique_ptr observer, Params params, ConfigurableParams configurable_params, - std::vector video_sources, + std::vector video_sources, rtc::scoped_refptr audio_processing, std::unique_ptr worker_thread); @@ -176,7 +176,7 @@ class TestPeer final : public StatsProvider { // worker thread and network thread. std::unique_ptr worker_thread_; std::unique_ptr wrapper_; - std::vector video_sources_; + std::vector video_sources_; rtc::scoped_refptr audio_processing_; std::vector> remote_ice_candidates_; diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 389fa3f821..7fc12f2c11 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -290,7 +290,7 @@ absl::optional RemotePeerAudioConfig::Create( } std::unique_ptr TestPeerFactory::CreateTestPeer( - std::unique_ptr configurer, + std::unique_ptr configurer, std::unique_ptr observer, absl::optional remote_audio_config, absl::optional echo_emulation_config) { @@ -299,7 +299,7 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( std::unique_ptr params = configurer->ReleaseParams(); std::unique_ptr configurable_params = configurer->ReleaseConfigurableParams(); - std::vector video_sources = + std::vector video_sources = configurer->ReleaseVideoSources(); RTC_DCHECK(components); RTC_DCHECK(params); diff --git a/test/pc/e2e/test_peer_factory.h b/test/pc/e2e/test_peer_factory.h index 1b9530b141..f2698e2a15 100644 --- a/test/pc/e2e/test_peer_factory.h +++ b/test/pc/e2e/test_peer_factory.h @@ -21,7 +21,6 @@ #include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_quality_test_params.h" #include "api/test/pclf/peer_configurer.h" -#include "api/test/peerconnection_quality_test_fixture.h" #include "api/test/time_controller.h" #include "modules/audio_device/include/test_audio_device.h" #include "rtc_base/task_queue.h" @@ -67,7 +66,7 @@ class TestPeerFactory { // also will setup dependencies, that are required for media analyzers // injection. std::unique_ptr CreateTestPeer( - std::unique_ptr configurer, + std::unique_ptr configurer, std::unique_ptr observer, absl::optional remote_audio_config, absl::optional echo_emulation_config);