From b47038b82f68878bc98560a2cf953014ed85d1d0 Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Wed, 11 Apr 2007 21:49:12 +0000 Subject: [PATCH] [SMACK-212] Added capability to try another way to establish the session. If just one side has Relay Server. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7987 b35dd754-fafc-0310-a699-88a17e54d16e --- .../jingle/mediaimpl/jmf/AudioChannel.java | 2 +- .../jingle/nat/TransportNegotiator.java | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioChannel.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioChannel.java index 888607bc2..fcca87b37 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioChannel.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/mediaimpl/jmf/AudioChannel.java @@ -367,7 +367,7 @@ public class AudioChannel { catch (InvalidSessionAddressException e) { // In case the local address is not allowed to read, we user another local address SessionAddress sessAddr = new SessionAddress(); - localAddr = new SessionAddress(InetAddress.getByName(sessAddr.getDataHostAddress()), + localAddr = new SessionAddress(sessAddr.getDataAddress(), localPort); rtpMgrs[i].initialize(localAddr); } diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java index a66b348ae..e5576c008 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java @@ -321,16 +321,51 @@ public abstract class TransportNegotiator extends JingleNegotiator { TransportCandidate bestRemote = getBestRemoteCandidate(); if (bestRemote == null) { + boolean foundRemoteRelay = false; for (TransportCandidate candidate : remoteCandidates) { if (candidate instanceof ICECandidate) { ICECandidate iceCandidate = (ICECandidate) candidate; if (iceCandidate.getType().equals("relay")) { //TODO Check if the relay is reacheable addValidRemoteCandidate(iceCandidate); + foundRemoteRelay = true; } } } + // If not found, check if we offered a relay. If yes, we should accept any remote candidate. + // We should accept the Public One if we received it, otherwise, accepts any. + if (!foundRemoteRelay) { + boolean foundLocalRelay = false; + for (TransportCandidate candidate : offeredCandidates) { + if (candidate instanceof ICECandidate) { + ICECandidate iceCandidate = (ICECandidate) candidate; + if (iceCandidate.getType().equals("relay")) { + foundLocalRelay = true; + } + } + } + if (foundLocalRelay) { + boolean foundRemotePublic = false; + for (TransportCandidate candidate : remoteCandidates) { + if (candidate instanceof ICECandidate) { + ICECandidate iceCandidate = (ICECandidate) candidate; + if (iceCandidate.getType().equals("srflx")) { + addValidRemoteCandidate(iceCandidate); + foundRemotePublic = true; + } + } + } + if (!foundRemotePublic) { + for (TransportCandidate candidate : remoteCandidates) { + if (candidate instanceof ICECandidate) { + ICECandidate iceCandidate = (ICECandidate) candidate; + addValidRemoteCandidate(iceCandidate); + } + } + } + } + } } for (int i = 0; i < 6; i++) {