Add a turn port prune policy to keep the first ready turn port.
Bug: webrtc:11026
Change-Id: I6222e9613ee4ce2dcfbb717e2430ea833c0dc373
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/155542
Commit-Queue: Honghai Zhang <honghaiz@webrtc.org>
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29470}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index c0e1831..f019ec9 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -758,6 +758,7 @@
bool prioritize_most_likely_ice_candidate_pairs;
struct cricket::MediaConfig media_config;
bool prune_turn_ports;
+ PortPrunePolicy turn_port_prune_policy;
bool presume_writable_when_fully_relayed;
bool enable_ice_renomination;
bool redetermine_role_on_ice_restart;
@@ -817,6 +818,7 @@
enable_dtls_srtp == o.enable_dtls_srtp &&
ice_candidate_pool_size == o.ice_candidate_pool_size &&
prune_turn_ports == o.prune_turn_ports &&
+ turn_port_prune_policy == o.turn_port_prune_policy &&
presume_writable_when_fully_relayed ==
o.presume_writable_when_fully_relayed &&
enable_ice_renomination == o.enable_ice_renomination &&
@@ -3675,6 +3677,7 @@
modified_config.ice_candidate_pool_size =
configuration.ice_candidate_pool_size;
modified_config.prune_turn_ports = configuration.prune_turn_ports;
+ modified_config.turn_port_prune_policy = configuration.turn_port_prune_policy;
modified_config.surface_ice_candidates_on_ice_transport_type_changed =
configuration.surface_ice_candidates_on_ice_transport_type_changed;
modified_config.ice_check_min_interval = configuration.ice_check_min_interval;
@@ -3746,7 +3749,7 @@
rtc::Bind(&PeerConnection::ReconfigurePortAllocator_n, this,
stun_servers, turn_servers, modified_config.type,
modified_config.ice_candidate_pool_size,
- modified_config.prune_turn_ports,
+ modified_config.GetTurnPortPrunePolicy(),
modified_config.turn_customizer,
modified_config.stun_candidate_keepalive_interval,
static_cast<bool>(local_description())))) {
@@ -3759,7 +3762,8 @@
// triggers an ICE restart which will pick up the changes.
if (modified_config.servers != configuration_.servers ||
modified_config.type != configuration_.type ||
- modified_config.prune_turn_ports != configuration_.prune_turn_ports) {
+ modified_config.GetTurnPortPrunePolicy() !=
+ configuration_.GetTurnPortPrunePolicy()) {
transport_controller_->SetNeedsIceRestartFlag();
}
@@ -5736,8 +5740,8 @@
// properties set above.
port_allocator_->SetConfiguration(
stun_servers, std::move(turn_servers_copy),
- configuration.ice_candidate_pool_size, configuration.prune_turn_ports,
- configuration.turn_customizer,
+ configuration.ice_candidate_pool_size,
+ configuration.GetTurnPortPrunePolicy(), configuration.turn_customizer,
configuration.stun_candidate_keepalive_interval);
InitializePortAllocatorResult res;
@@ -5750,7 +5754,7 @@
const std::vector<cricket::RelayServerConfig>& turn_servers,
IceTransportsType type,
int candidate_pool_size,
- bool prune_turn_ports,
+ PortPrunePolicy turn_port_prune_policy,
webrtc::TurnCustomizer* turn_customizer,
absl::optional<int> stun_candidate_keepalive_interval,
bool have_local_description) {
@@ -5771,7 +5775,8 @@
// candidate filter set above.
return port_allocator_->SetConfiguration(
stun_servers, std::move(turn_servers_copy), candidate_pool_size,
- prune_turn_ports, turn_customizer, stun_candidate_keepalive_interval);
+ turn_port_prune_policy, turn_customizer,
+ stun_candidate_keepalive_interval);
}
cricket::ChannelManager* PeerConnection::channel_manager() const {