Fixes cases with peer-reflexives Candidate as well as some calls initiated from Gmail. Fixes framing length calculation and some missing implemented methods reported by Ingo Bauersachs on dev mailing-list.
This commit is contained in:
parent
b6213785aa
commit
44fd1c4a06
@ -1229,8 +1229,11 @@ public class Agent
|
|||||||
|
|
||||||
if(compatibilityMode == CompatibilityMode.GTALK)
|
if(compatibilityMode == CompatibilityMode.GTALK)
|
||||||
{
|
{
|
||||||
localCandidate = findLocalCandidate(localAddress,
|
if(localAddress.getTransport() == Transport.TCP)
|
||||||
remoteUFrag);
|
localCandidate = findLocalCandidate(localAddress);
|
||||||
|
else
|
||||||
|
localCandidate = findLocalCandidate(localAddress,
|
||||||
|
remoteUFrag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1328,10 +1331,21 @@ public class Agent
|
|||||||
triggerPair.getLocalCandidate().getTransportAddress(),
|
triggerPair.getLocalCandidate().getTransportAddress(),
|
||||||
triggerPair.getRemoteCandidate().getTransportAddress());
|
triggerPair.getRemoteCandidate().getTransportAddress());
|
||||||
else
|
else
|
||||||
knownPair = findCandidatePair(
|
{
|
||||||
|
if(triggerPair.getLocalCandidate().getTransport() == Transport.TCP)
|
||||||
|
{
|
||||||
|
knownPair = findCandidatePair(
|
||||||
|
triggerPair.getLocalCandidate().getTransportAddress(),
|
||||||
|
triggerPair.getRemoteCandidate().getTransportAddress());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
knownPair = findCandidatePair(
|
||||||
((RemoteCandidate)triggerPair.getRemoteCandidate()).
|
((RemoteCandidate)triggerPair.getRemoteCandidate()).
|
||||||
getUfrag(),
|
getUfrag(),
|
||||||
triggerPair.getLocalCandidate().getUfrag());
|
triggerPair.getLocalCandidate().getUfrag());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IceMediaStream parentStream = triggerPair.getLocalCandidate()
|
IceMediaStream parentStream = triggerPair.getLocalCandidate()
|
||||||
.getParentComponent().getParentStream();
|
.getParentComponent().getParentStream();
|
||||||
@ -1407,6 +1421,8 @@ public class Agent
|
|||||||
// Its state is set to Waiting [and it] is enqueued into the
|
// Its state is set to Waiting [and it] is enqueued into the
|
||||||
// triggered check queue.
|
// triggered check queue.
|
||||||
//
|
//
|
||||||
|
logger.info("Add peer CandidatePair with new reflexive address to" +
|
||||||
|
" checkList");
|
||||||
parentStream.addToCheckList(triggerPair);
|
parentStream.addToCheckList(triggerPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -578,6 +578,12 @@ class ConnectivityCheckClient
|
|||||||
//generated from it momentarily
|
//generated from it momentarily
|
||||||
validLocalCandidate = peerReflexiveCandidate;
|
validLocalCandidate = peerReflexiveCandidate;
|
||||||
|
|
||||||
|
if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK)
|
||||||
|
{
|
||||||
|
validLocalCandidate.setUfrag(
|
||||||
|
checkedPair.getLocalCandidate().getUfrag());
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Receive a peer-reflexive candidate: " +
|
logger.info("Receive a peer-reflexive candidate: " +
|
||||||
peerReflexiveCandidate.getTransportAddress());
|
peerReflexiveCandidate.getTransportAddress());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -795,9 +795,13 @@ public class DelegatingSocket
|
|||||||
inputStream = this.getInputStream();
|
inputStream = this.getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
short desiredLength = (short)
|
int fb = inputStream.read();
|
||||||
(((inputStream.read() << 8) & 0xff) | (inputStream.read() & 0xff));
|
int sb = inputStream.read();
|
||||||
|
|
||||||
|
if(fb == -1 || sb == -1)
|
||||||
|
throw new SocketException("failed to read first two bytes");
|
||||||
|
|
||||||
|
int desiredLength = (((fb & 0xff) << 8) | (sb & 0xff));
|
||||||
int readLen = 0;
|
int readLen = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
|||||||
@ -264,7 +264,7 @@ public class GoogleRelayedCandidateSocket
|
|||||||
*
|
*
|
||||||
* @author Sebastien Vincent
|
* @author Sebastien Vincent
|
||||||
*/
|
*/
|
||||||
private class TCPOutputStream
|
protected class TCPOutputStream
|
||||||
extends OutputStream
|
extends OutputStream
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -87,16 +87,32 @@ public class IceTcpSocketWrapper
|
|||||||
|
|
||||||
byte data[] = p.getData();
|
byte data[] = p.getData();
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
int desiredLength =
|
||||||
|
(((inputStream.read() & 0xff) << 8) | (inputStream.read() & 0xff));
|
||||||
|
int readLen = 0;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
inputStream.skip(2);
|
while(readLen < desiredLength)
|
||||||
len = inputStream.read(data);
|
{
|
||||||
if(len > 0)
|
len = inputStream.read(data, offset, desiredLength - offset);
|
||||||
|
if(len == -1)
|
||||||
|
throw new SocketException("read failed");
|
||||||
|
offset += len;
|
||||||
|
readLen += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readLen == desiredLength)
|
||||||
{
|
{
|
||||||
p.setData(data);
|
p.setData(data);
|
||||||
p.setLength(len);
|
p.setLength(len);
|
||||||
p.setAddress(this.getLocalAddress());
|
p.setAddress(this.getLocalAddress());
|
||||||
p.setPort(this.getLocalPort());
|
p.setPort(this.getLocalPort());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new SocketException("Failed to receive data from socket");
|
||||||
|
}
|
||||||
|
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public class TCPOutputStream
|
|||||||
public void close()
|
public void close()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,6 +50,7 @@ public class TCPOutputStream
|
|||||||
public void flush()
|
public void flush()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
outputStream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +70,14 @@ public class TCPOutputStream
|
|||||||
public void write(byte[] b, int off, int len)
|
public void write(byte[] b, int off, int len)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
// GoogleRelayedCandidateSocket will encapsulate data in TURN message
|
||||||
|
// so do not add framing here
|
||||||
|
if(outputStream instanceof GoogleRelayedCandidateSocket.TCPOutputStream)
|
||||||
|
{
|
||||||
|
outputStream.write(b, off, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
byte data[] = new byte[len + 2];
|
byte data[] = new byte[len + 2];
|
||||||
data[0] = (byte)((len >> 8) & 0xff);
|
data[0] = (byte)((len >> 8) & 0xff);
|
||||||
data[1] = (byte)(len & 0xff);
|
data[1] = (byte)(len & 0xff);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user