diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java
index a2076d2..ddd7ac5 100644
--- a/src/org/ice4j/ice/Agent.java
+++ b/src/org/ice4j/ice/Agent.java
@@ -808,21 +808,7 @@ public class Agent
public String generateLocalUserName(RemoteCandidate remoteCandidate,
LocalCandidate localCandidate)
{
- String ret = null;
- String remoteUfrag = remoteCandidate.getUfrag();
- String localUfrag = localCandidate.getUfrag();
-
- /* Google Talk specific
- * each candidate has its own username/password
- */
- if(localUfrag == null || remoteUfrag == null ||
- compatibilityMode != CompatibilityMode.GTALK)
- {
- return null;
- }
-
- ret = remoteUfrag + localUfrag;
- return ret;
+ return generateUserName(remoteCandidate, localCandidate);
}
/**
@@ -837,22 +823,38 @@ public class Agent
*/
public String generateRemoteUserName(RemoteCandidate remoteCandidate,
LocalCandidate localCandidate)
+ {
+ return generateUserName(localCandidate, remoteCandidate);
+ }
+
+ /**
+ * Returns the user name that we should expect a peer Agent to use
+ * in connectivity checks for Binding Requests its sending our way in a
+ * Google Talk session.
+ *
+ * @param candidate1 The first candidate of a candidatePair.
+ * @param candidate2 The second candidate of a candidatePair.
+ * @return a user name that a peer Agent would use in connectivity
+ * check for outgoing Binding Requests.
+ */
+ private String generateUserName(
+ Candidate candidate1,
+ Candidate candidate2)
{
String ret = null;
- String remoteUfrag = remoteCandidate.getUfrag();
- String localUfrag = localCandidate.getUfrag();
+ String ufrag1 = candidate1.getUfrag();
+ String ufrag2 = candidate2.getUfrag();
/* Google Talk specific
* each candidate has its own username/password
*/
- if(remoteUfrag == null || localUfrag == null ||
- compatibilityMode != CompatibilityMode.GTALK)
+ if(ufrag1 != null
+ && ufrag2 != null
+ && compatibilityMode == CompatibilityMode.GTALK)
{
- return null;
+ ret = ufrag1 + ufrag2;
}
- ret = localUfrag + remoteUfrag;
-
return ret;
}
@@ -1258,15 +1260,13 @@ public class Agent
String localUFrag,
boolean useCandidate)
{
+ String ufrag = null;
LocalCandidate localCandidate = null;
- if(compatibilityMode == CompatibilityMode.GTALK)
+ if(compatibilityMode == CompatibilityMode.GTALK
+ && localAddress.getTransport() != Transport.TCP)
{
- if(localAddress.getTransport() == Transport.TCP)
- localCandidate = findLocalCandidate(localAddress);
- else
- localCandidate = findLocalCandidate(localAddress,
- remoteUFrag);
+ localCandidate = findLocalCandidate(localAddress, remoteUFrag);
}
else
{
@@ -1306,23 +1306,15 @@ public class Agent
useCandidate = pair2.useCandidateReceived();
}
- remoteCandidate = new RemoteCandidate(
- remoteAddress, parentComponent,
- CandidateType.PEER_REFLEXIVE_CANDIDATE,
- foundationsRegistry.
- obtainFoundationForPeerReflexiveCandidate(),
- priority,
- ((RemoteCandidate)pair.getRemoteCandidate()).getUfrag());
- }
- else
- {
- remoteCandidate = new RemoteCandidate(
- remoteAddress, parentComponent,
- CandidateType.PEER_REFLEXIVE_CANDIDATE,
- foundationsRegistry.
- obtainFoundationForPeerReflexiveCandidate(),
- priority);
+ ufrag = ((RemoteCandidate)pair.getRemoteCandidate()).getUfrag();
}
+ remoteCandidate = new RemoteCandidate(
+ remoteAddress,
+ parentComponent,
+ CandidateType.PEER_REFLEXIVE_CANDIDATE,
+ foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(),
+ priority,
+ ufrag);
CandidatePair triggeredPair
= new CandidatePair(localCandidate, remoteCandidate);
diff --git a/src/org/ice4j/ice/Candidate.java b/src/org/ice4j/ice/Candidate.java
index 582173f..bc03c74 100644
--- a/src/org/ice4j/ice/Candidate.java
+++ b/src/org/ice4j/ice/Candidate.java
@@ -766,4 +766,11 @@ public abstract class Candidate
* Component yet.
*/
public abstract boolean isDefault();
+
+ /**
+ * Get the local ufrag.
+ *
+ * @return local ufrag
+ */
+ public abstract String getUfrag();
}
diff --git a/src/org/ice4j/ice/ConnectivityCheckClient.java b/src/org/ice4j/ice/ConnectivityCheckClient.java
index 778b79f..8197ca1 100644
--- a/src/org/ice4j/ice/ConnectivityCheckClient.java
+++ b/src/org/ice4j/ice/ConnectivityCheckClient.java
@@ -378,24 +378,7 @@ class ConnectivityCheckClient
//If all of the pairs in the check list are now either in the Failed or
//Succeeded state:
- boolean allPairsDone = true;
-
- synchronized(checkList)
- {
- for(CandidatePair pair : checkList)
- {
- CandidatePairState pairState = pair.getState();
-
- if((pairState != CandidatePairState.FAILED)
- && (pairState != CandidatePairState.SUCCEEDED))
- {
- allPairsDone = false;
- break;
- }
- }
- }
-
- if (allPairsDone)
+ if(checkList.allChecksCompleted())
{
//If there is not a pair in the valid list for each component of the
//media stream, the state of the check list is set to Failed.
diff --git a/src/org/ice4j/ice/GoogleRelayedCandidate.java b/src/org/ice4j/ice/GoogleRelayedCandidate.java
index a73ad52..beabfdf 100644
--- a/src/org/ice4j/ice/GoogleRelayedCandidate.java
+++ b/src/org/ice4j/ice/GoogleRelayedCandidate.java
@@ -55,6 +55,11 @@ public class GoogleRelayedCandidate
*/
private final String username;
+ /**
+ * Password.
+ */
+ private final String password;
+
/**
* Initializes a new RelayedCandidate which is to represent a
* specific TransportAddress harvested through a specific
@@ -69,13 +74,16 @@ public class GoogleRelayedCandidate
* TURN server with the delivery of the replayed transportAddress
* to be represented by the new instance
* @param username username (Send request to the Google relay server need
- * it
+ * it)
+ * @param password password (used with XMPP gingle candidates).
+ * it)
*/
public GoogleRelayedCandidate(
TransportAddress transportAddress,
GoogleTurnCandidateHarvest turnCandidateHarvest,
TransportAddress mappedAddress,
- String username)
+ String username,
+ String password)
{
super(
transportAddress,
@@ -91,6 +99,7 @@ public class GoogleRelayedCandidate
this.turnCandidateHarvest = turnCandidateHarvest;
this.username = username;
+ this.password = password;
// RFC 5245: The base of a relayed candidate is that candidate itself.
setBase(this);
@@ -197,4 +206,13 @@ public class GoogleRelayedCandidate
}
return socket;
}
+
+ /**
+ * Returns the password for this candidate.
+ * @return the password for this candidate.
+ */
+ public String getPassword()
+ {
+ return this.password;
+ }
}
diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java
index d3e7785..dd802b8 100644
--- a/src/org/ice4j/ice/IceMediaStream.java
+++ b/src/org/ice4j/ice/IceMediaStream.java
@@ -891,31 +891,6 @@ public class IceMediaStream
}
}
- /**
- * Returns the {@link CandidatePair} from component that's
- * currently first in our valid list and that is therefore with the highest
- * priority.
- *
- * @param component the {@link Component} whose highest priority valid
- * {@link CandidatePair} we are looking for.
- *
- * @return the {@link CandidatePair} with the highest priority in our
- * valid list or null if our valid list is still empty.
- */
- public CandidatePair getFirstValidPair(Component component)
- {
- synchronized(validList)
- {
- for(CandidatePair pair : validList)
- {
- if (pair.getParentComponent() == component)
- return pair;
- }
- }
-
- return null;
- }
-
/**
* Specifies the user name that we received from the remote peer.
*
diff --git a/src/org/ice4j/ice/RemoteCandidate.java b/src/org/ice4j/ice/RemoteCandidate.java
index ee209fa..cfa6e04 100644
--- a/src/org/ice4j/ice/RemoteCandidate.java
+++ b/src/org/ice4j/ice/RemoteCandidate.java
@@ -49,9 +49,12 @@ public class RemoteCandidate
String foundation,
long priority)
{
- super(transportAddress, parentComponent, type);
- setFoundation(foundation);
- setPriority(priority);
+ this(transportAddress,
+ parentComponent,
+ type,
+ foundation,
+ priority,
+ null);
}
/**
@@ -76,7 +79,9 @@ public class RemoteCandidate
long priority,
String ufrag)
{
- this(transportAddress, parentComponent, type, foundation, priority);
+ super(transportAddress, parentComponent, type);
+ setFoundation(foundation);
+ setPriority(priority);
this.ufrag = ufrag;
}
diff --git a/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvest.java b/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvest.java
index a5a0633..b9fc788 100644
--- a/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvest.java
+++ b/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvest.java
@@ -40,6 +40,11 @@ public class GoogleTurnCandidateHarvest
*/
private Request requestToStartResolvingCandidate;
+ /**
+ * The gingle candidates password necessary to use the TURN server.
+ */
+ private String password;
+
/**
* Initializes a new TurnCandidateHarvest which is to represent the
* harvesting of TURN Candidates for a specific
@@ -50,12 +55,16 @@ public class GoogleTurnCandidateHarvest
* the TURN harvesting
* @param hostCandidate the HostCandidate for which TURN
* Candidates are to be harvested
+ * @param password The gingle candidates password necessary to use this TURN
+ * server.
*/
public GoogleTurnCandidateHarvest(
GoogleTurnCandidateHarvester harvester,
- HostCandidate hostCandidate)
+ HostCandidate hostCandidate,
+ String password)
{
super(harvester, hostCandidate);
+ this.password = password;
}
/**
@@ -144,7 +153,8 @@ public class GoogleTurnCandidateHarvest
transportAddress,
this,
mappedAddress,
- harvester.getShortTermCredentialUsername());
+ harvester.getShortTermCredentialUsername(),
+ this.password);
candidate.setUfrag(harvester.getShortTermCredentialUsername());
return candidate;
diff --git a/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvester.java b/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvester.java
index 8b37c89..45c01ec 100644
--- a/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/GoogleTurnCandidateHarvester.java
@@ -19,6 +19,11 @@ import org.ice4j.ice.*;
public class GoogleTurnCandidateHarvester
extends StunCandidateHarvester
{
+ /**
+ * The gingle candidates password necessary to use the TURN server.
+ */
+ private String password = null;
+
/**
* Initializes a new GoogleTurnCandidateHarvester instance which
* is to work with a specific Google TURN server.
@@ -28,7 +33,7 @@ public class GoogleTurnCandidateHarvester
*/
public GoogleTurnCandidateHarvester(TransportAddress turnServer)
{
- this(turnServer, null);
+ this(turnServer, null, null);
}
/**
@@ -42,11 +47,15 @@ public class GoogleTurnCandidateHarvester
* instance for the purposes of the STUN short-term credential mechanism or
* null if the use of the STUN short-term credential mechanism is
* not determined at the time of the construction of the new instance
+ * @param password The gingle candidates password necessary to use this TURN
+ * server.
*/
public GoogleTurnCandidateHarvester(TransportAddress turnServer,
- String shortTermCredentialUsername)
+ String shortTermCredentialUsername,
+ String password)
{
super(turnServer, shortTermCredentialUsername);
+ this.password = password;
}
/**
@@ -63,6 +72,18 @@ public class GoogleTurnCandidateHarvester
protected GoogleTurnCandidateHarvest createHarvest(
HostCandidate hostCandidate)
{
- return new GoogleTurnCandidateHarvest(this, hostCandidate);
+ return new GoogleTurnCandidateHarvest(
+ this,
+ hostCandidate,
+ this.password);
+ }
+
+ /**
+ * Returns the password for this candidate.
+ * @return the password for this candidate.
+ */
+ public String getPassword()
+ {
+ return this.password;
}
}
diff --git a/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java b/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
index fcc26bc..a86e946 100644
--- a/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
+++ b/src/org/ice4j/ice/harvest/GoogleTurnSSLCandidateHarvester.java
@@ -67,7 +67,7 @@ public class GoogleTurnSSLCandidateHarvester
*/
public GoogleTurnSSLCandidateHarvester(TransportAddress turnServer)
{
- this(turnServer, null);
+ this(turnServer, null, null);
}
/**
@@ -81,11 +81,14 @@ public class GoogleTurnSSLCandidateHarvester
* instance for the purposes of the STUN short-term credential mechanism or
* null if the use of the STUN short-term credential mechanism is
* not determined at the time of the construction of the new instance
+ * @param password The gingle candidates password necessary to use this TURN
+ * server.
*/
public GoogleTurnSSLCandidateHarvester(TransportAddress turnServer,
- String shortTermCredentialUsername)
+ String shortTermCredentialUsername,
+ String password)
{
- super(turnServer, shortTermCredentialUsername);
+ super(turnServer, shortTermCredentialUsername, password);
}
/**
@@ -102,7 +105,10 @@ public class GoogleTurnSSLCandidateHarvester
protected GoogleTurnCandidateHarvest createHarvest(
HostCandidate hostCandidate)
{
- return new GoogleTurnCandidateHarvest(this, hostCandidate);
+ return new GoogleTurnCandidateHarvest(
+ this,
+ hostCandidate,
+ this.getPassword());
}
/**