aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/protocol/media
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-11-16 21:57:32 +0200
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-11-16 21:57:32 +0200
commit51c937b7c7a02e23fcef6d254692ff837a830a83 (patch)
treeda69005a31b5f7604a4ff97920cd79bc47d17a7d /src/net/java/sip/communicator/service/protocol/media
parent3579a958bc0ee9aa20914fea8e10139ec74ee643 (diff)
downloadjitsi-51c937b7c7a02e23fcef6d254692ff837a830a83.zip
jitsi-51c937b7c7a02e23fcef6d254692ff837a830a83.tar.gz
jitsi-51c937b7c7a02e23fcef6d254692ff837a830a83.tar.bz2
Supports the Jingle ICE-UDP transport in telephony conferences utilizing the Jitsi Videobridge server-side technology.
Diffstat (limited to 'src/net/java/sip/communicator/service/protocol/media')
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java51
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/TransportManager.java59
2 files changed, 67 insertions, 43 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 3a7f62f..37c6d0b 100644
--- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java
+++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java
@@ -45,6 +45,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
private static final Logger logger
= Logger.getLogger(CallPeerMediaHandler.class);
+
/**
* The name of the <tt>CallPeerMediaHandler</tt> property which specifies
* the local SSRC of its audio <tt>MediaStream</tt>.
@@ -446,7 +447,10 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
if (mediaHandlerCloseStream)
mediaHandler.closeStream(this, mediaType);
- getTransportManager().closeStreamConnector(mediaType);
+ TransportManager<?> transportManager = queryTransportManager();
+
+ if (transportManager != null)
+ transportManager.closeStreamConnector(mediaType);
}
/**
@@ -651,7 +655,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public long getHarvestingTime(String harvesterName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -670,7 +674,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public String getICECandidateExtendedType(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -688,7 +692,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICELocalHostAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -707,7 +711,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICELocalReflexiveAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -726,7 +730,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICELocalRelayedAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -744,7 +748,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICERemoteHostAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -763,7 +767,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICERemoteReflexiveAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -782,7 +786,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public InetSocketAddress getICERemoteRelayedAddress(String streamName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -798,7 +802,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public String getICEState()
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -912,7 +916,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public int getNbHarvesting()
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -931,7 +935,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public int getNbHarvesting(String harvesterName)
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -1017,7 +1021,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
*/
public long getTotalHarvestingTime()
{
- TransportManager<?> transportManager = getTransportManager();
+ TransportManager<?> transportManager = queryTransportManager();
return
(transportManager == null)
@@ -1027,7 +1031,8 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
/**
* Gets the <tt>TransportManager</tt> implementation handling our address
- * management.
+ * management. If the <tt>TransportManager</tt> does not exist yet, it is
+ * created.
*
* @return the <tt>TransportManager</tt> implementation handling our address
* management
@@ -1035,6 +1040,16 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
protected abstract TransportManager<T> getTransportManager();
/**
+ * Gets the <tt>TransportManager</tt> implementation handling our address
+ * management. If the <tt>TransportManager</tt> does not exist yet, it is
+ * not created.
+ *
+ * @return the <tt>TransportManager</tt> implementation handling our address
+ * management
+ */
+ protected abstract TransportManager<T> queryTransportManager();
+
+ /**
* Gets the visual <tt>Component</tt> in which video from the remote peer is
* currently being rendered or <tt>null</tt> if there is currently no video
* streaming from the remote peer.
@@ -1847,6 +1862,7 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
{
if (logger.isInfoEnabled())
logger.info("Starting");
+
MediaStream stream;
stream = getStream(MediaType.AUDIO);
@@ -1881,13 +1897,12 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>>
stream.start();
/*
- * Send an empty packet to unblock some kinds of RTP proxies.
- * Do not consult whether the local video should be streamed and
+ * Send an empty packet to unblock some kinds of RTP proxies. Do
+ * not consult whether the local video should be streamed and
* send the hole-punch packet anyway to let the remote video
* reach this local peer.
*/
- if (stream instanceof VideoMediaStream)
- sendHolePunchPacket(stream.getTarget());
+ sendHolePunchPacket(stream.getTarget());
}
}
}
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 5bb4205..6764877 100644
--- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java
+++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java
@@ -386,60 +386,69 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>>
}
/**
- * 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.
+ * 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 type the {@link MediaType} of the connector we'd like to send the
+ * hole punching packet through.
*/
public void sendHolePunchPacket(MediaStreamTarget target, MediaType type)
{
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);
+ int packetCount
+ = ProtocolMediaActivator.getConfigurationService().getInt(
+ HOLE_PUNCH_PKT_COUNT_PROPERTY,
+ DEFAULT_HOLE_PUNCH_PKT_COUNT);
if (packetCount < 0)
packetCount = DEFAULT_HOLE_PUNCH_PKT_COUNT;
+ if (packetCount == 0)
+ return;
try
{
StreamConnector connector = getStreamConnector(type);
- synchronized(connector)
- {
- if(connector.getProtocol() == StreamConnector.Protocol.TCP)
- return;
+ if(connector.getProtocol() == StreamConnector.Protocol.TCP)
+ return;
- DatagramSocket socket;
+ byte[] buf = new byte[0];
+ synchronized(connector)
+ {
//we may want to send more than one packet in case they get lost
for(int i=0; i < packetCount; i++)
{
- /* data port (RTP) */
+ DatagramSocket socket;
+
+ // data/RTP
if((socket = connector.getDataSocket()) != null)
{
+ InetSocketAddress dataAddress = target.getDataAddress();
+
socket.send(
- new DatagramPacket(
- new byte[0],
- 0,
- target.getDataAddress().getAddress(),
- target.getDataAddress().getPort()));
+ new DatagramPacket(
+ buf,
+ buf.length,
+ dataAddress.getAddress(),
+ dataAddress.getPort()));
}
- /* control port (RTCP) */
+ // control/RTCP
if((socket = connector.getControlSocket()) != null)
{
+ InetSocketAddress controlAddress
+ = target.getControlAddress();
+
socket.send(
- new DatagramPacket(
- new byte[0],
- 0,
- target.getControlAddress().getAddress(),
- target.getControlAddress().getPort()));
+ new DatagramPacket(
+ buf,
+ buf.length,
+ controlAddress.getAddress(),
+ controlAddress.getPort()));
}
}
}