webrtc接入freeswitch的sip音视频传输
Posted dong1
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了webrtc接入freeswitch的sip音视频传输相关的知识,希望对你有一定的参考价值。
1、安装freeswitch
https://freeswitch.org/confluence/display/FREESWITCH/CentOS+7
dong@ubuntu:~/freeswitch$ vi freeswitch_v1.6_install_centos7.6.sh
#freeswitch_v1.6_install_centos7.6.sh yum install -y http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm epel-release yum install -y git alsa-lib-devel autoconf automake bison broadvoice-devel bzip2 curl-devel db-devel e2fsprogs-devel flite-devel g722_1-devel gcc-c++ gdbm-devel gnutls-devel ilbc2-devel ldns-devel libcodec2-devel libcurl-devel libedit-devel libidn-devel libjpeg-devel libmemcached-devel libogg-devel libsilk-devel libsndfile-devel libtheora-devel libtiff-devel libtool libuuid-devel libvorbis-devel libxml2-devel lua-devel lzo-devel mongo-c-driver-devel ncurses-devel net-snmp-devel openssl-devel opus-devel pcre-devel perl perl-ExtUtils-Embed pkgconfig portaudio-devel postgresql-devel python26-devel python-devel soundtouch-devel speex-devel sqlite-devel unbound-devel unixODBC-devel wget which yasm zlib-devel # cd /usr/local/src #git clone -b v1.6 https://github.com/signalwire/freeswitch.git freeswitch git clone -b v1.6 https://gitee.com/dong2/freeswitch.git freeswitch cd /usr/local/src/freeswitch ./bootstrap.sh -j ./configure make -j make -j install # #make -j cd-sounds-install #make -j cd-moh-install # ln -sf /usr/local/freeswitch/bin/freeswitch /usr/bin/ ln -sf /usr/local/freeswitch/bin/fs_cli /usr/bin/ # #freeswitch #freeswitch -nc #freeswitch -nonat -nonatmap #freeswitch -nonat -nonatmap -nosql # #netstat -anp|grep 5060 # #fs_cli
2、配置freeswitch
1) Change password
cd /usr/local/freeswitch/conf
vi vars.xml
Change: <X-PRE-PROCESS cmd="set" data="default_password=1"/> {!!set it to something different!!}
Save and close (<Esc> :wq!)
2) Delete IPv6
cd /usr/local/freeswitch/conf/sip_profiles
mv internal-ipv6.xml internal-ipv6.xml.removed {disables ipv6 support}
mv external-ipv6.xml external-ipv6.xml.removed {disables ipv6 support}
3) Configuring ext-rtp-ip
cd /usr/local/freeswitch/conf/sip_profiles/
vi internal.xml
<param name="ext-rtp-ip" value="182.61.xx.25"/>
<param name="ext-sip-ip" value="182.61.xx.25"/>
vi external.xml
<param name="ext-rtp-ip" value="182.61.xx.25"/>
<param name="ext-sip-ip" value="182.61.xx.25"/>
4)stun
<X-PRE-PROCESS cmd="stun-set" data="external_rtp_ip=stun:182.61.xx.25:3478"/>
<X-PRE-PROCESS cmd="stun-set" data="external_sip_ip=stun:182.61.xx.25:3478"/>
3、下载webrtc客户端sipml5(sipjs/jssip也类似)
https://github.com/DoubangoTelecom/sipml5
4、在sipml5根目录启动一个http服务
1)python -m SimpleHTTPServer 8000 &
2)访问http://192.168.18.130:8000/
3)进入Enjoy our live demo
4)填写sip账号信息和ws接入信息
5)拨号
5、stun穿透
sip终端拨不通webrtc或者webrtc拨sip终端很久才能拨通,一般是nat穿透问题,在webrtc端加个stun服务一般能解决
免费的stun,我验证过的就这三个能用,最好还是自己搭一个stun/turn/ice服务
以下url填入ICE Servers即可
[{url:\'stun:stun.schlund.de\'}]
[{url:\'stun:stun.voipbuster.com\'}]
[{url:\'stun:stun.xten.com\'}]
coturn和Stuntman比较好用
coturn
https://github.com/coturn/coturn
Stuntman
http://www.stunprotocol.org/
stuntman_centos7.2_install.sh
yum install boost yum install boost-devel yum install boost-doc wget http://www.stunprotocol.org/stunserver-1.2.7.tgz tar -zxvf stunserver-1.2.7.tgz make ./stuntestcode ./stunserver #./stunclient 182.61.xx.25 3478
stuntman_ubuntu16.04_install.sh
sudo apt-get install g++ sudo apt-get install make sudo apt-get install libboost-dev sudo apt-get install libssl-dev make ./stuntestcode ./stunserver #./stunclient 182.61.xx.25 3478
装好stunserver,即可在webrtc客户端sipml5 ICE Servers配置
[{url:\'stun:182.61.xx.25:3478\'}]
或者装好coturn
apt-get install coturn / yum install coturn
turnserver -o -a -f -v --mobility -m 10 --max-bps=1024000 --min-port=16384 --max-port=32768 --user=test:test123 -r test --cert=/usr/local/nginx/conf/SSL_Pub.pem --pkey=/usr/local/nginx/conf/SSL_Priv.pem CA-file=/usr/local/nginx/conf/SSL_CA.pem
(开放端口与freeswitch/conf/autoload_configs/switch.conf.xml配置保持同步,允许通过的比特流速率1M=1024×1024不能太小, 可以不检测密钥)
[{url:\'stun:8.134.xx.xxx:3478\'},{url:\'turn:8.134.xx.xxx:3478\', username:\'test\', credential:\'test123\'}]
除了在webrtc端添加stun服务来解决nat穿透问题,在freeswitch端配置应该也行,我还没验证。
6、参考设计
基于freeSWITCH的sip协议利用WebRTC 实现实时视频聊天
https://blog.csdn.net/graceup/article/details/79485976
7、freeswitch_webrtc
新版本chrome在http下已经没有操作麦克风和摄像头的权限,而且涉及webrtc的通信都需要安全传输
新版本freeswitch安装也更方便了,涉及webrtc的内容整理到github了
https://github.com/dong2/2FreeSWITCH/tree/master/VIV.freeswitch_webrtc
end
以上是关于webrtc接入freeswitch的sip音视频传输的主要内容,如果未能解决你的问题,请参考以下文章