diff options
author | damencho <damencho@jitsi.org> | 2017-02-07 22:27:54 +0200 |
---|---|---|
committer | damencho <damencho@jitsi.org> | 2017-02-07 22:27:54 +0200 |
commit | df85ae417f865bf392f92913fde858d777af7811 (patch) | |
tree | 90c77db42332e7e08a78b237178c852b33b793a7 /src | |
parent | 2b1dc3757081dd582049fb16a8421f486ae162df (diff) | |
download | jitsi-df85ae417f865bf392f92913fde858d777af7811.zip jitsi-df85ae417f865bf392f92913fde858d777af7811.tar.gz jitsi-df85ae417f865bf392f92913fde858d777af7811.tar.bz2 |
Updates libjitsi and sends hole punch packets for audio.
When sending hole punch packets, use as a content a generated rtp
packet.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java | 30 | ||||
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/TransportManager.java | 21 |
2 files changed, 46 insertions, 5 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java index c8a3a12..ead01d1 100644 --- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java @@ -87,6 +87,16 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> public static final String VIDEO_REMOTE_SSRC = "VIDEO_REMOTE_SSRC"; /** + * The initial content of a hole punch packet. It has some fields pre-set. + * Like rtp verion, sequence number and timestamp. + */ + private static final byte[] HOLE_PUNCH_PACKET = + { + (byte)0x80, 0x00, 0x02, (byte)0x9E, 0x00, 0x09, + (byte)0xD0, (byte)0x80, 0x00, 0x00, 0x00, (byte)0x00, + }; + + /** * List of advertised encryption methods. Indicated before establishing the * call. */ @@ -1575,11 +1585,21 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> * to open port on NAT or RTP proxy if any. In order to be really efficient, * this method should be called after we send our offer or answer. * - * @param target <tt>MediaStreamTarget</tt> + * @param stream <tt>MediaStream</tt> non-null stream + * @param mediaType <tt>MediaType</tt> */ - protected void sendHolePunchPacket(MediaStreamTarget target) + protected void sendHolePunchPacket(MediaStream stream, MediaType mediaType) { - getTransportManager().sendHolePunchPacket(target, MediaType.VIDEO); + // send as a hole punch packet a constructed rtp packet + // has the correct payload type and ssrc + RawPacket packet = new RawPacket( + HOLE_PUNCH_PACKET, 0, RawPacket.FIXED_HEADER_SIZE); + packet.setPayloadType( + dynamicPayloadTypes.getPayloadType(stream.getFormat())); + packet.setSSRC((int)stream.getLocalSourceID()); + + getTransportManager().sendHolePunchPacket( + stream.getTarget(), mediaType, packet); } /** @@ -1936,6 +1956,8 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> stream.getTarget(), MediaType.AUDIO); stream.start(); + + sendHolePunchPacket(stream, MediaType.AUDIO); } stream = getStream(MediaType.VIDEO); @@ -1964,7 +1986,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> * send the hole-punch packet anyway to let the remote video * reach this local peer. */ - sendHolePunchPacket(stream.getTarget()); + sendHolePunchPacket(stream, MediaType.VIDEO); } } } 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 a8222e0..051a302 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -516,6 +516,21 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> */ public void sendHolePunchPacket(MediaStreamTarget target, MediaType type) { + this.sendHolePunchPacket(target, type, null); + } + + /** + * Sends 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 the + * hole punching packet through. + * @param packet (optional) use a pre-generated packet that will be sent + */ + public void sendHolePunchPacket( + MediaStreamTarget target, MediaType type, RawPacket packet) + { logger.info("Send NAT hole punch packets"); //check how many hole punch packets we would be supposed to send: @@ -536,7 +551,11 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> if(connector.getProtocol() == StreamConnector.Protocol.TCP) return; - byte[] buf = new byte[0]; + byte[] buf; + if (packet != null) + buf = packet.getBuffer(); + else + buf = new byte[0]; synchronized(connector) { |