From 5527265f295a80f0794ac7fcbe4d4d11bd211167 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 6 Mar 2024 16:54:55 +1100 Subject: [PATCH] Immediately queue STUN request after forming pair --- src/ice/agent.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ice/agent.rs b/src/ice/agent.rs index b7eaeb99..de45a949 100644 --- a/src/ice/agent.rs +++ b/src/ice/agent.rs @@ -671,6 +671,20 @@ impl IceAgent { let pair = self.candidate_pairs.pop(); debug!("Remove overflow pair {:?}", pair); } + + let newly_formed_pairs = self + .candidate_pairs + .iter() + .enumerate() + .filter_map(|(idx, p)| { + (local_idxs.contains(&p.local_idx()) && remote_idxs.contains(&p.remote_idx())) + .then_some(idx) + }) + .collect::>(); + + for idx in newly_formed_pairs { + self.stun_client_binding_request(self.last_now.unwrap(), idx) + } } /// Invalidate a candidate and remove it from the connection.