diff options
author | Sebastien Vincent <seb@jitsi.org> | 2011-12-05 13:26:03 +0000 |
---|---|---|
committer | Sebastien Vincent <seb@jitsi.org> | 2011-12-05 13:26:03 +0000 |
commit | b8d0052c51e3628ae4a5865b0ce0d6de7b1c9c2e (patch) | |
tree | d505d363597fd9162e84c96ec024aa44257632ce /src/net/java/sip/communicator/service/protocol | |
parent | 0e27689c4b6b0a60838ab099c148ac730497a868 (diff) | |
download | jitsi-b8d0052c51e3628ae4a5865b0ce0d6de7b1c9c2e.zip jitsi-b8d0052c51e3628ae4a5865b0ce0d6de7b1c9c2e.tar.gz jitsi-b8d0052c51e3628ae4a5865b0ce0d6de7b1c9c2e.tar.bz2 |
Adds traffic class support for SIP/XMPP/RTP audio/RTP video.
Diffstat (limited to 'src/net/java/sip/communicator/service/protocol')
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java | 4 | ||||
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/TransportManager.java | 102 |
2 files changed, 104 insertions, 2 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 60f66a9..35efab2 100644 --- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java @@ -1658,6 +1658,8 @@ public abstract class CallPeerMediaHandler< && !stream.isStarted() && isLocalAudioTransmissionEnabled()) { + getTransportManager().setTrafficClass(stream.getTarget(), + MediaType.AUDIO); stream.start(); } @@ -1674,6 +1676,8 @@ public abstract class CallPeerMediaHandler< if(!stream.isStarted()) { + getTransportManager().setTrafficClass(stream.getTarget(), + MediaType.VIDEO); stream.start(); // send empty packet to deblock some kind of RTP proxy to let 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 a0f34ac..8140916 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -24,6 +24,7 @@ import net.java.sip.communicator.util.*; * * @author Emil Ivov * @author Lyubomir Marinov + * @author Sebastien Vincent */ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> { @@ -60,6 +61,18 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> private static int nextMediaPortToTry = -1; /** + * RTP audio DSCP configuration property name. + */ + private static final String RTP_AUDIO_DSCP_PROPERTY = + "net.java.sip.communicator.impl.protocol.RTP_AUDIO_DSCP"; + + /** + * RTP video DSCP configuration property name. + */ + private static final String RTP_VIDEO_DSCP_PROPERTY = + "net.java.sip.communicator.impl.protocol.RTP_VIDEO_DSCP"; + + /** * The {@link MediaAwareCallPeer} whose traffic we will be taking care of. */ private U callPeer; @@ -364,12 +377,14 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> } /* data port (RTP) */ - connector.getDataSocket().send(new DatagramPacket( + if(connector.getDataSocket() != null) + connector.getDataSocket().send(new DatagramPacket( new byte[0], 0, target.getDataAddress().getAddress(), target.getDataAddress().getPort())); /* control port (RTCP) */ - connector.getControlSocket().send(new DatagramPacket( + if(connector.getControlSocket() != null) + connector.getControlSocket().send(new DatagramPacket( new byte[0], 0, target.getControlAddress().getAddress(), target.getControlAddress().getPort())); } @@ -381,6 +396,89 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> } /** + * Set traffic class (QoS) for the RTP socket. + * + * @param target <tt>MediaStreamTarget</tt> + * @param type the {@link MediaType} of the connector we'd like to set + * traffic class + */ + protected void setTrafficClass(MediaStreamTarget target, MediaType type) + { + int trafficClass = 0; + + // get traffic class value for RTP audio/video + trafficClass = getTrafficClass(type); + + if(trafficClass <= 0) + return; + + if (logger.isInfoEnabled()) + logger.info("Set traffic class for " + type + " " + trafficClass); + try + { + StreamConnector connector = getStreamConnector(type); + + synchronized(connector) + { + if(connector.getProtocol() == StreamConnector.Protocol.TCP) + { + connector.getDataTCPSocket().setTrafficClass(trafficClass); + + if(connector.getControlTCPSocket() != null) + connector.getControlTCPSocket(). + setTrafficClass(trafficClass); + } + else + { + /* data port (RTP) */ + connector.getDataSocket().setTrafficClass(trafficClass); + + /* control port (RTCP) */ + if(connector.getControlSocket() != null) + connector.getControlSocket().setTrafficClass( + trafficClass); + } + } + } + catch(Exception e) + { + logger.error("Error cannot send to remote peer", e); + } + } + + + /** + * Get the SIP traffic class from configuration. + * + * @return SIP traffic class or 0 if not configured + */ + private int getTrafficClass(MediaType type) + { + ConfigurationService configService = + ProtocolMediaActivator.getConfigurationService(); + + String trafficClass = null; + + if(type == MediaType.AUDIO) + trafficClass = + (String)configService.getProperty( + RTP_AUDIO_DSCP_PROPERTY); + else if(type == MediaType.VIDEO) + trafficClass = + (String)configService.getProperty( + RTP_VIDEO_DSCP_PROPERTY); + else + return 0; + + if(trafficClass != null) + { + return Integer.parseInt(trafficClass); + } + + return 0; + } + + /** * Returns the <tt>InetAddress</tt> that is most likely to be used as a * next hop when contacting the specified <tt>destination</tt>. This is * an utility method that is used whenever we have to choose one of our |