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 <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43250}
This commit is contained in:
Artem Titov 2024-10-16 13:21:49 +02:00 committed by WebRTC LUCI CQ
parent 049b43bd02
commit e8d27c7092
4 changed files with 37 additions and 10 deletions

View File

@ -128,9 +128,14 @@ struct Params {
std::optional<std::string> name;
// If `audio_config` is set audio stream will be configured
std::optional<AudioConfig> 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<uint32_t> 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<std::string> rtc_event_log_path;

View File

@ -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<InjectableComponents> PeerConfigurer::ReleaseComponents() {
RTC_CHECK(components_);
auto components = std::move(components_);

View File

@ -99,9 +99,19 @@ class PeerConfigurer {
PeerConfigurer* SetIceTransportFactory(
std::unique_ptr<IceTransportFactory> 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.

View File

@ -243,15 +243,19 @@ PeerConnectionFactoryDependencies CreatePCFDependencies(
// from InjectableComponents::PeerConnectionComponents.
PeerConnectionDependencies CreatePCDependencies(
MockPeerConnectionObserver* observer,
uint32_t port_allocator_extra_flags,
std::optional<uint32_t> port_allocator_flags,
std::unique_ptr<PeerConnectionComponents> pc_dependencies) {
PeerConnectionDependencies pc_deps(observer);
auto port_allocator = std::make_unique<cricket::BasicPortAllocator>(
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<TestPeer> 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<PeerConnectionInterface> peer_connection =
peer_connection_factory