From 060b1fc6ca835bf31710fdae8ed361e51e8d4193 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 4 May 2021 10:21:24 -0400
Subject: [PATCH] ice_transport: trim only if the limit is reached per
 components

PJ_ICE_ST_MAX_CAND is a limit PER components, not for the whole
list

Change-Id: I51252b01170bbf5274a3e5c2d079fe37fed25fff
GitLab: #539
---
 src/ice_transport.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp
index 409b858f03..613e8ecf75 100644
--- a/src/ice_transport.cpp
+++ b/src/ice_transport.cpp
@@ -1100,7 +1100,8 @@ IceTransport::startIce(const Attribute& rem_attrs, std::vector<IceCandidate>&& r
         return false;
     }
 
-    if (rem_candidates.size() > PJ_ICE_ST_MAX_CAND - 1) {
+    auto comp_cnt = std::max(1u, getComponentCount());
+    if (rem_candidates.size() / comp_cnt > PJ_ICE_ST_MAX_CAND - 1) {
         std::vector<IceCandidate> rcands;
         rcands.reserve(PJ_ICE_ST_MAX_CAND - 1);
         JAMI_WARN("[ice:%p] too much candidates detected, trim list.", pimpl_.get());
-- 
GitLab