系統環境:
架構示意圖:
vorbis 套件
yum install libvorbis libvorbis-devel vorbis-tools libogg libogg-devel
curl 套件
yum install curl curl-devel libidn-devel
編譯 FreeSwitch 所需的套件
yum install gcc ncurses ncurses-devel make gcc-c++ libtermcap libtermcap-devel zlib zlib-devel libtool bison bison-devel openssl-devel bzip2 bzip2-devel wget newt newt-devel subversion flex gdbm-devel db4-devel
MySQL 套件
註:如果使用 PIAF 可忽略。
yum install mysql mysql-server mysql-devel
ODBC 套件
yum install unixODBC unixODBC-devel mysql-connector-odbc libtool-ltdl
FreeSwitch FAX 模組
註:如果使用 PIAF 可忽略。
yum install libtiff libtiff-devel libxml2 libxml2-devel libjpeg libjpeg-devel
XMPP 函式庫(連接 Google Talk)
yum install gnutls gnutls-devel gnutls-utils
OpenLDAP 套件
yum install compat-openldap openldap-clients openldap-devel openldap-servers openldap
SNMP 函式庫
yum install net-snmp-devel net-snmp-libs net-snmp-utils net-snmp
Mail Server 套件
yum install sendmail sendmail-devel sendmail-cf
X11 及 Alsa 函式庫
yum install libX11-devel Xvfb alsa-utils libXv libXScrnSaver xorg-x11-fonts* alsa-lib-devel libXScrnSaver kernel-devel alsa-lib libXScrnSaver libXv
TCL 套件
yum install tcl tcl-devel
安裝 git
註:這套件是為了要下載 FreeSwitch 安裝檔
yum install git
或者使用編譯方式安裝
cd /usr/src wget http://www.kernel.org/pub/software/scm/git/git-1.7.3.tar.gz tar -xf git-1.7.3.tar.gz cd git-1.7.3 ./configure --prefix=/usr make make install
安裝 FreeSwitch
cd /usr/src git clone git://git.freeswitch.org/freeswitch.git cd freeswitch/ ./bootstrap.sh ./configure make && make install && make hd-sounds-install && make hd-moh-install && make samples
安裝模組 mod_skypopen
編輯 /usr/src/freeswitch/modules.conf
找到這一行並移除註解符號
... endpoints/mod_skypopen ...
執行
make install
安裝 OSS driver for Skype
cd /usr/src/freeswitch/src/mod/endpoints/mod_skypopen/oss make clean make insmod ./skypopen.ko mknod /dev/dsp c 14 3
安裝及設定 Skype Client
cd /usr/src/freeswitch/src/mod/endpoints/mod_skypopen/install ./install.pl
以 skype channel x4 為例
Enter your name [Giovanni]: <whatever name you wanted> Enter the full path of the Skype download directory [/tmp/skype_download]: You gave: '/tmp/skype_download' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for Skype client binary [/usr/bin]: You gave: '/usr/bin' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for FreeSWITCH modules' config files [/usr/local/freeswitch/conf/autoload_configs]: You gave: '/usr/local/freeswitch/conf/autoload_configs' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for fake sound driver [/usr/local/freeswitch/skypopen/skypopen-sound-driver-dir]: You gave: '/usr/local/freeswitch/skypopen/skypopen-sound-driver-dir' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for Skype clients config [/usr/local/freeswitch/skypopen/skype-clients-configuration-dir]: You gave: '/usr/local/freeswitch/skypopen/skype-clients-configuration-dir' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for Skype clients startup script [/usr/local/freeswitch/skypopen/skype-clients-startup-dir]: You gave: '/usr/local/freeswitch/skypopen/skype-clients-startup-dir' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the directory full path for Skype clients symlinks [/usr/local/freeswitch/skypopen/skype-clients-symlinks-dir]: You gave: '/usr/local/freeswitch/skypopen/skype-clients-symlinks-dir' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter how many Skype clients will be launched [5]: 4 You gave: '4' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter 'one' or 'multi' [one]: one You gave: 'one' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the Skype clients username [your_own_skype_username]: <your skype username> You gave: '.......' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Enter the Skype clients password [your_own_skype_password]: <your skype pass> You gave: '....' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y Are you sure you like the values? Write 'sure' for yes [nope]: sure You gave: 'sure' It's OK? Please answer 'Y' for yes or 'N' for not [N]: y
啟動剛剛設定的 Skype channels x4
sh /usr/local/freeswitch/skypopen/skype-clients-startup-dir/start_skype_clients.sh
設定 FreeSwitch 啟動檔
cd /usr/src/freeswitch/build/ cp freeswitch.init.redhat /etc/init.d/freeswitch vi /etc/init.d/freeswitch
找到這幾行
PID_FILE=${PID_FILE-/opt/freeswitch/run/freeswitch.pid} FS_USER=${FS_USER-freeswitch} FS_FILE=${FS_FILE-/opt/freeswitch/bin/freeswitch} FS_HOME=${FS_HOME-/opt/freeswitch} FREESWITCH_ARGS="-nc"
修改成
PID_FILE=${PID_FILE-/usr/local/freeswitch/run/freeswitch.pid} FS_USER=${FS_USER-root} FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/freeswitch} FS_HOME=${FS_HOME-/usr/local/freeswitch} FREESWITCH_ARGS="-nc -nonat"
執行
chmod +x /etc/init.d/freeswitch chkconfig --add freeswitch chkconfig freeswitch on
設定電話從 Asterisk 到 FreeSwitch 的路由
編輯 /usr/local/freeswitch/conf/dialplan/public.xml
找到這幾行
<include> <context name="public">
在下方加上
<extension name="skype_uri"> <condition field="destination_number" expression="^skype/(.*)$"> <action application="set" data="skype_get_inband_dtmf=true"/> <action application="bridge" data="skypopen/RR/$1"/> </condition> </extension>
設定 mod_skypopen
編輯 /usr/local/freeswitch/conf/autoload_configs/skypopen.conf.xml
找到這幾行
<param name="context" value="default"/> <param name="destination" value="5000"/>
改成
<param name="context" value="skype"/> <param name="destination" value="3200"/>
註:將所有 Skype 來電導入 Ext#3200。
新增 context skype
編輯 /usr/local/freeswitch/conf/dialplan/skype.xml
<?xml version="1.0" encoding="utf-8"?> <include> <context name="skype"> <extension name="skype-call"> <condition field="destination_number" expression="^(3[1-5]00)$"> <action application="set" data="skype_get_inband_dtmf=true"/> <action application="bridge" data="sofia/gateway/asterisk/$1"/> </condition> </extension> </context> </include>
註:將分機 3100-3500 的來電送到 Gateway Asterisk。
新增 Gateway Asterisk
編輯 /usr/local/freeswitch/conf/sip_profiles/external/asterisk.xml
<include> <gateway name="asterisk"> <param name="username" value="freeswitch"/> <param name="realm" value="IPServidorAsterisk"/> <param name="from-domain" value="IPServidorAsterisk"/> <param name="password" value="password"/> <param name="extension" value="freeswitch"/> <param name="proxy" value="IPServidorAsterisk"/>--> <param name="expire-seconds" value="3600"/> <param name="register-transport" value="udp"/> <param name="retry-seconds" value="30"/> <param name="extension-in-contact" value="true"/> <param name="ping" value="25"/> </gateway> </include>
註:修改幾個連結 Asterisk 的參數。
新增 SIP Trunk
freePBX > Trunks > Add SIP Trunk
Trunk Name: freeswitch
PEER Details:
type=peer context=from-trunk host=dynamic fromuser=freeswitch defaultuser=freeswitch secret=password qualify=yes port=5080 directmedia=no dtmfmode=rfc2833 disallow=all allow=ulaw&alaw
Incoming Setting: 空白
Register String: 空白
Tips:
* fromuser, defaultuser,password 必須與 FreeSwitch 的 asterisk.xml 設定一樣。
新增 Inbound Route
freePBX > Inbound Rotes > Add Inbound Route
DID Numbers: 3200
Set Destination: <whatever you wanted>
Tips:
3200 必須與 skypopen.conf.xml , skype.xml 相同。
/usr/local/freeswitch/bin/freeswitch -nonat
載入 mod_skypopen 模組
freeswitch@pbx.local>load mod_skypopen ... 2011-06-19 13:41:02.222682 [CONSOLE] switch_loadable_module.c:946 Successfully Loaded [mod_skypopen] 2011-06-19 13:41:02.222682 [NOTICE] switch_loadable_module.c:145 Adding Endpoint 'skypopen' 2011-06-19 13:41:02.222682 [NOTICE] switch_loadable_module.c:274 Adding API Function 'sk' freeswitch@pbx.local> 2011-06-19 13:41:02.222682 [NOTICE] switch_loadable_module.c:274 Adding API Function 'skypopen' 2011-06-19 13:41:02.222682 [NOTICE] switch_loadable_module.c:274 Adding API Function 'skypopen_chat' 2011-06-19 13:41:02.222682 [NOTICE] switch_loadable_module.c:379 Adding Chat interface 'skype'
註:要關閉/離開 freeswitch 只要執行 shutdown。
到這裡,請確定 FreeSwitch 以及 mod_skypopen 啟動皆正常,且沒有錯誤。使用另一個 Skype 帳號,撥到設定在 FreeSwitch 的 Skype,此時 Asterisk 應該會有電話進來。
編輯 /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
加上這幾行
<!-- Skype Gateway --> <load module="mod_skypopen"/>
// 先啟動 Skype Client # sh /usr/local/freeswitch/skypopen/skype-clients-startup-dir/start_skype_clients.sh # ps -ef | grep skype root 3389 1 6 18:07 pts/0 00:00:01 /usr/local/freeswitch/skypopen/skype-clients-symlinks-dir/skype101 --dbpath=/usr/local/freeswitch/skypopen/skype-clients-configuration-dir/skype101 --pipelogin root 3405 1 9 18:07 pts/0 00:00:01 /usr/local/freeswitch/skypopen/skype-clients-symlinks-dir/skype102 --dbpath=/usr/local/freeswitch/skypopen/skype-clients-configuration-dir/skype102 --pipelogin // 手動啟動 FreeSwitch # service freeswitch start # /usr/local/freeswitch/bin/fs_cli freeswitch@internal> sk list sk console is NOT yet assigned F ID Name IB (F/T) OB (F/T) State CallFlw UUID = ==== ======== ======= ======= ====== ============ ====== 1 [skype101] 0/0 0/0 IDLE IDLE 2 [skype102] 0/0 0/0 IDLE IDLE Total Interfaces: 2 IB Calls(Failed/Total): 0/0 OB Calls(Failed/Total): 0/0
Tips:
* 如果設定 2 個 Skype channels, 應該要出現 skype101-102 的 process。
* 要離開 FS CLI, 輸入 /exit。
ERROR: Module snd_pcm_oss does not exist in /proc/modules
ERROR: Module snd_mixer_oss does not exist in /proc/modules
ERROR: Module snd_seq_oss does not exist in /proc/modules
Ans: 執行 ps -ef | grep skype,如果有看到 process,表示 skype client 已經啟動成功,可忽略這些錯誤。
Ans:
Ans: 修改兩個檔案
Ans:
文件 | 大小 | 日期 | 附件上傳者 | |||
---|---|---|---|---|---|---|
skypesipgw.png Skype Gateway with FreeSwitch | 15.32 KB | 17:35, 22 Jun 2011 | alang | 動作 |
Images 1 | ||
---|---|---|
Skype Gateway with FreeSwitchskypesipgw.png |