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