From 9353abd320c36b335eec5c7813400beb4a02fb9a Mon Sep 17 00:00:00 2001 From: seb Date: Tue, 19 Apr 2011 15:04:06 +0000 Subject: [PATCH] Add also the HostCandidate used for UPnP gathering as it is needed for peer reflexive detection. --- src/org/ice4j/ice/Agent.java | 1 - src/org/ice4j/ice/Component.java | 1 - src/org/ice4j/ice/harvest/UPNPHarvester.java | 23 +++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 3d1b695..8f37bdc 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -964,7 +964,6 @@ public class Agent public CandidatePair findCandidatePair(TransportAddress localAddress, TransportAddress remoteAddress) { - synchronized(mediaStreams) { Collection streamsCollection diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java index 604f426..37858ff 100644 --- a/src/org/ice4j/ice/Component.java +++ b/src/org/ice4j/ice/Component.java @@ -760,7 +760,6 @@ public class Component */ public LocalCandidate findLocalCandidate(TransportAddress localAddress) { - for( LocalCandidate localCnd : localCandidates) { if(localCnd.getTransportAddress().equals(localAddress)) diff --git a/src/org/ice4j/ice/harvest/UPNPHarvester.java b/src/org/ice4j/ice/harvest/UPNPHarvester.java index dddb4f5..7d24044 100644 --- a/src/org/ice4j/ice/harvest/UPNPHarvester.java +++ b/src/org/ice4j/ice/harvest/UPNPHarvester.java @@ -103,11 +103,20 @@ public class UPNPHarvester "UDP", "Ice4J: " + port)) { - LocalCandidate cand = createUPNPCandidate(socket, + List cands = createUPNPCandidate(socket, localAddress, externalIPAddress, externalPort, component, device); - component.addLocalCandidate(cand); - candidates.add(cand); + + // we have to add the UPNPCandidate and also the base. + // if we don't add the base, we won't be able to add + // peer reflexive candidate if someone contact us on the + // UPNPCandidate + for(LocalCandidate cand : cands) + { + component.addLocalCandidate(cand); + candidates.add(cand); + } + break; } else @@ -143,11 +152,12 @@ public class UPNPHarvester * represents the specified TransportAddress * @throws Exception if something goes wrong during candidate creation */ - public UPNPCandidate createUPNPCandidate(DatagramSocket socket, + public List createUPNPCandidate(DatagramSocket socket, InetAddress localAddr, String externalIP, int port, Component cmp, GatewayDevice device) throws Exception { + List ret = new ArrayList(); TransportAddress addr = new TransportAddress(externalIP, port, Transport.UDP); @@ -157,6 +167,9 @@ public class UPNPHarvester DatagramSocket stunSocket = candidate.getStunSocket(null); candidate.getStunStack().addSocket(stunSocket); - return candidate; + ret.add(candidate); + ret.add(base); + + return ret; } }