- 安装
我目前用的是Debian 11
cat /etc/debian_version,结果是11.8
uname -r,结果是5.10.0-26-amd64
我试过这样安装:
echo 'deb https://deb.sipwise.com/spce/mr11.1.1/ bullseye main' > /etc/apt/sources.list.d/sipwise.list
echo 'deb-src https://deb.sipwise.com/spce/mr11.1.1/ bullseye main' >> /etc/apt/sources.list.d/sipwise.list
wget -q -O - https://deb.sipwise.com/spce/keyring/sipwise-keyring-bootstrap.gpg | apt-key add -
apt-get update && apt-get install -y ngcp-rtpengine
改成11.2.1也可以,但是11.3.1则失败,估计是没有对应的apt源(Debian11)
至于Debian 12我还没来得及做测试
不改任何配置的情况下服务是可以启动的
systemctl status rtpengine
systemctl status rtpengine-recording
# 为了节省篇幅就不贴日志了
用下面的命令可以检查到是否启动了内核转发模块:
# lsmod | grep -i rtp
xt_RTPENGINE 61440 4
x_tables 53248 3 nft_compat,xt_RTPENGINE,ip_tables
- 源码编译安装(以后补充)
- docker安装
查了下资料,这二个比较优秀,但暂时没做测试:
# 估计只能做参考,docker还是需要自己来build,保证rtpengine版本足够新
# 此外,如果要启动内核转发模块(xt_RTPENGINE),要注意宿主机unix内核版本,要跟容器内保持一致
https://github.com/ianblenke/docker-rtpengine https://github.com/ReadyTalk/rtpengine-docker
- rtpengine的配置
配置项目比较多,但可能比较难配置的可能是interface,下面是我的配置:
interface=priv/172.16.228.202;pub/172.16.228.202!113.113.113 # 1:1 nat
interface=priv/172.16.228.202;pub/172.16.228.202!113.113.113.113;inner/172.16.228.203 # double nic
interface=eth0 # 配置网卡名称
- rtpengine-ctl常用命令(类似FreeSWITCH的fs_cli)
rtpengine-ctl list numsessions
rtpengine-ctl list sessions all
rtpengine-ctl terminate all
rtpengine-ctl是用perl写的,如果不想用perl,可考虑用curl,使能rtpengine的http配置即可
下面是一个例子:
curl 'http://127.0.0.1:2225/cli/list+interfaces'
- promotheus接口:
curl 'http://127.0.0.1:2225/metrics'
- 关于录音
先看这个配置:
recording-dir = /var/spool/rtpengine
recording-method = pcap
这个够简单,rtpengine一个进程就搞定,但是后期需要把pcap文件处理成wav文件
再看这个配置:
table = 0 #必须大于等于0
recording-method = proc
并且录音(rtpengine-recording)要这样配置:
# rtpengine-recording.conf
table = 0 #必须大于等于0
output-dir = /var/lib/rtpengine-recording
output-format = wav
mp3-bitrate = 48000
output-mixed = true
output-single = true
output-chmod = 0660
output-chown = root
output-chgrp = root
mysql-host = localhost
mysql-port = 3306
mysql-user = root
mysql-pass = root
mysql-db = rtpengine
log-mark-prefix = «
log-mark-suffix = »
log-facility = local2
同时,需要创建mysql数据库rtpengine,并创建下面的三张表:
CREATE TABLE `recording_calls` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`call_id` varchar(250) NOT NULL,
`start_timestamp` decimal(13,3) DEFAULT NULL,
`end_timestamp` decimal(13,3) DEFAULT NULL,
`status` enum('recording','completed','confirmed') DEFAULT 'recording',
PRIMARY KEY (`id`),
KEY `call_id` (`call_id`)
);
CREATE TABLE `recording_streams` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`call` int(10) unsigned NOT NULL,
`local_filename` varchar(250) NOT NULL,
`full_filename` varchar(250) NOT NULL,
`file_format` varchar(10) NOT NULL,
`stream` mediumblob,
`output_type` enum('mixed','single') NOT NULL,
`stream_id` int(10) unsigned NOT NULL,
`sample_rate` int(10) unsigned NOT NULL DEFAULT '0',
`channels` int(10) unsigned NOT NULL DEFAULT '0',
`ssrc` int(10) unsigned NOT NULL,
`start_timestamp` decimal(13,3) DEFAULT NULL,
`end_timestamp` decimal(13,3) DEFAULT NULL,
`tag_label` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `call` (`call`),
CONSTRAINT `fk_call_id` FOREIGN KEY (`call`) REFERENCES `recording_calls` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `recording_metakeys` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`call` int(10) unsigned NOT NULL,
`key` char(255) NOT NULL,
`value` char(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `prim_lookup` (`value`,`key`),
KEY `fk_call_idx` (`call`),
CONSTRAINT `fk_call_idx` FOREIGN KEY (`call`) REFERENCES `recording_calls` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
可参考这里:
https://blog.opensips.org/2018/02/16/audio-recording-and-speech-detection-experiments-with-opensips/
还有一种模式叫forwarding,就是rtpengine发rtp流出去,可能用的人比较少,就不介绍了
- 讨论组在哪里:
log-level要配置为7,拿到详细日志
日志如果太长可以事先发到pastebin,提供链接
保持礼貌
问题尽量描述清楚
- ng控制协议是怎样的:
https://github.com/sipwise/rtpengine/blob/master/docs/ng_control_protocol.md
- 常用的offer flag
replace-session-connection # 更换c地址(连接地址)
original-sendrecv # 保持原始的sendrecv,默认情况下rtpengine自动给每个media添加a=sendrecv属性
rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP" # web->sip
rtcp-mux-offer generate-mid DTLS=passive SDES-off ICE=force RTP/SAVPF # sip->web
ICE=remove RTP/AVP # srtp->rtp
ICE=remove RTP/SAVP # rtp->srtp
direction=priv direction=pub # a来自内网,去到外网的b
direction=pub direction=priv # 自己琢磨
codec-mask-PCMA codec-strip-opus transcode-opus single-codec # 转码,flag的含义依次是:跟a协商PCMA,不协商opus,跟b协商opus,单个编码,合起来就是rtpengie跟a协商PCMA,跟b协商opus
先写到这里,以后有机会再续