技术分享| Sip与WebRTC互通-SRProxy开源库讲解

SRProxy 介绍

目前 WebRTC 协议跟 SIP 协议互通场景主要运用在企业呼叫中心、企业内部通信、电话会议(PSTN)、智能门禁等场景,要想让 WebRTC 与 SIP 互通,要解决两个层面的问题:信令层媒体层。两个网络使用的信令机制不同,所以要进行信令的转换,才能完成媒体的协商,建立会话;媒体层要完成编码的转换,以及 rtp/srtp 转换等功能。anyRTC 开源 SRProxy 网关,解决了 WebRTC 与 SIP 的协议转换,配合 anyRTC 开源的 ARCall 音视频呼叫 demo,演示如何通过 App/Web 端呼叫落地,下文就如何使用部署 SRProxy 网关,以及如何跟 ARCall 互通进行展开,熟悉如何使用后,可集成 SDK 到自己的应用中,配合自身业务做对应的场景。

呼叫流程

一、ARCall 呼叫逻辑

在这里插入图片描述

在这里插入图片描述

二、SRProxy 转发逻辑

1、SRProxy 能做什么?

image-20200825140210910

从上图简单概括一下:SRProxy 是实现 RTC 和 SIP 之间业务互通的桥梁,更是实现业务拓展的关键服务。

2、ARCall 呼叫流程
1)状态流转图

呼叫邀请中,主叫可以通过 [LocalInvitation] 对象提供的 [getState] 方法查询当前呼叫邀请的有关状态;被叫可以通过 SDK 返回的 [RemoteInvitation]对象的 [getState]方法查询当前呼叫邀请的相关状态。

LocalInvitationState

下图描述了与主叫相关的呼叫邀请状态流转图:

img

RemoteInvitationState

下图描述了与被叫相关的呼叫邀请状态流转图:

img

2)API 时序图

取消已发送呼叫邀请

img

接受/拒绝呼叫邀请

img

注意事项及限制条件

  • 主叫设置的呼叫邀请 content 的字符串长度:8 KB,格式为 UTF-8。
  • 被叫设置的呼叫邀请响应 response 的字符串长度:8 KB,格式为 UTF-8。
  • 呼叫邀请的 channelId 仅用于与信令互通时设置。设置的 channelId 必须与信令 SDK 设置相同才能实现互通。字符串长度:64 字节,格式为 UTF-8。

创建一个应用

一、注册账号

anyRTC官网 注册一个开发者账号,并创建一个应用

image-20211116101342701

二、创建应用获取 AppId

image-20211116102040742

部署 freeswitch

一、准备

一、系统

Centos 7.9 最好是纯净服务器 不然可能会存在依赖装不上或冲突情况

二、防火墙

参考freeswitch防火墙: https://freeswitch.org/confluence/display/FREESWITCH/Firewall

# 开放sip端口tcp协议
[root@localhost ~]# firewall-cmd --permanent --add-port=5060/tcp
# 开放sip端口udp协议
[root@localhost ~]# firewall-cmd --permanent --add-port=5060/udp
# 开放ws端口
[root@localhost ~]# firewall-cmd --permanent --add-port=5066/tcp
# 开放wss端口
[root@localhost ~]# firewall-cmd --permanent --add-port=7443/tcp
# 开放rtp端口(范围)
[root@localhost ~]# firewall-cmd --permanent --add-port=16384-32768/udp
# 让防火墙配置生效
[root@localhost ~]# firewall-cmd --reload

# 也可以直接关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld

二、编译环境和 FreeSwitch 依赖库

# 更新yum源
[root@localhost ~]# yum update -y
    
# 安装lib相关需求依赖
[root@localhost ~]# yum install -y yum-utils git gcc gcc-c++ automake autoconf libtool libtiff-devel libjpeg-devel openssl-devel vim

# 添加环境变量
[root@localhost ~]# vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
[root@localhost ~]# source /etc/profile
    
# 单独下载spandsp源码
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# git clone https://github.com/freeswitch/spandsp.git
[root@localhost src]# cd spandsp
[root@localhost spandsp]# ./bootstrap.sh
[root@localhost spandsp]# ./configure
[root@localhost spandsp]# make
[root@localhost spandsp]# make install
[root@localhost spandsp]# ldconfig
    
# 单独下载sofia-sip(SIP协议栈)源码  尝试使用过码云上面的,但是freeswitch编译的时候一直报错需要sofia-sip
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# git clone https://github.com/freeswitch/sofia-sip.git
[root@localhost src]# cd sofia-sip
[root@localhost sofia-sip]# ./bootstrap.sh -j
[root@localhost sofia-sip]# ./configure
[root@localhost sofia-sip]# make
[root@localhost sofia-sip]# make install
[root@localhost sofia-sip]# ldconfig

# 单独下载libuuid源码
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# wget https://jaist.dl.sourceforge.net/project/libuuid/libuuid-1.0.3.tar.gz
[root@localhost src]# tar -zxvf libuuid-1.0.3.tar.gz
[root@localhost src]# cd libuuid-1.0.3
[root@localhost libuuid-1.0.3]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值