Asterisk11 webrtc 安装及demo测试(SIPML5)

一、环境:ubuntu12.04   Asterisk11.12.0

二、安装Asterisk准备:(此后全部是root权限)

apt-get install build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev openssl ncurses-dev zlibc zlib-bin libidn11-dev libidn libsrtp0-dev 
apt-get install uuid-dev (注:Asterisk 11 comes with an embedded pjproject. When building Asterisk 11, to get ICE support you'll need the UUID development library (uuid-dev for Debian, libuuid-devel for CentOS) library.)

三、实现webrtc功能要求:

1.浏览器支持
  最新的支持webrtc功能的浏览器列表链接 http://en.wikipedia.org/wiki/WebRTC
  最常用chrome浏览器

2.SRTP
   Secure media is a requirement of WebRTC and as a result SRTP must be available. In order for Asterisk to build SRTP support the libsrtp library and development headers must be available. 
  (注:上面的apt-get install libsrtp0-dev 可能已经实现了srtp的安装,本人没有尝试。我按如下方法安装的,后来再apt-get install libsrtp0-dev ,发现srtp已经安装,可以用这一条语句安装完试试看有没有 res_srtp.so 如果有,则那一条安装语句就可以搞定,估计是可行的。查看模块方法 asterisk源码目录下, ./configure  然后 make menuselect 查看有没有这个模块)
    本人安装srtp的方法:(转自 http://blog.csdn.net/yetyongjin/article/details/8563591)
            因为WEBRTC要求用SRTP,而asterisk的SRTP模块依赖于libsrtp包,所以要先安装它。
            #wgethttp://sourceforge.net/projects/srtp/files/srtp/1.4.4/srtp-1.4.4.tgz/download
            # tar vzxf srtp-1.4.4.tgz 
            # cd srtp
            # ./configure
            # make
            # make install
     记得这样装完没有 res_srtp.so ,然后 apt-get install srtp-utils ,有了res_srtp.so模块。

四、安装asterisk

1.解压 tar -zxvf asterisk~~~
2.进入源码目录  cd asterisk
3.配置环境   ./configure
4. make menuselect  检查res_http_websocket,res_srtp, res_crypto and chan_sip 模块是否被选中,没选中要选中。
5. make
6. make install
7. make samples
安装完毕~

五、generate certificates for Asterisk to be able to use WebRTC

参考链接 https://wiki.asterisk.org/wiki/display/AST/Secure+Calling+Tutorial
In newer versions of Chrome and Firefox (and others) DTLS-SRTP is mandatory. This means you must generate certificates for Asterisk to be able to use WebRTC.

(1)First, let's make a place for our keys.    


mkdir /etc/asterisk/keys

(2)Next, use the "ast_tls_cert" script in the "contrib/scripts" Asterisk source directory to make a self-signed certificate authority and an Asterisk certificate.
   

 ./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys


  •     The "-C" option is used to define our host - DNS name or our IP address.
  •     The "-O" option defines our organizational name.
  •     The "-d" option is the output directory of the keys.
       You'll be asked to enter a pass phrase for /etc/asterisk/keys/ca.key, put in something that you'll remember for later.
       This will create the /etc/asterisk/keys/ca.crt file.
       You'll be asked to enter the pass phrase again, and then the /etc/asterisk/keys/asterisk.key file will be created.
       The /etc/asterisk/keys/asterisk.crt file will be automatically generated.
       You'll be asked to enter the pass phrase a third time, and the /etc/asterisk/keys/asterisk.pem will be created, a combination of the     asterisk.key and asterisk.crt files.


(3)Next, we generate a client certificate for our SIP device.
   

 ./ast_tls_cert -m client -c /etc/asterisk/keys/ca.crt -k /etc/asterisk/keys/ca.key -C phone1.mycompany.com -O "My Super Company" -d /etc/asterisk/keys -o malcolm
    
  •     The "-m client" option tells the script that we want a client certificate, not a server certificate.
  •     The "-c /etc/asterisk/keys/ca.crt" option specifies which Certificate Authority (ourselves) that we're using.
  •     The "-k /etc/asterisk/keys/ca.key" provides the key for the above-defined Certificate Authority.
  •     The "-C" option, since we're defining a client this time, is used to define the hostname or IP address of our SIP phone
  •     The "-O" option defines our organizational name.
  •     The "-d" option is the output directory of the keys."
  •     The "-o" option is the name of the key we're outputting.
       You'll be asked to enter the pass phrase from before to unlock /etc/asterisk/keys/ca.key.

       Now, let's check the keys directory to see if all of the files we've built are there. You should have:

  • asterisk.crt
  • asterisk.csr
  • asterisk.key
  • asterisk.pem
  • malcolm.crt
  • malcolm.csr
  • malcolm.key
  • malcolm.pem
  • ca.cfg
  • ca.crt
  • ca.key
  • tmp.cfg
       Next, copy the malcolm.pem and ca.crt files to the computer running the Blink soft client.

六、配置Asterisk,以使用webrtc功能(配置文件在 /etc/asterisk/)

(参考文档 https://wiki.asterisk.org/wiki/display/AST/WebRTC+tutorial+using+SIPML5)
I always recommend backing up your current .conf files and using clean, blank text files for trying out a tutorial like this. Especially if you are new to Asterisk.

备份真的很重要,我把安装完默认的 /etc/asterisk/ 下的文件全部备份了一下。

1.http.conf 
[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
2.rtp.conf
[general]
rtpstart=10000
rtpend=20000
icesupport=yes
stunaddr=stun.l.google.com:19302
3.sip.conf
[general]
udpbindaddr=0.0.0.0:5060
realm=123.123.123.123 ;replace with your Asterisk server public IP address or host
transport=udp,ws
;[general] 要修改成这样样子,如果按默认的配置,在运行demo时会出问题。。 

[6001]
host=dynamic
secret=DONT_USE_THIS_INSECURE_PASSWORD
context=from-internal
type=friend
encryption=yes
avpf=yes
force_avp=yes
icesupport=yes
directmedia=no
disallow=all
allow=ulaw
dtlsenable=yes
dtlsverify=fingerprint
dtlscertfile=/etc/asterisk/keys/asterisk.pem ;这两句加上,运行demo会有问题,不知道为什么,可能是keys下的文件生成的有问题
dtlscafile=/etc/asterisk/keys/ca.crt ;同上
dtlssetup=actpass

transport=udp,ws,wss ;这两句是参考了另一个文档,加上是可以用的,具体含义还要在研究,加在这里是可以的,运行demo不影响
nat=yes,force_rport
4.extensions.conf
[default]
[from-internal]
exten => 1000,1,Answer()
same => n,Playback(hello-world) ;参考文档里是 Playback(demo-congrats)
same => n,Hangup()
七、配置防火墙
查看防火墙状态  ufw status
设置:
    
 ufw allow 5060
 ufw allow 8088/tcp
 ufw allow 10000:20000/udp
八、运行demo—— SIPML5

SIPML5网址:  http://sippackets.com/

参考链接 https://wiki.asterisk.org/wiki/display/AST/WebRTC+tutorial+using+SIPML5

Configure SIPML5

On the registration page use the following configuration, replacing the IP addresses with your public IP for the Asterisk server.

Asterisk11 webrtc 安装及demo测试(SIPML5)_第1张图片

Open the "Expert mode" settings page and use the following details, still replacing the IP of course:

Asterisk11 webrtc 安装及demo测试(SIPML5)_第2张图片

Be sure to hit save! Just leave that tab open, or close it and go back to the main tab to make a test call.

Make a test call

Restart Asterisk, or start Asterisk if you haven't already.

Click "Login" with the SIPML5 client. On the Asterisk CLI you should see:

  == WebSocket connection from 'X.X.X.X:46723' for protocol 'sip' accepted using version '13'
    -- Registered SIP '6001' at X.X.X.X:46723
       > Saved useragent "IM-client/OMA1.0 sipML5-v1.2014.01.27" for peer 6001

Dial extension 1000 from your SIPML5 client and you should see CLI output:

  == Using SIP RTP CoS mark 5
    -- Executing [1000@from-internal:1] Answer("SIP/6001-00000000", "") in new stack
       > 0x28057f0 -- Probation passed - setting RTP source address to X.X.X.X:9177
    -- Executing [1000@from-internal:2] Playback("SIP/6001-00000000", "demo-congrats") in new stack
    --  Playing 'demo-congrats.gsm' (language 'en')

If you don't have VERBOSE messages going to the console, and verbosity turned up at least to 3 then you may not see these messages.

Icon

When you attempt the call, Chrome may ask you for access to your microphone or camera. Be sure to say yes!


我运行时,控制台显示下面信息,但是听不到声音。。。

Asterisk11 webrtc 安装及demo测试(SIPML5)_第3张图片


你可能感兴趣的:(webrtc)