webrtc2sip项目说明

来源:互联网 发布:ta热分析软件 编辑:程序博客网 时间:2024/06/05 11:02
第一章 webrtc2sip项目环境说明
1.  操作系统:CentOS6.x 64位版本
2.  FreeSwitch版本号:1.2.x(注意:FreeSwitch最新版本有媒体协商错误问题)
3.  FFmepg版本号:1.2.x(注意:FFmepg最新版本函数名及参数有修改,会造成编译错误)
4.  其他软件版本号:最新
5.  浏览器:Chrome, Android 平台Chrome Beta
6.  测试电话:Yealink VP2009,Linphone for Android(含H264版本)
7.  编译,安装,执行软件都需要root权限

第二章 webrtc2sip项目编译安装
2.1 编译安装
注意:此过程需要root权限
参考资料:https://code.google.com/p/webrtc2sip/wiki/Building_Source_v2_0

Building_Source_v2_0  
Building Source v2.0 
Featured, Phase-Support, Phase-Deploy Updated Jul 5, 2013 by boss...@yahoo.fr
This section explains how to build the project using CentOS 64 but could be easily adapted for any Linux, Windows or OS X.

webrtc2sip gateway depends on Doubango IMS Framework v2.0. 

We highly recommend reading the Technical guide.

Preparing the system
Building Doubango IMS Framework and 3rd-party libraries
Building libsrtp
Building OpenSSL
Building libspeex and libspeexdsp
Building YASM
Building libvpx
Building libyuv
Building libopus
Building opencore-amr
Building libgsm
Building g729
Building iLBC
Building x264
Building FFmpeg
Building Doubango
Building webrtc2sip and 3rd-party libraries
Installing libxml2
Building webrtc2sip
Preparing the system
sudo yum update
sudo yum install make libtool autoconf subversion git cvs wget libogg-devel gcc gcc-c++
Building Doubango IMS Framework and 3rd-party libraries
Doubango is an IMS framework and contains all signaling protocols (SIP, SDP, WebSocket…) and media engine (RTP stack, audio/video codecs…) required by webrtc2sip gateway.


The first step is to checkout Doubango 2.0 source code:


svn checkout http://doubango.googlecode.com/svn/branches/2.0/doubango doubango
Building libsrtp
libsrtp is required.


git clone https://github.com/cisco/libsrtp/
cd libsrtp
CFLAGS="-fPIC" ./configure --enable-pic && make && make install
Building OpenSSL
OpenSSL is required if you want to use the RTCWeb Breaker module or Secure WebSocket transport (WSS). OpenSSL version 1.0.1 is required if you want support for DTLS-SRTP.


This section is only required if you don’t have OpenSSL installed on your system or using version prior to 1.0.1 and want to enable DTLS-SRTP.


A quick way to have OpenSSL may be installing openssl-devel package but this version will most likely be outdated (prior to 1.0.1). Anyway, you can check the version like this:


openssl version 
To build OpenSSL:


wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -xvzf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c
./config shared --prefix=/usr/local --openssldir=/usr/local/openssl && make && make install
Building libspeex and libspeexdsp
libspeex (audio codec) an libspeexdsp (audio processing and jitter buffer) are optional. It’s highly recommended to enable libspeexdsp.


You can install the devel packages:


sudo yum install speex-devel
Or build the source by yourself:


wget http://downloads.xiph.org/releases/speex/speex-1.2beta3.tar.gz
tar -xvzf speex-1.2beta3.tar.gz
cd speex-1.2beta3
./configure --disable-oggtest --without-libogg && make && make install
Building YASM
YASM is only required if you want to enable VPX (VP8 video codec) or x264 (H.264 codec).


wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar -xvzf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure && make && make install
Building libvpx
Date: December 1, 2012 


libvpx adds support for VP8 and is optional but highly recommended if you want support for video when using Google Chrome or Mozilla Firefox.


You can install the devel packages:


sudo yum install libvpx-devel
Or build the source by yourself:


git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --enable-realtime-only --enable-error-concealment --disable-examples --enable-vp8 --enable-pic --enable-shared --as=yasm
make && make install
Building libyuv
libyuv is optional. Adds support for video scaling and chroma conversion.


mkdir libyuv && cd libyuv
svn co http://src.chromium.org/svn/trunk/tools/depot_tools . 
./gclient config http://libyuv.googlecode.com/svn/trunk
./gclient sync && cd trunk
make -j6 V=1 -r libyuv BUILDTYPE=Release
make -j6 V=1 -r libjpeg BUILDTYPE=Release
cp out/Release/obj.target/libyuv.a /usr/local/lib
cp out/Release/obj.target/third_party/libjpeg_turbo/libjpeg_turbo.a /usr/local/lib
mkdir --parents /usr/local/include/libyuv/libyuv
cp -rf include/libyuv.h /usr/local/include/libyuv
cp -rf include/libyuv/*.h /usr/local/include/libyuv/libyuv
Building libopus
libopus is optional but highly recommended as it’s an MTI codec for WebRTC. Adds support for Opus audio codec.


wget http://downloads.xiph.org/releases/opus/opus-1.0.2.tar.gz
tar -xvzf opus-1.0.2.tar.gz
cd opus-1.0.2
./configure --with-pic --enable-float-approx && make && make install
Building opencore-amr
opencore-amr is optional. Adds support for AMR audio codec.


git clone git://opencore-amr.git.sourceforge.net/gitroot/opencore-amr/opencore-amr
cd opencore-amr
autoreconf --install && ./configure && make && make install
Building libgsm
libgsm is optional. Adds support for GSM audio codec.


You can install the devel packages (recommended):


sudo yum install gsm-devel
Or build the source by yourself:


wget http://www.quut.com/gsm/gsm-1.0.13.tar.gz
tar -xvzf gsm-1.0.13.tar.gz
cd gsm-1.0-pl13 && make && make install
#cp -rf ./inc/* /usr/local/include
#cp -rf ./lib/* /usr/local/lib
Building g729
G729 is optional. Adds support for G.729 audio codec.


svn co http://g729.googlecode.com/svn/trunk/ g729b
cd g729b
./autogen.sh && ./configure --enable-static --disable-shared && make && make install
Building iLBC
iLBC is optional. Adds support for iLBC audio codec.


svn co http://doubango.googlecode.com/svn/branches/2.0/doubango/thirdparties/scripts/ilbc
cd ilbc
wget http://www.ietf.org/rfc/rfc3951.txt
awk -f extract.awk rfc3951.txt
./autogen.sh && ./configure
make && make install
Building x264
Date: December 2, 2012 


x264 is optional and adds support for H.264 video codec (requires FFmpeg).


wget ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2
tar -xvjf last_x264.tar.bz2
# the output directory may be difference depending on the version and date
cd x264-snapshot-20121201-2245
./configure --enable-shared --enable-pic && make && make install
Building FFmpeg
Date: December 2, 2012 


FFmpeg is optional and adds support for H.263, H.264 (requires x264) and MP4V-ES video codecs.


git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg


# grap a release branch
git checkout n1.2


# configure source code
./configure \
--extra-cflags="-fPIC" \
--extra-ldflags="-lpthread" \
\
--enable-pic --enable-memalign-hack --enable-pthreads \
--enable-shared --disable-static \
--disable-network --enable-pthreads \
--disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe \
\
--enable-gpl \
\
--disable-debug


# build and install
make && make install
Building Doubango
Minimal build
cd doubango && ./autogen.sh && ./configure --with-ssl --with-srtp --with-speexdsp
make && make install
Recommended build
cd doubango && ./autogen.sh && ./configure --with-ssl --with-srtp --with-vpx --with-speexdsp --with-ffmpeg --with-opus
make && make install
Full build
cd doubango && ./autogen.sh && ./configure --with-ssl --with-srtp --with-vpx --with-yuv --with-amr --with-speex --with-speexdsp --with-opus --with-gsm --with-ilbc --with-g729 --with-ffmpeg
make && make install
Building webrtc2sip and 3rd-party libraries
webrtc2sip depends on Doubango IMS Framework v2.0 and libxml2.


The first step is to checkout the source code:


svn co http://webrtc2sip.googlecode.com/svn/trunk/ webrtc2sip
Installing libxml2
yum install libxml2-devel
Building webrtc2sip
export PREFIX=/opt/webrtc2sip
cd webrtc2sip && ./autogen.sh && ./configure --prefix=$PREFIX
make clean && make && make install
cp -f ./config.xml $PREFIX/sbin/config.xml
The gateway is configured using config.xml. Please check the technical guide for more information about this file.


Et voilà


2.2 常见问题
2.2.1 doubango编译出错
Hi,


Getting a build error on doubango .... following technical guide build instructions ... any ideas?  Thx.


In file included from /usr/include/vpx/vpx_encoder.h:32,
                 from src/codecs/vpx/tdav_codec_vp8.c:50:
/usr/include/vpx/vpx_codec.h:45:26: error: vpx_config.h: No such file or directory
src/codecs/vpx/tdav_codec_vp8.c: In function ‘tdav_codec_vp8_encode’:
src/codecs/vpx/tdav_codec_vp8.c:265: error: ‘VPX_IMG_FMT_I420’ undeclared (first use in this function)
src/codecs/vpx/tdav_codec_vp8.c:265: error: (Each undeclared identifier is reported only once
src/codecs/vpx/tdav_codec_vp8.c:265: error: for each function it appears in.)
src/codecs/vpx/tdav_codec_vp8.c: In function ‘tdav_codec_vp8_open_encoder’:
src/codecs/vpx/tdav_codec_vp8.c:675: warning: passing argument 1 of ‘vpx_codec_enc_config_default’ makes pointer from integer without a cast
/usr/include/vpx/vpx_encoder.h:609: note: expected ‘const struct vpx_codec_iface *’ but argument is of type ‘int’
src/codecs/vpx/tdav_codec_vp8.c:720: warning: passing argument 2 of ‘vpx_codec_enc_init_ver’ makes pointer from integer without a cast
/usr/include/vpx/vpx_encoder.h:575: note: expected ‘const struct vpx_codec_iface *’ but argument is of type ‘int’
src/codecs/vpx/tdav_codec_vp8.c: In function ‘tdav_codec_vp8_open_decoder’:
src/codecs/vpx/tdav_codec_vp8.c:774: warning: passing argument 2 of ‘vpx_codec_dec_init_ver’ makes pointer from integer without a cast
/usr/include/vpx/vpx_decoder.h:121: note: expected ‘const struct vpx_codec_iface *’ but argument is of type ‘int’
make[2]: *** [libtinyDAV_la-tdav_codec_vp8.lo] Error 1
make[2]: Leaving directory `/_/doubango/tinyDAV'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/_/doubango'
make: *** [all] Error 2


Richard Campion


Corrected .... on CentOS 6.5 need to build libvpx from source.


2.2.2 webrtc2sip编译出错
Error: configure: error: Failed to find libtinyIPSec


========================================================


Hi Federico \o/  


I always run this:


export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"


Before start the webrtc2sip compilation process.


Best Regards! 


========================================================


2.2.3 ffmpeg编译加入H264编码
需要在configure后添加一个参数:--enable-libx264
完整的configure:
# configure source code
./configure \
--extra-cflags="-fPIC" \
--extra-ldflags="-lpthread" \
\
--enable-pic --enable-memalign-hack --enable-pthreads \
--enable-shared --disable-static \
--disable-network --enable-pthreads \
--disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe \
\
--enable-gpl \
\
--disable-debug --enable-libx264
2.2.4 视频编解码崩溃问题解决
修改文件:doubango/tinySAK/src/tsk_object.c (199)
修改函数:tsk_object_unref()
修改内容:
将tsk_object_delete(self);
替换为:TSK_OBJECT_SAFE_FREE(self);


webrtc2sip项目配置
4.1 CentOS操作系统配置
局域网使用webrtc2sip项目,请将DNS配置清空。
# vi /etc/resolv.conf
nameserver 172.17.192.21 #==>此地址就是DNS地址
4.2 webrtc2sip配置
原始配置config.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Please check the technical guide (http://webrtc2sip.org/technical-guide-1.0.pdf) for more information on how to adjust this file -->
<config>


  <debug-level>ERROR</debug-level>


  <transport>udp;*;10060</transport>
  <transport>ws;*;10060</transport>
  <transport>wss;*;10062</transport>
  <!--transport>tcp;*;10063</transport-->
  <!--transport>tls;*;10064</transport-->


  <enable-rtp-symetric>yes</enable-rtp-symetric>
  <enable-100rel>no</enable-100rel>
  <enable-media-coder>no</enable-media-coder>
  <enable-videojb>yes</enable-videojb>
  <video-size-pref>vga</video-size-pref>
  <rtp-buffsize>65535</rtp-buffsize>
  <avpf-tail-length>100;400</avpf-tail-length>
  <srtp-mode>optional</srtp-mode>
  <srtp-type>sdes;dtls</srtp-type>
  <dtmf-type>rfc4733</dtmf-type>


  <codecs>opus;pcma;pcmu;gsm;vp8;h264-bp;h264-mp;h263;h263+</codecs>
  <codec-opus-maxrates>48000;48000</codec-opus-maxrates>


  <stun-server>stun.l.google.com;19302;stun-user@doubango.org;stun-password</stun-server>
  <enable-icestun>yes</enable-icestun>


  <max-fds>-1</max-fds>


  <!--nameserver>66.66.66.6</nameserver-->


  <!--ssl-certificates>
    C:/Projects/ssl/priv.pem;
    C:/Projects/ssl/pub.pem;
    C:/Projects/ssl/ca-cert.pem;
    no
  </ssl-certificates-->


  <!-- ***CLICK-TO-CALL SERVICE*** -->


  <transport>c2c;*;10070</transport>
  <transport>c2cs;*;10072</transport>
  <database>sqlite;*</database>
  <!--account-mail>smtps;*;*;auth.smtp.1and1.fr;465;noreply@example.com;noreply@example.com;mysecret</account-mail-->
  <!--account-sip-caller>*;sip:a@example.com;a;example.com;mysecret</account-sip-caller-->


</config>
修改成局域网的配置config.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Please check the technical guide (http://webrtc2sip.org/technical-guide-1.0.pdf) for more information on how to adjust this file -->
<config>


  <debug-level>ERROR</debug-level>


  <transport>udp;本地IP地址;10060</transport>
  <transport>ws;本地IP地址;10060</transport>
  <transport>wss;本地IP地址;10062</transport>
  <!--transport>tcp;本地IP地址;10063</transport-->
  <!--transport>tls;本地IP地址;10064</transport-->


  <enable-rtp-symetric>yes</enable-rtp-symetric>
  <enable-100rel>no</enable-100rel>
  <enable-media-coder>yes</enable-media-coder>
  <enable-videojb>yes</enable-videojb>
  <video-size-pref>cif</video-size-pref>
  <rtp-buffsize>65535</rtp-buffsize>
  <avpf-tail-length>100;400</avpf-tail-length>
  <srtp-mode>optional</srtp-mode>
  <srtp-type>sdes;dtls</srtp-type>
  <dtmf-type>rfc4733</dtmf-type>


  <codecs>opus;pcma;pcmu;gsm;vp8;h264-bp;h264-mp;h263;h263+</codecs>
  <codec-opus-maxrates>48000;48000</codec-opus-maxrates>


  <stun-server>stun.l.google.com;19302;stun-user@doubango.org;stun-password</stun-server>
  <enable-icestun>no</enable-icestun>


  <max-fds>-1</max-fds>


  <!--nameserver>66.66.66.6</nameserver-->


  <!--ssl-certificates>
    C:/Projects/ssl/priv.pem;
    C:/Projects/ssl/pub.pem;
    C:/Projects/ssl/ca-cert.pem;
    no
  </ssl-certificates-->


  <!-- ***CLICK-TO-CALL SERVICE*** -->


  <!--<transport>c2c;本地IP地址;10070</transport>
  <transport>c2cs;本地IP地址;10072</transport>
  <database>sqlite;本地IP地址</database>-->
  <!--account-mail>smtps;*;*;auth.smtp.1and1.fr;465;noreply@example.com;noreply@example.com;mysecret</account-mail-->
  <!--account-sip-caller>*;sip:a@example.com;a;example.com;mysecret</account-sip-caller-->


</config>


4.4 FreeSwitch服务器添加H264编码支持
修改文件:freeswitch/conf/vars.xml (126)
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=G722,PCMU,PCMA,GSM,H264"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=PCMU,PCMA,GSM,H264"/>


第五章 守护进程
5.1 使用守护进程的目的
当webrtc2sip服务崩溃退出时,能自动重新启动该服务。
5.2 进程守护者 process-monitor
顾名思义,process-monitor,进程守护者,用于监控你所建立的进程,如果监控到客户进程已经不存在,process-monitor会自动重启此进程。 
优势:通用型的解决方案,适用于大多数场合,你可以丢掉用脚本轮询实现的守护程序了。
使用方法:
1. 将二进制可执行文件process-monitor拷贝到webrtc2sip的sbin目录
2. 执行命令./process-monitor webrtc2sip


参考网址:https://github.com/russells/process-monitor




附件1:参考资料
http://www.webrtc2sip.org/
https://code.google.com/p/webrtc2sip/
https://code.google.com/p/webrtc2sip/wiki/Building_Source_v2_0
附件2:常见问题解答
问:Sipml5连接服务失败,可能的原因及解决方案有那些?
答:根本原因是没有连接上webrtc2sip或FreeSwitch的服务。
可能原因1:网络中断。解决方法:恢复网络连接。
可能原因2:Linux的防火墙阻止了webrtc2sip和FreeSwitch的服务,关闭防火强可以解决此类问题。


问:Sipml5连接无反应,可能的原因及解决方案有那些?
答:可能的原因是webrtc2sip有问题了,重新启动webrtc2sip。


问:Simpl5与Yealink可视电话进行语音通话成功,但是视频通话呼叫方语音进入echo模式,视频不通,可能的原因及解决方案有那些?
答:可能是webrtc2sip的配置中<enable-media-coder>no</enable-media-coder>应该改成yes。


问:webrtc2sip启动自动退出,可能的原因及解决方案有那些?
答:可能是配置中所设置的本地IP地址与服务器的IP地址不一致造成的。修改IP地址可以解决此问题。


问:Chrome浏览器,呼叫时出现“Media stream permission denied”如何解决。
答:
可能原因1:使用本地网页访问时容易出现这样的问题。请使用网址访问网站上的网页。
可能原因2:如果是询问时禁止访问了麦克风和摄像头,请关闭Chrome浏览器,重新启动Chrome浏览器。
如果是chrome for Android,到应用管理里,清除所有数据,可以解决。


问:Chrome浏览器主叫,被叫方隔很长时间才振铃,如何解决。
答:
很有肯能是webrtc2sip所在的服务器,设置了DNS所致,删除DNS就可以解决。





0 0
原创粉丝点击