呼入过程

定义

呼入过程是指:
SIP 终端/服务器向 LinkRTC 发起呼叫, LinkRTC 将呼叫交换到具有 WebRTC 功能的浏览器/客户端的过程。
呼出过程的参与者有:
  • 主叫 SIP 电话
  • LinkRTC 服务器
  • 具有 WebRTC 功能的浏览器/客户端
  • 用户的 Web 服务器

状态变化

外呼过程中,呼叫的状态有:
  • pendingLinkRTC 收到了来自 SIP 端点的呼入,单还没有决定如何处理。
  • calling:用户的程序告知 LinkRTC 将呼入选择到某一客户端,LinkRTC 开始呼叫这个客户端。
  • ringing:客户端收到了 LinkRTC 的呼叫。
  • confirmed:客户端接受了呼叫,双方可以建立通话。
  • dropped:呼叫失败或者通话结束。这是呼叫的结束状态。

digraph incoming_call_state { begin [shape=point] end [shape=doublecircle] begin -> pending [label="呼入"] pending -> calling [label="确定了目标客户端"] pending -> dropped [label="呼叫禁止"] calling -> ringing [label="客户端收到呼叫"] calling -> dropped [label="呼叫失败"] ringing -> confirmed [label="接通"] ringing -> dropped [label="呼叫失败"] confirmed -> dropped [label="通话结束"] dropped -> end }

步骤说明

以下分步骤说明呼入过程。

在顺序图中:
  • s1 代表:主叫叫 SIP 端点 s1
  • linkrtc 代表:LinkRTC 服务器
  • webserver 代表:用户的 Web 服务器
  • c1 代表:具有 WebRTC 功能的浏览器/客户端 c1

1. 呼入选择

1.1. LinkRTC 收到了来自 s1 的呼入请求

1.2. LinkRTCs1 回复 SIP 状态码 100 TRYING

1.3. LinkRTC 询问用户的服务程序,是否允许这个呼入,以及要将这个呼入交换到哪个客户端

1.3.1 如果用户的服务程序禁止该呼入,则结束呼叫过程

1.3.2 如果用户的服务程序指定了目标客户端,则继续后续过程

呼入选择

blockdiag s1 linkrtc webserver c1 INVITE TRYING notify: incoming_call command: switch to 'c1' continue

呼入拒绝

blockdiag s1 linkrtc webserver c1 INVITE TRYING notify: incoming_call command: drop! 403 Forbidden break

2. 呼叫客户端

2.1. LinkRTC 向目标客户端 c1 发起呼叫

2.1.1. 如果 c1 无法收到呼叫指令,则结束此次呼入过程,并通知用户的应用服务器。

2.1.2. 如果 c1 收到了呼叫,通知主叫 SIP 和用户的应用服务器,然后等待 c1 的响应。

2.2. 然后等待 c1 的响应。

2.2.1. 如果 c1 拒绝,或者超时无响应,则结束此次呼入过程,并通知用户的应用服务器。

2.2.2. 如果 c1 接受呼入,则通知主叫 SIP 和用户的应用服务器,继续后续步骤。

呼叫客户端成功

blockdiag s1 linkrtc webserver c1 INVITE: from='x', to='y' TRYING notify: incoming call(from=' x', to='y') command: switch to 'c1' notify: state=calling incoming call: from='x', to='y' return: accept notify: accepted 200 OK continue wait wait continue

呼叫客户端失败

blockdiag s1 linkrtc webserver c1 INVITE: from='x', to='y' TRYING notify: incoming call(from=' x', to='y') command: switch to 'c1' notify: state=calling incoming call: from='x', to='y' notify: state=dropped 480 Temporarily Unavailable continue wait break

3. 媒体连接

如果呼叫成功,客户端 c1 会收到 LinkRTC 转发的对端 SIP 终端的 SDPc1 根据该 SDP ,使用 WebRTC 建立点对点媒体通道。

4. 呼叫结束

SIP 终端 s1LinkRTC 发送 SIP BYE 指令;或者 c1LinkRTC 发结束命令,都会导致呼叫的结束。

s1 主动结束呼叫时, LinkRTC 会将通话状态变化 同时 通知 c1 和 用户的 Web 服务器。

SIP 一方结束呼叫

blockdiag s1 linkrtc webserver c1 BYE call state: disconnected call state: disconnected ACK continue

WebRTC 一方结束呼叫

blockdiag s1 linkrtc webserver c1 end call BYE call state: disconnected ACK continue