diff --git a/api/BUILD.gn b/api/BUILD.gn index 8bb6f06f58..51ae6e5b30 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -353,6 +353,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { ":audio_quality_analyzer_api", ":callfactory_api", ":fec_controller_api", + ":frame_generator_api", ":function_view", ":libjingle_peerconnection_api", ":network_state_predictor_api", diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index d0cdeab9d5..d2b69a762d 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -25,13 +25,13 @@ #include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/task_queue/task_queue_factory.h" #include "api/test/audio_quality_analyzer_interface.h" +#include "api/test/frame_generator_interface.h" #include "api/test/simulated_network.h" #include "api/test/stats_observer_interface.h" #include "api/test/video_quality_analyzer_interface.h" #include "api/transport/media/media_transport_interface.h" #include "api/transport/network_control.h" #include "api/units/time_delta.h" -#include "api/video/video_source_interface.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_factory.h" @@ -292,10 +292,10 @@ class PeerConnectionE2EQualityTestFixture { // Add new video stream to the call that will be sent from this peer. 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 source. + // provided own implementation of video frames generator. virtual PeerConfigurer* AddVideoConfig( VideoConfig config, - std::unique_ptr> source) = 0; + std::unique_ptr generator) = 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; diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 926301437b..15475dba71 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -177,19 +177,6 @@ rtc_library("quality_analyzing_video_encoder") { ] } -rtc_library("video_source_based_video_capturer") { - visibility = [ "*" ] - testonly = true - sources = [ - "video_source_based_video_capturer.cc", - "video_source_based_video_capturer.h", - ] - deps = [ - "../..:video_test_common", - "../../../api/video:video_frame", - ] -} - if (rtc_include_tests) { rtc_library("video_quality_analyzer_injection_helper") { visibility = [ "*" ] @@ -242,6 +229,7 @@ if (rtc_include_tests) { ":echo_emulation", ":peer_connection_quality_test_params", ":video_quality_analyzer_injection_helper", + "../../../api:frame_generator_api", "../../../api:peer_connection_quality_test_fixture_api", "../../../api:scoped_refptr", "../../../api/rtc_event_log:rtc_event_log_factory", @@ -287,7 +275,6 @@ if (rtc_include_tests) { ":stats_poller", ":test_peer", ":video_quality_analyzer_injection_helper", - ":video_source_based_video_capturer", "../..:field_trial", "../..:platform_video_capturer", "../..:video_test_common", diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 9baa3de9a9..2921a7e4bd 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -36,7 +36,6 @@ #include "test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h" #include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h" #include "test/pc/e2e/stats_poller.h" -#include "test/pc/e2e/video_source_based_video_capturer.h" #include "test/platform_video_capturer.h" #include "test/testsupport/file_utils.h" @@ -65,7 +64,9 @@ constexpr int kQuickTestModeRunDurationMs = 100; constexpr char kFlexFecEnabledFieldTrials[] = "WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/"; -std::string VideoConfigSourcePresenceToString(const VideoConfig& video_config) { +std::string VideoConfigSourcePresenceToString( + const VideoConfig& video_config, + bool has_user_provided_generator) { char buf[1024]; rtc::SimpleStringBuilder builder(buf); builder << "video_config.generator=" << video_config.generator.has_value() @@ -74,7 +75,9 @@ std::string VideoConfigSourcePresenceToString(const VideoConfig& video_config) { << "; video_config.screen_share_config=" << video_config.screen_share_config.has_value() << "; video_config.capturing_device_index=" - << video_config.capturing_device_index.has_value() << ";"; + << video_config.capturing_device_index.has_value() + << "; has_user_provided_generator=" << has_user_provided_generator + << ";"; return builder.str(); } @@ -236,19 +239,21 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { peer_configurations_[0]->ReleaseParams(); std::unique_ptr alice_components = peer_configurations_[0]->ReleaseComponents(); - std::vector>> - alice_video_sources = peer_configurations_[0]->ReleaseVideoSources(); + std::vector> + alice_video_generators = + peer_configurations_[0]->ReleaseVideoGenerators(); std::unique_ptr bob_params = peer_configurations_[1]->ReleaseParams(); std::unique_ptr bob_components = peer_configurations_[1]->ReleaseComponents(); - std::vector>> - bob_video_sources = peer_configurations_[1]->ReleaseVideoSources(); + std::vector> + bob_video_generators = peer_configurations_[1]->ReleaseVideoGenerators(); peer_configurations_.clear(); - SetDefaultValuesForMissingParams({alice_params.get(), bob_params.get()}, - {&alice_video_sources, &bob_video_sources}); + SetDefaultValuesForMissingParams( + {alice_params.get(), bob_params.get()}, + {&alice_video_generators, &bob_video_generators}); ValidateParams(run_params, {alice_params.get(), bob_params.get()}, - {&alice_video_sources, &bob_video_sources}); + {&alice_video_generators, &bob_video_generators}); SetupRequiredFieldTrials(run_params); // Print test summary @@ -281,7 +286,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { alice_ = TestPeer::CreateTestPeer( std::move(alice_components), std::move(alice_params), - std::move(alice_video_sources), + std::move(alice_video_generators), std::make_unique( [this, bob_video_configs]( rtc::scoped_refptr transceiver) { @@ -293,7 +298,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { run_params.echo_emulation_config, task_queue_.get()); bob_ = TestPeer::CreateTestPeer( std::move(bob_components), std::move(bob_params), - std::move(bob_video_sources), + std::move(bob_video_generators), std::make_unique( [this, alice_video_configs]( rtc::scoped_refptr transceiver) { @@ -448,9 +453,8 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { void PeerConnectionE2EQualityTest::SetDefaultValuesForMissingParams( std::vector params, - std::vector< - std::vector>>*> - video_sources) { + std::vector>*> + video_generators) { int video_counter = 0; int audio_counter = 0; std::set video_labels; @@ -459,11 +463,11 @@ void PeerConnectionE2EQualityTest::SetDefaultValuesForMissingParams( auto* p = params[i]; for (size_t j = 0; j < p->video_configs.size(); ++j) { VideoConfig& video_config = p->video_configs[j]; - std::unique_ptr>& video_source = - (*video_sources[i])[j]; + std::unique_ptr& video_generator = + (*video_generators[i])[j]; if (!video_config.generator && !video_config.input_file_name && !video_config.screen_share_config && - !video_config.capturing_device_index && !video_source) { + !video_config.capturing_device_index && !video_generator) { video_config.generator = VideoGeneratorType::kDefault; } if (!video_config.stream_label) { @@ -491,9 +495,8 @@ void PeerConnectionE2EQualityTest::SetDefaultValuesForMissingParams( void PeerConnectionE2EQualityTest::ValidateParams( const RunParams& run_params, std::vector params, - std::vector< - std::vector>>*> - video_sources) { + std::vector>*> + video_generators) { RTC_CHECK_GT(run_params.video_encoder_bitrate_multiplier, 0.0); std::set video_labels; @@ -526,11 +529,12 @@ void PeerConnectionE2EQualityTest::ValidateParams( ++input_sources_count; if (video_config.capturing_device_index) ++input_sources_count; - if ((*video_sources[i])[j]) + if ((*video_generators[i])[j]) ++input_sources_count; - RTC_CHECK_EQ(input_sources_count, 1) - << VideoConfigSourcePresenceToString(video_config); + // TODO(titovartem) handle video_generators case properly + RTC_CHECK_EQ(input_sources_count, 1) << VideoConfigSourcePresenceToString( + video_config, (*video_generators[i])[j] != nullptr); if (video_config.screen_share_config) { if (video_config.screen_share_config->slides_yuv_file_names.empty()) { @@ -733,7 +737,7 @@ PeerConnectionE2EQualityTest::MaybeAddVideo(TestPeer* peer) { test::VideoFrameWriter* writer = MaybeCreateVideoWriter(video_config.input_dump_file_name, video_config); std::unique_ptr capturer = CreateVideoCapturer( - video_config, peer->ReleaseVideoSource(i), + video_config, peer->ReleaseVideoGenerator(i), video_quality_analyzer_injection_helper_->CreateFramePreprocessor( video_config, writer)); rtc::scoped_refptr source = @@ -770,7 +774,7 @@ PeerConnectionE2EQualityTest::MaybeAddVideo(TestPeer* peer) { std::unique_ptr PeerConnectionE2EQualityTest::CreateVideoCapturer( const VideoConfig& video_config, - std::unique_ptr> source, + std::unique_ptr generator, std::unique_ptr frame_preprocessor) { if (video_config.capturing_device_index) { @@ -785,14 +789,11 @@ PeerConnectionE2EQualityTest::CreateVideoCapturer( return capturer; } - if (source != nullptr) { - std::unique_ptr capturer = - std::make_unique(std::move(source)); - capturer->SetFramePreprocessor(std::move(frame_preprocessor)); - return capturer; + std::unique_ptr frame_generator = nullptr; + if (generator) { + frame_generator = std::move(generator); } - std::unique_ptr frame_generator = nullptr; if (video_config.generator) { absl::optional frame_generator_type = absl::nullopt; diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index aeff087675..3f18a9ebf5 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -121,14 +121,14 @@ class PeerConfigurerImpl final PeerConfigurer* AddVideoConfig( PeerConnectionE2EQualityTestFixture::VideoConfig config) override { params_->video_configs.push_back(std::move(config)); - video_sources_.push_back(nullptr); + video_generators_.push_back(nullptr); return this; } PeerConfigurer* AddVideoConfig( PeerConnectionE2EQualityTestFixture::VideoConfig config, - std::unique_ptr> source) override { + std::unique_ptr generator) override { params_->video_configs.push_back(std::move(config)); - video_sources_.push_back(std::move(source)); + video_generators_.push_back(std::move(generator)); return this; } PeerConfigurer* SetAudioConfig( @@ -162,16 +162,15 @@ class PeerConfigurerImpl final return std::move(components_); } std::unique_ptr ReleaseParams() { return std::move(params_); } - std::vector>> - ReleaseVideoSources() { - return std::move(video_sources_); + std::vector> + ReleaseVideoGenerators() { + return std::move(video_generators_); } private: std::unique_ptr components_; std::unique_ptr params_; - std::vector>> - video_sources_; + std::vector> video_generators_; }; class TestVideoCapturerVideoTrackSource : public VideoTrackSource { @@ -262,16 +261,14 @@ class PeerConnectionE2EQualityTest // * Set video source generation mode if it is not specified void SetDefaultValuesForMissingParams( std::vector params, - std::vector< - std::vector>>*> + std::vector>*> video_sources); // Validate peer's parameters, also ensure uniqueness of all video stream // labels. void ValidateParams( const RunParams& run_params, std::vector params, - std::vector< - std::vector>>*> + std::vector>*> video_sources); // For some functionality some field trials have to be enabled, so we will // enable them here. @@ -287,7 +284,7 @@ class PeerConnectionE2EQualityTest MaybeAddVideo(TestPeer* peer); std::unique_ptr CreateVideoCapturer( const VideoConfig& video_config, - std::unique_ptr> source, + std::unique_ptr generator, std::unique_ptr frame_preprocessor); std::unique_ptr diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc index 4db591146b..4874725995 100644 --- a/test/pc/e2e/test_peer.cc +++ b/test/pc/e2e/test_peer.cc @@ -328,8 +328,8 @@ absl::optional TestPeer::CreateRemoteAudioConfig( std::unique_ptr TestPeer::CreateTestPeer( std::unique_ptr components, std::unique_ptr params, - std::vector>> - video_sources, + std::vector> + video_generators, std::unique_ptr observer, VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, rtc::Thread* signaling_thread, @@ -339,7 +339,7 @@ std::unique_ptr TestPeer::CreateTestPeer( rtc::TaskQueue* task_queue) { RTC_DCHECK(components); RTC_DCHECK(params); - RTC_DCHECK_EQ(params->video_configs.size(), video_sources.size()); + RTC_DCHECK_EQ(params->video_configs.size(), video_generators.size()); SetMandatoryEntities(components.get()); params->rtc_configuration.sdp_semantics = SdpSemantics::kUnifiedPlan; @@ -350,7 +350,7 @@ std::unique_ptr TestPeer::CreateTestPeer( return absl::WrapUnique(new TestPeer( tpc.peer_connection_factory(), tpc.peer_connection(), std::move(observer), - std::move(params), std::move(video_sources), tpc.audio_processing())); + std::move(params), std::move(video_generators), tpc.audio_processing())); } bool TestPeer::AddIceCandidates( @@ -376,14 +376,14 @@ TestPeer::TestPeer( rtc::scoped_refptr pc, std::unique_ptr observer, std::unique_ptr params, - std::vector>> - video_sources, + std::vector> + video_generators, rtc::scoped_refptr audio_processing) : PeerConnectionWrapper::PeerConnectionWrapper(std::move(pc_factory), std::move(pc), std::move(observer)), params_(std::move(params)), - video_sources_(std::move(video_sources)), + video_generators_(std::move(video_generators)), audio_processing_(audio_processing) {} } // namespace webrtc_pc_e2e diff --git a/test/pc/e2e/test_peer.h b/test/pc/e2e/test_peer.h index b9a7801dc7..3487720887 100644 --- a/test/pc/e2e/test_peer.h +++ b/test/pc/e2e/test_peer.h @@ -16,6 +16,7 @@ #include #include "absl/memory/memory.h" +#include "api/test/frame_generator_interface.h" #include "api/test/peerconnection_quality_test_fixture.h" #include "media/base/media_engine.h" #include "modules/audio_device/include/test_audio_device.h" @@ -62,8 +63,8 @@ class TestPeer final : public PeerConnectionWrapper { static std::unique_ptr CreateTestPeer( std::unique_ptr components, std::unique_ptr params, - std::vector>> - video_sources, + std::vector> + video_generators, std::unique_ptr observer, VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, rtc::Thread* signaling_thread, @@ -73,9 +74,9 @@ class TestPeer final : public PeerConnectionWrapper { rtc::TaskQueue* task_queue); Params* params() const { return params_.get(); } - std::unique_ptr> ReleaseVideoSource( + std::unique_ptr ReleaseVideoGenerator( size_t i) { - return std::move(video_sources_[i]); + return std::move(video_generators_[i]); } void DetachAecDump() { audio_processing_->DetachAecDump(); } @@ -89,13 +90,12 @@ class TestPeer final : public PeerConnectionWrapper { rtc::scoped_refptr pc, std::unique_ptr observer, std::unique_ptr params, - std::vector>> - video_sources, + std::vector> + video_generators, rtc::scoped_refptr audio_processing); std::unique_ptr params_; - std::vector>> - video_sources_; + std::vector> video_generators_; rtc::scoped_refptr audio_processing_; std::vector> remote_ice_candidates_; diff --git a/test/pc/e2e/video_source_based_video_capturer.cc b/test/pc/e2e/video_source_based_video_capturer.cc deleted file mode 100644 index 9a86604b4a..0000000000 --- a/test/pc/e2e/video_source_based_video_capturer.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "test/pc/e2e/video_source_based_video_capturer.h" - -#include - -namespace webrtc { -namespace webrtc_pc_e2e { - -VideoSourceBasedVideoCapturer::VideoSourceBasedVideoCapturer( - std::unique_ptr> source) - : source_(std::move(source)) { - source_->AddOrUpdateSink(this, rtc::VideoSinkWants()); -} -VideoSourceBasedVideoCapturer::~VideoSourceBasedVideoCapturer() { - source_->RemoveSink(this); -} - -void VideoSourceBasedVideoCapturer::OnFrame(const VideoFrame& frame) { - TestVideoCapturer::OnFrame(frame); -} - -} // namespace webrtc_pc_e2e -} // namespace webrtc diff --git a/test/pc/e2e/video_source_based_video_capturer.h b/test/pc/e2e/video_source_based_video_capturer.h deleted file mode 100644 index 6369fa5040..0000000000 --- a/test/pc/e2e/video_source_based_video_capturer.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef TEST_PC_E2E_VIDEO_SOURCE_BASED_VIDEO_CAPTURER_H_ -#define TEST_PC_E2E_VIDEO_SOURCE_BASED_VIDEO_CAPTURER_H_ - -#include - -#include "api/video/video_sink_interface.h" -#include "api/video/video_source_interface.h" -#include "test/test_video_capturer.h" - -namespace webrtc { -namespace webrtc_pc_e2e { - -// Used to forward VideoFrame's provided by custom video source into video -// quality analyzer and VideoAdapter inside TestVideoCapturer and then properly -// broadcast them. -class VideoSourceBasedVideoCapturer - : public webrtc::test::TestVideoCapturer, - public rtc::VideoSinkInterface { - public: - VideoSourceBasedVideoCapturer( - std::unique_ptr> source); - ~VideoSourceBasedVideoCapturer() override; - - void OnFrame(const VideoFrame& frame) override; - - private: - std::unique_ptr> source_; -}; - -} // namespace webrtc_pc_e2e -} // namespace webrtc - -#endif // TEST_PC_E2E_VIDEO_SOURCE_BASED_VIDEO_CAPTURER_H_