From e8d27c7092e5d2d3cba1c69e770f82423631f071 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 16 Oct 2024 13:21:49 +0200 Subject: [PATCH] PCLF: provide port allocator flags directly instead of providing only extra flags Bug: b/349563913 Change-Id: Ic2568c1ec4194bee6c2869dfa6a6fa8e1a2d2057 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365800 Commit-Queue: Artem Titov Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#43250} --- api/test/pclf/media_quality_test_params.h | 11 ++++++++--- api/test/pclf/peer_configurer.cc | 10 +++++++++- api/test/pclf/peer_configurer.h | 14 ++++++++++++-- test/pc/e2e/test_peer_factory.cc | 12 ++++++++---- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/api/test/pclf/media_quality_test_params.h b/api/test/pclf/media_quality_test_params.h index 56c4c1b35c..aae4d22a07 100644 --- a/api/test/pclf/media_quality_test_params.h +++ b/api/test/pclf/media_quality_test_params.h @@ -128,9 +128,14 @@ struct Params { std::optional name; // If `audio_config` is set audio stream will be configured std::optional audio_config; - // Flags to set on `cricket::PortAllocator`. These flags will be added - // to the default ones that are presented on the port allocator. - uint32_t port_allocator_extra_flags = cricket::kDefaultPortAllocatorFlags; + // Flags to set on `cricket::PortAllocator`. If not set, + // cricket::kDefaultPortAllocatorFlags will be used and + // cricket::PORTALLOCATOR_DISABLE_TCP will be disabled. + // + // IMPORTANT: if you use WebRTC Network Emulation + // (api/test/network_emulation_manager.h) and set this field, remember to set + // cricket::PORTALLOCATOR_DISABLE_TCP to 0. + std::optional port_allocator_flags = std::nullopt; // If `rtc_event_log_path` is set, an RTCEventLog will be saved in that // location and it will be available for further analysis. std::optional rtc_event_log_path; diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc index a19e250923..e608ee8ee8 100644 --- a/api/test/pclf/peer_configurer.cc +++ b/api/test/pclf/peer_configurer.cc @@ -240,9 +240,17 @@ PeerConfigurer* PeerConfigurer::SetFieldTrials( PeerConfigurer* PeerConfigurer::SetPortAllocatorExtraFlags( uint32_t extra_flags) { - params_->port_allocator_extra_flags = extra_flags; + params_->port_allocator_flags = cricket::kDefaultPortAllocatorFlags | + cricket::PORTALLOCATOR_DISABLE_TCP | + extra_flags; return this; } + +PeerConfigurer* PeerConfigurer::SetPortAllocatorFlags(uint32_t flags) { + params_->port_allocator_flags = flags; + return this; +} + std::unique_ptr PeerConfigurer::ReleaseComponents() { RTC_CHECK(components_); auto components = std::move(components_); diff --git a/api/test/pclf/peer_configurer.h b/api/test/pclf/peer_configurer.h index 3c88d9b3a6..1cb7c3a6ed 100644 --- a/api/test/pclf/peer_configurer.h +++ b/api/test/pclf/peer_configurer.h @@ -99,9 +99,19 @@ class PeerConfigurer { PeerConfigurer* SetIceTransportFactory( std::unique_ptr factory); // Flags to set on `cricket::PortAllocator`. These flags will be added - // to the default ones that are presented on the port allocator. - // For possible values check p2p/base/port_allocator.h. + // to the cricket::kDefaultPortAllocatorFlags with + // cricket::PORTALLOCATOR_DISABLE_TCP disabled. For possible values check + // p2p/base/port_allocator.h. PeerConfigurer* SetPortAllocatorExtraFlags(uint32_t extra_flags); + // Flags to set on `cricket::PortAllocator`. These flags will override + // the default ones that are presented on the port allocator. + // + // For possible values check p2p/base/port_allocator.h. + // + // IMPORTANT: if you use WebRTC Network Emulation + // (api/test/network_emulation_manager.h) and set this field, remember to set + // cricket::PORTALLOCATOR_DISABLE_TCP to 0. + PeerConfigurer* SetPortAllocatorFlags(uint32_t flags); // Add new video stream to the call that will be sent from this peer. // Default implementation of video frames generator will be used. diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index a744b95c89..d000b0b422 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -243,15 +243,19 @@ PeerConnectionFactoryDependencies CreatePCFDependencies( // from InjectableComponents::PeerConnectionComponents. PeerConnectionDependencies CreatePCDependencies( MockPeerConnectionObserver* observer, - uint32_t port_allocator_extra_flags, + std::optional port_allocator_flags, std::unique_ptr pc_dependencies) { PeerConnectionDependencies pc_deps(observer); auto port_allocator = std::make_unique( pc_dependencies->network_manager, pc_dependencies->packet_socket_factory); - // This test does not support TCP - int flags = port_allocator_extra_flags | cricket::PORTALLOCATOR_DISABLE_TCP; + // This test does not support TCP by default. + int flags = + cricket::kDefaultPortAllocatorFlags | cricket::PORTALLOCATOR_DISABLE_TCP; + if (port_allocator_flags.has_value()) { + flags = *port_allocator_flags; + } port_allocator->set_flags(port_allocator->flags() | flags); pc_deps.allocator = std::move(port_allocator); @@ -339,7 +343,7 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( // Create peer connection. PeerConnectionDependencies pc_deps = - CreatePCDependencies(observer.get(), params->port_allocator_extra_flags, + CreatePCDependencies(observer.get(), params->port_allocator_flags, std::move(components->pc_dependencies)); rtc::scoped_refptr peer_connection = peer_connection_factory