Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.util.event.PropertyChangeNotifier
      extended by net.java.sip.communicator.service.protocol.AbstractCallPeer<T,V>
          extended by net.java.sip.communicator.service.protocol.media.MediaAwareCallPeer<CallJabberImpl,CallPeerMediaHandlerJabberImpl,ProtocolProviderServiceJabberImpl>
              extended by net.java.sip.communicator.impl.protocol.jabber.CallPeerJabberImpl
All Implemented Interfaces:
EventListener, CsrcAudioLevelListener, SimpleAudioLevelListener, SrtpListener, CallPeer, CallPeerConferenceListener

public class CallPeerJabberImpl
extends MediaAwareCallPeer<CallJabberImpl,CallPeerMediaHandlerJabberImpl,ProtocolProviderServiceJabberImpl>

Implements a Jabber CallPeer.

Author:
Emil Ivov, Lyubomir Marinov

Field Summary
 
Fields inherited from class net.java.sip.communicator.service.protocol.AbstractCallPeer
callPeerConferenceListeners, callPeerListeners, callPeerSecurityListeners, NO_CONFERENCE_MEMBERS
 
Fields inherited from interface net.java.sip.communicator.service.neomedia.event.SimpleAudioLevelListener
MAX_LEVEL, MIN_LEVEL
 
Fields inherited from interface net.java.sip.communicator.service.protocol.CallPeer
CALL_DURATION_START_TIME_UNKNOWN, MUTE_PROPERTY_NAME
 
Constructor Summary
CallPeerJabberImpl(String peerAddress, CallJabberImpl owningCall)
          Creates a new call peer with address peerAddress.
CallPeerJabberImpl(String peerAddress, CallJabberImpl owningCall, JingleIQ sessionIQ)
          Creates a new call peer with address peerAddress.
 
Method Summary
 void answer()
          Indicates a user request to answer an incoming call from this CallPeer.
 String getAddress()
          Returns a String locator for that peer.
 Contact getContact()
          Returns the contact corresponding to this peer or null if no particular contact has been associated.
 org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfo()
          Returns the service discovery information that we have for this peer.
 String getDisplayName()
          Returns a human readable name representing this peer.
 String getJingleSID()
          Returns the session ID of the Jingle session associated with this call.
 String getSessInitID()
          Returns the IQ ID of the Jingle session-initiate packet associated with this call.
 JingleIQ getSessionIQ()
          Returns the IQ ID of the Jingle session-initiate packet associated with this call.
 String getURI()
          Returns full URI of the address.
 void hangup(boolean failed, String reasonText, org.jivesoftware.smack.packet.PacketExtension reasonOtherExtension)
          Ends the call with for this CallPeer.
protected  void initiateSession(Iterable<org.jivesoftware.smack.packet.PacketExtension> sessionInitiateExtensions)
          Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.
 boolean isInitiator()
          Determines whether this peer was the one that initiated the session.
 void processContentAccept(JingleIQ content)
          Processes the content-accept JingleIQ.
 void processContentAdd(JingleIQ content)
          Processes the content-add JingleIQ.
 void processContentModify(JingleIQ content)
          Processes the content-modify JingleIQ.
 void processContentReject(JingleIQ content)
          Processes the content-reject JingleIQ.
 void processContentRemove(JingleIQ content)
          Processes the content-remove JingleIQ.
 void processSessionAccept(JingleIQ sessionInitIQ)
          Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.
 void processSessionInfo(SessionInfoPacketExtension info)
          Handles the specified session info packet according to its content.
protected  void processSessionInitiate(JingleIQ sessionInitIQ)
          Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.
 void processSessionTerminate(JingleIQ jingleIQ)
          Puts this peer into a CallPeerState.DISCONNECTED, indicating a reason to the user, if there is one.
 void processTransfer(TransferPacketExtension transfer)
          Processes a specific "XEP-0251: Jingle Session Transfer" transfer packet (extension).
 void processTransportInfo(JingleIQ jingleIQ)
          Processes the transport-info JingleIQ.
 void putOnHold(boolean onHold)
          Puts the CallPeer represented by this instance on or off hold.
 void sendCoinSessionInfo(boolean isConference)
          Send a content message to reflect change in audio setup (start, stop or conference starts).
 void sendModifyVideoContent(boolean allowed)
          Send a content message to reflect change in video setup (start or stop).
 void sendModifyVideoResolutionContent()
          Send a content message to reflect change in video setup (start or stop).
protected  void sendTransportInfo(Iterable<ContentPacketExtension> contents)
          Sends local candidate addresses from the local peer to the remote peer using the transport-info JingleIQ.
 void setAddress(String address)
          Specifies the address, phone number, or other protocol specific identifier that represents this call peer.
 void setDiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo)
          Sets the service discovery information that we have for this peer.
 void setState(CallPeerState newState, String reason, int reasonCode)
          Overrides the parent set state method in order to make sure that we close our media handler whenever we enter a disconnected state.
protected  void transfer(String to, String sid)
          Transfer (in the sense of call transfer) this CallPeer to a specific callee address which may optionally be participating in an active Call.
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.MediaAwareCallPeer
addConferenceMembersSoundLevelListener, addStreamSoundLevelListener, addVideoPropertyChangeListener, audioLevelChanged, audioLevelsReceived, callPeerAdded, callPeerRemoved, conferenceFocusChanged, conferenceMemberAdded, conferenceMemberRemoved, getCall, getImage, getMediaHandler, getPeerID, getProtocolProvider, isLocalVideoStreaming, isMute, logAndFail, reevalLocalHoldStatus, reevalRemoteHoldStatus, removeConferenceMembersSoundLevelListener, removeStreamSoundLevelListener, removeVideoPropertyChangeListener, securityMessageReceived, securityNegotiationStarted, securityTimeout, securityTurnedOff, securityTurnedOn, setCall, setImage, setLocalVideoAllowed, setMediaHandler, setMute, setPeerID
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractCallPeer
addCallPeerConferenceListener, addCallPeerListener, addCallPeerSecurityListener, addConferenceMember, findConferenceMember, fireCallPeerChangeEvent, fireCallPeerChangeEvent, fireCallPeerChangeEvent, fireCallPeerConferenceEvent, fireCallPeerSecurityMessageEvent, fireCallPeerSecurityNegotiationStartedEvent, fireCallPeerSecurityOffEvent, fireCallPeerSecurityOnEvent, fireCallPeerSecurityTimeoutEvent, getCallDurationStartTime, getCallInfoURL, getConferenceMemberCount, getConferenceMembers, getCurrentSecuritySettings, getState, isConferenceFocus, removeCallPeerConferenceListener, removeCallPeerListener, removeCallPeerSecurityListener, removeConferenceMember, setConferenceFocus, setState, setState, toString
 
Methods inherited from class net.java.sip.communicator.util.event.PropertyChangeNotifier
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.CallPeer
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

CallPeerJabberImpl

public CallPeerJabberImpl(String peerAddress,
                          CallJabberImpl owningCall)
Creates a new call peer with address peerAddress.

Parameters:
peerAddress - the Jabber address of the new call peer.
owningCall - the call that contains this call peer.

CallPeerJabberImpl

public CallPeerJabberImpl(String peerAddress,
                          CallJabberImpl owningCall,
                          JingleIQ sessionIQ)
Creates a new call peer with address peerAddress.

Parameters:
peerAddress - the Jabber address of the new call peer.
owningCall - the call that contains this call peer.
sessionIQ - Session initiate IQ
Method Detail

getAddress

public String getAddress()
Returns a String locator for that peer.

Returns:
the peer's address or phone number.

getURI

public String getURI()
Returns full URI of the address.

Returns:
full URI of the address

setAddress

public void setAddress(String address)
Specifies the address, phone number, or other protocol specific identifier that represents this call peer. This method is to be used by service users and MUST NOT be called by the implementation.

Parameters:
address - The address of this call peer.

getDisplayName

public String getDisplayName()
Returns a human readable name representing this peer.

Returns:
a String containing a name for that peer.

getContact

public Contact getContact()
Returns the contact corresponding to this peer or null if no particular contact has been associated.

Returns:
the Contact corresponding to this peer or null if no particular contact has been associated.

processSessionInitiate

protected void processSessionInitiate(JingleIQ sessionInitIQ)
Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.

Parameters:
sessionInitIQ - The JingleIQ that created the session that we are handling here.

initiateSession

protected void initiateSession(Iterable<org.jivesoftware.smack.packet.PacketExtension> sessionInitiateExtensions)
                        throws OperationFailedException
Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.

Parameters:
sessionInitiateExtensions - a collection of additional and optional PacketExtensions to be added to the session-initiate JingleIQ which is to initiate the session with this CallPeerJabberImpl
Throws:
OperationFailedException - exception

answer

public void answer()
            throws OperationFailedException
Indicates a user request to answer an incoming call from this CallPeer. Sends an OK response to callPeer. Make sure that the call peer contains an SDP description when you call this method.

Throws:
OperationFailedException - if we fail to create or send the response.

hangup

public void hangup(boolean failed,
                   String reasonText,
                   org.jivesoftware.smack.packet.PacketExtension reasonOtherExtension)
Ends the call with for this CallPeer. Depending on the state of the peer the method would send a CANCEL, BYE, or BUSY_HERE message and set the new state to DISCONNECTED.

Parameters:
failed - indicates if the hangup is following to a call failure or simply a disconnect
reasonText - the text, if any, to be set on the ReasonPacketExtension as the value of its
reasonOtherExtension - the PacketExtension, if any, to be set on the ReasonPacketExtension as the value of its otherExtension property

getJingleSID

public String getJingleSID()
Returns the session ID of the Jingle session associated with this call.

Returns:
the session ID of the Jingle session associated with this call.

getSessInitID

public String getSessInitID()
Returns the IQ ID of the Jingle session-initiate packet associated with this call.

Returns:
the IQ ID of the Jingle session-initiate packet associated with this call.

getSessionIQ

public JingleIQ getSessionIQ()
Returns the IQ ID of the Jingle session-initiate packet associated with this call.

Returns:
the IQ ID of the Jingle session-initiate packet associated with this call.

processSessionTerminate

public void processSessionTerminate(JingleIQ jingleIQ)
Puts this peer into a CallPeerState.DISCONNECTED, indicating a reason to the user, if there is one.

Parameters:
jingleIQ - the JingleIQ that's terminating our session.

processSessionAccept

public void processSessionAccept(JingleIQ sessionInitIQ)
Processes the session initiation JingleIQ that we were created with, passing its content to the media handler and then sends either a "session-info/ringing" or a "session-terminate" response.

Parameters:
sessionInitIQ - The JingleIQ that created the session that we are handling here.

putOnHold

public void putOnHold(boolean onHold)
               throws OperationFailedException
Puts the CallPeer represented by this instance on or off hold.

Parameters:
onHold - true to have the CallPeer put on hold; false, otherwise
Throws:
OperationFailedException - if we fail to construct or send the INVITE request putting the remote side on/off hold.

setDiscoverInfo

public void setDiscoverInfo(org.jivesoftware.smackx.packet.DiscoverInfo discoverInfo)
Sets the service discovery information that we have for this peer.

Parameters:
discoverInfo - the discovery information that we have obtained for this peer.

getDiscoverInfo

public org.jivesoftware.smackx.packet.DiscoverInfo getDiscoverInfo()
Returns the service discovery information that we have for this peer.

Returns:
the service discovery information that we have for this peer.

isInitiator

public boolean isInitiator()
Determines whether this peer was the one that initiated the session. Note that if this peer is the initiator of the session then this means we are the responder!

Returns:
true if this peer is the one that initiated the session and false otherwise (i.e. if _we_ initiated the session).

processSessionInfo

public void processSessionInfo(SessionInfoPacketExtension info)
Handles the specified session info packet according to its content.

Parameters:
info - the SessionInfoPacketExtension that we just received.

processTransfer

public void processTransfer(TransferPacketExtension transfer)
                     throws OperationFailedException
Processes a specific "XEP-0251: Jingle Session Transfer" transfer packet (extension).

Parameters:
transfer - the "XEP-0251: Jingle Session Transfer" transfer packet (extension) to process
Throws:
OperationFailedException - if anything goes wrong while processing the specified transfer packet (extension)

sendCoinSessionInfo

public void sendCoinSessionInfo(boolean isConference)
Send a content message to reflect change in audio setup (start, stop or conference starts).

Parameters:
isConference - if the call if now a conference call

sendModifyVideoResolutionContent

public void sendModifyVideoResolutionContent()
Send a content message to reflect change in video setup (start or stop).


sendModifyVideoContent

public void sendModifyVideoContent(boolean allowed)
Send a content message to reflect change in video setup (start or stop). Message can be content-modify if video content exists, content-add if we start video but video is not enabled on the peer or content-remove if we stop video and video is not enabled on the peer.

Parameters:
allowed - if the local video is allowed or not

processContentAdd

public void processContentAdd(JingleIQ content)
Processes the content-add JingleIQ.

Parameters:
content - The JingleIQ that contains content that remote peer wants to be added

processContentAccept

public void processContentAccept(JingleIQ content)
Processes the content-accept JingleIQ.

Parameters:
content - The JingleIQ that contains content that remote peer has accepted

processContentModify

public void processContentModify(JingleIQ content)
Processes the content-modify JingleIQ.

Parameters:
content - The JingleIQ that contains content that remote peer wants to be modified

processContentRemove

public void processContentRemove(JingleIQ content)
Processes the content-remove JingleIQ.

Parameters:
content - The JingleIQ that contains content that remote peer wants to be removed

processContentReject

public void processContentReject(JingleIQ content)
Processes the content-reject JingleIQ.

Parameters:
content - The JingleIQ

processTransportInfo

public void processTransportInfo(JingleIQ jingleIQ)
Processes the transport-info JingleIQ.

Parameters:
jingleIQ - the transport-info JingleIQ to process

sendTransportInfo

protected void sendTransportInfo(Iterable<ContentPacketExtension> contents)
Sends local candidate addresses from the local peer to the remote peer using the transport-info JingleIQ.

Parameters:
contents - the local candidate addresses to be sent from the local peer to the remote peer using the transport-info JingleIQ

setState

public void setState(CallPeerState newState,
                     String reason,
                     int reasonCode)
Description copied from class: MediaAwareCallPeer
Overrides the parent set state method in order to make sure that we close our media handler whenever we enter a disconnected state.

Overrides:
setState in class MediaAwareCallPeer<CallJabberImpl,CallPeerMediaHandlerJabberImpl,ProtocolProviderServiceJabberImpl>
Parameters:
newState - the CallPeerState that we are about to enter and that we pass to our predecessor.
reason - a reason phrase explaining the state (e.g. if newState indicates a failure) and that we pass to our predecessor.
reasonCode - the code for the reason of the state change.

transfer

protected void transfer(String to,
                        String sid)
                 throws OperationFailedException
Transfer (in the sense of call transfer) this CallPeer to a specific callee address which may optionally be participating in an active Call.

Parameters:
to - the address of the callee to transfer this CallPeer to
sid - the Jingle session ID of the active Call between the local peer and the callee in the case of attended transfer; null in the case of unattended transfer
Throws:
OperationFailedException - if something goes wrong

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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