Android 简明教程

Android - SIP Protocol

SIP(会话发起协议)是一种协议,可让应用程序轻松设置拨出和接入语音呼叫,而无需直接管理会话、传输级通信或音频记录或回放。

SIP stands for (Session Initiation Protocol). It is a protocol that let applications easily set up outgoing and incoming voice calls, without having to manage sessions, transport-level communication, or audio record or playback directly.

Applications

一些 SIP 的常见应用程序如下。

Some of the common applications of SIP are.

  1. Video conferencing

  2. Instant messaging

Requirements

以下为开发 SIP 应用程序的要求−

Here are the requirements for developing a SIP application −

  1. Android OS must be 2.3 or higher

  2. You must have a data connection or WIFI

  3. You must have an SIP account in order to use this service.

SIP Classes

以下是 Android SIP API 中包含的类摘要:

Here is a summary of the classes that are included in the Android SIP API:

Sr.No

Class & description

1

SipAudioCall Handles an Internet audio call over SIP

2

SipErrorCode Defines error codes returned during SIP actions

3

SipManager Provides APIs for SIP tasks, such as initiating SIP connections, and provides access to related SIP services

4

SipProfile Defines a SIP profile, including a SIP account, domain and server information

5

SipSession Represents a SIP session that is associated with a SIP dialog or a standalone transaction not within a dialog

Functions of SIP

SIP 有以下主要功能。

SIP has following major functions.

  1. SIP allows for the establishment of user location

  2. SIP provides a mechanism for call management

  3. SIP provides feature negotiation, so that all the parties in the call can agree to the features supported among them

Components of SIP

SIP 有以下两个主要组件。

SIP has two major components which are listed below.

  1. User Agent Client (UAC)

  2. User Agent Server (UAS)

UAC

UAC 或用户代理客户端是指生成请求并将请求发送到服务器的最终用户。这些请求由运行在他们系统上的客户端应用程序生成。

UAC or User Agent Client are those end users who generates requests and send those requests to the server.These requests are generated by the client applications running on their systems.

UAS

UAS 或用户代理服务器是指获取 UAC 生成请求的系统。UAS 处理这些请求,然后根据请求生成相应的响应。

UAS or User Agent Server are those systems which get the request generated by UAC. The UAS process those requests and then according to the requests it generates responses accordingly.

SipManager

SipManager 是一个安卓 SIP 任务 API,如发起 SIP 呼叫,并提供访问相关的 SIP 服务。此类是任何 SIP 操作的起点。你可以使用 newInstance() 获取其实例。

SipManager is an android API for SIP tasks, such as initiating SIP connections, and provides access to related SIP services. This class is the starting point for any SIP actions. You can acquire an instance of it with newInstance().

SipManager 具有许多用于管理 SIP 任务的功能。下面的列表列出了其中部分功能。

The SipManager has many functions for managing SIP tasks. Some of the functions are listed below.

Sr.No

Class & description

1

close(String localProfileUri) Closes the specified profile to not make/receive calls

2

getCallId(Intent incomingCallIntent) Gets the call ID from the specified incoming call broadcast intent

3

isOpened(String localProfileUri) Checks if the specified profile is opened in the SIP service for making and/or receiving calls

4

isSipWifiOnly(Context context) Returns true if SIP is only available on WIFI

5

isRegistered(String localProfileUri) Checks if the SIP service has successfully registered the profile to the SIP provider (specified in the profile) for receiving calls

6

isVoipSupported(Context context) Returns true if the system supports SIP-based VOIP API

7

takeAudioCall(Intent incomingCallIntent, SipAudioCall.Listener listener) Creates a SipAudioCall to take an incoming call

8

unregister(SipProfile localProfile, SipRegistrationListener listener) Manually unregisters the profile from the corresponding SIP provider for stop receiving further calls