Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.media.AbstractOperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
      extended by net.java.sip.communicator.impl.protocol.sip.OperationSetBasicTelephonySipImpl
All Implemented Interfaces:
MethodProcessor, OperationSet, OperationSetAdvancedTelephony<ProtocolProviderServiceSipImpl>, OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>, OperationSetSecureSDesTelephony, OperationSetSecureTelephony, OperationSetSecureZrtpTelephony

public class OperationSetBasicTelephonySipImpl
extends AbstractOperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
implements MethodProcessor, OperationSetAdvancedTelephony<ProtocolProviderServiceSipImpl>, OperationSetSecureZrtpTelephony, OperationSetSecureSDesTelephony

Implements all call management logic and exports basic telephony support by implementing OperationSetBasicTelephony.

Author:
Emil Ivov, Lyubomir Marinov, Alan Kelly, Emanuel Onica

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicTelephony
HANGUP_REASON_ENCRYPTION_REQUIRED, HANGUP_REASON_NORMAL_CLEARING, HANGUP_REASON_TIMEOUT, MAX_MEDIA_PORT_NUMBER_PROPERTY_NAME, MIN_MEDIA_PORT_NUMBER_PROPERTY_NAME
 
Constructor Summary
OperationSetBasicTelephonySipImpl(ProtocolProviderServiceSipImpl protocolProvider)
          Creates a new instance and adds itself as an INVITE method handler in the creating protocolProvider.
 
Method Summary
 void answerCallPeer(CallPeer peer)
          Indicates a user request to answer an incoming call from the specified CallPeer.
 Call createCall(Contact callee)
          Creates a new Call and invites a specific CallPeer to it given by her Contact.
 Call createCall(Contact callee, CallGroup group)
          Creates a new Call and invites a specific CallPeer to it given by her Contact.
 Call createCall(String callee)
          Creates a new Call and invites a specific CallPeer to it given by her String URI.
 Call createCall(String callee, CallGroup group)
          Creates a new Call and invites a specific CallPeer to it given by her String URI.
protected  CallSipImpl createOutgoingCall()
          Initializes a new outgoing Call with no peers in it.
 Iterator<CallSipImpl> getActiveCalls()
          Returns an iterator over all currently active calls.
protected  ActiveCallsRepositorySipImpl getActiveCallsRepository()
          Returns a reference to the ActiveCallsRepositorySipImpl that we are currently using.
 ProtocolProviderServiceSipImpl getProtocolProvider()
          Returns the protocol provider that this operation set belongs to.
 void hangupCallPeer(CallPeer peer)
          Ends the call with the specified peer.
 void hangupCallPeer(CallPeer peer, int reasonCode, String reason)
          Ends the call with the specified peer.
 boolean isSecure(CallPeer peer)
          Returns true to indicate that the call associated with the given peer is secured, otherwise returns false.
 boolean processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
          Process an asynchronously reported DialogTerminatedEvent.
 boolean processIOException(javax.sip.IOExceptionEvent exceptionEvent)
          Process an asynchronously reported IO Exception.
 boolean processRequest(javax.sip.RequestEvent requestEvent)
          Processes a Request received on a SipProvider upon which this SipListener is registered.
 boolean processResponse(javax.sip.ResponseEvent responseEvent)
          Analyzes the incoming responseEvent and then forwards it to the proper event handler.
 boolean processTimeout(javax.sip.TimeoutEvent timeoutEvent)
          Processes a retransmit or expiration Timeout of an underlying Transactionhandled by this SipListener.
 boolean processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
          Process an asynchronously reported TransactionTerminatedEvent.
 void putOffHold(CallPeer peer)
          Resumes communication with a call peer previously put on hold.
 void putOnHold(CallPeer peer)
          Puts the specified CallPeer "on hold".
 void setMute(Call call, boolean mute)
          Sets the mute state of the Call.
 void setTransferAuthority(TransferAuthority authority)
          Transfer authority used for interacting with user for unknown calls and the requests for transfer.
 void shutdown()
          Closes all active calls.
 String toString()
          Returns a string representation of this OperationSetBasicTelephony instance including information that would permit to distinguish it among other instances when reading a log file.
 void transfer(CallPeer transferee, CallPeer transferTarget)
          Transfers the call we have with transferee to transferTarget.
 void transfer(CallPeer peer, String target)
          Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which already participates in an active Call.
 
Methods inherited from class net.java.sip.communicator.service.protocol.media.AbstractOperationSetBasicTelephony
addCallListener, createRecorder, fireCallEvent, fireCallEvent, removeCallListener
 
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.OperationSetBasicTelephony
addCallListener, createRecorder, removeCallListener
 

Constructor Detail

OperationSetBasicTelephonySipImpl

public OperationSetBasicTelephonySipImpl(ProtocolProviderServiceSipImpl protocolProvider)
Creates a new instance and adds itself as an INVITE method handler in the creating protocolProvider.

Parameters:
protocolProvider - a reference to the ProtocolProviderServiceSipImpl instance that created us.
Method Detail

createCall

public Call createCall(String callee)
                throws OperationFailedException,
                       ParseException
Creates a new Call and invites a specific CallPeer to it given by her String URI.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
callee - the address of the callee who we should invite to a new Call
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
ParseException - if callee is not a valid SIP address String
See Also:
OperationSetBasicTelephony.createCall(String)

createCall

public Call createCall(Contact callee)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her Contact.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
callee - the address of the callee who we should invite to a new call
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
See Also:
OperationSetBasicTelephony.createCall(Contact)

createCall

public Call createCall(String callee,
                       CallGroup group)
                throws OperationFailedException,
                       ParseException
Creates a new Call and invites a specific CallPeer to it given by her String URI.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
callee - the address of the callee who we should invite to a new Call
group - CallGroup from which the Call will belong
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call
ParseException - if callee is not a valid SIP address String

createCall

public Call createCall(Contact callee,
                       CallGroup group)
                throws OperationFailedException
Creates a new Call and invites a specific CallPeer to it given by her Contact.

Specified by:
createCall in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
callee - the address of the callee who we should invite to a new call
group - CallGroup from which the Call will belong
Returns:
a newly created Call. The specified callee is available in the Call as a CallPeer
Throws:
OperationFailedException - with the corresponding code if we fail to create the call

createOutgoingCall

protected CallSipImpl createOutgoingCall()
                                  throws OperationFailedException
Initializes a new outgoing Call with no peers in it. Intended for use by other OperationSets willing to initialize Calls and willing to control their establishment in ways different than createOutgoingCall(Address, javax.sip.message.Message,CallGroup).

Returns:
a new outgoing Call with no peers in it
Throws:
OperationFailedException - if initializing the new outgoing Call fails

getActiveCalls

public Iterator<CallSipImpl> getActiveCalls()
Returns an iterator over all currently active calls.

Specified by:
getActiveCalls in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Returns:
an iterator over all currently active calls.

getActiveCallsRepository

protected ActiveCallsRepositorySipImpl getActiveCallsRepository()
Returns a reference to the ActiveCallsRepositorySipImpl that we are currently using.

Returns:
a reference to the ActiveCallsRepositorySipImpl that we are currently using.

putOffHold

public void putOffHold(CallPeer peer)
                throws OperationFailedException
Resumes communication with a call peer previously put on hold.

Specified by:
putOffHold in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the call peer to put on hold.
Throws:
OperationFailedException - if we fail to construct or send the INVITE request putting the remote side on/off hold.

putOnHold

public void putOnHold(CallPeer peer)
               throws OperationFailedException
Puts the specified CallPeer "on hold".

Specified by:
putOnHold in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the peer that we'd like to put on hold.
Throws:
OperationFailedException - if we fail to construct or send the INVITE request putting the remote side on/off hold.

processRequest

public boolean processRequest(javax.sip.RequestEvent requestEvent)
Processes a Request received on a SipProvider upon which this SipListener is registered.

Specified by:
processRequest in interface MethodProcessor
Parameters:
requestEvent - requestEvent fired from the SipProvider to the SipListener representing a Request received from the network.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

processTransactionTerminated

public boolean processTransactionTerminated(javax.sip.TransactionTerminatedEvent transactionTerminatedEvent)
Process an asynchronously reported TransactionTerminatedEvent.

Specified by:
processTransactionTerminated in interface MethodProcessor
Parameters:
transactionTerminatedEvent - -- an event that indicates that the transaction has transitioned into the terminated state.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

processResponse

public boolean processResponse(javax.sip.ResponseEvent responseEvent)
Analyzes the incoming responseEvent and then forwards it to the proper event handler.

Specified by:
processResponse in interface MethodProcessor
Parameters:
responseEvent - the responseEvent that we received ProtocolProviderService.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

processTimeout

public boolean processTimeout(javax.sip.TimeoutEvent timeoutEvent)
Processes a retransmit or expiration Timeout of an underlying Transactionhandled by this SipListener. This Event notifies the application that a retransmission or transaction Timer expired in the SipProvider's transaction state machine. The TimeoutEvent encapsulates the specific timeout type and the transaction identifier either client or server upon which the timeout occurred. The type of Timeout can by determined by: timeoutType = timeoutEvent.getTimeout().getValue();

Specified by:
processTimeout in interface MethodProcessor
Parameters:
timeoutEvent - the timeoutEvent received indicating either the message retransmit or transaction timed out.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

processIOException

public boolean processIOException(javax.sip.IOExceptionEvent exceptionEvent)
Process an asynchronously reported IO Exception. Asynchronous IO Exceptions may occur as a result of errors during retransmission of requests. The transaction state machine requires to report IO Exceptions to the application immediately (according to RFC 3261). This method enables an implementation to propagate the asynchronous handling of IO Exceptions to the application.

Specified by:
processIOException in interface MethodProcessor
Parameters:
exceptionEvent - The Exception event that is reported to the application.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

processDialogTerminated

public boolean processDialogTerminated(javax.sip.DialogTerminatedEvent dialogTerminatedEvent)
Process an asynchronously reported DialogTerminatedEvent.

Specified by:
processDialogTerminated in interface MethodProcessor
Parameters:
dialogTerminatedEvent - -- an event that indicates that the dialog has transitioned into the terminated state.
Returns:
true if the specified event has been handled by this processor and shouldn't be offered to other processors registered for the same method; false, otherwise

hangupCallPeer

public void hangupCallPeer(CallPeer peer)
                    throws ClassCastException,
                           OperationFailedException
Ends the call with the specified peer.

Specified by:
hangupCallPeer in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the peer that we'd like to hang up on.
Throws:
ClassCastException - if peer is not an instance of this CallPeerSipImpl.
OperationFailedException - if we fail to terminate the call.

hangupCallPeer

public void hangupCallPeer(CallPeer peer,
                           int reasonCode,
                           String reason)
                    throws ClassCastException,
                           OperationFailedException
Ends the call with the specified peer.

Specified by:
hangupCallPeer in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the peer that we'd like to hang up on.
reasonCode - indicates if the hangup is following to a call failure or simply a disconnect indicate by the reason.
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:
ClassCastException - if peer is not an instance of this CallPeerSipImpl.
OperationFailedException - if we fail to terminate the call.

answerCallPeer

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

Specified by:
answerCallPeer in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the call peer that we need to send the ok to.
Throws:
OperationFailedException - if we fail to create or send the response.
ClassCastException - if peer is not an instance of a CallPeerSipImpl

toString

public String toString()
Returns a string representation of this OperationSetBasicTelephony instance including information that would permit to distinguish it among other instances when reading a log file.

Overrides:
toString in class Object
Returns:
a string representation of this operation set.

shutdown

public void shutdown()
Closes all active calls. And releases resources.


setMute

public void setMute(Call call,
                    boolean mute)
Sets the mute state of the Call.

Muting audio streams sent from the call is implementation specific and one of the possible approaches to it is sending silence.

Specified by:
setMute in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Overrides:
setMute in class AbstractOperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Parameters:
call - the Call whose mute state is set
mute - true to mute the call streams being sent to peers; otherwise, false

isSecure

public boolean isSecure(CallPeer peer)
Returns true to indicate that the call associated with the given peer is secured, otherwise returns false.

Specified by:
isSecure in interface OperationSetSecureTelephony
Parameters:
peer - the CallPeer whose security we'd like to check.
Returns:
true to indicate that the call associated with the given peer is secured, otherwise returns false.

transfer

public void transfer(CallPeer transferee,
                     CallPeer transferTarget)
              throws OperationFailedException
Transfers the call we have with transferee to transferTarget.

Specified by:
transfer in interface OperationSetAdvancedTelephony<ProtocolProviderServiceSipImpl>
Parameters:
transferee - the CallPeer that we are about to transfer.
transferTarget - the CallPeer that we are about to direct transferee to.
Throws:
OperationFailedException - if the transfer fails.

transfer

public void transfer(CallPeer peer,
                     String target)
              throws OperationFailedException
Transfers (in the sense of call transfer) a specific CallPeer to a specific callee address which already participates in an active Call.

The method is suitable for providing the implementation of attended call transfer (though no such requirement is imposed).

Specified by:
transfer in interface OperationSetAdvancedTelephony<ProtocolProviderServiceSipImpl>
Parameters:
peer - the CallPeer to be transfered to the specified callee address
target - the address in the form of CallPeer of the callee to transfer peer to
Throws:
OperationFailedException - if creating or sending the transferring INVITE request fails.

getProtocolProvider

public ProtocolProviderServiceSipImpl getProtocolProvider()
Returns the protocol provider that this operation set belongs to.

Specified by:
getProtocolProvider in interface OperationSetBasicTelephony<ProtocolProviderServiceSipImpl>
Returns:
a reference to the ProtocolProviderService that created this operation set.

setTransferAuthority

public void setTransferAuthority(TransferAuthority authority)
Transfer authority used for interacting with user for unknown calls and the requests for transfer.

Specified by:
setTransferAuthority in interface OperationSetAdvancedTelephony<ProtocolProviderServiceSipImpl>
Parameters:
authority - transfer authority.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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