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++) {