diff options
author | Emil Ivov <emcho@jitsi.org> | 2012-07-13 22:22:44 +0000 |
---|---|---|
committer | Emil Ivov <emcho@jitsi.org> | 2012-07-13 22:22:44 +0000 |
commit | 6c888f0bfb2af77c72be6fb17c88f427c6419773 (patch) | |
tree | 95a3a17ea023180d2d82df66cd28db2f73c3bedf /src/net/java/sip/communicator/service | |
parent | 29c3efc0d8055eb5563930eb307b984291ba0e46 (diff) | |
download | jitsi-6c888f0bfb2af77c72be6fb17c88f427c6419773.zip jitsi-6c888f0bfb2af77c72be6fb17c88f427c6419773.tar.gz jitsi-6c888f0bfb2af77c72be6fb17c88f427c6419773.tar.bz2 |
Increases hole punch packet count to 3 from 1
Diffstat (limited to 'src/net/java/sip/communicator/service')
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/TransportManager.java | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java index 6a3cd6a..a9326ea 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -75,6 +75,17 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> "net.java.sip.communicator.impl.protocol.RTP_VIDEO_DSCP"; /** + * Number of empty UDP packets to send for NAT hole punching. + */ + private static final String HOLE_PUNCH_PKT_COUNT_PROPERTY = + "net.java.sip.communicator.impl.protocol.HOLE_PUNCH_PKT_COUNT"; + + /** + * Number of empty UDP packets to send for NAT hole punching. + */ + private static final int DEFAULT_HOLE_PUNCH_PKT_COUNT = 3; + + /** * The {@link MediaAwareCallPeer} whose traffic we will be taking care of. */ private U callPeer; @@ -360,8 +371,9 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> } /** - * Send empty UDP packet to target destination data/control ports - * in order to open port on NAT or RTP proxy if any. + * Send empty UDP packets to target destination data/control ports + * in order to open ports on NATs or and help RTP proxies latch onto our + * RTP ports. * * @param target <tt>MediaStreamTarget</tt> * @param type the {@link MediaType} of the connector we'd like to send @@ -369,18 +381,30 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> */ public void sendHolePunchPacket(MediaStreamTarget target, MediaType type) { - if (logger.isInfoEnabled()) - logger.info("Try to open port on NAT if any"); + logger.info("Send NAT hole punch packets"); + + //check how many hole punch packets we would be supposed to send: + int packetCount = ProtocolMediaActivator.getConfigurationService() + .getInt( HOLE_PUNCH_PKT_COUNT_PROPERTY, + DEFAULT_HOLE_PUNCH_PKT_COUNT); + + if (packetCount < 0) + packetCount = DEFAULT_HOLE_PUNCH_PKT_COUNT; + try { StreamConnector connector = getStreamConnector(type); synchronized(connector) { - if(connector.getProtocol() != StreamConnector.Protocol.TCP) - { - DatagramSocket socket; + if(connector.getProtocol() == StreamConnector.Protocol.TCP) + return; + + DatagramSocket socket; + //we may want to send more than one packet in case they get lost + for(int i=0; i < packetCount; i++) + { /* data port (RTP) */ if((socket = connector.getDataSocket()) != null) { |