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 <mbonadei@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Cr-Commit-Position: refs/heads/main@{#38603}
This commit is contained in:
Jeremy Leconte
2022-11-04 14:01:12 +01:00
committed by WebRTC LUCI CQ
parent e87ec28b80
commit 389228d0f0
17 changed files with 399 additions and 456 deletions

View File

@ -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",

View File

@ -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<test::TestVideoCapturer> MediaHelper::CreateVideoCapturer(
const VideoConfig& video_config,
PeerConfigurerImpl::VideoSource source,
PeerConfigurer::VideoSource source,
std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
frame_preprocessor) {
CapturingDeviceIndex* capturing_device_index =

View File

@ -43,7 +43,7 @@ class MediaHelper {
private:
std::unique_ptr<test::TestVideoCapturer> CreateVideoCapturer(
const VideoConfig& video_config,
PeerConfigurerImpl::VideoSource source,
PeerConfigurer::VideoSource source,
std::unique_ptr<test::TestVideoCapturer::FramePreprocessor>
frame_preprocessor);

View File

@ -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_

View File

@ -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<std::unique_ptr<PeerConfigurerImpl>>& peers) {
const std::vector<std::unique_ptr<PeerConfigurer>>& 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<void(PeerConfigurer*)> configurer) {
peer_configurations_.push_back(
std::make_unique<PeerConfigurerImpl>(network_dependencies));
std::make_unique<PeerConfigurer>(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<PeerConfigurerImpl> alice_configurer =
std::unique_ptr<PeerConfigurer> alice_configurer =
std::move(peer_configurations_[0]);
std::unique_ptr<PeerConfigurerImpl> bob_configurer =
std::unique_ptr<PeerConfigurer> bob_configurer =
std::move(peer_configurations_[1]);
peer_configurations_.clear();

View File

@ -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<TestActivitiesExecutor> executor_;
test::MetricsLogger* const metrics_logger_;
std::vector<std::unique_ptr<PeerConfigurerImpl>> peer_configurations_;
std::vector<std::unique_ptr<PeerConfigurer>> peer_configurations_;
std::vector<PeerHandleImpl> peer_handles_;
std::unique_ptr<TestPeer> alice_;

View File

@ -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 <set>
#include <string>
#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<const absl::string_view> default_names = {})
: prefix_(prefix), default_names_(default_names) {}
void MaybeSetName(absl::optional<std::string>& 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<const absl::string_view> default_names_;
std::set<std::string> known_names_;
size_t counter_ = 0;
};
PeerParamsPreprocessor::PeerParamsPreprocessor()
: peer_names_provider_(
std::make_unique<DefaultNamesProvider>("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<ScalabilityMode> scalability_mode =
ScalabilityModeFromString(*encoding_param.scalability_mode);
RTC_CHECK(scalability_mode) << "Unknown scalability_mode requested";
absl::optional<ScalableVideoController::StreamLayersConfig>
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

View File

@ -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 <memory>
#include <set>
#include <string>
#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<DefaultNamesProvider> peer_names_provider_;
std::set<std::string> peer_names_;
std::set<std::string> video_labels_;
std::set<std::string> audio_labels_;
std::set<std::string> video_sync_groups_;
std::set<std::string> audio_sync_groups_;
};
} // namespace webrtc_pc_e2e
} // namespace webrtc
#endif // TEST_PC_E2E_PEER_PARAMS_PREPROCESSOR_H_

View File

@ -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<MockPeerConnectionObserver> observer,
Params params,
ConfigurableParams configurable_params,
std::vector<PeerConfigurerImpl::VideoSource> video_sources,
std::vector<PeerConfigurer::VideoSource> video_sources,
rtc::scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<rtc::Thread> worker_thread)
: params_(std::move(params)),

View File

@ -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<MockPeerConnectionObserver> observer,
Params params,
ConfigurableParams configurable_params,
std::vector<PeerConfigurerImpl::VideoSource> video_sources,
std::vector<PeerConfigurer::VideoSource> video_sources,
rtc::scoped_refptr<AudioProcessing> audio_processing,
std::unique_ptr<rtc::Thread> worker_thread);
@ -176,7 +176,7 @@ class TestPeer final : public StatsProvider {
// worker thread and network thread.
std::unique_ptr<rtc::Thread> worker_thread_;
std::unique_ptr<PeerConnectionWrapper> wrapper_;
std::vector<PeerConfigurerImpl::VideoSource> video_sources_;
std::vector<PeerConfigurer::VideoSource> video_sources_;
rtc::scoped_refptr<AudioProcessing> audio_processing_;
std::vector<std::unique_ptr<IceCandidateInterface>> remote_ice_candidates_;

View File

@ -290,7 +290,7 @@ absl::optional<RemotePeerAudioConfig> RemotePeerAudioConfig::Create(
}
std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer(
std::unique_ptr<PeerConfigurerImpl> configurer,
std::unique_ptr<PeerConfigurer> configurer,
std::unique_ptr<MockPeerConnectionObserver> observer,
absl::optional<RemotePeerAudioConfig> remote_audio_config,
absl::optional<EchoEmulationConfig> echo_emulation_config) {
@ -299,7 +299,7 @@ std::unique_ptr<TestPeer> TestPeerFactory::CreateTestPeer(
std::unique_ptr<Params> params = configurer->ReleaseParams();
std::unique_ptr<ConfigurableParams> configurable_params =
configurer->ReleaseConfigurableParams();
std::vector<PeerConfigurerImpl::VideoSource> video_sources =
std::vector<PeerConfigurer::VideoSource> video_sources =
configurer->ReleaseVideoSources();
RTC_DCHECK(components);
RTC_DCHECK(params);

View File

@ -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<TestPeer> CreateTestPeer(
std::unique_ptr<PeerConfigurerImpl> configurer,
std::unique_ptr<PeerConfigurer> configurer,
std::unique_ptr<MockPeerConnectionObserver> observer,
absl::optional<RemotePeerAudioConfig> remote_audio_config,
absl::optional<EchoEmulationConfig> echo_emulation_config);