sip.jsで通信する。1.demo phoneで通話するまで
sip.jsのgetting startedを簡単に解説。
【環境】 centOS:7.4 Asterisk:13.20
まずはAsteriskのインストール
必要なパッケージのインストール
yum install wget gcc gcc-c++ ncurses-devel libuuid-devel jansson-devel libxml2-devel sqlite-devel libsrtp-devel openssl-devel
Asteriskのダウンロードとインストール
cd /usr/local/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13.20.0.tar.gz
tar zxvf asterisk*
cd /usr/local/src/asterisk*
./configure --with-pjproject-bundled
make menuselect
メニューセレクト画面でres_srtp
とpjproject
にチェックが入っているか確認する。
入っていなければsrtp libraryをインストールする インストール方法は→コチラ
make && make install
make samples
make config
インストールした後でポートを開放する。 開放するポートは 5060 8089/udp 10000-20000/udp
意外と忘れがち
DTLSのインストール
mkdir /etc/asterisk/keys
cd /usr/src/asterisk*/contrib/scripts
./ast_tls_cert -C -O 【クライアントのIPアドレス】"My Super Company" -d /etc/asterisk/keys
ここでハマった。IPアドレスはホスト側(Asterisk)ではなくてHP側(タブレット側)のIPアドレスを書いておく。
http.conf,sip.conf,extensions.confの編集。
http.conf
;http.conf [general] enabled=yes bindaddr=【ホスト側のIPアドレス】 ; Replace this with your IP address bindport=8088 ; Replace this with the port you want to listen on tlsendable=yes tlsbindaddr=【ホスト側のIPアドレス】:8089 ; Replace this with your IP address tlscertfile=/etc/asterisk/keys/asterisk.pem
sip.conf
[general] realm=192.168.10.14 udpbindaddr=192.168.10.14 transport=udp maxexpirey=3600 defaultexpirey=3600 context=default bindport=5060 bindaddr=192.168.10.14 srvlookup=yes allowguest=no disallow=all allow=ulaw allow=alaw allow=gsm allow=vp8 allow=h264 language=ja udpenable=yes tcpenable=yes icesupport=yes [1060];webRTC client type=friend username=1060 host=dynamic secret=pass encryption=yes avpf=yes context=default directmedia=no transport=udp,ws,wss force_avp=yes dtlsenable=yes dtlsverify=fingerprint dtlscertfile=/etc/asterisk/keys/asterisk.pem dtlsprivatekey=/etc/asterisk/keys/asterisk.pem dtlssetup=actpass nat=force_rport rtcp_mux=yes allow=vp8,h264,ulaw dtmfmode=rfc2833
extensions.conf
exten => 1060,1,Dial(SIP/1060)
でOK
あとはdemo phoneに各種パラメータを記入したらOK