public class SipAudioCall
extends Object
| java.lang.Object | |
| android.net.sip.SipAudioCall | |
通过SIP处理互联网音频呼叫。 你可以用SipManager实例化这个类,使用makeAudioCall()和takeAudioCall() 。
注意:使用此类需要INTERNET和USE_SIP权限。 此外, startAudio()要求RECORD_AUDIO , ACCESS_WIFI_STATE ,并WAKE_LOCK权限; 和setSpeakerMode()需要MODIFY_AUDIO_SETTINGS权限。
有关使用SIP的更多信息,请阅读 Session Initiation Protocol开发人员指南。
Nested classes |
|
|---|---|
class |
SipAudioCall.Listener 收听与SIP呼叫相关的事件,例如收到呼叫(“正在响铃”)或呼出(“正在呼叫”)时。 |
Public constructors |
|
|---|---|
SipAudioCall(Context context, SipProfile localProfile) 用本地SIP配置文件创建一个呼叫对象。 |
|
公共方法(Public methods) |
|
|---|---|
void |
answerCall(int timeout) 接听电话。 |
void |
attachCall(SipSession session, String sessionDescription) 将来电连接到此通话对象。 |
void |
close() 关闭这个对象。 |
void |
continueCall(int timeout) 继续保持通话。 |
void |
endCall() 结束通话。 |
SipProfile |
getLocalProfile() 获取本地SIP配置文件。 |
SipProfile |
getPeerProfile() 获取对等的SIP配置文件。 |
int |
getState() 获取携带此调用的 |
void |
holdCall(int timeout) 保持通话。 |
boolean |
isInCall() 检查呼叫是否建立。 |
boolean |
isMuted() 检查通话是否静音。 |
boolean |
isOnHold() 检查通话是否处于保持状态。 |
void |
makeCall(SipProfile peerProfile, SipSession sipSession, int timeout) 开始对指定的配置文件进行音频呼叫。 |
void |
sendDtmf(int code) 发送DTMF代码。 |
void |
sendDtmf(int code, Message result) 发送DTMF代码。 |
void |
setListener(SipAudioCall.Listener listener, boolean callbackImmediately) 将侦听器设置为侦听音频呼叫事件。 |
void |
setListener(SipAudioCall.Listener listener) 将侦听器设置为侦听音频呼叫事件。 |
void |
setSpeakerMode(boolean speakerMode) 将设备置于扬声器模式。 |
void |
startAudio() 为已建立的呼叫启动音频。 |
void |
toggleMute() 切换静音。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
SipAudioCall (Context context, SipProfile localProfile)
用本地SIP配置文件创建一个呼叫对象。
| 参数(Parameters) | |
|---|---|
context |
Context: the context for accessing system services such as ringtone, audio, WIFI etc |
localProfile |
SipProfile
|
void answerCall (int timeout)
接听电话。 尝试将超时如果呼叫没有内建立timeout秒onError(SipAudioCall, SipErrorCode.TIME_OUT, String)将被调用。
| 参数(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 |
void attachCall (SipSession session, String sessionDescription)
将来电连接到此通话对象。
| 参数(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 |
也可以看看:
void continueCall (int timeout)
继续保持通话。 当成功时, onCallEstablished(SipAudioCall)被调用。 尝试将超时如果呼叫没有内建立timeout秒onError(SipAudioCall, SipErrorCode.TIME_OUT, String)将被调用。
| 参数(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 |
void endCall ()
结束通话。
| 抛出异常(Throws) | |
|---|---|
SipException |
if the SIP service fails to end the call |
SipProfile getLocalProfile ()
获取本地SIP配置文件。
| 返回(Returns) | |
|---|---|
SipProfile |
the local SIP profile |
SipProfile getPeerProfile ()
获取对等的SIP配置文件。
| 返回(Returns) | |
|---|---|
SipProfile |
the peer's SIP profile |
int getState ()
获取携带此调用的SipSession的状态。 返回的值必须是SipSession.State一个状态。
| 返回(Returns) | |
|---|---|
int |
the session state |
void holdCall (int timeout)
保持通话。 成功时, onCallHeld(SipAudioCall) 。 尝试将超时如果呼叫没有内建立timeout秒onError(SipAudioCall, SipErrorCode.TIME_OUT, String)将被调用。
| 参数(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 |
boolean isInCall ()
检查呼叫是否建立。
| 返回(Returns) | |
|---|---|
boolean |
true if the call is established |
boolean isMuted ()
检查通话是否静音。
| 返回(Returns) | |
|---|---|
boolean |
true if the call is muted |
boolean isOnHold ()
检查通话是否处于保持状态。
| 返回(Returns) | |
|---|---|
boolean |
true if the call is on hold |
void makeCall (SipProfile peerProfile, SipSession sipSession, int timeout)
开始对指定的配置文件进行音频呼叫。 尝试将超时如果呼叫没有内建立timeout秒onError(SipAudioCall, SipErrorCode.TIME_OUT, String)将被调用。
| 参数(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 |
void sendDtmf (int code)
发送DTMF代码。 根据RFC 2883 ,事件0--9映射到十进制值0-9,'*'到10,'#'到11,事件'A' - 'D'到12--15,事件闪烁到16目前,不支持事件闪光。
| 参数(Parameters) | |
|---|---|
code |
int: the DTMF code to send. Value 0 to 15 (inclusive) are valid inputs. |
void sendDtmf (int code,
Message result)
发送DTMF代码。 根据RFC 2883 ,事件0--9映射到十进制值0-9,'*'到10,'#'到11,事件'A' - 'D'到12--15,事件闪烁到16目前,不支持事件闪光。
| 参数(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 |
void setListener (SipAudioCall.Listener listener, boolean callbackImmediately)
将侦听器设置为侦听音频呼叫事件。 A SipAudioCall一次只能容纳一个听众。 随后对此方法的调用将覆盖先前的侦听器。
| 参数(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 |
void setListener (SipAudioCall.Listener listener)
将侦听器设置为侦听音频呼叫事件。 该方法调用setListener(listener, false) 。
| 参数(Parameters) | |
|---|---|
listener |
SipAudioCall.Listener: to listen to the audio call events of this object |
void setSpeakerMode (boolean speakerMode)
将设备置于扬声器模式。
注意:需要 MODIFY_AUDIO_SETTINGS权限。
| 参数(Parameters) | |
|---|---|
speakerMode |
boolean: set true to enable speaker mode; false to disable |
void startAudio ()
为已建立的呼叫启动音频。 应在调用onCallEstablished(SipAudioCall)后调用此方法。
注:需要在 RECORD_AUDIO , ACCESS_WIFI_STATE和 WAKE_LOCK权限。