Refactors the finding of a CandidatePair's socket.
This commit is contained in:
parent
6999ebc19d
commit
f322f67f93
@ -731,32 +731,15 @@ public class CandidatePair
|
||||
if (base != null)
|
||||
localCandidate = base;
|
||||
|
||||
if (localCandidate instanceof TcpHostCandidate)
|
||||
RemoteCandidate remoteCandidate = getRemoteCandidate();
|
||||
if (remoteCandidate != null)
|
||||
{
|
||||
/*
|
||||
* TcpHostCandidates can have multiple sockets, and the one
|
||||
* to be used by this specific CandidatePair has to have the
|
||||
* same remote socket address as the pair's remote candidate.
|
||||
*/
|
||||
RemoteCandidate remoteCandidate = getRemoteCandidate();
|
||||
if (remoteCandidate == null)
|
||||
return null;
|
||||
|
||||
SocketAddress remoteSocketAddress
|
||||
SocketAddress remoteAddress
|
||||
= remoteCandidate.getTransportAddress();
|
||||
for (IceSocketWrapper socket
|
||||
: ((TcpHostCandidate) localCandidate).getIceSocketWrappers())
|
||||
{
|
||||
if (socket.getTCPSocket()
|
||||
.getRemoteSocketAddress().equals(remoteSocketAddress))
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return localCandidate.getIceSocketWrapper();
|
||||
if (remoteAddress != null)
|
||||
return localCandidate.getIceSocketWrapper(remoteAddress);
|
||||
}
|
||||
|
||||
return null;
|
||||
return localCandidate.getIceSocketWrapper();
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +122,20 @@ public abstract class LocalCandidate
|
||||
*/
|
||||
protected abstract IceSocketWrapper getIceSocketWrapper();
|
||||
|
||||
/**
|
||||
* Gets the <tt>IceSocketWrapper</tt> associated with this
|
||||
* <tt>Candidate</tt> which is to be used for a specific remote address.
|
||||
* This default implementation ignores the remote address.
|
||||
*
|
||||
* @param remoteAddress the remote address for which to get a socket.
|
||||
* @return the <tt>IceSocketWrapper</tt> associated with this
|
||||
* <tt>Candidate</tt> which is to be used for a specific remote address.
|
||||
*/
|
||||
protected IceSocketWrapper getIceSocketWrapper(SocketAddress remoteAddress)
|
||||
{
|
||||
return getIceSocketWrapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates if necessary and returns a <tt>DatagramSocket</tt> that would
|
||||
* capture all STUN packets arriving on this candidate's socket. If the
|
||||
|
||||
@ -73,8 +73,16 @@ public class TcpHostCandidate
|
||||
super.free();
|
||||
}
|
||||
|
||||
public List<IceSocketWrapper> getIceSocketWrappers()
|
||||
@Override
|
||||
protected IceSocketWrapper getIceSocketWrapper(SocketAddress remoteAddress)
|
||||
{
|
||||
return sockets;
|
||||
for (IceSocketWrapper socket : sockets)
|
||||
{
|
||||
if (socket.getTCPSocket().getRemoteSocketAddress()
|
||||
.equals(remoteAddress))
|
||||
return socket;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user