通过部署opensips,opensips-cp,rtpproxy,mediaproxy实现voip通话。测试可以通过安卓原生客户端验证,CSipSimple客户端通话(拨打/接收)
1.安装opensips
opensips需要编译源码安装
官网:http://opensips.org
文件目录:http://opensips.org/pub/opensips/1.11.2/src/
tarxcf opensips-1.11.2_src.tar.gz
cdopensips-1.11.2-tls /
makemenuconfig
在menuconfig中选择—>Configure Compile Options—> Configure Excluded Modules
方向键向下滚动,按空格选中[*] db_MysqL
按q键返回上一级,选择—> Configure Install Prefix,输入/回车表示安装在/目录下的配置目录而不是/usr/local目录下。
选择 —> Save Changes 保存修改。
按q返回,选择 —> Compile And Install OpenSIPS,回车安装。
安装完成后会将配置文件放在/etc/opensips目录下。运行文件在/sbin目录下。
如果出现依赖错误,先通过apt-get安装依赖。
2.配置opensips
进入/etc/opensips目录,运行osipsconfig命令
osipsconfig
依次选择—> Generate OpenSIPS Script —> Residential Script —> Configure Residential Script
选中如下几项
[*] ENABLE_TCP
[*] USE_ALIASES
[*] USE_AUTH
[*] USE_DBACC
[*] USE_DBUSRLOC
[*] USE_DIALOG
[*] USE_NAT
按q返回,选择 —> Generate Residential Script 回车,生成新的配置文件。按q(三次)退出命令
将新生成的opensips_residential_*.cfg文件重命名为opensips.cfg编辑
viopensips.cfg
log_stderror=no
log_facility=LOG_LOCAL0
fork= yes
children= 4
/*uncomment the following lines to enabledebugging */
#debug=6
#fork=no
#log_stderror=yes
/*uncomment the next line to enablethe auto temporary blacklisting of
not available destinations (default disabled ) */
#disable_dns_blacklist=no
/*uncomment the next line to enableIPv6 lookup after IPv4 dns
lookup failures (default disabled ) */
#dns_try_ipv6=yes
/*comment the next line to enablethe auto discovery of localaliases
based on revers DNS on IPs */
auto_aliases=no
alias=xdty.org # 增加alias,修改为你的域名
listen=udp:域名对应 ip地址: 6060 # CUSTOMIZE ME
disable_tcp=no
listen=tcp:域名对应 disable_tls= yes
####### Modules Section ########
#set module path
mpath= "/lib64/opensips/modules/" # 增加一个斜杠
#### SIGNALING module
loadmodule "signaling.so"
#### StateLess module
loadmodule "sl.so"
#### Transaction Module
loadmodule "tm.so"
modparam ( "tm","fr_timer",5 )
modparam ( "fr_inv_timer",60);">30 )
modparam ( "restart_fr_on_each_reply",60);">0 )
modparam ( "onreply_avp_mode",60);">1 )
#### Record Route Module
loadmodule "rr.so"
/* donot append from tag to the RR (no need forthis script ) */
modparam ( "rr",60);">"append_fromtag",60);">0 )
#### MAX ForWarD module
loadmodule "maxfwd.so"
#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"
#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam ( "mi_fifo",60);">"fifo_name",60);">"/tmp/opensips_fifo" )
modparam ( "fifo_mode",0666 )
#### URI module
loadmodule "uri.so"
modparam ( "uri",60);">"use_uri_table",60);">0 )
#增加这一行,不然报错
modparam ( "db_url",60);">"MysqL://opensips:opensipsrw@localhost/opensips" )
#### MysqL module
loadmodule "db_MysqL.so"
#### USeR LOCation module
loadmodule "usrloc.so"
modparam ( "usrloc",60);">"nat_bflag",60);">"NAT" )
modparam ( "db_mode",60);">2 )
modparam ( "MysqL://opensips:opensipsrw@localhost/opensips" ) # CUSTOMIZE ME
#### REGISTRAR module
loadmodule "registrar.so"
modparam ( "registrar",60);">"tcp_persistent_flag",60);">"TCP_PERSISTENT" )
modparam ( "received_avp",60);">"$avp(received_nh)" )
/*uncomment the next line not to allow morethan 10contacts per AOR */
#modparam("registrar","max_contacts",10)
#### ACCounting module
loadmodule "acc.so"
/*what special events should be accounted ? */
modparam ( "acc",60);">"early_media",60);">"report_cancels",60);">0 )
/*by default we donot adjust the direct of the sequential requests.
ifyou enablethis parameter,be sure the enable "append_fromtag"
in "rr"module */
modparam ( "detect_direction",60);">"Failed_transaction_flag",60);">"ACC_Failed" )
/*account triggers (flags ) */
modparam ( "db_flag",60);">"ACC_DO" )
modparam ( "db_missed_flag",60);">"ACC_MISSED" )
modparam ( #### AUTHentication modules
loadmodule "auth.so"
loadmodule "auth_db.so"
modparam ( "auth_db",60);">"calculate_ha1",yes )
modparam ( "password_column",60);">"password" )
modparam ( # CUSTOMIZE ME
modparam ( "load_credentials",60);">"" )
#### ALIAS module
loadmodule "alias_db.so"
modparam ( "alias_db",174);"># CUSTOMIZE ME
#### DIALOG module
loadmodule "dialog.so"
modparam ( "dialog",60);">"dlg_match_mode",60);">1 )
modparam ( "default_timeout",60);">21600 ) # 6 hours timeout
modparam ( # CUSTOMIZE ME
#### NAT modules
loadmodule "nathelper.so"
modparam ( "nathelper",60);">"natping_interval",60);">10 )
modparam ( "ping_nated_only",60);">"$avp(received_nh)" )
loadmodule "rtpproxy.so"
modparam ( "rtpproxy",60);">"rtpproxy_sock",60);">"udp:localhost:22222" ) # 修改端口
#增加下边这一段
#### MediaProxy module
loadmodule "mediaproxy.so"
modparam ( "mediaproxy",60);">"disable",60);">"mediaproxy_socket",60);">"/var/run/mediaproxy/dispatcher.sock" )
modparam ( "mediaproxy_timeout",60);">1000 )
modparam ( "signaling_ip_avp",60);">"$avp(nat_ip)" )
modparam ( "media_relay_avp",60);">"$avp(media_relay)" )
modparam ( "ice_candidate",60);">"low-priority" )