Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.jabber
Class IceUdpTransportManager

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.media.TransportManager<CallPeerJabberImpl>
      extended by net.java.sip.communicator.impl.protocol.jabber.TransportManagerJabberImpl
          extended by net.java.sip.communicator.impl.protocol.jabber.IceUdpTransportManager
All Implemented Interfaces:
PropertyChangeListener, EventListener
Direct Known Subclasses:
P2PTransportManager

public class IceUdpTransportManager
extends TransportManagerJabberImpl
implements PropertyChangeListener

A TransportManagerJabberImpl implementation that would use ICE for candidate management.

Author:
Emil Ivov, Lyubomir Marinov, Sebastien Vincent

Field Summary
protected  List<ContentPacketExtension> cpeList
          This is where we keep our answer between the time we get the offer and are ready with the answer.
protected static String DEFAULT_STUN_SERVER_ADDRESS
          Default STUN server address.
protected static int DEFAULT_STUN_SERVER_PORT
          Default STUN server port.
protected  org.ice4j.ice.Agent iceAgent
          The ICE agent that this transport manager would be using for ICE negotiation.
 
Constructor Summary
IceUdpTransportManager(CallPeerJabberImpl callPeer)
          Creates a new instance of this transport manager, binding it to the specified peer.
 
Method Summary
 void close()
          Close this transport manager and release resources.
protected  org.ice4j.ice.Agent createIceAgent()
          Creates the ICE agent that we would be using in this transport manager for all negotiation.
protected  org.ice4j.ice.IceMediaStream createIceStream(String media)
          Creates an IceMediaStream with the specified media name.
protected  StreamConnector createStreamConnector(MediaType mediaType)
          Initializes a new StreamConnector to be used as the connector of the MediaStream with a specific MediaType.
 org.jivesoftware.smack.packet.PacketExtension createTransport(org.ice4j.ice.IceMediaStream stream)
          Converts the ICE media stream and its local candidates into a IceUdpTransportPacketExtension.
 String getICECandidateExtendedType()
          Returns the extended type of the candidate selected if this transport manager is using ICE.
 String getICEState()
          Returns the current state of ICE processing.
 StreamConnector getStreamConnector(MediaType mediaType)
          Gets the StreamConnector to be used as the connector of the MediaStream with a specific MediaType.
 MediaStreamTarget getStreamTarget(MediaType mediaType)
          Implements TransportManagerJabberImpl.getStreamTarget(MediaType).
protected  org.jivesoftware.smack.packet.PacketExtension getTransportPacketExtension()
          Get the transport PacketExtension to add.
 String getXmlNamespace()
          Implements TransportManagerJabberImpl.getXmlNamespace().
 void propertyChange(PropertyChangeEvent evt)
          Retransmit state change events from the Agent to the media handler.
 void removeContent(String name)
          Removes a content with a specific name from the transport-related part of the session represented by this TransportManagerJabberImpl which may have been reported through previous calls to the startCandidateHarvest and startConnectivityEstablishment methods.
 void startCandidateHarvest(List<ContentPacketExtension> theirOffer, List<ContentPacketExtension> ourAnswer, TransportInfoSender transportInfoSender)
          Starts transport candidate harvest.
 void startCandidateHarvest(List<ContentPacketExtension> ourOffer, TransportInfoSender transportInfoSender)
          Starts transport candidate harvest.
 boolean startConnectivityEstablishment(Iterable<ContentPacketExtension> remote)
          Starts the connectivity establishment of the associated ICE Agent.
 List<ContentPacketExtension> wrapupCandidateHarvest()
          Simply returns the list of local candidates that we gathered during the harvest.
 void wrapupConnectivityEstablishment()
          Waits for the associated ICE Agent to finish any started connectivity checks.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.jabber.TransportManagerJabberImpl
findContentByName, getCurrentGeneration, getIntendedDestination, getNextID, incrementGeneration, removeContent
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.TransportManager
closeStreamConnector, closeStreamConnector, getCallPeer, getICECandidateExtendedType, getLastUsedLocalHost, getNextMediaPortToTry, initializePortNumbers, sendHolePunchPacket, setNextMediaPortToTry, setTrafficClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cpeList

protected List<ContentPacketExtension> cpeList
This is where we keep our answer between the time we get the offer and are ready with the answer.


iceAgent

protected final org.ice4j.ice.Agent iceAgent
The ICE agent that this transport manager would be using for ICE negotiation.


DEFAULT_STUN_SERVER_ADDRESS

protected static final String DEFAULT_STUN_SERVER_ADDRESS
Default STUN server address.

See Also:
Constant Field Values

DEFAULT_STUN_SERVER_PORT

protected static final int DEFAULT_STUN_SERVER_PORT
Default STUN server port.

See Also:
Constant Field Values
Constructor Detail

IceUdpTransportManager

public IceUdpTransportManager(CallPeerJabberImpl callPeer)
Creates a new instance of this transport manager, binding it to the specified peer.

Parameters:
callPeer - the CallPeer whose traffic we will be taking care of.
Method Detail

createIceAgent

protected org.ice4j.ice.Agent createIceAgent()
Creates the ICE agent that we would be using in this transport manager for all negotiation.

Returns:
the ICE agent to use for all the ICE negotiation that this transport manager would be going through

createStreamConnector

protected StreamConnector createStreamConnector(MediaType mediaType)
                                         throws OperationFailedException
Initializes a new StreamConnector to be used as the connector of the MediaStream with a specific MediaType.

Overrides:
createStreamConnector in class TransportManager<CallPeerJabberImpl>
Parameters:
mediaType - the MediaType of the MediaStream which is to have its connector set to the returned StreamConnector
Returns:
a new StreamConnector to be used as the connector of the MediaStream with the specified MediaType
Throws:
OperationFailedException - if anything goes wrong while initializing the new StreamConnector

getStreamConnector

public StreamConnector getStreamConnector(MediaType mediaType)
                                   throws OperationFailedException
Gets the StreamConnector to be used as the connector of the MediaStream with a specific MediaType.

Overrides:
getStreamConnector in class TransportManager<CallPeerJabberImpl>
Parameters:
mediaType - the MediaType of the MediaStream which is to have its connector set to the returned StreamConnector
Returns:
the StreamConnector to be used as the connector of the MediaStream with the specified MediaType
Throws:
OperationFailedException - if anything goes wrong while initializing the requested StreamConnector
See Also:
getStreamConnector(MediaType)

getStreamTarget

public MediaStreamTarget getStreamTarget(MediaType mediaType)
Implements TransportManagerJabberImpl.getStreamTarget(MediaType). Gets the MediaStreamTarget to be used as the target of the MediaStream with a specific MediaType.

Specified by:
getStreamTarget in class TransportManagerJabberImpl
Parameters:
mediaType - the MediaType of the MediaStream which is to have its target set to the returned MediaStreamTarget
Returns:
the MediaStreamTarget to be used as the target of the MediaStream with the specified MediaType
See Also:
TransportManagerJabberImpl.getStreamTarget(MediaType)

getXmlNamespace

public String getXmlNamespace()
Implements TransportManagerJabberImpl.getXmlNamespace(). Gets the XML namespace of the Jingle transport implemented by this TransportManagerJabberImpl.

Specified by:
getXmlNamespace in class TransportManagerJabberImpl
Returns:
the XML namespace of the Jingle transport implemented by this TransportManagerJabberImpl
See Also:
TransportManagerJabberImpl.getXmlNamespace()

getTransportPacketExtension

protected org.jivesoftware.smack.packet.PacketExtension getTransportPacketExtension()
Get the transport PacketExtension to add.

Returns:
PacketExtension

startCandidateHarvest

public void startCandidateHarvest(List<ContentPacketExtension> theirOffer,
                                  List<ContentPacketExtension> ourAnswer,
                                  TransportInfoSender transportInfoSender)
                           throws OperationFailedException
Starts transport candidate harvest. This method should complete rapidly and, in case of lengthy procedures like STUN/TURN/UPnP candidate harvests are necessary, they should be executed in a separate thread. Candidate harvest would then need to be concluded in the wrapupCandidateHarvest() method which would be called once we absolutely need the candidates.

Specified by:
startCandidateHarvest in class TransportManagerJabberImpl
Parameters:
theirOffer - a media description offer that we've received from the remote party and that we should use in case we need to know what transports our peer is using.
ourAnswer - the content descriptions that we should be adding our transport lists to (although not necessarily in this very instance).
transportInfoSender - the TransportInfoSender to be used by this TransportManagerJabberImpl to send transport-info JingleIQs from the local peer to the remote peer if this TransportManagerJabberImpl wishes to utilize transport-info. Local candidate addresses sent by this TransportManagerJabberImpl in transport-info are expected to not be included in the result of wrapupCandidateHarvest().
Throws:
OperationFailedException - if we fail to allocate a port number.
See Also:
TransportManagerJabberImpl.startCandidateHarvest(List, List, TransportInfoSender)

startCandidateHarvest

public void startCandidateHarvest(List<ContentPacketExtension> ourOffer,
                                  TransportInfoSender transportInfoSender)
                           throws OperationFailedException
Starts transport candidate harvest. This method should complete rapidly and, in case of lengthy procedures like STUN/TURN/UPnP candidate harvests are necessary, they should be executed in a separate thread. Candidate harvest would then need to be concluded in the wrapupCandidateHarvest() method which would be called once we absolutely need the candidates.

Specified by:
startCandidateHarvest in class TransportManagerJabberImpl
Parameters:
ourOffer - the content list that should tell us how many stream connectors we actually need.
transportInfoSender - the TransportInfoSender to be used by this TransportManagerJabberImpl to send transport-info JingleIQs from the local peer to the remote peer if this TransportManagerJabberImpl wishes to utilize transport-info. Local candidate addresses sent by this TransportManagerJabberImpl in transport-info are expected to not be included in the result of wrapupCandidateHarvest().
Throws:
OperationFailedException - in case we fail allocating ports

createTransport

public org.jivesoftware.smack.packet.PacketExtension createTransport(org.ice4j.ice.IceMediaStream stream)
Converts the ICE media stream and its local candidates into a IceUdpTransportPacketExtension.

Parameters:
stream - the IceMediaStream that we'd like to describe in XML.
Returns:
the IceUdpTransportPacketExtension that we

createIceStream

protected org.ice4j.ice.IceMediaStream createIceStream(String media)
                                                throws OperationFailedException
Creates an IceMediaStream with the specified media name.

Parameters:
media - the name of the stream we'd like to create.
Returns:
the newly created IceMediaStream
Throws:
OperationFailedException - if binding on the specified media stream fails for some reason.

wrapupCandidateHarvest

public List<ContentPacketExtension> wrapupCandidateHarvest()
Simply returns the list of local candidates that we gathered during the harvest.

Specified by:
wrapupCandidateHarvest in class TransportManagerJabberImpl
Returns:
the list of local candidates that we gathered during the harvest
See Also:
TransportManagerJabberImpl.wrapupCandidateHarvest()

startConnectivityEstablishment

public boolean startConnectivityEstablishment(Iterable<ContentPacketExtension> remote)
Starts the connectivity establishment of the associated ICE Agent.

Overrides:
startConnectivityEstablishment in class TransportManagerJabberImpl
Parameters:
remote - the collection of ContentPacketExtensions which represents the remote counterpart of the negotiation between the local and the remote peers
Returns:
true if connectivity establishment has been started in response to the call; otherwise, false
See Also:
TransportManagerJabberImpl.startConnectivityEstablishment(Iterable)

wrapupConnectivityEstablishment

public void wrapupConnectivityEstablishment()
                                     throws OperationFailedException
Waits for the associated ICE Agent to finish any started connectivity checks.

Overrides:
wrapupConnectivityEstablishment in class TransportManagerJabberImpl
Throws:
OperationFailedException - if ICE processing has failed
See Also:
TransportManagerJabberImpl.wrapupConnectivityEstablishment()

removeContent

public void removeContent(String name)
Removes a content with a specific name from the transport-related part of the session represented by this TransportManagerJabberImpl which may have been reported through previous calls to the startCandidateHarvest and startConnectivityEstablishment methods.

Specified by:
removeContent in class TransportManagerJabberImpl
Parameters:
name - the name of the content to be removed from the transport-related part of the session represented by this TransportManagerJabberImpl
See Also:
TransportManagerJabberImpl.removeContent(String)

close

public void close()
Close this transport manager and release resources. In case of ICE, it releases Ice4j's Agent that will cleanup all streams, component and close every candidate's sockets.

Overrides:
close in class TransportManagerJabberImpl

getICECandidateExtendedType

public String getICECandidateExtendedType()
Returns the extended type of the candidate selected if this transport manager is using ICE.

Specified by:
getICECandidateExtendedType in class TransportManager<CallPeerJabberImpl>
Returns:
The extended type of the candidate selected if this transport manager is using ICE. Otherwise, returns null.

getICEState

public String getICEState()
Returns the current state of ICE processing.

Specified by:
getICEState in class TransportManager<CallPeerJabberImpl>
Returns:
the current state of ICE processing.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Retransmit state change events from the Agent to the media handler.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - the event for state change.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.