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}
diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h
index 20ca065..8165443 100644
--- a/api/test/peerconnection_quality_test_fixture.h
+++ b/api/test/peerconnection_quality_test_fixture.h
@@ -54,6 +54,12 @@
// API is in development. Can be changed/removed without notice.
class PeerConnectionE2EQualityTestFixture {
public:
+ // The index of required capturing device in OS provided list of video
+ // devices. On Linux and Windows the list will be obtained via
+ // webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via
+ // [RTCCameraVideoCapturer captureDevices].
+ enum class CapturingDeviceIndex : size_t {};
+
// Contains parameters for screen share scrolling.
//
// If scrolling is enabled, then it will be done by putting sliding window
@@ -185,12 +191,6 @@
// Will be set for current video track. If equals to kText or kDetailed -
// screencast in on.
absl::optional<VideoTrackInterface::ContentHint> content_hint;
- // If specified this capturing device will be used to get input video. The
- // |capturing_device_index| is the index of required capturing device in OS
- // provided list of video devices. On Linux and Windows the list will be
- // obtained via webrtc::VideoCaptureModule::DeviceInfo, on Mac OS via
- // [RTCCameraVideoCapturer captureDevices].
- absl::optional<size_t> capturing_device_index;
// If presented video will be transfered in simulcast/SVC mode depending on
// which encoder is used.
//
@@ -319,6 +319,11 @@
virtual PeerConfigurer* AddVideoConfig(
VideoConfig config,
std::unique_ptr<test::FrameGeneratorInterface> 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;
// 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 182bbfd..d340f1a 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -222,12 +222,15 @@
"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 @@
"media/test_video_capturer_video_track_source.h",
]
deps = [
+ ":peer_configurer",
":test_peer",
":video_quality_analyzer_injection_helper",
"../..:fileutils",
@@ -282,6 +286,7 @@
"../../../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 e41c58a..d3fa6ff 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 @@
::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 @@
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 @@
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 08f7433..8b36646 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 @@
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 179482b..010ddce 100644
--- a/test/pc/e2e/peer_configurer.h
+++ b/test/pc/e2e/peer_configurer.h
@@ -39,6 +39,10 @@
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 @@
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 @@
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 @@
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 @@
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 a95cd8d..8c9c6d9 100644
--- a/test/pc/e2e/test_peer.cc
+++ b/test/pc/e2e/test_peer.cc
@@ -42,14 +42,13 @@
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 ae664f4..c506127 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 @@
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 @@
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 009c446..455337e 100644
--- a/test/pc/e2e/test_peer_factory.cc
+++ b/test/pc/e2e/test_peer_factory.cc
@@ -283,8 +283,7 @@
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 @@
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 @@
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 @@
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 8f6b56e..3233bb6 100644
--- a/test/pc/e2e/test_peer_factory.h
+++ b/test/pc/e2e/test_peer_factory.h
@@ -55,8 +55,7 @@
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,