PJSIP在Asterisk12中被集成进来,作为asterisk第二个SIP协议栈。以下是安装步骤,记录下来已备忘。
首先安装版本控制工具git,在这里只是下载pjsip的代码;
下载git-1.8.1.5到/home目录内:
# cd /home
# tar zxvf git-1.8.1.5.tar.gz
# cd git-1.8.1.5
下面编译安装:
# make prefix=/usr/local install
二进制文件会被安装到/usr/local/bin目录里;
系统上已经安装过git的,此步可以无视。
下载pjsip源代码:
# git clone https://github.com/asterisk/pjproject pjproject
# cd pjproject
# ./configure --prefix=/usr --libdir=/usr/lib --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
# make dep
# make
# make install
# ldconfig
查看是否安装正确:
# ldconfig -p | grep pj
libpjsua.so.2 (libc6) => /usr/lib/libpjsua.so.2
libpjsua.so (libc6) => /usr/lib/libpjsua.so
libpjsip.so.2 (libc6) => /usr/lib/libpjsip.so.2
libpjsip.so (libc6) => /usr/lib/libpjsip.so
libpjsip-ua.so.2 (libc6) => /usr/lib/libpjsip-ua.so.2
libpjsip-ua.so (libc6) => /usr/lib/libpjsip-ua.so
libpjsip-simple.so.2 (libc6) => /usr/lib/libpjsip-simple.so.2
libpjsip-simple.so (libc6) => /usr/lib/libpjsip-simple.so
libpjnath.so.2 (libc6) => /usr/lib/libpjnath.so.2
libpjnath.so (libc6) => /usr/lib/libpjnath.so
libpjmedia.so.2 (libc6) => /usr/lib/libpjmedia.so.2
libpjmedia.so (libc6) => /usr/lib/libpjmedia.so
libpjmedia-videodev.so.2 (libc6) => /usr/lib/libpjmedia-videodev.so.2
libpjmedia-videodev.so (libc6) => /usr/lib/libpjmedia-videodev.so
libpjmedia-codec.so.2 (libc6) => /usr/lib/libpjmedia-codec.so.2
libpjmedia-codec.so (libc6) => /usr/lib/libpjmedia-codec.so
libpjmedia-audiodev.so.2 (libc6) => /usr/lib/libpjmedia-audiodev.so.2
libpjmedia-audiodev.so (libc6) => /usr/lib/libpjmedia-audiodev.so
libpjlib-util.so.2 (libc6) => /usr/lib/libpjlib-util.so.2
libpjlib-util.so (libc6) => /usr/lib/libpjlib-util.so
libpj.so.2 (libc6) => /usr/lib/libpj.so.2
libpj.so (libc6) => /usr/lib/libpj.so
如果看到上面的结果,就表明安装正确。
接下来安装asterisk-12
先安装依赖库:jansson和sqlite:
下载安装jansson:
http://www.digip.org/jansson/releases/jansson-2.5.tar.gz
# tar zxvf jansson-2.5.tar.gz
# cd jansson-2.5
# ./configure
# make
# make install
# make check
安装sqlite:
CentOS发行版本自带的有sqlite和sqlite-devel,利用rpm安装即可;
从asterisk官网上下载:asterisk-12-current.tar.gz,我下载时的版本是12.1.1。
# tar zxvf asterisk-12-current.tar.gz
# cd asterisk-12.1.1
# ./configure --disable-asteriskssl
# make menuslect
进入Channel Drivers 中chan_pjsip被选中 且 Resource Modules中res_pjsip开头的几个模块别选中,表明pjsip模块已被asterisk正确识别。
# make
# make install
asterisk12安装成功!
启动asterisk后,在CLI中可以利用pjsip查看模块的相关命令。
创建pjsip的endpoint
在/etc/asterisk/pjsip.conf的最后,添加两行:
#include “/etc/asterisk/peers_pjsip.conf”
#include "/etc/asterisk/trunk_pjsip.conf"
/etc/asterisk/peers_pjsip.conf文件中配置pjsip的endpoint,例如:
[6001]
type=endpoint
transport=transport-udp
context=from-internal
disallow=all
allow=ulaw
allow=gsm
allow=g729
auth=6001-auth
aors=6001
[6002]
type=endpoint
transport=transport-udp
context=from-internal
disallow=all
allow=ulaw
allow=gsm
allow=g729
auth=6002-auth
aors=6002
[6001-auth]
type=auth
auth_type=userpass
password=6001
username=6001
[6002-auth]
type=auth
auth_type=userpass
password=6002
username=6002
[transport-udp]
type=transport
protocol=udp ;udp,tcp,tls,ws,wss
bind=0.0.0.0:5070
[6001]
type=aor
max_contacts=2
;contact=sip:6001@192.0.2.1:5060
[6002]
type=aor
max_contacts=1
以上内容是创建了两个pjsip的endpoint。注意transport-udp标签,其监听的是5070端口,也就是pjsip监听的是5070端口,而chan_sip默认情况向监听的是5060,两者不能重复。
/etc/asterisk/trunk_pjsip.conf中创建trunk,示例内容如下:
[mytrunk]
type=endpoint
transport=transport-udp
context=from-external
disallow=all
allow=ulaw
allow=alaw
outbound_auth=mytrunk_auth
aors=mytrunk
[mytrunk]
type=aor
contact=sip:192.168.2.20:5070
[mytrunk]
type=identify
endpoint=mytrunk
match=192.168.2.20
这样pjsip就可以接受来自192.168.2.20的呼叫了,否则,在默认的情况下pjsip是不接受匿名呼叫的;另一种方法是创建anonymous的endpoint,这样会带来安全隐患。
---------------------
作者:clliu
来源:CSDN
原文:https://blog.csdn.net/clliu/article/details/22484809
版权声明:本文为博主原创文章,转载请附上博文链接!
本文链接:https://www.kinber.cn/post/485.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: