From 9d94eba147390512ee33c0851d6ff8de774516ba Mon Sep 17 00:00:00 2001 From: chenzo Date: Fri, 5 Oct 2012 12:34:11 +0000 Subject: [PATCH] Updates rel-addr/rel-port management. --- src/org/ice4j/ice/Agent.java | 7 +- src/org/ice4j/ice/Candidate.java | 199 ++++++++++++++++-- src/org/ice4j/ice/Component.java | 4 +- src/org/ice4j/ice/GoogleRelayedCandidate.java | 4 +- src/org/ice4j/ice/HostCandidate.java | 6 +- src/org/ice4j/ice/IceMediaStream.java | 4 +- src/org/ice4j/ice/LocalCandidate.java | 97 +++------ src/org/ice4j/ice/PeerReflexiveCandidate.java | 3 +- src/org/ice4j/ice/RelayedCandidate.java | 4 +- src/org/ice4j/ice/RemoteCandidate.java | 141 +++---------- .../ice4j/ice/ServerReflexiveCandidate.java | 17 +- src/org/ice4j/ice/UPNPCandidate.java | 3 +- test/test/Ice.java | 3 +- test/test/SdpUtils.java | 13 +- 14 files changed, 283 insertions(+), 222 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index d5c06a5..20ed32b 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -1171,13 +1171,13 @@ public class Agent * remoteAddress if it belongs to any of this {@link Agent}'s * streams or null if it doesn't. */ - public Candidate findRemoteCandidate(TransportAddress remoteAddress) + public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress) { Collection streamsCollection = mediaStreams.values(); for( IceMediaStream stream : streamsCollection) { - Candidate cnd = stream.findRemoteCandidate(remoteAddress); + RemoteCandidate cnd = stream.findRemoteCandidate(remoteAddress); if(cnd != null) return cnd; @@ -1334,6 +1334,9 @@ public class Agent CandidateType.PEER_REFLEXIVE_CANDIDATE, foundationsRegistry.obtainFoundationForPeerReflexiveCandidate(), priority, + // We can not know the related candidate of a remote peer + // reflexive candidate. We must set it to "null". + null, ufrag); CandidatePair triggeredPair diff --git a/src/org/ice4j/ice/Candidate.java b/src/org/ice4j/ice/Candidate.java index bc03c74..5c9f856 100644 --- a/src/org/ice4j/ice/Candidate.java +++ b/src/org/ice4j/ice/Candidate.java @@ -27,6 +27,7 @@ import org.ice4j.*; * @author Lyubomir Marinov */ public abstract class Candidate + { /** * The transport address represented by this candidate. @@ -57,7 +58,7 @@ public abstract class Candidate * a base, equal to that candidate itself. Similarly, the base of a * relayed candidate is that candidate itself. */ - private LocalCandidate base = null; + private T base = null; /** * A unique priority number that MUST be a positive integer between 1 and @@ -103,6 +104,17 @@ public abstract class Candidate */ private TransportAddress mappedAddress = null; + /** + * The related candidate: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. + */ + private T relatedCandidate = null; + /** * The maximum value for a candidate's type preference. */ @@ -131,14 +143,23 @@ public abstract class Candidate * @param parentComponent the Component that this candidate * belongs to. * @param type the CandidateType for this Candidate. + * @param relatedCandidate The related candidate: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. */ public Candidate(TransportAddress transportAddress, Component parentComponent, - CandidateType type) + CandidateType type, + T relatedCandidate) { this.transportAddress = transportAddress; this.parentComponent = parentComponent; this.candidateType = type; + this.relatedCandidate = relatedCandidate; } /** @@ -206,7 +227,7 @@ public abstract class Candidate * * @return the base Candidate for this Candidate. */ - public LocalCandidate getBase() + public T getBase() { return base; } @@ -220,7 +241,7 @@ public abstract class Candidate * * @param base the base Candidate of this Candidate. */ - public void setBase(LocalCandidate base) + public void setBase(T base) { this.base = base; } @@ -660,22 +681,35 @@ public abstract class Candidate */ public TransportAddress getRelatedAddress() { - if(this instanceof RemoteCandidate) - return null; - - switch (getType()) + if(getRelatedCandidate() != null) { - case SERVER_REFLEXIVE_CANDIDATE: - case PEER_REFLEXIVE_CANDIDATE: - return getBase().getTransportAddress(); - case RELAYED_CANDIDATE: - return getMappedAddress(); - default: - //host candidate - return null; + return getRelatedCandidate().getTransportAddress(); } + return null; } + /** + * Find the candidate corresponding to the address given in parameter. + * + * @param relatedAddress The related address: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. + * + * @return The related candidate corresponding to the address given in + * parameter: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. + */ + protected abstract T findRelatedCandidate(TransportAddress relatedAddress); + /** * Returns a String representation of this Candidate * containing its TransportAddress, base, foundation, priority and @@ -773,4 +807,137 @@ public abstract class Candidate * @return local ufrag */ public abstract String getUfrag(); + + /** + * Returns this candidate host address. + * + * @return This candidate host address. + */ + public TransportAddress getHostAddress() + { + switch (getType()) + { + case SERVER_REFLEXIVE_CANDIDATE: + if(getBase() != null) + { + return getBase().getHostAddress(); + } + break; + case PEER_REFLEXIVE_CANDIDATE: + if(getBase() != null) + { + return getBase().getHostAddress(); + } + break; + case RELAYED_CANDIDATE: + if(getRelatedCandidate() != null) + { + return getRelatedCandidate().getHostAddress(); + } + break; + default: //host candidate + return getTransportAddress(); + } + return null; + } + + /** + * Returns this candidate reflexive address. + * + * @return This candidate reflexive address. Null if this candidate + * does not use a peer/server reflexive address. + */ + public TransportAddress getReflexiveAddress() + { + switch (getType()) + { + case SERVER_REFLEXIVE_CANDIDATE: + return getTransportAddress(); + case PEER_REFLEXIVE_CANDIDATE: + return getTransportAddress(); + case RELAYED_CANDIDATE: + // Corresponding to getMappedAddress(); + if(getRelatedCandidate() != null) + { + return getRelatedCandidate().getReflexiveAddress(); + } + break; + default: //host candidate + return null; + } + return null; + } + + /** + * Returns this candidate relayed address. + * + * @return This candidate relayed address. Null if this candidate + * does not use a relay. + */ + public TransportAddress getRelayedAddress() + { + switch (getType()) + { + case SERVER_REFLEXIVE_CANDIDATE: + return null; + case PEER_REFLEXIVE_CANDIDATE: + return null; + case RELAYED_CANDIDATE: + return getTransportAddress(); + default: //host candidate + return null; + } + } + + /** + * Returns the related candidate corresponding to the address given in + * parameter: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. + * + * @return The related candidate corresponding to the address given in + * parameter: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. + */ + public T getRelatedCandidate() + { + if(this.relatedCandidate == null) + { + TransportAddress relatedAddress = null; + switch (getType()) + { + case SERVER_REFLEXIVE_CANDIDATE: + if(getBase() != null) + { + relatedAddress = getBase().getTransportAddress(); + } + break; + case PEER_REFLEXIVE_CANDIDATE: + if(getBase() != null) + { + relatedAddress = getBase().getTransportAddress(); + } + break; + case RELAYED_CANDIDATE: + relatedAddress = getMappedAddress(); + break; + default: + //host candidate + return null; + } + // Update the related candidate conforming to the related address. + this.relatedCandidate = findRelatedCandidate(relatedAddress); + } + + return this.relatedCandidate; + } } diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java index b626569..7ac78af 100644 --- a/src/org/ice4j/ice/Component.java +++ b/src/org/ice4j/ice/Component.java @@ -912,9 +912,9 @@ public class Component * localAddress if it belongs to this component or null * if it doesn't. */ - public Candidate findRemoteCandidate(TransportAddress remoteAddress) + public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress) { - for( Candidate remoteCnd : localCandidates) + for(RemoteCandidate remoteCnd : remoteCandidates) { if(remoteCnd.getTransportAddress().equals(remoteAddress)) return remoteCnd; diff --git a/src/org/ice4j/ice/GoogleRelayedCandidate.java b/src/org/ice4j/ice/GoogleRelayedCandidate.java index beabfdf..792af13 100644 --- a/src/org/ice4j/ice/GoogleRelayedCandidate.java +++ b/src/org/ice4j/ice/GoogleRelayedCandidate.java @@ -89,7 +89,9 @@ public class GoogleRelayedCandidate transportAddress, turnCandidateHarvest.hostCandidate.getParentComponent(), CandidateType.RELAYED_CANDIDATE, - CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE); + CandidateExtendedType.GOOGLE_TURN_RELAYED_CANDIDATE, + turnCandidateHarvest.hostCandidate.getParentComponent() + .findLocalCandidate(mappedAddress)); if(transportAddress.getTransport() == Transport.TCP) { diff --git a/src/org/ice4j/ice/HostCandidate.java b/src/org/ice4j/ice/HostCandidate.java index 648d846..4954ff3 100644 --- a/src/org/ice4j/ice/HostCandidate.java +++ b/src/org/ice4j/ice/HostCandidate.java @@ -50,7 +50,8 @@ public class HostCandidate extends LocalCandidate socket.getLocalPort(), Transport.UDP), parentComponent, CandidateType.HOST_CANDIDATE, - CandidateExtendedType.HOST_CANDIDATE); + CandidateExtendedType.HOST_CANDIDATE, + null); this.socket = socket; setBase(this); @@ -73,7 +74,8 @@ public class HostCandidate extends LocalCandidate socket.getLocalPort(), transport), parentComponent, CandidateType.HOST_CANDIDATE, - CandidateExtendedType.HOST_CANDIDATE); + CandidateExtendedType.HOST_CANDIDATE, + null); this.socket = socket; setBase(this); diff --git a/src/org/ice4j/ice/IceMediaStream.java b/src/org/ice4j/ice/IceMediaStream.java index e9a7f52..dca8388 100644 --- a/src/org/ice4j/ice/IceMediaStream.java +++ b/src/org/ice4j/ice/IceMediaStream.java @@ -558,13 +558,13 @@ public class IceMediaStream * Component}s or null if it doesn't. * */ - public Candidate findRemoteCandidate(TransportAddress remoteAddress) + public RemoteCandidate findRemoteCandidate(TransportAddress remoteAddress) { Collection cmpCol = components.values(); for( Component cmp : cmpCol) { - Candidate cnd = cmp.findRemoteCandidate(remoteAddress); + RemoteCandidate cnd = cmp.findRemoteCandidate(remoteAddress); if(cnd != null) return cnd; diff --git a/src/org/ice4j/ice/LocalCandidate.java b/src/org/ice4j/ice/LocalCandidate.java index 08f7465..744261b 100644 --- a/src/org/ice4j/ice/LocalCandidate.java +++ b/src/org/ice4j/ice/LocalCandidate.java @@ -23,7 +23,7 @@ import org.ice4j.stack.*; * @author Lyubomir Marinov */ public abstract class LocalCandidate - extends Candidate + extends Candidate { /** * The type of method used to discover this candidate ("host", "upnp", "stun @@ -57,13 +57,18 @@ public abstract class LocalCandidate * ("host", "upnp", "stun peer reflexive", "stun server reflexive", "turn * relayed", "google turn relayed", "google tcp turn relayed" or "jingle * node"). + * @param relatedCandidate the relatedCandidate: null for a host candidate, + * the base address (host candidate) for a reflexive candidate, the mapped + * address (the mapped address of the TURN allocate response) for a relayed + * candidate. */ public LocalCandidate(TransportAddress transportAddress, Component parentComponent, CandidateType type, - CandidateExtendedType extendedType) + CandidateExtendedType extendedType, + LocalCandidate relatedCandidate) { - super(transportAddress, parentComponent, type); + super(transportAddress, parentComponent, type, relatedCandidate); this.extendedType = extendedType; } @@ -350,76 +355,28 @@ public abstract class LocalCandidate } /** - * Returns this candidate host address. + * Find the candidate corresponding to the address given in parameter. * - * @return This candidate host address. - */ - public TransportAddress getHostAddress() - { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - if(getBase() != null) - { - return getBase().getTransportAddress(); - } - return null; - case PEER_REFLEXIVE_CANDIDATE: - if(getBase() != null) - { - return getBase().getTransportAddress(); - } - return null; - case RELAYED_CANDIDATE: - if(getBase() != null) - { - return getBase().getTransportAddress(); - } - return null; - default: //host candidate - return getTransportAddress(); - } - } - - /** - * Returns this candidate reflexive address. + * @param relatedAddress The related address: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. * - * @return This candidate reflexive address. Null if this candidate - * does not use a peer/server reflexive address. + * @return The related candidate corresponding to the address given in + * parameter: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. */ - public TransportAddress getReflexiveAddress() + protected LocalCandidate findRelatedCandidate( + TransportAddress relatedAddress) { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - return getTransportAddress(); - case PEER_REFLEXIVE_CANDIDATE: - return getTransportAddress(); - case RELAYED_CANDIDATE: - return getMappedAddress(); - default: //host candidate - return null; - } - } - - /** - * Returns this candidate relayed address. - * - * @return This candidate relayed address. Null if this candidate - * does not use a relay. - */ - public TransportAddress getRelayedAddress() - { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - return null; - case PEER_REFLEXIVE_CANDIDATE: - return null; - case RELAYED_CANDIDATE: - return getTransportAddress(); - default: //host candidate - return null; - } + return getParentComponent().findLocalCandidate(relatedAddress); } } diff --git a/src/org/ice4j/ice/PeerReflexiveCandidate.java b/src/org/ice4j/ice/PeerReflexiveCandidate.java index 1be6881..0885f9a 100644 --- a/src/org/ice4j/ice/PeerReflexiveCandidate.java +++ b/src/org/ice4j/ice/PeerReflexiveCandidate.java @@ -46,7 +46,8 @@ public class PeerReflexiveCandidate transportAddress, parentComponent, CandidateType.PEER_REFLEXIVE_CANDIDATE, - CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE); + CandidateExtendedType.STUN_PEER_REFLEXIVE_CANDIDATE, + base); super.setBase(base); super.priority = priority; } diff --git a/src/org/ice4j/ice/RelayedCandidate.java b/src/org/ice4j/ice/RelayedCandidate.java index 0d9d534..8ce5941 100644 --- a/src/org/ice4j/ice/RelayedCandidate.java +++ b/src/org/ice4j/ice/RelayedCandidate.java @@ -67,7 +67,9 @@ public class RelayedCandidate transportAddress, turnCandidateHarvest.hostCandidate.getParentComponent(), CandidateType.RELAYED_CANDIDATE, - CandidateExtendedType.TURN_RELAYED_CANDIDATE); + CandidateExtendedType.TURN_RELAYED_CANDIDATE, + turnCandidateHarvest.hostCandidate.getParentComponent() + .findLocalCandidate(mappedAddress)); this.turnCandidateHarvest = turnCandidateHarvest; diff --git a/src/org/ice4j/ice/RemoteCandidate.java b/src/org/ice4j/ice/RemoteCandidate.java index 949c0a9..9285dc3 100644 --- a/src/org/ice4j/ice/RemoteCandidate.java +++ b/src/org/ice4j/ice/RemoteCandidate.java @@ -17,13 +17,8 @@ import org.ice4j.*; * @author Emil Ivov */ public class RemoteCandidate - extends Candidate + extends Candidate { - /** - * The related address that the remote party sent in SDP, if it did. - */ - private TransportAddress raddr; - /** * Ufrag for the Google Talk candidate. */ @@ -42,13 +37,18 @@ public class RemoteCandidate * by the session description protocol. * @param priority the RemoteCandidate's priority as reported * by the session description protocol. + * @param relatedCandidate the relatedCandidate: null for a host candidate, + * the base address (host candidate) for a reflexive candidate, the mapped + * address (the mapped address of the TURN allocate response) for a relayed + * candidate. */ public RemoteCandidate( TransportAddress transportAddress, Component parentComponent, CandidateType type, String foundation, - long priority) + long priority, + RemoteCandidate relatedCandidate) { this( transportAddress, @@ -56,6 +56,7 @@ public class RemoteCandidate type, foundation, priority, + relatedCandidate, null); } @@ -72,6 +73,10 @@ public class RemoteCandidate * by the session description protocol. * @param priority the RemoteCandidate's priority as reported * by the session description protocol. + * @param relatedCandidate the relatedCandidate: null for a host candidate, + * the base address (host candidate) for a reflexive candidate, the mapped + * address (the mapped address of the TURN allocate response) for a relayed + * candidate. * @param ufrag ufrag for the remote candidate */ public RemoteCandidate( @@ -80,9 +85,10 @@ public class RemoteCandidate CandidateType type, String foundation, long priority, + RemoteCandidate relatedCandidate, String ufrag) { - super(transportAddress, parentComponent, type); + super(transportAddress, parentComponent, type, relatedCandidate); setFoundation(foundation); setPriority(priority); this.ufrag = ufrag; @@ -121,39 +127,6 @@ public class RemoteCandidate return equals(parentCmp.getDefaultRemoteCandidate()); } - /** - * Returns the TransportAddress that the remote party indicated - * as "related" for this Candidate. - *

- * Related addresses are present for server reflexive, peer reflexive and - * relayed candidates. If a candidate is server or peer reflexive, - * the related address is equal to the base of this Candidate. - * If the candidate is relayed, the returned address is equal to the mapped - * address. If the candidate is a host candidate then the method returns - * null. - * - * @return the TransportAddress that the remote party indicated - * as "related" for this Candidate or null if they didn't - * include it in SDP. - */ - @Override - public TransportAddress getRelatedAddress() - { - return raddr; - } - - /** - * Specifies the TransportAddress that the remote party indicated - * as "related" for this Candidate. - * - * @param relatedAddr the TransportAddress that the remote party - * indicated as "related" for this Candidate. - */ - public void setRelatedAddress(TransportAddress relatedAddr) - { - this.raddr = relatedAddr; - } - /** * Get the remote ufrag. * @@ -165,76 +138,28 @@ public class RemoteCandidate } /** - * Returns this candidate host address. + * Find the candidate corresponding to the address given in parameter. * - * @return This candidate host address. - */ - public TransportAddress getHostAddress() - { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - if(getBase() != null) - { - return getBase().getTransportAddress(); - } - return null; - case PEER_REFLEXIVE_CANDIDATE: - if(getBase() != null) - { - return getBase().getTransportAddress(); - } - return null; - case RELAYED_CANDIDATE: - // If we are able to find the base address of the mapped - // address, it will be a great enhancement. - // i.e. but not working - // getMappedAddress().getBase().getTransportAddress(); - return null; - default: //host candidate - return getTransportAddress(); - } - } - - /** - * Returns this candidate reflexive address. + * @param relatedAddress The related address: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. * - * @return This candidate reflexive address. Null if this candidate - * does not use a peer/server reflexive address. + * @return The related candidate corresponding to the address given in + * parameter: + * - null for a host candidate, + * - the base address (host candidate) for a reflexive candidate, + * - the mapped address (the mapped address of the TURN allocate response) + * for a relayed candidate. + * - null for a peer reflexive candidate : there is no way to know the + * related address. */ - public TransportAddress getReflexiveAddress() + protected RemoteCandidate findRelatedCandidate( + TransportAddress relatedAddress) { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - return getTransportAddress(); - case PEER_REFLEXIVE_CANDIDATE: - return getTransportAddress(); - case RELAYED_CANDIDATE: - return getMappedAddress(); - default: //host candidate - return null; - } - } - - /** - * Returns this candidate relayed address. - * - * @return This candidate relayed address. Null if this candidate - * does not use a relay. - */ - public TransportAddress getRelayedAddress() - { - switch (getType()) - { - case SERVER_REFLEXIVE_CANDIDATE: - return null; - case PEER_REFLEXIVE_CANDIDATE: - return null; - case RELAYED_CANDIDATE: - return getTransportAddress(); - default: //host candidate - return null; - } + return getParentComponent().findRemoteCandidate(relatedAddress); } } diff --git a/src/org/ice4j/ice/ServerReflexiveCandidate.java b/src/org/ice4j/ice/ServerReflexiveCandidate.java index ae73ed2..8adac57 100644 --- a/src/org/ice4j/ice/ServerReflexiveCandidate.java +++ b/src/org/ice4j/ice/ServerReflexiveCandidate.java @@ -52,14 +52,12 @@ public class ServerReflexiveCandidate TransportAddress stunSrvrAddr, CandidateExtendedType extendedType) { - super(address, - base.getParentComponent(), - CandidateType.SERVER_REFLEXIVE_CANDIDATE, - extendedType); - - setBase(base); - setStunServerAddress(stunSrvrAddr); - stunHarvest = null; + this( + address, + base, + stunSrvrAddr, + null, + extendedType); } /** @@ -87,7 +85,8 @@ public class ServerReflexiveCandidate super(address, base.getParentComponent(), CandidateType.SERVER_REFLEXIVE_CANDIDATE, - extendedType); + extendedType, + base); setBase(base); setStunServerAddress(stunSrvrAddr); diff --git a/src/org/ice4j/ice/UPNPCandidate.java b/src/org/ice4j/ice/UPNPCandidate.java index 1680234..10f49d7 100644 --- a/src/org/ice4j/ice/UPNPCandidate.java +++ b/src/org/ice4j/ice/UPNPCandidate.java @@ -44,7 +44,8 @@ public class UPNPCandidate transportAddress, parentComponent, CandidateType.SERVER_REFLEXIVE_CANDIDATE, - CandidateExtendedType.UPNP_CANDIDATE); + CandidateExtendedType.UPNP_CANDIDATE, + base); this.setBase(base); this.device = device; diff --git a/test/test/Ice.java b/test/test/Ice.java index fedfd7e..09bb83a 100644 --- a/test/test/Ice.java +++ b/test/test/Ice.java @@ -245,7 +245,8 @@ public class Ice localComponent, rCand.getType(), rCand.getFoundation(), - rCand.getPriority())); + rCand.getPriority(), + null)); } } diff --git a/test/test/SdpUtils.java b/test/test/SdpUtils.java index 939f188..31eacf6 100644 --- a/test/test/SdpUtils.java +++ b/test/test/SdpUtils.java @@ -229,13 +229,9 @@ public class SdpUtils if(component == null) return null; - RemoteCandidate cand = new RemoteCandidate(transAddr, component, type, - foundation, priority); - - component.addRemoteCandidate(cand); - // check if there's a related address property + RemoteCandidate relatedCandidate = null; if (tokenizer.countTokens() >= 4) { tokenizer.nextToken(); // skip the raddr element @@ -246,9 +242,14 @@ public class SdpUtils TransportAddress raddr = new TransportAddress( relatedAddr, relatedPort, Transport.UDP); - cand.setRelatedAddress(raddr); + relatedCandidate = component.findRemoteCandidate(raddr); } + RemoteCandidate cand = new RemoteCandidate(transAddr, component, type, + foundation, priority, relatedCandidate); + + component.addRemoteCandidate(cand); + return cand; }