📜 ⬆️ ⬇️

Install and configure Asterisk to work with WebRTC


The network has a lot of information and instructions on the topic, but at the moment they are no longer relevant and quite complex. In many cases, webrtc2sip is used , but it is rather difficult to assemble and make it work. Under the cat, I wrote detailed instructions on how to make WebRTC work through Asterisk.

1. Preparing the system (ubuntu 14.04)

update
aptitude update && aptitude upgrade -y 


Download version 12 of the asterisk:
 cd /usr/src/ wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-12-current.tar.gz tar -zxvf asterisk-12-current.tar.gz 


In the package with aster there is a script that installs all the dependencies, first we will try to use it.
 cd asterisk-12.5.0/contrib/scripts/ ./install_prereq install 

in my case, the script issued a bunch of conflicts, I have ubuntu 64 and the creak is trying to install i386 packages. Therefore, we will install all dependencies manually.
')
 aptitude install -y libncurses-dev libz-dev libssl-dev libxml2-dev libsqlite3-dev uuid-dev uuid libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev libpq-dev unixodbc-dev libsqlite0-dev libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1 libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev libsnmp-dev libiksemel-dev libcorosync-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev doxygen libjansson-dev libldap-dev subversion git libxslt1-dev mc htop iftop 


once again use the script to install additional packages libsrtp and pjproject they are very important for the work of webrtc

 ./install_prereq install-unpackaged 


everything gathered here without any problems, but if any errors occur, then we put everything by hand
 cd /usr/src/ git clone https://github.com/cisco/libsrtp.git cd libsrtp ./configure CFLAGS=-fPIC && make libsrtp.a && make uninstall && make install cd .. echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf /sbin/ldconfig git clone https://github.com/asterisk/pjproject.git cd pjproject ./configure --enable-shared --with-external-speex --with-external-gsm --with-external-srtp --disable-sound --disable-resample && make && make install /sbin/ldconfig 


on this system is ready to install an asterisk with the support of webrtc.

Install Asterisk


 cd /usr/src/asterisk-12.5.0/ ./configure && make menuselect 


in the menu you need to check whether there are asterisks

Channel Drivers -> chan_pjsip and chan_sip
Resource Modules -> res_srtp, res_crypto and res_http_websocket

if everything is, then continue; if not, we re-check the dependencies.

 make && make install && make samples 


We generate certificates.

 mkdir /etc/asterisk/keys cd /usr/src/asterisk-12.5.0/contrib/scripts/ ./ast_tls_cert -C pbx.pbxware.ru -O "ATC Design" -d /etc/asterisk/keys 

The script will ask you to set a password (at least 4 characters) for the certificate.

Installation is complete, go to settings.

Customization


edit the file http.conf
 [general] enabled=yes bindaddr=0.0.0.0 bindport=8088 


rtp.conf
 [general] rtpstart=10000 rtpend=20000 icesupport=yes stunaddr=stun.l.google.com:19302 


sip.conf

 [general] udpbindaddr=0.0.0.0:5060 realm=webrtc.pbxware.ru ;           . transport=udp,ws 


 [webrtc](!) host=dynamic context=from-internal type=friend encryption=yes avpf=yes force_avp=yes icesupport=yes nat=force_rport,comedia directmedia=no disallow=all qualify=yes videosupport=yes allow=ulaw,alaw,vp8,h264,h263p,mpeg4 dtlsenable=yes dtlsverify=no dtlscertfile=/etc/asterisk/keys/asterisk.pem dtlscafile=/etc/asterisk/keys/ca.crt dtlssetup=actpass [101](webrtc) defaultusername=101 secret=101badpassword [102](webrtc) defaultusername=102 secret=102badpassword [103](webrtc) defaultusername=103 secret=103badpassword [104](webrtc) defaultusername=104 secret=104badpassword [105](webrtc) defaultusername=105 secret=105badpassword [106](webrtc) defaultusername=106 secret=106badpassword 


extensions.conf
 [from-internal] exten => 999,1,Answer() same => n,Playback(demo-congrats) same => n,Hangup() exten => 888,1,Answer() same => n,Echo() same => n,Hangup() exten => _XXX,1,Noop(webrtc test call) same => n,DIAL(SIP/${EXTEN}) same => n,Hangup() 


Testing


For testing, we can use the HTML5 sip client from the sipml5.org/call.htm server or install it on our server.

 aptitude install apache2 cd /var/www/html/ svn checkout http://sipml5.googlecode.com/svn/trunk/ sipml5 


now HTML5 web-client is available on our server webrtc.pbxware.ru/sipml5/call.htm
Customization

Display Name: web1
Private Identity *: 101
Public Identity *: sip: 101@webrtc.pbxware.ru
Password: 101badpassword
Realm *: webrtc.pbxware.ru


in expert mode
WebSocket Server URL [2]: ws: //webrtc.pbxware.ru: 8088 / ws
ICE Servers [4]: ​​[{url: 'stun: stun.l.google.com: 19302'}]


We are testing


A call between two laptops:

Call on android (chrome)



call log
 webrtc*CLI> == Using SIP VIDEO CoS mark 6 == Using SIP RTP CoS mark 5 -- Executing [104@from-internal:1] NoOp("SIP/103-00000020", "webrtc test call") in new stack -- Executing [104@from-internal:2] Dial("SIP/103-00000020", "SIP/104") in new stack == Using SIP VIDEO CoS mark 6 == Using SIP RTP CoS mark 5 -- Called SIP/104 -- SIP/104-00000021 is ringing webrtc*CLI> -- SIP/104-00000021 answered SIP/103-00000020 -- Channel SIP/103-00000020 joined 'simple_bridge' basic-bridge <13742dcb-5019-4fd2-b85e-0e1b70b1ccd7> -- Channel SIP/104-00000021 joined 'simple_bridge' basic-bridge <13742dcb-5019-4fd2-b85e-0e1b70b1ccd7> 


 webrtc*CLI> sip show channels Peer User/ANR Call ID Format Hold Last Message Expiry Peer 91.203.82.152 104 0a9b261a3926a75 (ulaw|vp8) No Tx: ACK 104 91.203.82.152 103 3f8b4b42-600d-8 (ulaw|vp8) No Rx: ACK 103 


Tests were conducted on
chrome 37.0.2062.94 - voice, video, DTMF works.
android chrome 37.0.2062.117 - works voice, video, DTMF.
Firefox 32.0 - works voice, DTMF. The video works only in one direction.

PS Now the server is working, you can call and check how WebRTC works.

Source: https://habr.com/ru/post/236291/


All Articles