diff options
author | Andrey Logvin <landrey@webrtc.org> | 2020-05-13 08:02:26 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-13 09:16:40 +0000 |
commit | f3319816ad981ead6a584e3ff6a4dc9fe24e7996 (patch) | |
tree | 3050cca35c3d3ccd53fcd95a779eaa99604ce8e4 /test | |
parent | 381d10963ae256d3d0bce7d74a7b08f600c63439 (diff) | |
download | webrtc-f3319816ad981ead6a584e3ff6a4dc9fe24e7996.tar.gz |
Separate capturing device index from VideoConfig
The last step of the pc framework tests migration.
Bug: webrtc:11534
Change-Id: I344c443b6d21422ef418315b7e5a6cb26ae3473d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174741
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31232}
Diffstat (limited to 'test')
-rw-r--r-- | test/pc/e2e/BUILD.gn | 5 | ||||
-rw-r--r-- | test/pc/e2e/media/media_helper.cc | 22 | ||||
-rw-r--r-- | test/pc/e2e/media/media_helper.h | 3 | ||||
-rw-r--r-- | test/pc/e2e/peer_configurer.h | 36 | ||||
-rw-r--r-- | test/pc/e2e/test_peer.cc | 5 | ||||
-rw-r--r-- | test/pc/e2e/test_peer.h | 13 | ||||
-rw-r--r-- | test/pc/e2e/test_peer_factory.cc | 9 | ||||
-rw-r--r-- | test/pc/e2e/test_peer_factory.h | 3 |
8 files changed, 57 insertions, 39 deletions
diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 182bbfd307..d340f1a00c 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -222,12 +222,15 @@ if (rtc_include_tests) { "test_peer.h", ] deps = [ + ":peer_configurer", ":peer_connection_quality_test_params", "../../../api:frame_generator_api", + "../../../api:peer_connection_quality_test_fixture_api", "../../../api:scoped_refptr", "../../../modules/audio_processing:api", "../../../pc:peerconnection_wrapper", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/types:variant", ] } @@ -271,6 +274,7 @@ if (rtc_include_tests) { "media/test_video_capturer_video_track_source.h", ] deps = [ + ":peer_configurer", ":test_peer", ":video_quality_analyzer_injection_helper", "../..:fileutils", @@ -282,6 +286,7 @@ if (rtc_include_tests) { "../../../api:peer_connection_quality_test_fixture_api", "../../../api/video:video_frame", "../../../pc:peerconnection", + "//third_party/abseil-cpp/absl/types:variant", ] } diff --git a/test/pc/e2e/media/media_helper.cc b/test/pc/e2e/media/media_helper.cc index e41c58a213..d3fa6ffe03 100644 --- a/test/pc/e2e/media/media_helper.cc +++ b/test/pc/e2e/media/media_helper.cc @@ -12,6 +12,7 @@ #include <string> #include <utility> +#include "absl/types/variant.h" #include "api/media_stream_interface.h" #include "api/test/create_frame_generator.h" #include "test/frame_generator_capturer.h" @@ -26,6 +27,8 @@ using VideoConfig = ::webrtc::webrtc_pc_e2e::PeerConnectionE2EQualityTestFixture::VideoConfig; using AudioConfig = ::webrtc::webrtc_pc_e2e::PeerConnectionE2EQualityTestFixture::AudioConfig; +using CapturingDeviceIndex = ::webrtc::webrtc_pc_e2e:: + PeerConnectionE2EQualityTestFixture::CapturingDeviceIndex; } // namespace @@ -53,7 +56,7 @@ MediaHelper::MaybeAddVideo(TestPeer* peer) { auto video_config = params->video_configs[i]; // Setup input video source into peer connection. std::unique_ptr<test::TestVideoCapturer> capturer = CreateVideoCapturer( - video_config, peer->ReleaseVideoGenerator(i), + video_config, peer->ReleaseVideoSource(i), video_quality_analyzer_injection_helper_->CreateFramePreprocessor( video_config)); bool is_screencast = @@ -93,25 +96,28 @@ MediaHelper::MaybeAddVideo(TestPeer* peer) { std::unique_ptr<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer( const VideoConfig& video_config, - std::unique_ptr<test::FrameGeneratorInterface> generator, + PeerConfigurerImpl::VideoSource source, std::unique_ptr<test::TestVideoCapturer::FramePreprocessor> frame_preprocessor) { - if (video_config.capturing_device_index) { + CapturingDeviceIndex* capturing_device_index = + absl::get_if<CapturingDeviceIndex>(&source); + if (capturing_device_index != nullptr) { std::unique_ptr<test::TestVideoCapturer> capturer = test::CreateVideoCapturer(video_config.width, video_config.height, video_config.fps, - *video_config.capturing_device_index); + static_cast<size_t>(*capturing_device_index)); RTC_CHECK(capturer) << "Failed to obtain input stream from capturing device #" - << *video_config.capturing_device_index; + << *capturing_device_index; capturer->SetFramePreprocessor(std::move(frame_preprocessor)); return capturer; } - RTC_CHECK(generator) << "No input source."; - auto capturer = std::make_unique<test::FrameGeneratorCapturer>( - clock_, std::move(generator), video_config.fps, *task_queue_factory_); + clock_, + absl::get<std::unique_ptr<test::FrameGeneratorInterface>>( + std::move(source)), + video_config.fps, *task_queue_factory_); capturer->SetFramePreprocessor(std::move(frame_preprocessor)); capturer->Init(); return capturer; diff --git a/test/pc/e2e/media/media_helper.h b/test/pc/e2e/media/media_helper.h index 08f74335ee..8b36646a0b 100644 --- a/test/pc/e2e/media/media_helper.h +++ b/test/pc/e2e/media/media_helper.h @@ -18,6 +18,7 @@ #include "api/test/peerconnection_quality_test_fixture.h" #include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h" #include "test/pc/e2e/media/test_video_capturer_video_track_source.h" +#include "test/pc/e2e/peer_configurer.h" #include "test/pc/e2e/test_peer.h" namespace webrtc { @@ -41,7 +42,7 @@ class MediaHelper { private: std::unique_ptr<test::TestVideoCapturer> CreateVideoCapturer( const PeerConnectionE2EQualityTestFixture::VideoConfig& video_config, - std::unique_ptr<test::FrameGeneratorInterface> generator, + PeerConfigurerImpl::VideoSource source, std::unique_ptr<test::TestVideoCapturer::FramePreprocessor> frame_preprocessor); diff --git a/test/pc/e2e/peer_configurer.h b/test/pc/e2e/peer_configurer.h index 179482b875..010ddcee82 100644 --- a/test/pc/e2e/peer_configurer.h +++ b/test/pc/e2e/peer_configurer.h @@ -39,6 +39,10 @@ namespace webrtc_pc_e2e { class PeerConfigurerImpl final : public PeerConnectionE2EQualityTestFixture::PeerConfigurer { public: + using VideoSource = + absl::variant<std::unique_ptr<test::FrameGeneratorInterface>, + PeerConnectionE2EQualityTestFixture::CapturingDeviceIndex>; + PeerConfigurerImpl(rtc::Thread* network_thread, rtc::NetworkManager* network_manager) : components_(std::make_unique<InjectableComponents>(network_thread, @@ -123,7 +127,7 @@ class PeerConfigurerImpl final PeerConfigurer* AddVideoConfig( PeerConnectionE2EQualityTestFixture::VideoConfig config) override { - video_generators_.push_back( + video_sources_.push_back( CreateSquareFrameGenerator(config, /*type=*/absl::nullopt)); params_->video_configs.push_back(std::move(config)); return this; @@ -132,7 +136,15 @@ class PeerConfigurerImpl final PeerConnectionE2EQualityTestFixture::VideoConfig config, std::unique_ptr<test::FrameGeneratorInterface> generator) override { params_->video_configs.push_back(std::move(config)); - video_generators_.push_back(std::move(generator)); + video_sources_.push_back(std::move(generator)); + return this; + } + PeerConfigurer* AddVideoConfig( + PeerConnectionE2EQualityTestFixture::VideoConfig config, + PeerConnectionE2EQualityTestFixture::CapturingDeviceIndex index) + override { + params_->video_configs.push_back(std::move(config)); + video_sources_.push_back(index); return this; } PeerConfigurer* SetAudioConfig( @@ -173,10 +185,7 @@ class PeerConfigurerImpl final InjectableComponents* components() { return components_.get(); } Params* params() { return params_.get(); } - std::vector<std::unique_ptr<test::FrameGeneratorInterface>>* - video_generators() { - return &video_generators_; - } + std::vector<VideoSource>* video_sources() { return &video_sources_; } // Returns InjectableComponents and transfer ownership to the caller. // Can be called once. @@ -194,19 +203,18 @@ class PeerConfigurerImpl final params_ = nullptr; return params; } - // Returns frame generators and transfer ownership to the caller. - // Can be called once. - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> - ReleaseVideoGenerators() { - auto video_generators = std::move(video_generators_); - video_generators_.clear(); - return video_generators; + // Returns video sources and transfer frame generators ownership to the + // caller. Can be called once. + std::vector<VideoSource> ReleaseVideoSources() { + auto video_sources = std::move(video_sources_); + video_sources_.clear(); + return video_sources; } private: std::unique_ptr<InjectableComponents> components_; std::unique_ptr<Params> params_; - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> video_generators_; + std::vector<VideoSource> video_sources_; }; // Set missing params to default values if it is required: diff --git a/test/pc/e2e/test_peer.cc b/test/pc/e2e/test_peer.cc index a95cd8db5a..8c9c6d9c8f 100644 --- a/test/pc/e2e/test_peer.cc +++ b/test/pc/e2e/test_peer.cc @@ -42,14 +42,13 @@ TestPeer::TestPeer( rtc::scoped_refptr<PeerConnectionInterface> pc, std::unique_ptr<MockPeerConnectionObserver> observer, std::unique_ptr<Params> params, - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> - video_generators, + std::vector<PeerConfigurerImpl::VideoSource> video_sources, rtc::scoped_refptr<AudioProcessing> audio_processing) : PeerConnectionWrapper::PeerConnectionWrapper(std::move(pc_factory), std::move(pc), std::move(observer)), params_(std::move(params)), - video_generators_(std::move(video_generators)), + video_sources_(std::move(video_sources)), 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 ae664f4810..c506127488 100644 --- a/test/pc/e2e/test_peer.h +++ b/test/pc/e2e/test_peer.h @@ -15,8 +15,11 @@ #include <vector> #include "absl/memory/memory.h" +#include "absl/types/variant.h" #include "api/test/frame_generator_interface.h" +#include "api/test/peerconnection_quality_test_fixture.h" #include "pc/peer_connection_wrapper.h" +#include "test/pc/e2e/peer_configurer.h" #include "test/pc/e2e/peer_connection_quality_test_params.h" namespace webrtc { @@ -28,9 +31,8 @@ class TestPeer final : public PeerConnectionWrapper { using PeerConnectionWrapper::PeerConnectionWrapper; Params* params() const { return params_.get(); } - std::unique_ptr<test::FrameGeneratorInterface> ReleaseVideoGenerator( - size_t i) { - return std::move(video_generators_[i]); + PeerConfigurerImpl::VideoSource ReleaseVideoSource(size_t i) { + return std::move(video_sources_[i]); } void DetachAecDump() { @@ -49,13 +51,12 @@ class TestPeer final : public PeerConnectionWrapper { rtc::scoped_refptr<PeerConnectionInterface> pc, std::unique_ptr<MockPeerConnectionObserver> observer, std::unique_ptr<Params> params, - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> - video_generators, + std::vector<PeerConfigurerImpl::VideoSource> video_sources, rtc::scoped_refptr<AudioProcessing> audio_processing); private: std::unique_ptr<Params> params_; - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> video_generators_; + std::vector<PeerConfigurerImpl::VideoSource> video_sources_; rtc::scoped_refptr<AudioProcessing> audio_processing_; std::vector<std::unique_ptr<IceCandidateInterface>> remote_ice_candidates_; diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 009c446a90..455337ef3a 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -283,8 +283,7 @@ absl::optional<RemotePeerAudioConfig> RemotePeerAudioConfig::Create( std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer( std::unique_ptr<InjectableComponents> components, std::unique_ptr<Params> params, - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> - video_generators, + std::vector<PeerConfigurerImpl::VideoSource> video_sources, std::unique_ptr<MockPeerConnectionObserver> observer, VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, rtc::Thread* signaling_thread, @@ -294,7 +293,7 @@ std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer( rtc::TaskQueue* task_queue) { RTC_DCHECK(components); RTC_DCHECK(params); - RTC_DCHECK_EQ(params->video_configs.size(), video_generators.size()); + RTC_DCHECK_EQ(params->video_configs.size(), video_sources.size()); SetMandatoryEntities(components.get()); params->rtc_configuration.sdp_semantics = SdpSemantics::kUnifiedPlan; @@ -334,7 +333,7 @@ std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer( return absl::WrapUnique(new TestPeer( peer_connection_factory, peer_connection, std::move(observer), - std::move(params), std::move(video_generators), audio_processing)); + std::move(params), std::move(video_sources), audio_processing)); } std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer( @@ -349,7 +348,7 @@ std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer( rtc::TaskQueue* task_queue) { return CreateTestPeer( configurer->ReleaseComponents(), configurer->ReleaseParams(), - configurer->ReleaseVideoGenerators(), std::move(observer), + configurer->ReleaseVideoSources(), std::move(observer), video_analyzer_helper, signaling_thread, remote_audio_config, bitrate_multiplier, echo_emulation_config, task_queue); } diff --git a/test/pc/e2e/test_peer_factory.h b/test/pc/e2e/test_peer_factory.h index 8f6b56e60b..3233bb65f7 100644 --- a/test/pc/e2e/test_peer_factory.h +++ b/test/pc/e2e/test_peer_factory.h @@ -55,8 +55,7 @@ class TestPeerFactory { static std::unique_ptr<TestPeer> CreateTestPeer( std::unique_ptr<InjectableComponents> components, std::unique_ptr<Params> params, - std::vector<std::unique_ptr<test::FrameGeneratorInterface>> - video_generators, + std::vector<PeerConfigurerImpl::VideoSource> video_sources, std::unique_ptr<MockPeerConnectionObserver> observer, VideoQualityAnalyzerInjectionHelper* video_analyzer_helper, rtc::Thread* signaling_thread, |