From bd176c2515702680c0981e5fb786944523666bdf Mon Sep 17 00:00:00 2001 From: Thiago Camargo Date: Thu, 22 Feb 2007 19:14:18 +0000 Subject: [PATCH] More Jingle Refactoring git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7245 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/jingle/nat/ICECandidate.java | 338 ++++++++++++++++++ .../smackx/jingle/nat/ICEResolver.java | 6 +- .../jingle/nat/ICETransportManager.java | 4 +- .../smackx/jingle/nat/TransportCandidate.java | 282 +-------------- .../jingle/nat/TransportNegotiator.java | 10 +- .../smackx/packet/JingleTransport.java | 5 +- .../provider/JingleTransportProvider.java | 3 +- .../smackx/jingle/nat/STUNResolverTest.java | 23 +- .../jingle/nat/TransportCandidateTest.java | 16 +- jingle/media/test/JingleMediaTest.java | 4 +- 10 files changed, 375 insertions(+), 316 deletions(-) create mode 100644 jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java new file mode 100644 index 000000000..33b2a03ef --- /dev/null +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICECandidate.java @@ -0,0 +1,338 @@ +/** + * $RCSfile$ + * $Revision$ + * $Date$ + * + * Copyright (C) 2002-2006 Jive Software. All rights reserved. + * ==================================================================== + * The Jive Software License (based on Apache Software License, Version 1.1) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by + * Jive Software (http://www.jivesoftware.com)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Smack" and "Jive Software" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please + * contact webmaster@jivesoftware.com. + * + * 5. Products derived from this software may not be called "Smack", + * nor may "Smack" appear in their name, without prior written + * permission of Jive Software. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + */ +package org.jivesoftware.smackx.jingle.nat; + +/** + * ICE Transport candidate. + *

+ * A candidate represents the possible transport for data interchange between + * the two endpoints. + * + * @author Thiago Camargo + */ +public class ICECandidate extends TransportCandidate implements Comparable { + + private String id; // An identification + + private String username; + + private int preference; + + private Protocol proto; + + private Channel channel; + + private int network; + + private String type; + + public ICECandidate() { + super(); + } + + /** + * Constructor with the basic elements of a transport definition. + * + * @param ip the IP address to use as a local address + * @param generation used to keep track of the candidates + * @param network used for diagnostics (used when the machine has + * several NICs) + * @param password user name, as it is used in ICE + * @param port the port at the candidate IP address + * @param username user name, as it is used in ICE + * @param preference preference for this transportElement, as it is used + * in ICE + * @param type type as defined in ICE-12 + */ + public ICECandidate(String ip, int generation, int network, + String password, int port, String username, + int preference, String type) { + super(ip, port, generation); + + proto = Protocol.UDP; + channel = Channel.MYRTPVOICE; + + this.network = network; + this.password = password; + this.username = username; + this.preference = preference; + this.type = type; + } + + /** + * Get the ID + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Set the ID + * + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * Get the protocol used for the transmission + * + * @return the protocol used for transmission + */ + public Protocol getProto() { + return proto; + } + + /** + * Set the protocol for the transmission + * + * @param proto the protocol to use + */ + public void setProto(Protocol proto) { + this.proto = proto; + } + + /** + * Get the network interface used for this connection + * + * @return the interface number + */ + public int getNetwork() { + return network; + } + + /** + * Set the interface for this connection + * + * @param network the interface number + */ + public void setNetwork(int network) { + this.network = network; + } + + /** + * Get the username for this transportElement in ICE + * + * @return a username string + */ + public String getUsername() { + return username; + } + + /** + * Get the channel + * + * @return the channel associated + */ + public Channel getChannel() { + return channel; + } + + /** + * Set the channel for this transportElement + * + * @param channel the new channel + */ + public void setChannel(Channel channel) { + this.channel = channel; + } + + /** + * Set the username for this transportElement in ICE + * + * @param username the username used in ICE + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Get the preference number for this transportElement + * + * @return the preference for this transportElement + */ + public int getPreference() { + return preference; + } + + /** + * Set the preference order for this transportElement + * + * @param preference a number identifying the preference (as defined in + * ICE) + */ + public void setPreference(int preference) { + this.preference = preference; + } + + /** + * Get the Candidate Type + * + * @return candidate Type + */ + public String getType() { + return type; + } + + /** + * Set the Candidate Type + * + * @param type candidate type. + */ + public void setType(String type) { + this.type = type; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + final ICECandidate other = (ICECandidate) obj; + if (getChannel() == null) { + if (other.getChannel() != null) { + return false; + } + } + else if (!getChannel().equals(other.getChannel())) { + return false; + } + if (getId() == null) { + if (other.getId() != null) { + return false; + } + } + else if (!getId().equals(other.getId())) { + return false; + } + if (getNetwork() != other.getNetwork()) { + return false; + } + if (getPassword() == null) { + if (other.getPassword() != null) { + return false; + } + } + else if (!getPassword().equals(other.password)) { + return false; + } + if (getPreference() != other.getPreference()) { + return false; + } + if (getProto() == null) { + if (other.getProto() != null) { + return false; + } + } + else if (!getProto().equals(other.getProto())) { + return false; + } + if (getUsername() == null) { + if (other.getUsername() != null) { + return false; + } + } + else if (!getUsername().equals(other.getUsername())) { + return false; + } + return true; + } + + public boolean isNull() { + if (super.isNull()) { + return true; + } + else if (getProto().isNull()) { + return true; + } + else if (getChannel().isNull()) { + return true; + } + return false; + } + + /** + * Compare the to other Transport candidate. + * + * @param arg another Transport candidate + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * object + */ + public int compareTo(Object arg) { + if (arg instanceof ICECandidate) { + ICECandidate tc = (ICECandidate) arg; + if (getPreference() < tc.getPreference()) { + return -1; + } + else if (getPreference() > tc.getPreference()) { + return 1; + } + } + return 0; + } +} + diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICEResolver.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICEResolver.java index 425da068e..0ddc2fb9b 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICEResolver.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICEResolver.java @@ -77,7 +77,7 @@ public class ICEResolver extends TransportResolver { else typeString = "host"; - TransportCandidate transportCandidate = new TransportCandidate.Ice(candidate.getAddress().getInetAddress().getHostAddress(), 1, candidate.getNetwork(), "1", candidate.getPort(), "1", candidate.getPriority(), typeString); + TransportCandidate transportCandidate = new ICECandidate(candidate.getAddress().getInetAddress().getHostAddress(), 1, candidate.getNetwork(), "1", candidate.getPort(), "1", candidate.getPriority(), typeString); transportCandidate.setLocalIp(candidate.getBase().getAddress().getInetAddress().getHostAddress()); transportCandidate.setPort(getFreePort()); this.addCandidate(transportCandidate); @@ -100,11 +100,11 @@ public class ICEResolver extends TransportResolver { RTPBridge rtpBridge = RTPBridge.getRTPBridge(connection, String.valueOf(sid)); - TransportCandidate localCandidate = new TransportCandidate.Ice( + TransportCandidate localCandidate = new ICECandidate( rtpBridge.getIp(), 1, cc.getPublicCandidate().getNetwork(), "1", rtpBridge.getPortA(), "1", 0, "relay"); localCandidate.setLocalIp(localIp); - TransportCandidate remoteCandidate = new TransportCandidate.Ice( + TransportCandidate remoteCandidate = new ICECandidate( rtpBridge.getIp(), 1, cc.getPublicCandidate().getNetwork(), "1", rtpBridge.getPortB(), "1", 0, "relay"); remoteCandidate.setLocalIp(localIp); diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICETransportManager.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICETransportManager.java index e4d8dcf71..864883331 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICETransportManager.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/ICETransportManager.java @@ -53,8 +53,8 @@ public class ICETransportManager extends JingleTransportManager implements Jingl // Implement a Session Listener to relay candidates after establishment public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) { - if (lc instanceof TransportCandidate.Ice) { - if (((TransportCandidate.Ice) lc).getType().equals("relay")) { + if (lc instanceof ICECandidate) { + if (((ICECandidate) lc).getType().equals("relay")) { RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc); } } diff --git a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java index 2a488951a..dcb8a6ccb 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportCandidate.java @@ -461,287 +461,7 @@ public abstract class TransportCandidate { super(ip, port, generation); } } - - /** - * Ice candidate. - */ - public static class Ice extends TransportCandidate implements Comparable { - - private String id; // An identification - - private String username; - - private int preference; - - private Protocol proto; - - private Channel channel; - - private int network; - - private String type; - - public Ice() { - super(); - } - - /** - * Constructor with the basic elements of a transport definition. - * - * @param ip the IP address to use as a local address - * @param generation used to keep track of the candidates - * @param network used for diagnostics (used when the machine has - * several NICs) - * @param password user name, as it is used in ICE - * @param port the port at the candidate IP address - * @param username user name, as it is used in ICE - * @param preference preference for this transportElement, as it is used - * in ICE - * @param type type as defined in ICE-12 - */ - public Ice(String ip, int generation, int network, - String password, int port, String username, - int preference, String type) { - super(ip, port, generation); - - proto = Protocol.UDP; - channel = Channel.MYRTPVOICE; - - this.network = network; - this.password = password; - this.username = username; - this.preference = preference; - this.type = type; - } - - /** - * Get the ID - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Set the ID - * - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * Get the protocol used for the transmission - * - * @return the protocol used for transmission - */ - public Protocol getProto() { - return proto; - } - - /** - * Set the protocol for the transmission - * - * @param proto the protocol to use - */ - public void setProto(Protocol proto) { - this.proto = proto; - } - - /** - * Get the network interface used for this connection - * - * @return the interface number - */ - public int getNetwork() { - return network; - } - - /** - * Set the interface for this connection - * - * @param network the interface number - */ - public void setNetwork(int network) { - this.network = network; - } - - /** - * Get the username for this transportElement in ICE - * - * @return a username string - */ - public String getUsername() { - return username; - } - - /** - * Get the channel - * - * @return the channel associated - */ - public Channel getChannel() { - return channel; - } - - /** - * Set the channel for this transportElement - * - * @param channel the new channel - */ - public void setChannel(Channel channel) { - this.channel = channel; - } - - /** - * Set the username for this transportElement in ICE - * - * @param username the username used in ICE - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Get the preference number for this transportElement - * - * @return the preference for this transportElement - */ - public int getPreference() { - return preference; - } - - /** - * Set the preference order for this transportElement - * - * @param preference a number identifying the preference (as defined in - * ICE) - */ - public void setPreference(int preference) { - this.preference = preference; - } - - /** - * Get the Candidate Type - * - * @return candidate Type - */ - public String getType() { - return type; - } - - /** - * Set the Candidate Type - * - * @param type candidate type. - */ - public void setType(String type) { - this.type = type; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - final Ice other = (Ice) obj; - if (getChannel() == null) { - if (other.getChannel() != null) { - return false; - } - } - else if (!getChannel().equals(other.getChannel())) { - return false; - } - if (getId() == null) { - if (other.getId() != null) { - return false; - } - } - else if (!getId().equals(other.getId())) { - return false; - } - if (getNetwork() != other.getNetwork()) { - return false; - } - if (getPassword() == null) { - if (other.getPassword() != null) { - return false; - } - } - else if (!getPassword().equals(other.password)) { - return false; - } - if (getPreference() != other.getPreference()) { - return false; - } - if (getProto() == null) { - if (other.getProto() != null) { - return false; - } - } - else if (!getProto().equals(other.getProto())) { - return false; - } - if (getUsername() == null) { - if (other.getUsername() != null) { - return false; - } - } - else if (!getUsername().equals(other.getUsername())) { - return false; - } - return true; - } - - public boolean isNull() { - if (super.isNull()) { - return true; - } - else if (getProto().isNull()) { - return true; - } - else if (getChannel().isNull()) { - return true; - } - return false; - } - - /** - * Compare the to other Transport candidate. - * - * @param arg another Transport candidate - * @return a negative integer, zero, or a positive integer as this - * object is less than, equal to, or greater than the specified - * object - */ - public int compareTo(Object arg) { - if (arg instanceof TransportCandidate.Ice) { - TransportCandidate.Ice tc = (TransportCandidate.Ice) arg; - if (getPreference() < tc.getPreference()) { - return -1; - } - else if (getPreference() > tc.getPreference()) { - return 1; - } - } - return 0; - } - } - + /** * Type-safe enum for the transportElement protocol */ 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 728fc8a82..cbcd79017 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java +++ b/jingle/extension/source/org/jivesoftware/smackx/jingle/nat/TransportNegotiator.java @@ -817,13 +817,13 @@ public abstract class TransportNegotiator extends JingleNegotiator { * @return the bestRemoteCandidate */ public TransportCandidate getBestRemoteCandidate() { - TransportCandidate.Ice result = null; + ICECandidate result = null; - ArrayList cands = getValidRemoteCandidatesList(); + ArrayList cands = getValidRemoteCandidatesList(); if (!cands.isEmpty()) { int highest = -1; - TransportCandidate.Ice chose = null; - for (TransportCandidate.Ice transportCandidate : cands) { + ICECandidate chose = null; + for (ICECandidate transportCandidate : cands) { if (transportCandidate.getPreference() > highest) { chose = transportCandidate; highest = transportCandidate.getPreference(); @@ -839,7 +839,7 @@ public abstract class TransportNegotiator extends JingleNegotiator { * Return true for ICE candidates. */ public boolean acceptableTransportCandidate(TransportCandidate tc, List localCandidates) { - return tc instanceof TransportCandidate.Ice; + return tc instanceof ICECandidate; } } } diff --git a/jingle/extension/source/org/jivesoftware/smackx/packet/JingleTransport.java b/jingle/extension/source/org/jivesoftware/smackx/packet/JingleTransport.java index cd09caf79..4d4eeabb0 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/packet/JingleTransport.java +++ b/jingle/extension/source/org/jivesoftware/smackx/packet/JingleTransport.java @@ -2,6 +2,7 @@ package org.jivesoftware.smackx.packet; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smackx.jingle.nat.TransportCandidate; +import org.jivesoftware.smackx.jingle.nat.ICECandidate; import java.util.ArrayList; import java.util.Collections; @@ -303,8 +304,8 @@ public class JingleTransport implements PacketExtension { protected String getChildElements() { StringBuilder buf = new StringBuilder(); - if (transportCandidate != null) {// && transportCandidate instanceof TransportCandidate.Ice) { - TransportCandidate.Ice tci = (TransportCandidate.Ice) transportCandidate; + if (transportCandidate != null) {// && transportCandidate instanceof ICECandidate) { + ICECandidate tci = (ICECandidate) transportCandidate; // We convert the transportElement candidate to XML here... buf.append(" generation=\"").append(tci.getGeneration()).append("\""); diff --git a/jingle/extension/source/org/jivesoftware/smackx/provider/JingleTransportProvider.java b/jingle/extension/source/org/jivesoftware/smackx/provider/JingleTransportProvider.java index 9f53af795..7b91bd9dd 100644 --- a/jingle/extension/source/org/jivesoftware/smackx/provider/JingleTransportProvider.java +++ b/jingle/extension/source/org/jivesoftware/smackx/provider/JingleTransportProvider.java @@ -3,6 +3,7 @@ package org.jivesoftware.smackx.provider; import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.jivesoftware.smackx.jingle.nat.TransportCandidate; +import org.jivesoftware.smackx.jingle.nat.ICECandidate; import org.jivesoftware.smackx.packet.JingleTransport; import org.jivesoftware.smackx.packet.JingleTransport.JingleTransportCandidate; import org.xmlpull.v1.XmlPullParser; @@ -97,7 +98,7 @@ public abstract class JingleTransportProvider implements PacketExtensionProvider * @throws Exception */ protected JingleTransportCandidate parseCandidate(XmlPullParser parser) throws Exception { - TransportCandidate.Ice mt = new TransportCandidate.Ice(); + ICECandidate mt = new ICECandidate(); String channel = parser.getAttributeValue("", "channel"); String generation = parser.getAttributeValue("", "generation"); diff --git a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java index 75e97221a..cdd656b09 100644 --- a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java +++ b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/STUNResolverTest.java @@ -60,15 +60,15 @@ public class STUNResolverTest extends SmackTestCase { public void testGetPreferredCandidate() throws Exception { int highestPref = 100; - TransportCandidate cand1 = new TransportCandidate.Ice("192.168.2.1", 3, 2, + TransportCandidate cand1 = new ICECandidate("192.168.2.1", 3, 2, "password", 3468, "username1", 1, ""); - TransportCandidate cand2 = new TransportCandidate.Ice("192.168.5.1", 2, 10, + TransportCandidate cand2 = new ICECandidate("192.168.5.1", 2, 10, "password", 3469, "username2", 15, ""); - TransportCandidate candH = new TransportCandidate.Ice("192.168.2.11", 1, 2, + TransportCandidate candH = new ICECandidate("192.168.2.11", 1, 2, "password", 3468, "usernameH", highestPref, ""); - TransportCandidate cand3 = new TransportCandidate.Ice("192.168.2.10", 2, 10, + TransportCandidate cand3 = new ICECandidate("192.168.2.10", 2, 10, "password", 3469, "username3", 2, ""); - TransportCandidate cand4 = new TransportCandidate.Ice("192.168.4.1", 3, 2, + TransportCandidate cand4 = new ICECandidate("192.168.4.1", 3, 2, "password", 3468, "username4", 78, ""); STUNResolver stunResolver = new STUNResolver() { @@ -90,15 +90,15 @@ public class STUNResolverTest extends SmackTestCase { public void testGetPreferredCandidateICE() throws Exception { int highestPref = 100; - TransportCandidate cand1 = new TransportCandidate.Ice("192.168.2.1", 3, 2, + TransportCandidate cand1 = new ICECandidate("192.168.2.1", 3, 2, "password", 3468, "username1", 1, ""); - TransportCandidate cand2 = new TransportCandidate.Ice("192.168.5.1", 2, 10, + TransportCandidate cand2 = new ICECandidate("192.168.5.1", 2, 10, "password", 3469, "username2", 15, ""); - TransportCandidate candH = new TransportCandidate.Ice("192.168.2.11", 1, 2, + TransportCandidate candH = new ICECandidate("192.168.2.11", 1, 2, "password", 3468, "usernameH", highestPref, ""); - TransportCandidate cand3 = new TransportCandidate.Ice("192.168.2.10", 2, 10, + TransportCandidate cand3 = new ICECandidate("192.168.2.10", 2, 10, "password", 3469, "username3", 2, ""); - TransportCandidate cand4 = new TransportCandidate.Ice("192.168.4.1", 3, 2, + TransportCandidate cand4 = new ICECandidate("192.168.4.1", 3, 2, "password", 3468, "username4", 78, ""); ICEResolver iceResolver = new ICEResolver(getConnection(0), "stun.xten.net", 3478) { @@ -129,11 +129,10 @@ public class STUNResolverTest extends SmackTestCase { // priorize candidates cc.prioritizeCandidates(); // get SortedCandidates - //List sortedCandidates = cc.getSortedCandidates(); for (Candidate candidate : cc.getSortedCandidates()) try { - TransportCandidate transportCandidate = new TransportCandidate.Ice(candidate.getAddress().getInetAddress().getHostAddress(), 1, candidate.getNetwork(), "1", candidate.getPort(), "1", candidate.getPriority(), ""); + TransportCandidate transportCandidate = new ICECandidate(candidate.getAddress().getInetAddress().getHostAddress(), 1, candidate.getNetwork(), "1", candidate.getPort(), "1", candidate.getPriority(), ""); transportCandidate.setLocalIp(candidate.getBase().getAddress().getInetAddress().getHostAddress()); System.out.println("C: " + candidate.getAddress().getInetAddress() + "|" + candidate.getBase().getAddress().getInetAddress() + " p:" + candidate.getPriority()); } diff --git a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/TransportCandidateTest.java b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/TransportCandidateTest.java index 505cd1455..89800a77b 100644 --- a/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/TransportCandidateTest.java +++ b/jingle/extension/test/org/jivesoftware/smackx/jingle/nat/TransportCandidateTest.java @@ -18,11 +18,11 @@ public class TransportCandidateTest extends SmackTestCase { * Test for equals() */ public void testEqualsObject() { - TransportCandidate cand1 = new TransportCandidate.Ice("192.168.2.1", 1, 2, + TransportCandidate cand1 = new ICECandidate("192.168.2.1", 1, 2, "password", 3468, "username", 25, ""); - TransportCandidate cand2 = new TransportCandidate.Ice("192.168.2.1", 1, 2, + TransportCandidate cand2 = new ICECandidate("192.168.2.1", 1, 2, "password", 3468, "username", 25, ""); - TransportCandidate cand3 = new TransportCandidate.Ice("192.168.2.1", 1, 2, + TransportCandidate cand3 = new ICECandidate("192.168.2.1", 1, 2, "password", 3469, "username", 25, ""); assertEquals(cand1, cand2); @@ -35,15 +35,15 @@ public class TransportCandidateTest extends SmackTestCase { public void testCompareTo() { int highestPref = 100; - TransportCandidate cand1 = new TransportCandidate.Ice("192.168.2.1", 3, 2, + TransportCandidate cand1 = new ICECandidate("192.168.2.1", 3, 2, "password", 3468, "username", 1, ""); - TransportCandidate cand2 = new TransportCandidate.Ice("192.168.5.1", 2, 10, + TransportCandidate cand2 = new ICECandidate("192.168.5.1", 2, 10, "password", 3469, "username", 15, ""); - TransportCandidate candH = new TransportCandidate.Ice("192.168.2.1", 1, 2, + TransportCandidate candH = new ICECandidate("192.168.2.1", 1, 2, "password", 3468, "username", highestPref, ""); - TransportCandidate cand3 = new TransportCandidate.Ice("192.168.2.10", 2, 10, + TransportCandidate cand3 = new ICECandidate("192.168.2.10", 2, 10, "password", 3469, "username", 2, ""); - TransportCandidate cand4 = new TransportCandidate.Ice("192.168.4.1", 3, 2, + TransportCandidate cand4 = new ICECandidate("192.168.4.1", 3, 2, "password", 3468, "username", 78, ""); ArrayList candList = new ArrayList(); diff --git a/jingle/media/test/JingleMediaTest.java b/jingle/media/test/JingleMediaTest.java index 983c04b0c..5e6c1d64f 100644 --- a/jingle/media/test/JingleMediaTest.java +++ b/jingle/media/test/JingleMediaTest.java @@ -51,8 +51,8 @@ public class JingleMediaTest extends SmackTestCase { XMPPConnection x0 = getConnection(0); XMPPConnection x1 = getConnection(1); - ICETransportManager icetm0 = new ICETransportManager(x0, "stun.xten.net", 3478); - ICETransportManager icetm1 = new ICETransportManager(x1, "stun.xten.net", 3478); + ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478); + ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478); final JingleManager jm0 = new JingleManager( x0, icetm0);