Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.sip
Class CallPeerSipImpl

java.lang.Object
  extended by net.java.sip.communicator.util.PropertyChangeNotifier
      extended by net.java.sip.communicator.service.protocol.AbstractCallPeer<T,V>
          extended by net.java.sip.communicator.service.protocol.media.MediaAwareCallPeer<CallSipImpl,CallPeerMediaHandlerSipImpl,ProtocolProviderServiceSipImpl>
              extended by net.java.sip.communicator.impl.protocol.sip.CallPeerSipImpl
All Implemented Interfaces:
EventListener, CsrcAudioLevelListener, SimpleAudioLevelListener, SrtpListener, CallPeer, CallPeerConferenceListener

public class CallPeerSipImpl
extends MediaAwareCallPeer<CallSipImpl,CallPeerMediaHandlerSipImpl,ProtocolProviderServiceSipImpl>

Our SIP implementation of the default CallPeer;

Author:
Emil Ivov, Lubomir Marinov

Field Summary
(package private) static String PICTURE_FAST_UPDATE_CONTENT_SUB_TYPE
          The sub-type of the content carried by SIP INFO Requests for the purposes of picture_fast_update.
 
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
CallPeerSipImpl(javax.sip.address.Address peerAddress, CallSipImpl owningCall, javax.sip.Transaction containingTransaction, javax.sip.SipProvider sourceProvider)
          Creates a new call peer with address peerAddress.
 
Method Summary
(package private)  void addMethodProcessorListener(MethodProcessorListener listener)
          Registers a specific MethodProcessorListener with this CallPeer so that it gets notified by this instance about the processing of SIP signaling.
 void answer()
          Indicates a user request to answer an incoming call from this CallPeer.
protected  void fireRequestProcessed(javax.sip.message.Request request, javax.sip.message.Response response)
          Notifies the MethodProcessorListeners registered with this CallPeer that it has processed a specific SIP Request by sending a specific SIP Response.
protected  void fireResponseProcessed(javax.sip.message.Response response, javax.sip.message.Request request)
          Notifies the MethodProcessorListeners registered with this CallPeer that it has processed a specific SIP Response by sending a specific SIP Request.
 String getAddress()
          Returns a String locator for that peer.
 URL getCallInfoURL()
          Returns a URL pointing to a location with call control information for this peer or null if no such URL is available for this call peer.
 Contact getContact()
          Returns the contact corresponding to this peer or null if no particular contact has been associated.
 javax.sip.Dialog getDialog()
          Returns the JAIN SIP dialog that has been created by the application for communication with this call peer.
 String getDisplayName()
          Returns a human readable name representing this peer.
 javax.sip.SipProvider getJainSipProvider()
          Returns the jain sip provider instance that is responsible for sending and receiving requests and responses related to this call peer.
 javax.sip.Transaction getLatestInviteTransaction()
          Returns the transaction instance that contains the INVITE which started this call.
 javax.sip.address.Address getPeerAddress()
          Returns the address of the remote party (making sure that it corresponds to the latest address we've received) and caches it.
 String getURI()
          Returns full URI of the address.
 void handleAuthenticationChallenge(javax.sip.ClientTransaction retryTran)
          Updates this call so that it would record a new transaction and dialog that have been recreated because of a re-authentication.
 void hangup()
          Ends the call with for this CallPeer.
 void hangup(boolean failed, String reason)
          Ends the call with for this CallPeer.
 void invite()
          Creates a CallPeerSipImpl from calleeAddress and sends them an invite request.
 void processAck(javax.sip.ServerTransaction serverTransaction, javax.sip.message.Request ack)
          Updates the session description and sends the state of the corresponding call peer to CONNECTED.
 void processBye(javax.sip.ServerTransaction byeTran)
          Sets the state of the corresponding call peer to DISCONNECTED and sends an OK response.
 void processCancel(javax.sip.ServerTransaction serverTransaction)
          Sets the state of the specifies call peer as DISCONNECTED.
 void processInviteOK(javax.sip.ClientTransaction clientTransaction, javax.sip.message.Response ok)
          Sets our state to CONNECTED, sends an ACK and processes the SDP description in the ok Response.
(package private)  void processPictureFastUpdate(javax.sip.ClientTransaction clientTransaction, javax.sip.message.Response response)
           
(package private)  boolean processPictureFastUpdate(javax.sip.ServerTransaction serverTransaction, javax.sip.message.Request request)
           
 void processReInvite(javax.sip.ServerTransaction serverTransaction)
          Reinitializes the media session of the CallPeer that this INVITE request is destined to.
 void processSessionProgress(javax.sip.ClientTransaction tran, javax.sip.message.Response response)
          Handles early media in 183 Session Progress responses.
 void putOnHold(boolean onHold)
          Puts the CallPeer represented by this instance on or off hold.
(package private)  void removeMethodProcessorListener(MethodProcessorListener listener)
          Unregisters a specific MethodProcessorListener from this CallPeer so that it no longer gets notified by this instance about the processing of SIP signaling.
(package private)  void sendReInvite()
          Sends a reINVITE request to this CallPeer within its current Dialog.
 void setDialog(javax.sip.Dialog dialog)
          Sets the JAIN SIP dialog that has been created by the application for communication with this call peer.
 void setDisplayName(String displayName)
          Sets a human readable name representing this peer.
 void setJainSipProvider(javax.sip.SipProvider jainSipProvider)
          Sets the jain sip provider instance that is responsible for sending and receiving requests and responses related to this call peer.
 void setLatestInviteTransaction(javax.sip.Transaction transaction)
          Sets the transaction instance that contains the INVITE which started this call.
 void setTransportAddress(InetSocketAddress transportAddress)
          The address that we have used to contact this peer.
 
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, securityTurnedOff, securityTurnedOn, setCall, setImage, setLocalVideoAllowed, setMediaHandler, setMute, setPeerID, setState
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractCallPeer
addCallPeerConferenceListener, addCallPeerListener, addCallPeerSecurityListener, addConferenceMember, findConferenceMember, fireCallPeerChangeEvent, fireCallPeerChangeEvent, fireCallPeerChangeEvent, fireCallPeerConferenceEvent, fireCallPeerSecurityMessageEvent, fireCallPeerSecurityOffEvent, fireCallPeerSecurityOnEvent, getCallDurationStartTime, getConferenceMemberCount, getConferenceMembers, getCurrentSecuritySettings, getState, isConferenceFocus, removeCallPeerConferenceListener, removeCallPeerListener, removeCallPeerSecurityListener, removeConferenceMember, setConferenceFocus, setState, setState, toString
 
Methods inherited from class net.java.sip.communicator.util.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
 

Field Detail

PICTURE_FAST_UPDATE_CONTENT_SUB_TYPE

static final String PICTURE_FAST_UPDATE_CONTENT_SUB_TYPE
The sub-type of the content carried by SIP INFO Requests for the purposes of picture_fast_update.

See Also:
Constant Field Values
Constructor Detail

CallPeerSipImpl

public CallPeerSipImpl(javax.sip.address.Address peerAddress,
                       CallSipImpl owningCall,
                       javax.sip.Transaction containingTransaction,
                       javax.sip.SipProvider sourceProvider)
Creates a new call peer with address peerAddress.

Parameters:
peerAddress - the JAIN SIP Address of the new call peer.
owningCall - the call that contains this call peer.
containingTransaction - the transaction that created the call peer.
sourceProvider - the provider that the containingTransaction belongs to.
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

getPeerAddress

public javax.sip.address.Address getPeerAddress()
Returns the address of the remote party (making sure that it corresponds to the latest address we've received) and caches it.

Returns:
the most recent javax.sip.address.Address that we have for the remote party.

getDisplayName

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

Returns:
a String containing a name for that peer.

setDisplayName

public void setDisplayName(String displayName)
Sets a human readable name representing this peer.

Parameters:
displayName - the peer's display name

setDialog

public void setDialog(javax.sip.Dialog dialog)
Sets the JAIN SIP dialog that has been created by the application for communication with this call peer.

Parameters:
dialog - the JAIN SIP dialog that has been created by the application for this call.

getDialog

public javax.sip.Dialog getDialog()
Returns the JAIN SIP dialog that has been created by the application for communication with this call peer.

Returns:
the JAIN SIP dialog that has been created by the application for communication with this call peer.

setLatestInviteTransaction

public void setLatestInviteTransaction(javax.sip.Transaction transaction)
Sets the transaction instance that contains the INVITE which started this call.

Parameters:
transaction - the Transaction that initiated this call.

getLatestInviteTransaction

public javax.sip.Transaction getLatestInviteTransaction()
Returns the transaction instance that contains the INVITE which started this call.

Returns:
the Transaction that initiated this call.

setJainSipProvider

public void setJainSipProvider(javax.sip.SipProvider jainSipProvider)
Sets the jain sip provider instance that is responsible for sending and receiving requests and responses related to this call peer.

Parameters:
jainSipProvider - the SipProvider that serves this call peer.

getJainSipProvider

public javax.sip.SipProvider getJainSipProvider()
Returns the jain sip provider instance that is responsible for sending and receiving requests and responses related to this call peer.

Returns:
the jain sip provider instance that is responsible for sending and receiving requests and responses related to this call peer.

setTransportAddress

public void setTransportAddress(InetSocketAddress transportAddress)
The address that we have used to contact this peer. In cases where no direct connection has been established with the peer, this method will return the address that will be first tried when connection is established (often the one used to connect with the protocol server). The address may change during a session and

Parameters:
transportAddress - The address that we have used to contact this 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.

getCallInfoURL

public URL getCallInfoURL()
Returns a URL pointing to a location with call control information for this peer or null if no such URL is available for this call peer.

Specified by:
getCallInfoURL in interface CallPeer
Overrides:
getCallInfoURL in class AbstractCallPeer<CallSipImpl,ProtocolProviderServiceSipImpl>
Returns:
a URL link to a location with call information or a call control web interface related to this peer or null if no such URL is available.

processPictureFastUpdate

void processPictureFastUpdate(javax.sip.ClientTransaction clientTransaction,
                              javax.sip.message.Response response)

processPictureFastUpdate

boolean processPictureFastUpdate(javax.sip.ServerTransaction serverTransaction,
                                 javax.sip.message.Request request)
                           throws OperationFailedException
Throws:
OperationFailedException

processReInvite

public void processReInvite(javax.sip.ServerTransaction serverTransaction)
Reinitializes the media session of the CallPeer that this INVITE request is destined to.

Parameters:
serverTransaction - a reference to the ServerTransaction that contains the reINVITE request.

processBye

public void processBye(javax.sip.ServerTransaction byeTran)
Sets the state of the corresponding call peer to DISCONNECTED and sends an OK response.

Parameters:
byeTran - the ServerTransaction the the BYE request arrived in.

processCancel

public void processCancel(javax.sip.ServerTransaction serverTransaction)
Sets the state of the specifies call peer as DISCONNECTED.

Parameters:
serverTransaction - the transaction that the cancel was received in.

processAck

public void processAck(javax.sip.ServerTransaction serverTransaction,
                       javax.sip.message.Request ack)
Updates the session description and sends the state of the corresponding call peer to CONNECTED.

Parameters:
serverTransaction - the transaction that the ACK was received in.
ack - the ACK Request we need to process

processSessionProgress

public void processSessionProgress(javax.sip.ClientTransaction tran,
                                   javax.sip.message.Response response)
Handles early media in 183 Session Progress responses. Retrieves the SDP and makes sure that we start transmitting and playing early media that we receive. Puts the call into a CONNECTING_WITH_EARLY_MEDIA state.

Parameters:
tran - the ClientTransaction that the response arrived in.
response - the 183 Response to process

processInviteOK

public void processInviteOK(javax.sip.ClientTransaction clientTransaction,
                            javax.sip.message.Response ok)
Sets our state to CONNECTED, sends an ACK and processes the SDP description in the ok Response.

Parameters:
clientTransaction - the ClientTransaction that the response arrived in.
ok - the OK Response to process

hangup

public void hangup()
            throws OperationFailedException
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.

Throws:
OperationFailedException - if we fail to terminate the call.

hangup

public void hangup(boolean failed,
                   String reason)
            throws OperationFailedException
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
reason - the reason of the hangup. If the hangup is due to a call failure, then this string could indicate the reason of the failure
Throws:
OperationFailedException - if we fail to terminate the call.

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.

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.

sendReInvite

void sendReInvite()
            throws OperationFailedException
Sends a reINVITE request to this CallPeer within its current Dialog.

Throws:
OperationFailedException - if sending the reINVITE request fails

invite

public void invite()
            throws OperationFailedException
Creates a CallPeerSipImpl from calleeAddress and sends them an invite request. The invite request will be initialized according to any relevant parameters in the cause message (if different from null) that is the reason for creating this call.

Throws:
OperationFailedException - with the corresponding code if we fail to create the call or in case we someone calls us mistakenly while we are actually wrapped around an invite transaction.

addMethodProcessorListener

void addMethodProcessorListener(MethodProcessorListener listener)
Registers a specific MethodProcessorListener with this CallPeer so that it gets notified by this instance about the processing of SIP signaling. If the specified listener is already registered with this instance, does nothing

Parameters:
listener - the MethodProcessorListener to be registered with this CallPeer so that it gets notified by this instance about the processing of SIP signaling

fireRequestProcessed

protected void fireRequestProcessed(javax.sip.message.Request request,
                                    javax.sip.message.Response response)
Notifies the MethodProcessorListeners registered with this CallPeer that it has processed a specific SIP Request by sending a specific SIP Response.

Parameters:
request - the SIP Request processed by this CallPeer
response - the SIP Response this CallPeer sent as part of its processing of the specified request

fireResponseProcessed

protected void fireResponseProcessed(javax.sip.message.Response response,
                                     javax.sip.message.Request request)
Notifies the MethodProcessorListeners registered with this CallPeer that it has processed a specific SIP Response by sending a specific SIP Request.

Parameters:
response - the SIP Response processed by this CallPeer
request - the SIP Request this CallPeer sent as part of its processing of the specified response

removeMethodProcessorListener

void removeMethodProcessorListener(MethodProcessorListener listener)
Unregisters a specific MethodProcessorListener from this CallPeer so that it no longer gets notified by this instance about the processing of SIP signaling. If the specified listener is not registered with this instance, does nothing.

Parameters:
listener - the MethodProcessorListener to be unregistered from this CallPeer so that it no longer gets notified by this instance about the processing of SIP signaling

handleAuthenticationChallenge

public void handleAuthenticationChallenge(javax.sip.ClientTransaction retryTran)
Updates this call so that it would record a new transaction and dialog that have been recreated because of a re-authentication.

Parameters:
retryTran - the new transaction

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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