Most visited

Recently visited

Added in API level 9

SipAudioCall

public class SipAudioCall
extends Object

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


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

Note: Using this class require the INTERNET and USE_SIP permissions. In addition, startAudio() requires the RECORD_AUDIO, ACCESS_WIFI_STATE, and WAKE_LOCK permissions; and setSpeakerMode() requires the 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 recieved ("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

From class java.lang.Object

Public constructors

SipAudioCall

Added in API level 9
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
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

See also:

attachCall

Added in API level 9
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

See also:

close

Added in API level 9
void close ()

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

continueCall

Added in API level 9
void continueCall (int timeout)

Continues a call that's on hold. When succeeds, onCallEstablished(SipAudioCall) 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

See also:

endCall

Added in API level 9
void endCall ()

Ends a call.

Throws
SipException if the SIP service fails to end the call

getLocalProfile

Added in API level 9
SipProfile getLocalProfile ()

Gets the local SIP profile.

Returns
SipProfile the local SIP profile

getPeerProfile

Added in API level 9
SipProfile getPeerProfile ()

Gets the peer's SIP profile.

Returns
SipProfile the peer's SIP profile

getState

Added in API level 9
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
void holdCall (int timeout)

Puts a call on hold. When succeeds, onCallHeld(SipAudioCall) 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

See also:

isInCall

Added in API level 9
boolean isInCall ()

Checks if the call is established.

Returns
boolean true if the call is established

isMuted

Added in API level 9
boolean isMuted ()

Checks if the call is muted.

Returns
boolean true if the call is muted

isOnHold

Added in API level 9
boolean isOnHold ()

Checks if the call is on hold.

Returns
boolean true if the call is on hold

makeCall

Added in API level 9
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

See also:

sendDtmf

Added in API level 9
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
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
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
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

See also:

setSpeakerMode

Added in API level 9
void setSpeakerMode (boolean speakerMode)

Puts the device to speaker mode.

Note: Requires the MODIFY_AUDIO_SETTINGS permission.

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

startAudio

Added in API level 9
void startAudio ()

Starts the audio for the established call. This method should be called after onCallEstablished(SipAudioCall) is called.

Note: Requires the RECORD_AUDIO, ACCESS_WIFI_STATE and WAKE_LOCK permissions.

toggleMute

Added in API level 9
void toggleMute ()

Toggles mute.

Hooray!