Added in API level 9
Deprecated in API level 31

SipAudioCall


public class SipAudioCall
extends Object

java.lang.Object
   ↳ android.net.sip.SipAudioCall


This class was deprecated in API level 31.
SipManager and associated classes are no longer supported and should not be used as the basis of future VOIP apps.

Handles an Internet audio call over SIP. You can instantiate this class with SipManager, using makeAudioCall() and takeAudioCall().

Note: Using this class require the Manifest.permission.INTERNET and Manifest.permission.USE_SIP permissions. In addition, startAudio() requires the Manifest.permission.RECORD_AUDIO, Manifest.permission.ACCESS_WIFI_STATE, and Manifest.permission.WAKE_LOCK permissions; and setSpeakerMode() requires the Manifest.permission.MODIFY_AUDIO_SETTINGS permission.

Developer Guides

For more information about using SIP, read the Session Initiation Protocol developer guide.

Summary

Nested classes

class SipAudioCall.Listener

Listener for events relating to a SIP call, such as when a call is being received ("on ringing") or a call is outgoing ("on calling"). 

Public constructors

SipAudioCall(Context context, SipProfile localProfile)

Creates a call object with the local SIP profile.

Public methods

void answerCall(int timeout)

Answers a call.

void attachCall(SipSession session, String sessionDescription)

Attaches an incoming call to this call object.

void close()

Closes this object.

void continueCall(int timeout)

Continues a call that's on hold.

void endCall()

Ends a call.

SipProfile getLocalProfile()

Gets the local SIP profile.

SipProfile getPeerProfile()

Gets the peer's SIP profile.

int getState()

Gets the state of the SipSession that carries this call.

void holdCall(int timeout)

Puts a call on hold.

boolean isInCall()

Checks if the call is established.

boolean isMuted()

Checks if the call is muted.

boolean isOnHold()

Checks if the call is on hold.

void makeCall(SipProfile peerProfile, SipSession sipSession, int timeout)

Initiates an audio call to the specified profile.

void sendDtmf(int code)

Sends a DTMF code.

void sendDtmf(int code, Message result)

Sends a DTMF code.

void setListener(SipAudioCall.Listener listener, boolean callbackImmediately)

Sets the listener to listen to the audio call events.

void setListener(SipAudioCall.Listener listener)

Sets the listener to listen to the audio call events.

void setSpeakerMode(boolean speakerMode)

Puts the device to speaker mode.

void startAudio()

Starts the audio for the established call.

void toggleMute()

Toggles mute.

Inherited methods

Public constructors

SipAudioCall

Added in API level 9
public SipAudioCall (Context context, 
                SipProfile localProfile)

Creates a call object with the local SIP profile.

Parameters
context Context: the context for accessing system services such as ringtone, audio, WIFI etc

localProfile SipProfile

Public methods

answerCall

Added in API level 9
public void answerCall (int timeout)

Answers a call. The attempt will be timed out if the call is not established within timeout seconds and onError(SipAudioCall, SipErrorCode.TIME_OUT, String) will be called.

Parameters
timeout int: the timeout value in seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

Throws
SipException if the SIP service fails to answer the call

attachCall

Added in API level 9
public void attachCall (SipSession session, 
                String sessionDescription)

Attaches an incoming call to this call object.

Parameters
session SipSession: the session that receives the incoming call

sessionDescription String: the session description of the incoming call

Throws
SipException if the SIP service fails to attach this object to the session or VOIP API is not supported by the device

close

Added in API level 9
public void close ()

Closes this object. This object is not usable after being closed.

continueCall

Added in API level 9
public void continueCall (int timeout)

Continues a call that's on hold. When succeeds, Listener#onCallEstablished is called. The attempt will be timed out if the call is not established within timeout seconds and onError(SipAudioCall, SipErrorCode.TIME_OUT, String) will be called.

Parameters
timeout int: the timeout value in seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

Throws
SipException if the SIP service fails to unhold the call

endCall

Added in API level 9
public void endCall ()

Ends a call.

Throws
SipException if the SIP service fails to end the call

getLocalProfile

Added in API level 9
public SipProfile getLocalProfile ()

Gets the local SIP profile.

Returns
SipProfile the local SIP profile

getPeerProfile

Added in API level 9
public SipProfile getPeerProfile ()

Gets the peer's SIP profile.

Returns
SipProfile the peer's SIP profile

getState

Added in API level 9
public int getState ()

Gets the state of the SipSession that carries this call. The value returned must be one of the states in SipSession.State.

Returns
int the session state

holdCall

Added in API level 9
public void holdCall (int timeout)

Puts a call on hold. When succeeds, Listener#onCallHeld is called. The attempt will be timed out if the call is not established within timeout seconds and onError(SipAudioCall, SipErrorCode.TIME_OUT, String) will be called.

Parameters
timeout int: the timeout value in seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

Throws
SipException if the SIP service fails to hold the call

isInCall

Added in API level 9
public boolean isInCall ()

Checks if the call is established.

Returns
boolean true if the call is established

isMuted

Added in API level 9
public boolean isMuted ()

Checks if the call is muted.

Returns
boolean true if the call is muted

isOnHold

Added in API level 9
public boolean isOnHold ()

Checks if the call is on hold.

Returns
boolean true if the call is on hold

makeCall

Added in API level 9
public void makeCall (SipProfile peerProfile, 
                SipSession sipSession, 
                int timeout)

Initiates an audio call to the specified profile. The attempt will be timed out if the call is not established within timeout seconds and onError(SipAudioCall, SipErrorCode.TIME_OUT, String) will be called.

Parameters
peerProfile SipProfile: the SIP profile to make the call to

sipSession SipSession: the SipSession for carrying out the call

timeout int: the timeout value in seconds. Default value (defined by SIP protocol) is used if timeout is zero or negative.

Throws
SipException if the SIP service fails to create a session for the call or VOIP API is not supported by the device

sendDtmf

Added in API level 9
public void sendDtmf (int code)

Sends a DTMF code. According to RFC 2883, event 0--9 maps to decimal value 0--9, '*' to 10, '#' to 11, event 'A'--'D' to 12--15, and event flash to 16. Currently, event flash is not supported.

Parameters
code int: the DTMF code to send. Value 0 to 15 (inclusive) are valid inputs.

sendDtmf

Added in API level 9
public void sendDtmf (int code, 
                Message result)

Sends a DTMF code. According to RFC 2883, event 0--9 maps to decimal value 0--9, '*' to 10, '#' to 11, event 'A'--'D' to 12--15, and event flash to 16. Currently, event flash is not supported.

Parameters
code int: the DTMF code to send. Value 0 to 15 (inclusive) are valid inputs.

result Message: the result message to send when done

setListener

Added in API level 9
public void setListener (SipAudioCall.Listener listener, 
                boolean callbackImmediately)

Sets the listener to listen to the audio call events. A SipAudioCall can only hold one listener at a time. Subsequent calls to this method override the previous listener.

Parameters
listener SipAudioCall.Listener: to listen to the audio call events of this object

callbackImmediately boolean: set to true if the caller wants to be called back immediately on the current state

setListener

Added in API level 9
public void setListener (SipAudioCall.Listener listener)

Sets the listener to listen to the audio call events. The method calls setListener(listener,false).

Parameters
listener SipAudioCall.Listener: to listen to the audio call events of this object

setSpeakerMode

Added in API level 9
public void setSpeakerMode (boolean speakerMode)

Puts the device to speaker mode.

Note: Requires the Manifest.permission.MODIFY_AUDIO_SETTINGS permission.

Parameters
speakerMode boolean: set true to enable speaker mode; false to disable

startAudio

Added in API level 9
public void startAudio ()

Starts the audio for the established call. This method should be called after Listener#onCallEstablished is called.

Note: Requires the Manifest.permission.RECORD_AUDIO, Manifest.permission.ACCESS_WIFI_STATE and Manifest.permission.WAKE_LOCK permissions.

toggleMute

Added in API level 9
public void toggleMute ()

Toggles mute.