View Source

{toc}
Свершилось. !skype_and_asterisk.jpeg|align=right!
Asterisk стал первой АТС, столь органично интегрированной со Skype. Еще раньше существовали решения по интеграции со Skype, но все они использовали работающего Skype клиента в качестве поставщика Skype API. Представьте себе сервер, с дюжиной виртуальных X серверов с запущенными копиями Skype клиентов, на каждом по отдельному Skype эккаунту….

Решение Skype от [Digium|http://trac.asteriskpbx.ru/wiki//Digium] \- первое и пока уникальное в своем роде. [Digium|http://trac.asteriskpbx.ru/wiki//Digium] предоставляет chan_skype - обычный канал для Asterisk, внешне выглядящий точно также, как и chan_sip или chan_iax2. Никаких Иксов и Skype клиентов. Запускается с пол-оборота. Все, что надо сделать, это скачать пакет с сайта [Digium|http://trac.asteriskpbx.ru/wiki//Digium], и приобрести лицензию. Лицензии кстати бывают многоканальные, таким образом, у компании будет единый многоканальный Skype эккаунт.
* [ http://downloads.digium.com/pub/telephony/skypeforasterisk/|http://downloads.digium.com/pub/telephony/skypeforasterisk/] \- качаем chan_skype
* [ Заказываем|mailto:request@pbxware.ru?subject=Skype%20license] лицензию у авторизованного реселлера Дигим в России.
* Регистрируем канал при помощи утилиты [ register|http://downloads.digium.com/pub/register/linux/register] (подробное описание ниже).

В момент написания этой публикации доступны бесплатные лицензии сроком действия в один месяц\! Спешите опробовать\!

h2. *Установка*


{color:#000000}До безобразия просто:{color}
{code}snowflake tmp # wget 'http://downloads.digium.com/pub/telephony/skypeforasterisk/skypeforasterisk-1.4_0.9.10-x86_32.tar.gz'
--2009-07-31 04:45:11-- http://downloads.digium.com/pub/telephony/skypeforasterisk/skypeforasterisk-1.4_0.9.10-x86_32.tar.gz
Resolving downloads.digium.com... 76.164.171.232
Connecting to downloads.digium.com|76.164.171.232|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2346062 (2.2M) [application/x-gzip]
Saving to: `skypeforasterisk-1.4_0.9.10-x86_32.tar.gz'

100%[=================================================================================================>] 2,346,062 1.55M/s in 1.4s

2009-07-31 04:45:13 (1.55 MB/s) - `skypeforasterisk-1.4_0.9.10-x86_32.tar.gz' saved [2346062/2346062]

snowflake tmp # tar zxf skypeforasterisk-1.4_0.9.10-x86_32.tar.gz
snowflake tmp # cd skypeforasterisk-1.4_0.9.10-x86_32
snowflake skypeforasterisk-1.4_0.9.10-x86_32 # ls
chan_skype.c chan_skype.conf.sample chan_skype.exports Makefile README res_skypeforasterisk.so skypeforasterisk.h version.h
snowflake skypeforasterisk-1.4_0.9.10-x86_32 # make
gcc -o chan_skype.o -c chan_skype.c -pipe -fPIC -DAST_MODULE=\"chan_skype\" -MD -MT chan_skype.o -MF .chan_skype.o.d -MP
gcc -o chan_skype.so -pthread -shared -Wl,--version-script,chan_skype.exports chan_skype.o
***********************************
Skype For Asterisk build completed.

Type 'make install' to install.
***********************************{code}
Далее надо зарегистрировать канал.

{code}snowflake skypeforasterisk-1.4_0.9.10-x86_32 # wget 'http://downloads.digium.com/pub/register/linux/register'
--2009-07-31 04:52:44-- http://downloads.digium.com/pub/register/linux/register
Resolving downloads.digium.com... 76.164.171.232
Connecting to downloads.digium.com|76.164.171.232|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1177820 (1.1M) [text/plain]
Saving to: `register'

100%[=================================================================================================>] 1,177,820 1.00M/s in 1.1s

2009-07-31 04:52:45 (1.00 MB/s) - `register' saved [1177820/1177820]

snowflake skypeforasterisk-1.4_0.9.10-x86_32 # chmod +x register
snowflake skypeforasterisk-1.4_0.9.10-x86_32 # ./register

Digium Product Registration - Version 3.0.3
Copyright (C) 2004-2007, Digium, Inc.
Use the '-l' option to see license information for software
included in this program.

Please select a category

1 - Digium Products
2 - Cepstral Products

0 - Quit

Your Choice: 1
You selected 1, Digium Products
Please select a product

1 - Asterisk Business Edition
2 - Asterisk Business Edition C Expansion
3 - Asterisk For Smart Cube
4 - Asterisk For Smart Cube Expansion
5 - G.729 Codecc
6 - High Performance Echo Can
7 - Skype For Asterisk
8 - Skype For Asterisk (Beta)
9 - Fax for Asterisk
10 - Free Fax for Asterisk
11 - Vestec Speech Engine

0 - Quit

Your Choice: 8
You selected 8, Skype For Asterisk (Beta)
Please enter your Key-ID: {code}
Ввести полученный код и установить канал:

{code}snowflake skypeforasterisk-1.4_0.9.10-x86_32 # make install
install -m 755 -d /usr/lib/asterisk/modules
install -m 755 chan_skype.so /usr/lib/asterisk/modules
install -m 755 res_skypeforasterisk.so /usr/lib/asterisk/modules
{code}

h2. *Настраиваем chan_skype.conf*

{color:#000000}Конфигурационный файл с комментариями находится в /etc/asterisk/. Образец конфига находится в папке с исходными текстами. Простейший конфиг:{color}
{code}snowflake asterisk # cat chan_skype.conf | grep -v '^;'

[general]
engine_directory=/tmp/skype
default_user=pbxware.ru
bind_address=x.x.x.x
bind_port=0

[pbxware.ru]
secret=xxx
context=default
exten=s
disallow=all
allow=ulaw
direction=incoming
auth_policy=accept:m-i-6
auth_policy=accept:martini
auth_policy=block{code}

h2. {color:#000000}{*}Загружаем модуль{*}{color}

Модуль подгрузится автоматически после рестарта Asterisk, или это можно сделать вручную:
{code}snowflake*CLI> load chan_skype.so
[2009-07-31 05:00:22] == Parsing '/home/asterisk.pbxware/etc/asterisk/chan_skype.conf': [2009-07-31 05:00:22] Found
[2009-07-31 05:00:22] DEBUG[3264]: core.cpp:1311 sfa_startup: License directory set to: /var/lib/asterisk/licenses
[2009-07-31 05:00:22] DEBUG[3269]: core.cpp:1424 sfa_startup: starting skyhost as: skypeforasterisk -z -f /var/spool/asterisk/skype/data
[2009-07-31 05:00:22] DEBUG[3269]: core.cpp:1426 sfa_startup: skyhost environment is : HOME=/var/spool/asterisk/skype
[2009-07-31 05:00:22] DEBUG[3268]: core.cpp:1512 sfa_startup: starting skypewatcher as: skypewatcher 3269
[2009-07-31 05:00:24] DEBUG[3267]: core.cpp:415 skyhost_watcher: got SkyHost Copyright (C) 2003-2008 Skype Technologies S.A.
[2009-07-31 05:00:24] DEBUG[3267]: core.cpp:415 skyhost_watcher: got Proprietary and confidential, do not share this application.
[2009-07-31 05:00:24] DEBUG[3267]: core.cpp:415 skyhost_watcher: got Ready to accept connections
[2009-07-31 05:00:24] DEBUG[3267]: core.cpp:420 skyhost_watcher: skyhost is ready!
[2009-07-31 05:00:24] -- Launched Skype for username 'pbxware.ru'
[2009-07-31 05:00:24] == Registered channel type 'Skype' (Skype For Asterisk Channel Driver)
[2009-07-31 05:00:24] == Manager registered action SkypeBuddies
[2009-07-31 05:00:24] == Manager registered action SkypeBuddy
[2009-07-31 05:00:24] == Manager registered action SkypeAccountProperty
[2009-07-31 05:00:24] == Manager registered action SkypeAddBuddy
[2009-07-31 05:00:24] == Manager registered action SkypeRemoveBuddy
[2009-07-31 05:00:24] == Manager registered action SkypeLicenseStatus
[2009-07-31 05:00:24] == Manager registered action SkypeLicenseList
[2009-07-31 05:00:24] == Registered custom function SKYPE_CALL_PROPERTY
[2009-07-31 05:00:24] == Registered custom function SKYPE_ACCOUNT_PROPERTY
[2009-07-31 05:00:24] == Registered custom function SKYPE_BUDDIES
[2009-07-31 05:00:24] == Registered custom function SKYPE_BUDDY_FETCH
[2009-07-31 05:00:24] Loaded chan_skype.so => (Skype For Asterisk Channel Driver)
snowflake*CLI>
snowflake*CLI> skype
login logout set show
snowflake*CLI> skype
login logout set show
snowflake*CLI> skype show
buddies hostid licenses settings user users version
snowflake*CLI> skype show licenses
Skype For Asterisk Licensing Information
========================================
Total licensed channels: 2

Licenses Found:
File: S4AB-CCKG2FR2G5PF.lic -- Key: S4AB-CCKG2FR2G5PF -- Expires: 2009-08-31 -- Host-ID: 39:c9:af:ea:f4:b1:5c:74:35:52:48:1b:09:57:38:c8:35:7c:f4:5c -- Channels: 2 (OK)
snowflake*CLI> skype show users
Skype UsersLI>
pbxware.ru: Logged In{code}

Готово\!



h2. *Тестовый звонок*
{code}snowflake*CLI>
[2009-07-31 03:37:43] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:37:43] DEBUG[25311]: AContactGroup.cpp:87 OnGroupChanged: Contact 'xpoison' added to CONTACTS_WAITING_MY_AUTHORIZATION group for user 'pbxware.ru'
[2009-07-31 03:37:43] DEBUG[25311]: AAccount.cpp:113 process_contact_authorization: Contact 'xpoison' requesting authorization from user 'pbxware.ru'
[2009-07-31 03:37:43] DEBUG[25311]: AAccount.cpp:148 process_contact_authorization: Contact 'xpoison' denied for user 'pbxware.ru'
[2009-07-31 03:37:43] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:37:43] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:37:43] DEBUG[25311]: AContactGroup.cpp:107 OnGroupChanged: Contact 'xpoison' removed from CONTACTS_WAITING_MY_AUTHORIZATION group for user 'pbxware.ru'
[2009-07-31 03:37:43] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:37:51] DEBUG[25311]: core.cpp:255 create_control_socket: creating socket sfa-control-0x82680a0-00000012
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:815 new_call: Incoming call for Skype user pbxware.ru from xpoison (Вадим)
[2009-07-31 03:37:51] -- Executing [s@default:1] Set("Skype/pbxware.ru-082350d0", "FROM_OUTSIDE=1") in new stack
[2009-07-31 03:37:51] -- Executing [s@default:2] Set("Skype/pbxware.ru-082350d0", "LANGUAGE()=ru") in new stack
[2009-07-31 03:37:51] WARNING[27311]: func_language.c:61 language_write: LANGUAGE() is deprecated; use CHANNEL(language) instead.
[2009-07-31 03:37:51] -- Executing [s@default:3] Goto("Skype/pbxware.ru-082350d0", "menu-main|s|1") in new stack
[2009-07-31 03:37:51] -- Goto (menu-main,s,1)
[2009-07-31 03:37:51] -- Executing [s@menu-main:1] Answer("Skype/pbxware.ru-082350d0", "") in new stack
[2009-07-31 03:37:51] -- Executing [s@menu-main:2] Wait("Skype/pbxware.ru-082350d0", "1") in new stack
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:37:51] DEBUG[27311]: core.cpp:1663 sfa_call_process: accepting socket connection from voice engine
[2009-07-31 03:37:51] DEBUG[27311]: core.cpp:1636 process_ve_frame: received audio socket address 127.0.0.1:48581
[2009-07-31 03:37:51] DEBUG[27311]: core.cpp:1773 sfa_call_set_audio_socket_address: sending audio socket address 127.0.0.1:13738
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:730 queue_event: got control event type 4 with subclass 4.
[2009-07-31 03:37:51] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:37:52] -- Executing [s@menu-main:3] Set("Skype/pbxware.ru-082350d0", "FROM_OUTSIDE=1") in new stack
[2009-07-31 03:37:52] -- Executing [s@menu-main:4] Set("Skype/pbxware.ru-082350d0", "CHANNEL(language)=ru") in new stack
[2009-07-31 03:37:52] -- Executing [s@menu-main:5] GotoIfTime("Skype/pbxware.ru-082350d0", "00:00-23:59|mon-sun|*|*?menu-work-time|s|1") in new stack
[2009-07-31 03:37:52] -- Goto (menu-work-time,s,1)
[2009-07-31 03:37:52] -- Executing [s@menu-work-time:1] Ringing("Skype/pbxware.ru-082350d0", "") in new stack
[2009-07-31 03:37:52] -- Executing [s@menu-work-time:2] Set("Skype/pbxware.ru-082350d0", "choice_counter=0") in new stack
[2009-07-31 03:37:52] -- Executing [s@menu-work-time:3] Wait("Skype/pbxware.ru-082350d0", "2") in new stack
[2009-07-31 03:37:54] -- Executing [s@menu-work-time:4] Gosub("Skype/pbxware.ru-082350d0", "call-record|401|1") in new stack
[2009-07-31 03:37:54] DEBUG[27311]: func_db.c:70 function_db_read: DB: rec_a/xpoison not found in database.
[2009-07-31 03:37:54] -- Executing [401@call-record:1] GotoIf("Skype/pbxware.ru-082350d0", "0?record") in new stack
[2009-07-31 03:37:54] DEBUG[27311]: func_db.c:70 function_db_read: DB: rec_b/401 not found in database.
[2009-07-31 03:37:54] -- Executing [401@call-record:2] GotoIf("Skype/pbxware.ru-082350d0", "0?record") in new stack
[2009-07-31 03:37:54] -- Executing [401@call-record:3] GotoIf("Skype/pbxware.ru-082350d0", "0?record") in new stack
[2009-07-31 03:37:54] -- Executing [401@call-record:4] Return("Skype/pbxware.ru-082350d0", "") in new stack
[2009-07-31 03:37:54] -- Executing [s@menu-work-time:5] Set("Skype/pbxware.ru-082350d0", "choice_counter=0") in new stack
[2009-07-31 03:37:54] -- Executing [s@menu-work-time:6] Set("Skype/pbxware.ru-082350d0", "TIMEOUT(response)=5") in new stack
[2009-07-31 03:37:54] -- Response timeout set to 5
[2009-07-31 03:37:54] -- Executing [s@menu-work-time:7] Set("Skype/pbxware.ru-082350d0", "TIMEOUT(digit)=3") in new stack
[2009-07-31 03:37:54] -- Digit timeout set to 3
[2009-07-31 03:37:54] -- Executing [s@menu-work-time:8] BackGround("Skype/pbxware.ru-082350d0", "zdravstujte") in new stack
[2009-07-31 03:37:54] WARNING[27311]: channel.c:3055 set_format: Unable to find a codec translation path from 0x4 (ulaw) to 0x0 (nothing)
[2009-07-31 03:37:54] -- <Skype/pbxware.ru-082350d0> Playing 'zdravstujte' (language 'ru')
[2009-07-31 03:37:55] -- Executing [s@menu-work-time:9] BackGround("Skype/pbxware.ru-082350d0", "record/vas-privetstvuet-ats-design") in new stack
[2009-07-31 03:37:55] -- <Skype/pbxware.ru-082350d0> Playing 'record/vas-privetstvuet-ats-design' (language 'ru')
[2009-07-31 03:37:58] -- Executing [s@menu-work-time:10] BackGround("Skype/pbxware.ru-082350d0", "to-contact-sales") in new stack
[2009-07-31 03:37:58] -- <Skype/pbxware.ru-082350d0> Playing 'to-contact-sales' (language 'ru')
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:730 queue_event: got control event type 4 with subclass 1.
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
[2009-07-31 03:38:01] -- Executing [h@menu-work-time:1] ExecIf("Skype/pbxware.ru-082350d0", "0|Set|CDR(userfield)=") in new stack
[2009-07-31 03:38:01] DEBUG[27311]: chan_skype.c:3334 unlink_client_call: channel 0x82350d0
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3255 do_monitor: poll returned 1
[2009-07-31 03:38:01] DEBUG[27311]: chan_skype.c:3348 destroy_client_call: channel 0x82350d0
[2009-07-31 03:38:01] DEBUG[25311]: chan_skype.c:3245 do_monitor: entering poll for 2 fds
{code}
Красота\!