Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.media.TransportManager<CallPeerJabberImpl>
      extended by net.java.sip.communicator.impl.protocol.jabber.TransportManagerJabberImpl
Direct Known Subclasses:
IceUdpTransportManager, RawUdpTransportManager

public abstract class TransportManagerJabberImpl
extends TransportManager<CallPeerJabberImpl>

TransportManagers gather local candidates for incoming and outgoing calls. Their work starts by calling a start method which, using the remote peer's session description, would start the harvest. Calling a second wrapup method would deliver the candidate harvest, possibly after blocking if it has not yet completed.

Author:
Emil Ivov, Lyubomir Marinov

Constructor Summary
protected TransportManagerJabberImpl(CallPeerJabberImpl callPeer)
          Creates a new instance of this transport manager, binding it to the specified peer.
 
Method Summary
 void close()
          Releases the resources acquired by this TransportManager and prepares it for garbage collection.
protected static ContentPacketExtension findContentByName(Iterable<ContentPacketExtension> cpExtList, String name)
          Looks through the cpExtList and returns the ContentPacketExtension with the specified name.
protected  int getCurrentGeneration()
          Returns the generation that our current candidates belong to.
protected  InetAddress getIntendedDestination(CallPeerJabberImpl peer)
          Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination.
protected  String getNextID()
          Returns the ID that we will be assigning to the next candidate we create.
abstract  MediaStreamTarget getStreamTarget(MediaType mediaType)
          Gets the MediaStreamTarget to be used as the target of the MediaStream with a specific MediaType.
abstract  String getXmlNamespace()
          Gets the XML namespace of the Jingle transport implemented by this TransportManagerJabberImpl.
protected  void incrementGeneration()
          Increments the generation that we are assigning candidates.
protected  ContentPacketExtension removeContent(Iterable<ContentPacketExtension> contents, String name)
          Removes a content with a specific name from a specific collection of contents and closes any associated StreamConnector.
abstract  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.
abstract  void startCandidateHarvest(List<ContentPacketExtension> theirOffer, List<ContentPacketExtension> ourAnswer, TransportInfoSender transportInfoSender)
          Starts transport candidate harvest.
abstract  void startCandidateHarvest(List<ContentPacketExtension> ourOffer, TransportInfoSender transportInfoSender)
          Starts transport candidate harvest.
 boolean startConnectivityEstablishment(Iterable<ContentPacketExtension> remote)
          Starts the connectivity establishment of this TransportManagerJabberImpl i.e.
abstract  List<ContentPacketExtension> wrapupCandidateHarvest()
          Notifies the transport manager that it should conclude candidate harvesting as soon as possible and return the lists of candidates gathered so far.
 void wrapupConnectivityEstablishment()
          Notifies this TransportManagerJabberImpl that it should conclude any started connectivity establishment.
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.TransportManager
closeStreamConnector, closeStreamConnector, createStreamConnector, getCallPeer, getICECandidateExtendedType, getICECandidateExtendedType, getICEState, getLastUsedLocalHost, getNextMediaPortToTry, getStreamConnector, initializePortNumbers, sendHolePunchPacket, setNextMediaPortToTry, setTrafficClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransportManagerJabberImpl

protected TransportManagerJabberImpl(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

getIntendedDestination

protected InetAddress getIntendedDestination(CallPeerJabberImpl peer)
Returns the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination. This is an utility method that is used whenever we have to choose one of our local addresses to put in the Via, Contact or (in the case of no registrar accounts) From headers.

Specified by:
getIntendedDestination in class TransportManager<CallPeerJabberImpl>
Parameters:
peer - the CallPeer that we would contact.
Returns:
the InetAddress that is most likely to be to be used as a next hop when contacting the specified destination.
Throws:
IllegalArgumentException - if destination is not a valid host/IP/FQDN

getNextID

protected String getNextID()
Returns the ID that we will be assigning to the next candidate we create.

Returns:
the next ID to use with a candidate.

getStreamTarget

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

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

getXmlNamespace

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

Returns:
the XML namespace of the Jingle transport implemented by this TransportManagerJabberImpl

getCurrentGeneration

protected int getCurrentGeneration()
Returns the generation that our current candidates belong to.

Returns:
the generation that we should assign to candidates that we are currently advertising.

incrementGeneration

protected void incrementGeneration()
Increments the generation that we are assigning candidates.


startCandidateHarvest

public abstract 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.

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.

startCandidateHarvest

public abstract 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.

Parameters:
ourOffer - 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.

wrapupCandidateHarvest

public abstract List<ContentPacketExtension> wrapupCandidateHarvest()
Notifies the transport manager that it should conclude candidate harvesting as soon as possible and return the lists of candidates gathered so far.

Returns:
the content list that we received earlier (possibly cloned into a new instance) and that we have updated with transport lists.

findContentByName

protected static ContentPacketExtension findContentByName(Iterable<ContentPacketExtension> cpExtList,
                                                          String name)
Looks through the cpExtList and returns the ContentPacketExtension with the specified name.

Parameters:
cpExtList - the list that we will be searching for a specific content.
name - the name of the content element we are looking for.
Returns:
the ContentPacketExtension with the specified name or null if no such content element exists.

startConnectivityEstablishment

public boolean startConnectivityEstablishment(Iterable<ContentPacketExtension> remote)
Starts the connectivity establishment of this TransportManagerJabberImpl i.e. checks the connectivity between the local and the remote peers given the remote counterpart of the negotiation between them.

Parameters:
remote - the collection of ContentPacketExtensions which represents the remote counterpart of the negotiation between the local and the remote peer
Returns:
true if connectivity establishment has been started in response to the call; otherwise, false. TransportManagerJabberImpl implementations which do not perform connectivity checks (e.g. raw UDP) should return true. The default implementation does not perform connectivity checks and always returns true.

wrapupConnectivityEstablishment

public void wrapupConnectivityEstablishment()
                                     throws OperationFailedException
Notifies this TransportManagerJabberImpl that it should conclude any started connectivity establishment.

Throws:
OperationFailedException - if anything goes wrong with connectivity establishment (i.e. ICE failed, ...)

removeContent

public abstract 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.

Note: Because TransportManager deals with MediaTypes, not content names and TransportManagerJabberImpl does not implement translating from content name to MediaType, implementers are expected to call TransportManager.closeStreamConnector(MediaType).

Parameters:
name - the name of the content to be removed from the transport-related part of the session represented by this TransportManagerJabberImpl

removeContent

protected ContentPacketExtension removeContent(Iterable<ContentPacketExtension> contents,
                                               String name)
Removes a content with a specific name from a specific collection of contents and closes any associated StreamConnector.

Parameters:
contents - the collection of contents to remove the content with the specified name from
name - the name of the content to remove
Returns:
the removed ContentPacketExtension if any; otherwise, null

close

public void close()
Releases the resources acquired by this TransportManager and prepares it for garbage collection.


Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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