Deprecate EmulatedNetworkManagerInterface::network_dependencies

That accessor forces test helpers to create BasicPortAllocator themself
rather than deligate such task to PeerConnectionFactory

Bug: webrtc:42232556
Change-Id: I262e032da110222198e6308f57a5e5f2d7ba4601
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376741
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43870}
This commit is contained in:
Danil Chapovalov 2025-02-10 16:23:30 +01:00 committed by WebRTC LUCI CQ
parent 5ebaa2f7bd
commit 8a97881882
10 changed files with 45 additions and 39 deletions

View File

@ -159,9 +159,9 @@ class EmulatedNetworkManagerInterface {
virtual absl::Nonnull<std::unique_ptr<rtc::NetworkManager>> virtual absl::Nonnull<std::unique_ptr<rtc::NetworkManager>>
ReleaseNetworkManager() = 0; ReleaseNetworkManager() = 0;
// TODO: bugs.webrtc.org/42232556 - Cleanup usages of this accessor in WebRTC, [[deprecated("bugs.webrtc.org/42232556")]] //
// and then deprecate or remove it. webrtc::webrtc_pc_e2e::PeerNetworkDependencies
webrtc::webrtc_pc_e2e::PeerNetworkDependencies network_dependencies() { network_dependencies() {
return {network_thread(), network_manager(), packet_socket_factory()}; return {network_thread(), network_manager(), packet_socket_factory()};
} }
// Returns list of endpoints that are associated with this instance. Pointers // Returns list of endpoints that are associated with this instance. Pointers

View File

@ -98,6 +98,7 @@ rtc_library("peer_configurer") {
":media_configuration", ":media_configuration",
":media_quality_test_params", ":media_quality_test_params",
"../..:async_dns_resolver", "../..:async_dns_resolver",
"../..:network_emulation_manager_api",
"../../../api:create_peer_connection_quality_test_frame_generator", "../../../api:create_peer_connection_quality_test_frame_generator",
"../../../api:fec_controller_api", "../../../api:fec_controller_api",
"../../../api:field_trials_view", "../../../api:field_trials_view",

View File

@ -32,6 +32,7 @@
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "api/test/create_peer_connection_quality_test_frame_generator.h" #include "api/test/create_peer_connection_quality_test_frame_generator.h"
#include "api/test/frame_generator_interface.h" #include "api/test/frame_generator_interface.h"
#include "api/test/network_emulation_manager.h"
#include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_configuration.h"
#include "api/test/pclf/media_quality_test_params.h" #include "api/test/pclf/media_quality_test_params.h"
#include "api/test/peer_network_dependencies.h" #include "api/test/peer_network_dependencies.h"
@ -55,6 +56,14 @@ PeerConfigurer::PeerConfigurer(
params_(std::make_unique<Params>()), params_(std::make_unique<Params>()),
configurable_params_(std::make_unique<ConfigurableParams>()) {} configurable_params_(std::make_unique<ConfigurableParams>()) {}
PeerConfigurer::PeerConfigurer(EmulatedNetworkManagerInterface& network)
: components_(std::make_unique<InjectableComponents>(
network.network_thread(),
network.network_manager(),
network.packet_socket_factory())),
params_(std::make_unique<Params>()),
configurable_params_(std::make_unique<ConfigurableParams>()) {}
PeerConfigurer* PeerConfigurer::SetName(absl::string_view name) { PeerConfigurer* PeerConfigurer::SetName(absl::string_view name) {
params_->name = std::string(name); params_->name = std::string(name);
return this; return this;

View File

@ -30,6 +30,7 @@
#include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "api/test/frame_generator_interface.h" #include "api/test/frame_generator_interface.h"
#include "api/test/network_emulation_manager.h"
#include "api/test/pclf/media_configuration.h" #include "api/test/pclf/media_configuration.h"
#include "api/test/pclf/media_quality_test_params.h" #include "api/test/pclf/media_quality_test_params.h"
#include "api/test/peer_network_dependencies.h" #include "api/test/peer_network_dependencies.h"
@ -50,7 +51,9 @@ class PeerConfigurer {
absl::variant<std::unique_ptr<test::FrameGeneratorInterface>, absl::variant<std::unique_ptr<test::FrameGeneratorInterface>,
CapturingDeviceIndex>; CapturingDeviceIndex>;
explicit PeerConfigurer(const PeerNetworkDependencies& network_dependencies); [[deprecated("bugs.webrtc.org/42232556")]] explicit PeerConfigurer(
const PeerNetworkDependencies& network_dependencies);
explicit PeerConfigurer(EmulatedNetworkManagerInterface& network);
// Sets peer name that will be used to report metrics related to this peer. // Sets peer name that will be used to report metrics related to this peer.
// If not set, some default name will be assigned. All names have to be // If not set, some default name will be assigned. All names have to be

View File

@ -71,10 +71,8 @@ CreateTestFixture(absl::string_view test_case_name,
auto fixture = webrtc_pc_e2e::CreatePeerConnectionE2EQualityTestFixture( auto fixture = webrtc_pc_e2e::CreatePeerConnectionE2EQualityTestFixture(
std::string(test_case_name), time_controller, nullptr, std::string(test_case_name), time_controller, nullptr,
std::move(video_quality_analyzer)); std::move(video_quality_analyzer));
auto alice = std::make_unique<PeerConfigurer>( auto alice = std::make_unique<PeerConfigurer>(*network_links.first);
network_links.first->network_dependencies()); auto bob = std::make_unique<PeerConfigurer>(*network_links.second);
auto bob = std::make_unique<PeerConfigurer>(
network_links.second->network_dependencies());
alice_configurer(alice.get()); alice_configurer(alice.get());
bob_configurer(bob.get()); bob_configurer(bob.get());
fixture->AddPeer(std::move(alice)); fixture->AddPeer(std::move(alice));

View File

@ -82,8 +82,7 @@ class PeerConnectionE2EQualityTestSmokeTest : public ::testing::Test {
void AddPeer(EmulatedNetworkManagerInterface* network, void AddPeer(EmulatedNetworkManagerInterface* network,
rtc::FunctionView<void(PeerConfigurer*)> update_configurer) { rtc::FunctionView<void(PeerConfigurer*)> update_configurer) {
auto configurer = auto configurer = std::make_unique<PeerConfigurer>(*network);
std::make_unique<PeerConfigurer>(network->network_dependencies());
update_configurer(configurer.get()); update_configurer(configurer.get());
fixture_->AddPeer(std::move(configurer)); fixture_->AddPeer(std::move(configurer));
} }

View File

@ -46,17 +46,16 @@ using ::webrtc::webrtc_pc_e2e::PeerConfigurer;
// Adds a peer with some audio and video (the client should not care about // Adds a peer with some audio and video (the client should not care about
// details about audio and video configs). // details about audio and video configs).
void AddDefaultAudioVideoPeer( void AddDefaultAudioVideoPeer(absl::string_view peer_name,
absl::string_view peer_name, absl::string_view audio_stream_label,
absl::string_view audio_stream_label, absl::string_view video_stream_label,
absl::string_view video_stream_label, EmulatedNetworkManagerInterface& network,
const PeerNetworkDependencies& network_dependencies, PeerConnectionE2EQualityTestFixture& fixture) {
PeerConnectionE2EQualityTestFixture& fixture) {
AudioConfig audio{.stream_label = std::string(audio_stream_label), AudioConfig audio{.stream_label = std::string(audio_stream_label),
.sync_group = std::string(peer_name)}; .sync_group = std::string(peer_name)};
VideoConfig video(std::string(video_stream_label), 320, 180, 15); VideoConfig video(std::string(video_stream_label), 320, 180, 15);
video.sync_group = std::string(peer_name); video.sync_group = std::string(peer_name);
auto peer = std::make_unique<PeerConfigurer>(network_dependencies); auto peer = std::make_unique<PeerConfigurer>(network);
peer->SetName(peer_name); peer->SetName(peer_name);
peer->SetAudioConfig(std::move(audio)); peer->SetAudioConfig(std::move(audio));
peer->AddVideoConfig(std::move(video)); peer->AddVideoConfig(std::move(video));
@ -135,9 +134,9 @@ TEST(PeerConnectionE2EQualityTestMetricNamesTest,
network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint}); network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint});
AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video", AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video",
alice_network->network_dependencies(), fixture); *alice_network, fixture);
AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", *bob_network,
bob_network->network_dependencies(), fixture); fixture);
fixture.AddQualityMetricsReporter( fixture.AddQualityMetricsReporter(
std::make_unique<StatsBasedNetworkQualityMetricsReporter>( std::make_unique<StatsBasedNetworkQualityMetricsReporter>(
std::map<std::string, std::vector<EmulatedEndpoint*>>( std::map<std::string, std::vector<EmulatedEndpoint*>>(
@ -1175,9 +1174,9 @@ TEST(PeerConnectionE2EQualityTestMetricNamesTest,
network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint}); network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint});
AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video", AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video",
alice_network->network_dependencies(), fixture); *alice_network, fixture);
AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", *bob_network,
bob_network->network_dependencies(), fixture); fixture);
std::string kAliceNetworkLabel = "alice_label"; std::string kAliceNetworkLabel = "alice_label";
std::string kBobNetworkLabel = "bob_label"; std::string kBobNetworkLabel = "bob_label";
fixture.AddQualityMetricsReporter( fixture.AddQualityMetricsReporter(

View File

@ -116,12 +116,12 @@ TEST_F(PeerConnectionE2EQualityTestTest, OutputVideoIsDumpedWhenRequested) {
VideoConfig alice_video("alice_video", 320, 180, 15); VideoConfig alice_video("alice_video", 320, 180, 15);
alice_video.output_dump_options = VideoDumpOptions(test_directory_); alice_video.output_dump_options = VideoDumpOptions(test_directory_);
PeerConfigurer alice(alice_network->network_dependencies()); PeerConfigurer alice(*alice_network);
alice.SetName("alice"); alice.SetName("alice");
alice.AddVideoConfig(std::move(alice_video)); alice.AddVideoConfig(std::move(alice_video));
fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(alice))); fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(alice)));
PeerConfigurer bob(bob_network->network_dependencies()); PeerConfigurer bob(*bob_network);
bob.SetName("bob"); bob.SetName("bob");
fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(bob))); fixture.AddPeer(std::make_unique<PeerConfigurer>(std::move(bob)));

View File

@ -47,17 +47,16 @@ using ::webrtc::webrtc_pc_e2e::PeerConfigurer;
// Adds a peer with some audio and video (the client should not care about // Adds a peer with some audio and video (the client should not care about
// details about audio and video configs). // details about audio and video configs).
void AddDefaultAudioVideoPeer( void AddDefaultAudioVideoPeer(absl::string_view peer_name,
absl::string_view peer_name, absl::string_view audio_stream_label,
absl::string_view audio_stream_label, absl::string_view video_stream_label,
absl::string_view video_stream_label, EmulatedNetworkManagerInterface& network,
const PeerNetworkDependencies& network_dependencies, PeerConnectionE2EQualityTestFixture& fixture) {
PeerConnectionE2EQualityTestFixture& fixture) {
AudioConfig audio{.stream_label = std::string(audio_stream_label), AudioConfig audio{.stream_label = std::string(audio_stream_label),
.sync_group = std::string(peer_name)}; .sync_group = std::string(peer_name)};
VideoConfig video(std::string(video_stream_label), 320, 180, 15); VideoConfig video(std::string(video_stream_label), 320, 180, 15);
video.sync_group = std::string(peer_name); video.sync_group = std::string(peer_name);
auto peer = std::make_unique<PeerConfigurer>(network_dependencies); auto peer = std::make_unique<PeerConfigurer>(network);
peer->SetName(peer_name); peer->SetName(peer_name);
peer->SetAudioConfig(std::move(audio)); peer->SetAudioConfig(std::move(audio));
peer->AddVideoConfig(std::move(video)); peer->AddVideoConfig(std::move(video));
@ -108,9 +107,9 @@ TEST(StatsBasedNetworkQualityMetricsReporterTest, DebugStatsAreCollected) {
network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint}); network_emulation->CreateEmulatedNetworkManagerInterface({bob_endpoint});
AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video", AddDefaultAudioVideoPeer("alice", "alice_audio", "alice_video",
alice_network->network_dependencies(), fixture); *alice_network, fixture);
AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", AddDefaultAudioVideoPeer("bob", "bob_audio", "bob_video", *bob_network,
bob_network->network_dependencies(), fixture); fixture);
auto network_stats_reporter = auto network_stats_reporter =
std::make_unique<StatsBasedNetworkQualityMetricsReporter>( std::make_unique<StatsBasedNetworkQualityMetricsReporter>(

View File

@ -60,10 +60,8 @@ CreateTestFixture(const std::string& test_case_name,
auto fixture = webrtc_pc_e2e::CreatePeerConnectionE2EQualityTestFixture( auto fixture = webrtc_pc_e2e::CreatePeerConnectionE2EQualityTestFixture(
test_case_name, time_controller, /*audio_quality_analyzer=*/nullptr, test_case_name, time_controller, /*audio_quality_analyzer=*/nullptr,
/*video_quality_analyzer=*/nullptr); /*video_quality_analyzer=*/nullptr);
auto alice = std::make_unique<PeerConfigurer>( auto alice = std::make_unique<PeerConfigurer>(*network_links.first);
network_links.first->network_dependencies()); auto bob = std::make_unique<PeerConfigurer>(*network_links.second);
auto bob = std::make_unique<PeerConfigurer>(
network_links.second->network_dependencies());
alice_configurer(alice.get()); alice_configurer(alice.get());
bob_configurer(bob.get()); bob_configurer(bob.get());
fixture->AddPeer(std::move(alice)); fixture->AddPeer(std::move(alice));