From b92d3e6ef98e75a950e0b018b64a17dd77480b82 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 15 Feb 2022 18:46:21 +0100 Subject: [PATCH] [PCLF] Move FEC and bitrate mulitplier into per peer configs Bug: b/213863770 Change-Id: Idcf37150e769db18d4a12baa1057840d521b8e1f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251761 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Mirko Bonadei Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/main@{#36006} --- .../peerconnection_quality_test_fixture.h | 25 +++ test/pc/e2e/peer_configurer.cc | 192 ++++++++++++++---- test/pc/e2e/peer_configurer.h | 65 ++++++ test/pc/e2e/peer_connection_e2e_smoke_test.cc | 24 ++- test/pc/e2e/peer_connection_quality_test.cc | 26 +-- test/pc/e2e/peer_connection_quality_test.h | 2 +- .../e2e/peer_connection_quality_test_params.h | 10 + test/pc/e2e/test_peer_factory.cc | 13 ++ test/pc/e2e/test_peer_factory.h | 7 + video/pc_full_stack_tests.cc | 178 +++++----------- 10 files changed, 345 insertions(+), 197 deletions(-) diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 303671c12d..c352aa9da5 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -396,6 +396,22 @@ class PeerConnectionE2EQualityTestFixture { // 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; @@ -427,8 +443,17 @@ class PeerConnectionE2EQualityTestFixture { // it will be shut downed. TimeDelta run_duration; + // If set to true peers will be able to use Flex FEC, otherwise they won't + // be able to negotiate it even if it's enabled on per peer level. + bool enable_flex_fec_support = false; + // TODO(titovartem): delete this field. + // Deprecated. Use `PeerConfigurer::SetUseUlpFEC`. bool use_ulp_fec = false; + // TODO(titovartem): delete this field. + // Deprecated. Use `PeerConfigurer::SetUseFlexFEC`. bool use_flex_fec = false; + // TODO(titovartem): delete this field. + // Deprecated. Use `PeerConfigurer::SetVideoEncoderBitrateMultiplier`. // Specifies how much video encoder target bitrate should be different than // target bitrate, provided by WebRTC stack. Must be greater then 0. Can be // used to emulate overshooting of video encoders. This multiplier will diff --git a/test/pc/e2e/peer_configurer.cc b/test/pc/e2e/peer_configurer.cc index ec147fe24c..00d6f79745 100644 --- a/test/pc/e2e/peer_configurer.cc +++ b/test/pc/e2e/peer_configurer.cc @@ -30,48 +30,154 @@ using VideoCodecConfig = PeerConnectionE2EQualityTestFixture::VideoCodecConfig; constexpr absl::string_view kDefaultNames[] = {"alice", "bob", "charlie", "david", "erin", "frank"}; -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 = {}) - : 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; -}; - } // namespace +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) { + auto* p = peer.params(); + peer_names_provider.MaybeSetName(p->name); + DefaultNamesProvider video_stream_names_provider(*p->name + + "_auto_video_stream_label_"); + for (VideoConfig& video_config : p->video_configs) { + video_stream_names_provider.MaybeSetName(video_config.stream_label); + } + if (p->audio_config) { + DefaultNamesProvider audio_stream_names_provider( + *p->name + "_auto_audio_stream_label_"); + audio_stream_names_provider.MaybeSetName(p->audio_config->stream_label); + } + + if (p->video_codecs.empty()) { + p->video_codecs.push_back( + PeerConnectionE2EQualityTestFixture::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(); + } + + if (p.audio_config) { + media_streams_count++; + } + media_streams_count += p.video_configs.size(); + + // Validate that all video stream labels are unique and sync groups are + // valid. + for (const VideoConfig& video_config : p.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(); + + if (video_config.input_dump_file_name.has_value()) { + RTC_CHECK_GT(video_config.input_dump_sampling_modulo, 0) + << "video_config.input_dump_sampling_modulo must be greater than 0"; + } + if (video_config.output_dump_file_name.has_value()) { + RTC_CHECK_GT(video_config.output_dump_sampling_modulo, 0) + << "video_config.input_dump_sampling_modulo must be greater than 0"; + } + + // 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.simulcast_config->target_spatial_index) { + RTC_CHECK_GE(*video_config.simulcast_config->target_spatial_index, 0); + RTC_CHECK_LT(*video_config.simulcast_config->target_spatial_index, + video_config.simulcast_config->simulcast_streams_count); + } + RTC_CHECK(!video_config.max_encode_bitrate_bps) + << "Setting max encode bitrate is not implemented for simulcast."; + RTC_CHECK(!video_config.min_encode_bitrate_bps) + << "Setting min encode bitrate is not implemented for simulcast."; + if (p.video_codecs[0].name == cricket::kVp8CodecName && + !video_config.simulcast_config->encoding_params.empty()) { + RTC_CHECK_EQ(video_config.simulcast_config->simulcast_streams_count, + video_config.simulcast_config->encoding_params.size()) + << "|encoding_params| have to be specified for each simulcast " + << "stream in |simulcast_config|."; + } + } + } + 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"; + } + } +} + void SetDefaultValuesForMissingParams( RunParams* run_params, std::vector>* peers) { @@ -79,16 +185,16 @@ void SetDefaultValuesForMissingParams( for (size_t i = 0; i < peers->size(); ++i) { auto* peer = peers->at(i).get(); auto* p = peer->params(); - peer_names_provider.MaybeSetName(&p->name); + peer_names_provider.MaybeSetName(p->name); DefaultNamesProvider video_stream_names_provider( *p->name + "_auto_video_stream_label_"); for (VideoConfig& video_config : p->video_configs) { - video_stream_names_provider.MaybeSetName(&video_config.stream_label); + video_stream_names_provider.MaybeSetName(video_config.stream_label); } if (p->audio_config) { DefaultNamesProvider audio_stream_names_provider( *p->name + "_auto_audio_stream_label_"); - audio_stream_names_provider.MaybeSetName(&p->audio_config->stream_label); + audio_stream_names_provider.MaybeSetName(p->audio_config->stream_label); } if (p->video_codecs.empty()) { diff --git a/test/pc/e2e/peer_configurer.h b/test/pc/e2e/peer_configurer.h index 41eeb29549..89a26f5160 100644 --- a/test/pc/e2e/peer_configurer.h +++ b/test/pc/e2e/peer_configurer.h @@ -148,6 +148,18 @@ class PeerConfigurerImpl final params_->audio_config = std::move(config); return this; } + PeerConfigurer* SetUseUlpFEC(bool value) override { + params_->use_ulp_fec = value; + return this; + } + PeerConfigurer* SetUseFlexFEC(bool value) override { + params_->use_flex_fec = value; + return this; + } + PeerConfigurer* SetVideoEncoderBitrateMultiplier(double multiplier) override { + params_->video_encoder_bitrate_multiplier = multiplier; + return this; + } PeerConfigurer* SetNetEqFactory( std::unique_ptr neteq_factory) override { components_->pcf_dependencies->neteq_factory = std::move(neteq_factory); @@ -187,6 +199,7 @@ class PeerConfigurerImpl final InjectableComponents* components() { return components_.get(); } Params* params() { return params_.get(); } + const Params& params() const { return *params_; } std::vector* video_sources() { return &video_sources_; } // Returns InjectableComponents and transfer ownership to the caller. @@ -219,6 +232,56 @@ 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; + int media_streams_count = 0; +}; + +// TODO(titovartem): delete this method. +// Deprecated. Use `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 @@ -227,6 +290,8 @@ class PeerConfigurerImpl final void SetDefaultValuesForMissingParams( PeerConnectionE2EQualityTestFixture::RunParams* run_params, std::vector>* peers); +// TODO(titovartem): delete this method. +// Deprecated. Use `PeerParamsPreprocessor`. // Validate peer's parameters, also ensure uniqueness of all video stream // labels. void ValidateParams( diff --git a/test/pc/e2e/peer_connection_e2e_smoke_test.cc b/test/pc/e2e/peer_connection_e2e_smoke_test.cc index 5a7f10b9bc..f861d88a8e 100644 --- a/test/pc/e2e/peer_connection_e2e_smoke_test.cc +++ b/test/pc/e2e/peer_connection_e2e_smoke_test.cc @@ -147,6 +147,10 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Smoke) { alice->SetAudioConfig(std::move(audio)); alice->SetVideoCodecs( {VideoCodecConfig(cricket::kVp9CodecName, {{"profile-id", "0"}})}); + + alice->SetUseFlexFEC(true); + alice->SetUseUlpFEC(true); + alice->SetVideoEncoderBitrateMultiplier(1.1); }); AddPeer(network_links.second, [](PeerConfigurer* charlie) { charlie->SetName("charlie"); @@ -163,6 +167,10 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Smoke) { charlie->SetAudioConfig(std::move(audio)); charlie->SetVideoCodecs( {VideoCodecConfig(cricket::kVp9CodecName, {{"profile-id", "0"}})}); + + charlie->SetUseFlexFEC(true); + charlie->SetUseUlpFEC(true); + charlie->SetVideoEncoderBitrateMultiplier(1.1); }); fixture()->AddQualityMetricsReporter( std::make_unique( @@ -171,9 +179,7 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_Smoke) { {"charlie", network_links.second->endpoints()}}), network_emulation())); RunParams run_params(TimeDelta::Seconds(2)); - run_params.use_flex_fec = true; - run_params.use_ulp_fec = true; - run_params.video_encoder_bitrate_multiplier = 1.1; + run_params.enable_flex_fec_support = true; RunAndCheckEachVideoStreamReceivedFrames(run_params); } @@ -219,10 +225,18 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_ChangeNetworkConditions) { alice->AddVideoConfig(std::move(video)); alice->SetVideoCodecs( {VideoCodecConfig(cricket::kVp9CodecName, {{"profile-id", "0"}})}); + + alice->SetUseFlexFEC(true); + alice->SetUseUlpFEC(true); + alice->SetVideoEncoderBitrateMultiplier(1.1); }); AddPeer(bob_network, [](PeerConfigurer* bob) { bob->SetVideoCodecs( {VideoCodecConfig(cricket::kVp9CodecName, {{"profile-id", "0"}})}); + + bob->SetUseFlexFEC(true); + bob->SetUseUlpFEC(true); + bob->SetVideoEncoderBitrateMultiplier(1.1); }); fixture()->AddQualityMetricsReporter( std::make_unique( @@ -238,9 +252,7 @@ TEST_F(PeerConnectionE2EQualityTestSmokeTest, MAYBE_ChangeNetworkConditions) { }); RunParams run_params(TimeDelta::Seconds(2)); - run_params.use_flex_fec = true; - run_params.use_ulp_fec = true; - run_params.video_encoder_bitrate_multiplier = 1.1; + run_params.enable_flex_fec_support = true; RunAndCheckEachVideoStreamReceivedFrames(run_params); } diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 4875658fb5..34d5e80d3c 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -254,8 +254,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { OnTrackCallback(alice_name, transceiver, bob_video_configs); }, [this]() { StartVideo(alice_video_sources_); }), - alice_remote_audio_config, run_params.video_encoder_bitrate_multiplier, - run_params.echo_emulation_config); + alice_remote_audio_config, run_params.echo_emulation_config); bob_ = test_peer_factory.CreateTestPeer( std::move(bob_configurer), std::make_unique( @@ -264,8 +263,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { OnTrackCallback(bob_name, transceiver, alice_video_configs); }, [this]() { StartVideo(bob_video_sources_); }), - bob_remote_audio_config, run_params.video_encoder_bitrate_multiplier, - run_params.echo_emulation_config); + bob_remote_audio_config, run_params.echo_emulation_config); int num_cores = CpuInfo::DetectNumberOfCores(); RTC_DCHECK_GE(num_cores, 1); @@ -411,7 +409,7 @@ std::string PeerConnectionE2EQualityTest::GetFieldTrials( const RunParams& run_params) { std::vector default_field_trials = { kUseStandardsBytesStats}; - if (run_params.use_flex_fec) { + if (run_params.enable_flex_fec_support) { default_field_trials.push_back(kFlexFecEnabledFieldTrials); } rtc::StringBuilder sb; @@ -480,7 +478,7 @@ void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread( for (int i = 0; i < video_config.simulcast_config->simulcast_streams_count; ++i) { RtpEncodingParameters enc_params; - if (video_config.simulcast_config->encoding_params.size() > 0) { + if (!video_config.simulcast_config->encoding_params.empty()) { enc_params = video_config.simulcast_config->encoding_params[i]; } // We need to be sure, that all rids will be unique with all mids. @@ -523,28 +521,26 @@ void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread( media_helper_->MaybeAddAudio(bob_.get()); bob_video_sources_ = media_helper_->MaybeAddVideo(bob_.get()); - SetPeerCodecPreferences(alice_.get(), run_params); - SetPeerCodecPreferences(bob_.get(), run_params); + SetPeerCodecPreferences(alice_.get()); + SetPeerCodecPreferences(bob_.get()); } void PeerConnectionE2EQualityTest::TearDownCallOnSignalingThread() { TearDownCall(); } -void PeerConnectionE2EQualityTest::SetPeerCodecPreferences( - TestPeer* peer, - const RunParams& run_params) { +void PeerConnectionE2EQualityTest::SetPeerCodecPreferences(TestPeer* peer) { std::vector with_rtx_video_capabilities = FilterVideoCodecCapabilities( - peer->params()->video_codecs, true, run_params.use_ulp_fec, - run_params.use_flex_fec, + peer->params()->video_codecs, true, peer->params()->use_ulp_fec, + peer->params()->use_flex_fec, peer->pc_factory() ->GetRtpSenderCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO) .codecs); std::vector without_rtx_video_capabilities = FilterVideoCodecCapabilities( - peer->params()->video_codecs, false, run_params.use_ulp_fec, - run_params.use_flex_fec, + peer->params()->video_codecs, false, peer->params()->use_ulp_fec, + peer->params()->use_flex_fec, peer->pc_factory() ->GetRtpSenderCapabilities(cricket::MediaType::MEDIA_TYPE_VIDEO) .codecs); diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index a3f3e14ba6..7738a83329 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -94,7 +94,7 @@ class PeerConnectionE2EQualityTest // Have to be run on the signaling thread. void SetupCallOnSignalingThread(const RunParams& run_params); void TearDownCallOnSignalingThread(); - void SetPeerCodecPreferences(TestPeer* peer, const RunParams& run_params); + void SetPeerCodecPreferences(TestPeer* peer); std::unique_ptr CreateSignalingInterceptor( const RunParams& run_params); void WaitUntilIceCandidatesGathered(rtc::Thread* signaling_thread); diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h index 9225ddf5ee..37ccf57033 100644 --- a/test/pc/e2e/peer_connection_quality_test_params.h +++ b/test/pc/e2e/peer_connection_quality_test_params.h @@ -119,6 +119,16 @@ struct Params { // it will be available for further analysis. absl::optional aec_dump_path; + bool use_ulp_fec = false; + bool use_flex_fec = false; + // Specifies how much video encoder target bitrate should be different than + // target bitrate, provided by WebRTC stack. Must be greater then 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(...). + double video_encoder_bitrate_multiplier = 1.0; + PeerConnectionInterface::RTCConfiguration rtc_configuration; BitrateSettings bitrate_settings; std::vector diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index c735f19101..6349ee7acc 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -296,6 +296,19 @@ absl::optional RemotePeerAudioConfig::Create( return RemotePeerAudioConfig(config.value()); } +std::unique_ptr TestPeerFactory::CreateTestPeer( + std::unique_ptr configurer, + std::unique_ptr observer, + absl::optional remote_audio_config, + absl::optional + echo_emulation_config) { + double bitrate_multiplier = + configurer->params()->video_encoder_bitrate_multiplier; + return CreateTestPeer(std::move(configurer), std::move(observer), + remote_audio_config, bitrate_multiplier, + echo_emulation_config); +} + std::unique_ptr TestPeerFactory::CreateTestPeer( std::unique_ptr configurer, std::unique_ptr observer, diff --git a/test/pc/e2e/test_peer_factory.h b/test/pc/e2e/test_peer_factory.h index 0e8463f188..4010167e91 100644 --- a/test/pc/e2e/test_peer_factory.h +++ b/test/pc/e2e/test_peer_factory.h @@ -66,6 +66,13 @@ class TestPeerFactory { // PeerConnectionFactory and PeerConnection creation methods, // also will setup dependencies, that are required for media analyzers // injection. + std::unique_ptr CreateTestPeer( + std::unique_ptr configurer, + std::unique_ptr observer, + absl::optional remote_audio_config, + absl::optional + echo_emulation_config); + // Deprecated. Use the one above. std::unique_ptr CreateTestPeer( std::unique_ptr configurer, std::unique_ptr observer, diff --git a/video/pc_full_stack_tests.cc b/video/pc_full_stack_tests.cc index 6728e4bd19..d052e2813d 100644 --- a/video/pc_full_stack_tests.cc +++ b/video/pc_full_stack_tests.cc @@ -132,10 +132,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Net_Delay_0_0_Plr_0_VP9) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -166,10 +163,7 @@ TEST(PCGenericDescriptorTest, {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } // VP9 2nd profile isn't supported on android arm and arm 64. @@ -207,10 +201,7 @@ TEST(PCFullStackTest, MAYBE_Pc_Generator_Net_Delay_0_0_Plr_0_VP9Profile2) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile2)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } /* @@ -260,10 +251,7 @@ TEST(PCFullStackTest, Pc_Net_Delay_0_0_Plr_0) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -283,10 +271,7 @@ TEST(PCGenericDescriptorTest, alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -313,8 +298,6 @@ TEST(PCGenericDescriptorTest, }, [](PeerConfigurer* bob) {}); RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; fixture->Run(std::move(run_params)); } @@ -336,10 +319,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Link_150kbps_Net_Delay_0_0_Plr_0) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Foreman_Cif_Link_130kbps_Delay100ms_Loss1_Ulpfec) { @@ -359,12 +339,10 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Link_130kbps_Delay100ms_Loss1_Ulpfec) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseUlpFEC(true); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = true; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetUseUlpFEC(true); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Foreman_Cif_Link_50kbps_Delay100ms_Loss1_Ulpfec) { @@ -384,12 +362,10 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Link_50kbps_Delay100ms_Loss1_Ulpfec) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseUlpFEC(true); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = true; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetUseUlpFEC(true); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } // Restricted network and encoder overproducing by 30%. @@ -411,13 +387,10 @@ TEST(PCFullStackTest, auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetVideoEncoderBitrateMultiplier(1.30); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - run_params.video_encoder_bitrate_multiplier = 1.30; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetVideoEncoderBitrateMultiplier(1.30); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } // Weak 3G-style link: 250kbps, 1% loss, 100ms delay, 15 packets queue. @@ -442,13 +415,10 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Link_250kbps_Delay100ms_10pkts_Loss1) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetVideoEncoderBitrateMultiplier(1.30); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - run_params.video_encoder_bitrate_multiplier = 1.30; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetVideoEncoderBitrateMultiplier(1.30); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -470,10 +440,7 @@ TEST(PCGenericDescriptorTest, alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -493,12 +460,10 @@ TEST(PCGenericDescriptorTest, auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseUlpFEC(true); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = true; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetUseUlpFEC(true); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Foreman_Cif_Delay_50_0_Plr_5_Flexfec) { @@ -517,11 +482,11 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_Delay_50_0_Plr_5_Flexfec) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseFlexFEC(true); }, - [](PeerConfigurer* bob) {}); + [](PeerConfigurer* bob) { bob->SetUseFlexFEC(true); }); RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = true; - run_params.use_ulp_fec = false; + run_params.enable_flex_fec_support = true; fixture->Run(std::move(run_params)); } @@ -542,11 +507,11 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_Delay_50_0_Plr_3_Flexfec) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseFlexFEC(true); }, - [](PeerConfigurer* bob) {}); + [](PeerConfigurer* bob) { bob->SetUseFlexFEC(true); }); RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = true; - run_params.use_ulp_fec = false; + run_params.enable_flex_fec_support = true; fixture->Run(std::move(run_params)); } @@ -567,12 +532,10 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_Delay_50_0_Plr_3_Ulpfec) { auto frame_generator = CreateFromYuvFileFrameGenerator( video, ClipNameToClipPath("foreman_cif")); alice->AddVideoConfig(std::move(video), std::move(frame_generator)); + alice->SetUseUlpFEC(true); }, - [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = true; - fixture->Run(std::move(run_params)); + [](PeerConfigurer* bob) { bob->SetUseUlpFEC(true); }); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } #if defined(WEBRTC_USE_H264) @@ -765,10 +728,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_32pkts_Queue) { @@ -790,10 +750,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_32pkts_Queue) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_100ms) { @@ -815,10 +772,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_500kbps_100ms) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCGenericDescriptorTest, @@ -841,10 +795,7 @@ TEST(PCGenericDescriptorTest, alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } /* @@ -887,10 +838,7 @@ TEST(PCFullStackTest, Pc_Foreman_Cif_1000kbps_100ms_32pkts_Queue) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } // TODO(sprang): Remove this if we have the similar ModerateLimits below? @@ -913,10 +861,7 @@ TEST(PCFullStackTest, Pc_Conference_Motion_Hd_2000kbps_100ms_32pkts_Queue) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } /* @@ -1074,10 +1019,7 @@ TEST(PCFullStackTest, Pc_Conference_Motion_Hd_2000kbps_100ms_32pkts_Queue_Vp9) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } #endif @@ -1098,10 +1040,7 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides_No_Conference_Mode) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Screenshare_Slides) { @@ -1121,8 +1060,6 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides) { }, [](PeerConfigurer* bob) {}); RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; run_params.use_conference_mode = true; fixture->Run(std::move(run_params)); } @@ -1148,10 +1085,7 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides_Simulcast_No_Conference_Mode) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Screenshare_Slides_Simulcast) { @@ -1174,8 +1108,6 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides_Simulcast) { }, [](PeerConfigurer* bob) {}); RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; run_params.use_conference_mode = true; fixture->Run(std::move(run_params)); } @@ -1388,10 +1320,7 @@ TEST(PCFullStackTest, Pc_Screenshare_Slides_Vp9_3sl_High_Fps) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Vp9svc_3sl_High) { @@ -1423,10 +1352,7 @@ TEST(PCFullStackTest, Pc_Vp9svc_3sl_High) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Vp9svc_3sl_Low) { @@ -1458,10 +1384,7 @@ TEST(PCFullStackTest, Pc_Vp9svc_3sl_Low) { {kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}})}); }); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } #endif // defined(RTC_ENABLE_VP9) @@ -1582,10 +1505,7 @@ TEST(PCFullStackTest, MAYBE_Pc_Simulcast_HD_High) { alice->AddVideoConfig(std::move(video)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Simulcast_Vp8_3sl_High) { @@ -1607,10 +1527,7 @@ TEST(PCFullStackTest, Pc_Simulcast_Vp8_3sl_High) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } TEST(PCFullStackTest, Pc_Simulcast_Vp8_3sl_Low) { @@ -1631,10 +1548,7 @@ TEST(PCFullStackTest, Pc_Simulcast_Vp8_3sl_Low) { alice->AddVideoConfig(std::move(video), std::move(frame_generator)); }, [](PeerConfigurer* bob) {}); - RunParams run_params(TimeDelta::Seconds(kTestDurationSec)); - run_params.use_flex_fec = false; - run_params.use_ulp_fec = false; - fixture->Run(std::move(run_params)); + fixture->Run(RunParams(TimeDelta::Seconds(kTestDurationSec))); } /*