Tuesday, December 6, 2011

Freeswitch + mod_skypiax + asterisk on CentOS 5.3

Howto: Freeswitch + mod_skypiax + asterisk on CentOS 5.3
This post describes the experience of installing and configuring skype gateway under CentOS 5.3 with the use of PBX FreeSwitch and external connection to Asterisk.
 When writing, the materials listed at the end of fasting.

Description of actions undertaken

  1. SELinux Installed CENTOS 5.3 + KDE with disabled Firewall and SELinux
  2. Updated packages
  3. Wound up SKYPE user someuser

Installing SKYPE-client

  1. Create a file / etc / yum.repos.d / skype.repo and make it
    [Skype]
    name=Skype Repository name = Skype Repository
    baseurl = http://download.skype.com/linux/repos/fedora/updates/i586/
    gpgkey = file: / / / etc / pki / rpm-gpg / RPM-GPG-KEY-skype
  2. qt4-x11 . At rpm.pbone.net looking for, download and install packages qt4, qt4-x11. I used qt4-4.4.3-1.fc8.i386.rpm and qt4-x11-4.4.3-1.fc8.i386.rpm respectively
    rpm -ivh qt4-4.4.3-1.fc8.i386.rpm qt4-x11-4.4.3-1.fc8.i386.rpm
  3. yum --nogpgcheck install skype
  4. yum install x11vnc

Installing FREESWITCH and mod_skypiax

  1. as root execute:
    yum update -y
    yum install -y subversion autoconf automake libtool gcc-c++ ncurses-devel make libX11-devel Xvfb alsa-utils xorg-x11-fonts*
    cd /usr/src
  2. svn co http://svn.freeswitch.org/svn/freeswitch/t svn co http://svn.freeswitch.org/svn/freeswitch/t runk freeswitch runk freeswitch
    cd freeswitch cd freeswitch
    # ---- HUMAN build / modules.conf.in, remove comment from mod_sofia and mod_skypiax, save ...
    ./bootstrap.sh .
    ./configure
    make && make install && make hd-sounds-install && make hd-moh-install && make samples
  3. Copy the config mod_skypiax and init-script to run FreeSwitch:
    cp /usr/src/freeswitch/src/mod/endpoints/mo cp / usr / src / freeswitch / src / mod / endpoints / mo d_skypiax/configs/skypiax.conf.xml \ d_skypiax / configs / skypiax.conf.xml \
    /usr/local/freeswitch/conf/autoload_conf / Usr / local / freeswitch / conf / autoload_conf igs/ igs /
    cp /usr/src/freeswitch/debian/freeswitch.in cp / usr / src / freeswitch / debian / freeswitch.in it /etc/init.d/freeswitch it / etc / init.d / freeswitch
    sed -i 's/opt/usr\/local/g' /etc/init.d/freeswitch sed-i 's / opt / usr \ / local / g' / etc / init.d / freeswitch
  4. Создаем пользователей и группы Create users and groups
    adduser --home /usr/local/freeswitch -g daemon freeswitch adduser - home / usr / local / freeswitch-g daemon freeswitch
    chown -R freeswitch.daemon /usr/local/freeswitch chown-R freeswitch.daemon / usr / local / freeswitch
    groupadd audio groupadd audio
  5. Заводим пользователя, под которым будет работать Skype: Set up user that will operate Skype:
    adduser --home /home/skype -g audio skype adduser - home / home / skype-g audio skype
  6. Создаем директорию, из которой Skype будет читать свой конфиг: Create a directory from which Skype will read your configuration:
    mkdir -p /home/skype/multi/interface01 mkdir-p / home/skype/multi/interface01
    chown -R skype.audio /home/skype/multi chown-R skype.audio / home / skype / multi

Starting and Configuring SKYPE

  1. Запускаем звуковые модули Start the Sound Modules
    rmmod snd-dummy rmmod snd-dummy
    modprobe snd-dummy modprobe snd-dummy
  2. Запуск окна, где будет запущен скайп Starting window, where it will be launched Skype
    /usr/bin/Xvfb :101 -ac & / Usr / bin / Xvfb: 101-ac &
  3. Запуск скайпа в отдельном окне Running Skype in a separate window
    DISPLAY=:101 /usr/bin/skype --dbpath=/home/skype/multi/interface01 & DISPLAY =: 101 / usr / bin / skype - dbpath = / home/skype/multi/interface01 &
  4. Для тестирования и настройки скайп-клиента запускаем vnc-сервер To test and configure Skype client run vnc-server
    x11vnc -display :101 x11vnc-display: 101
  5. Подключаемся с помощью vnc-клиента (VNC Viewer, например) удаленно к скайпу. Connecting with vnc-client (VNC Viewer, for example) remotely to Skype. Отключаем все события, уведомления. Disable all events and notifications.
  6. Пподключаем mod_skypiax к Public API. Ppodklyuchaem mod_skypiax to the Public API. Для этого нужно собрать и запустить спецальную утилиту из исходников freeswitch : To do this you need to build and run the utility from source spetsalnuyu freeswitch:
    cd /usr/src/freeswitch/src/mod/endpoints/mo cd / usr / src / freeswitch / src / mod / endpoints / mo d_skypiax/configs d_skypiax / configs
    gcc -Wall -ggdb skypiax_auth.c -o skypiax_auth -lX11 gcc-Wall-ggdb skypiax_auth.c-o skypiax_auth-lX11
    ./skypiax_auth :101 . / Skypiax_auth: 101
    Выскочит сообщение у скайпа "Программа хочет использовать Skype", cтавим скайпу галочку "запомнить выбор" Pop up a message from Skype "program wants to use Skype", ctavim Skype tick "remember choice"
  7. На этом настройка Skype-клиента завершена. In this setting Skype-client completed. Осталось только клонировать полученный конфиг для нужного количества Skype-каналов. What remains now is to clone the resulting configuration for the desired number of Skype-channels.
    cd /home/skype/multi cd / home / skype / multi
    for i in $(seq 2 N ); do i=$(printf "%02d" $i); cp -a interface01 interface$i; done for i in $ (seq 2 N); do i = $ (printf "% 02d" $ i); cp-a interface01 interface $ i; done
    где N — нужное количество Skype-каналов. where N - the right amount of Skype-channels.

Setting mod_skypiax

  1. Редактируем конфиг mod_skypiax для нужного количества каналов: Edit the configuration mod_skypiax for the desired number of channels:
    kedit /usr/local/freeswitch/conf/autoload_conf kedit / usr / local / freeswitch / conf / autoload_conf igs/skypiax.conf.xml igs / skypiax.conf.xml
    В параметрах: In parameters:
    • destination указываем экстеншн, куда будет перенаправляться соединение (к примеру - 8889) specify the destination extension, which will be redirected to the connection (for example - 8889)
    • X11-display указываем номер дисплея X-сервера, где запущен скайп-клиент X11-display screen indicates the number of X-server running the Skype client
    • skype_user указываем имя скайп-аккаунта skype_user specify the name Skype-account

  2. Запускаем FREESWITCH и загружаем mod_skypiax Starting FREESWITCH and load mod_skypiax
    /usr/local/freeswitch/bin/freeswitch / Usr / local / freeswitch / bin / freeswitch
    > console loglevel 9 # детализированный отчет > Console loglevel 9 # detailed report
    > load mod_skypiax # загрузка модуля > Load mod_skypiax # module loading
    > sk list # проверка загруженности модуля > Sk list # test load module
    > shutdown # выход > Shutdown # exit
  3. Добавляем mod_skypiax в список модулей, загружающихся во время старта FreeSwitch . Add to the list mod_skypiax modules to be loaded during start FreeSwitch. Для этого в файле /usr/local/freeswitch/conf/autoload_conf To do this in the file / usr / local / freeswitch / conf / autoload_conf igs/modules.conf.xml нужно раскоментировать/добавить строчку igs / modules.conf.xml need to uncomment / add the line
    <load module="mod_skypiax"/> <load module="mod_skypiax"/>
  4. Важным моментом является то, что skype-клиенты должны запускаться до загрузки модуля mod_skypiax , т.е. The important point is that the skype-client should be run before loading the module mod_skypiax, ie перед стартом FreeSwitch . before the start FreeSwitch. Также, остановка уже задействованных mod_skypiax копий Skype приведет к падению FreeSwitch . Also, stop already involved mod_skypiax copies of Skype will lead to a fall FreeSwitch.
  5. Добавляем обработчик для перенаправляемого экстеншена (8889). Add a handler for the redirected Extension (8889).
    В директории /usr/local/freeswitch/conf/dialplan/defa In the directory / usr / local / freeswitch / conf / dialplan / defa ult создаем файл 02_skype.xml следующего содержания: ult create a file 02_skype.xml read:
    <include> <include>
    <extension name="skype_incoming"> <extension name="skype_incoming">
    <condition field="destination_number" expression="^8889$"> <condition field="destination_number" expression="^8889$">
    <action application="set" data="hangup_after_bridge=true"/> <action application="set" data="hangup_after_bridge=true"/>
    <action application="set" data="effective_caller_id_name=Skype"/> <action application="set" data="effective_caller_id_name=Skype"/>
    <action application="bridge" data="sofia/gateway/asterisk/351"/> <action application="bridge" data="sofia/gateway/asterisk/351"/>
    <action application="hangup"/> <action application="hangup"/>
    </condition> </ Condition>
    </extension> </ Extension>
    </include> </ Include>
    В поле <action application="bridge"...> указан экстеншен который будет обрабатываться в asterisk при поступлении вызова, в моем примере это будет экстеншн 351 . In the <action application="bridge"...> specified Extension will be processed in asterisk when a call comes in, in my example it would be extension 351.
    В этом же каталоге находятся примеры других экстеншенов, которые нужно будет закоментировать, что бы нужный нам экстеншен не обрабатывался в другом месте. In the same directory are examples of other extensions that need to be commented out, what would you want us to Extension not to be processed elsewhere. Ту же операцию нужно проделать и в файле /usr/local/freeswitch/conf/dialplan/defa The same procedure should be done in the file / usr / local / freeswitch / conf / dialplan / defa ult.xml ult.xml

Configuring SIP-trunk between Asterisk and FreeSwitch

  1. На сервере c FreeSwitch в директории /usr/local/freeswitch/conf/sip_profiles/e On the server c FreeSwitch in the directory / usr / local / freeswitch / conf / sip_profiles / e xternal создаем файл asterisk.xml следующего содержания: xternal create a file asterisk.xml read:
    <include> <include>
    <gateway name="asterisk"> <gateway name="asterisk">
    <param name="username" value="8889"/> <param name="username" value="8889"/>
    <param name="realm" value="asterisk.example.tld"/> <param name="realm" value="asterisk.example.tld"/>
    <param name="password" value="******"/> <param name="password" value="******"/>
    <param name="register" value="false"/> <param name="register" value="false"/>
    </gateway> </ Gateway>
    </include> </ Include>
    где where
    asterisk — имя шлюза (должно совпадать с указанным в предыдущем шаге); asterisk - the name of the gateway (this should coincide with that in the previous step);
    asterisk.example.tld — имя хоста или IP адрес сервера Asterisk ; asterisk.example.tld - host name or IP address of the server Asterisk;
    8889 — имя пользователя для доступа к серверу Asterisk ; 8889 - The user name to access the server Asterisk;
    ******* — пароль. ******* - Password.
    На сервере Asterisk добавляем в sip.conf следующее: On the server, add to the Asterisk sip.conf as follows:
    [freeswitch] [Freeswitch]
    type=peer type = peer
    host=1.1.1.1 host = 1.1.1.1
    username=8889 username = 8889
    port=5080 port = 5080
    fromdomain=1.1.1.1 fromdomain = 1.1.1.1
    secret=****** secret =******
    Перезагружаем Asterisk Restart Asterisk
    asterisk -x 'sip reload' asterisk-x 'sip reload'

Calls to Skype

  1. Сначала в файле sip.conf в Asterisk создаем пользователя (или несколько пользователей) под которым в FS будет принимать входящие вызовы. First, in the file sip.conf in Asterisk create a user (or multiple users), under which in the FS will accept incoming calls. В качестве примера пусть будет 8890 . As an example, let it be 8890. При наборе этого номера на SIP-телефоне звонок будет переадресовываться на сервер FS и коммутироваться на нужного нам skype-пользователя. When dialing this number on the SIP-phone call will be forwarded to the server FS and commute on the right we skype-user. Если хотим, что бы Asteisk обрабатывал DTMF сигналы, то прописываем дополнительно параметр dtmfmode=inband. FS когда совершает BRIDGE If you want, what would Asteisk handles DTMF signals, then prescribe additional parameter dtmfmode = inband. FS when committing BRIDGE   двух каналов режет out-of-band dtmf-сигналы, пропуская только inband и нужно, что бы Asterisk обрабатывал inband сигналы. two channels cut out-of-band dtmf-tones, letting through only inband and need that would Asterisk handles inband signals. По умолчанию Asterisk обрабатывает out-of-band. By default, Asterisk handles out-of-band.
  2. В конфиг-файле /freeswitch/conf/autoload_configs/acl.co In the configuration file / freeswitch / conf / autoload_configs / acl.co nf.xml нужно разрешить входящие вызовы с сервера Asterisk, для чего в блоке domains добавляем строку <node type="allow" cidr="xxx.xxx.xxx.xxx/32"/> , где xxx.xxx.xxx.xxx - IP адрес сервера Asterisk nf.xml need to allow incoming calls from the server, Asterisk, for which the block domains to add the line <node type="allow" cidr="xxx.xxx.xxx.xxx/32"/>, where xxx.xxx.xxx.xxx - IP address of Asterisk
  3. В каталоге /freeswitch/conf/sip_profiles/internal/ создаем файл asterisk.xml с описанием параметров подключения к asterisk: In the directory / freeswitch / conf / sip_profiles / internal / create a file asterisk.xml describing the parameters to connect to asterisk:
    <include> <include>
    <gateway name="asterisk_in"> <gateway name="asterisk_in">
    <param name="username" value=" 8890 "/> <param name="username" value=" 8890 "/>
    <param name="realm" value=" xxx.xxx.xxx.xxx "/> <param name="realm" value=" xxx.xxx.xxx.xxx "/>
    <param name="password" value=" password_for_8890 "/> <param name="password" value=" password_for_8890 "/>
    <param name="register" value="true"/> <param name="register" value="true"/>
    <param name="retry-seconds" value="30"/> <param name="retry-seconds" value="30"/>
    <param name="ping" value="25"/> <param name="ping" value="25"/>
    </gateway> </ Gateway>
    </include> </ Include>
    где username - имя юзера, password - пароль для юзера, realm - IP адрес сервера Asterisk where username - user name, password - password for the user, realm - IP address of the Asterisk
  4. В каталоге /freeswitch/conf/dialplan/public/ создаем файл 02_skype.xml в котором описываем правила перенаправления поступающих вызовов на Skype-абонентов. In the directory / freeswitch / conf / dialplan / public / 02_skype.xml create a file which describes the rules for redirecting incoming calls to a Skype-subscribers. В простом случае это будет выглядеть примерно так: In the simplest case, it will look like this: <include> <include>
    <extension name="skype_someuser"> <extension name="skype_someuser">
    <condition field="destination_number" expression="^8890$"> <condition field="destination_number" expression="^8890$">
    <action application="bridge" data="skypiax/ANY/ someuser "/> <action application="bridge" data="skypiax/ANY/ someuser "/>
    </condition> </ Condition>
    </extension> </ Extension>
    </include> </ Include>
    где в поле <action...> вместо someuser указывается skype-аккаунт нужного нам пользователя where in the field instead <action...> someuser indicated skype-account you want us to User

Sources:

  1. http://habrahabr.ru/blogs/voip/68399/
  2. http://wiki.freeswitch.org/wiki/Skypiax # A n_example_of_Skypiax_and_FreeSWITCH_inst n_example_of_Skypiax_and_FreeSWITCH_inst allation_on_CentOS.2C_from_scratch allation_on_CentOS.2C_from_scratch
  3. http://fedorasolved.org/multimedia-solut ions/installing-skype ions / installing-skype

No comments:

Post a Comment