не бейте сильно, уважаемые самизнаетекто.
перечитав мгого этого ресурса и многих других, я так и не нашёл ответа.
По мотивам известной всем статьи пытаюсь реализовать конференции. Всё замечательно работает, если инициатором конференции является звонящий (caller), но, когда конференцию инициирует принимающий вызов (callee) - не работает.
никак не могу понять может ли callee сделать ChannelRedirect(${BRIDGEPEER},bla-bla,xxx,1)? caller делает это отлично.
*CLI> core show version
Asterisk 1.6.2.9-2+squeeze4 built by buildd @ biber on a i686 running Linux on 2011-12-18 21:42:21 UTC
features.conf:
[applicationmap]
nway-start => *1,self,Macro,nway-start
extetsion.conf:
[globals]
INDIAL_TIMEOUT=300 ; таймаут для внутренних вызовов
INDIAL_OPTS=gTtkw ; параметы для внутренних вызовов
[dst_local]
exten => _1[012]XX,1,Macro(stdexten,SIP,${EXTEN})
[macro-stdexten]
exten => s,1,NoOp(MACRO_CONTEXT=${MACRO_CONTEXT})
same => n,Set(BACK_EXTEN=${ARG2})
same => n,ExecIf($[${EXISTS(${BACK_EXTEN})} = 0 ]?Set(BACK_EXTEN=${CALLERID(num)}))
same => n,ExecIf($[${LEN(${CALLERID(num)})} = 4 ]?Set(ALERTINFO=internal):Set(ALERTINFO=external))
same => n,SIPAddHeader(Alert-Info: ${ALERTINFO}) ; здест точка с запятой не комент.
same => n,Set(__DYNAMIC_FEATURES=nway-start)
same => n,Dial(${ARG1}/${ARG2},${INDIAL_TIMEOUT},${INDIAL_OPTS})
same => n,Goto(dialstatus,s-${DIALSTATUS},1)
exten => i,1,Macro(invalidcall,${ARG2})
[dynamic-nway]
exten => _XXXXX,1,Answer
same => n,Set(CONFNO=${EXTEN})
same => n,Set(MEETME_EXIT_CONTEXT=dynamic-nway-invite)
same => n,Set(DYNAMIC_FEATURES=)
same => n,MeetMe(${CONFNO},pdMX)
same => n,Hangup
[dynamic-nway-invite]
exten => 0,1,Read(DEST,dial,10,i)
exten => 0,n,Set(DYNAMIC_FEATURES=nway-inv#nway-noinv)
exten => 0,n,Dial(Local/${DEST}@dynamic-nway-dest,,g)
exten => 0,n,Set(DYNAMIC_FEATURES=)
exten => 0,n,Goto(dynamic-nway,${CONFNO},1)
exten => i,1,Goto(dynamic-nway,${CONFNO},1)
[dynamic-nway-dest]
exten => _XXXX,1,Dial(SIP/${EXTEN})
[macro-nway-start]
exten => s,1,NoOp(nway-start BRIDGEPEER: ${BRIDGEPEER} , CHANNEL: ${CHANNEL})
same => n,Set(CONFID=0)
same => n(repeat),Set(CONFID=$[ ${CONFID} + 1 ])
same => n,MeetMeCount(${CALLERID(num)}${CONFID},COUNT)
same => n,GotoIf($[ ${COUNT} > 0 ] ? s,repeat)
same => n,Set(CONFNO=${CALLERID(num)}${CONFID})
same => n,ChannelRedirect(${BRIDGEPEER},dynamic-nway,${CONFNO},1)
same => n,Set(DYNAMIC_FEATURES=)
same => n,Goto(dynamic-nway,${CONFNO},1)
логи:
успешный редирект:
1111 звонит на 1211, в процессе разговора жмет *1, 1211 попадает в конференцию, 1111 тудаже.
VERBOSE[30809] pbx.c: [Dec 27 09:37:11] -- Executing [s@macro-stdexten:9] Set("SIP/1111-000161a1", "__DYNAMIC_FEATURES=nway-start") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:11] -- Executing [s@macro-stdexten:10] Dial("SIP/1111-000161a1", "SIP/1211,300,gTtkw") in new stack
....
VERBOSE[30809] app_dial.c: [Dec 27 09:37:11] -- Called 1211
VERBOSE[30809] app_dial.c: [Dec 27 09:37:11] -- SIP/1211-000161a2 is ringing
VERBOSE[30809] app_dial.c: [Dec 27 09:37:13] -- SIP/1211-000161a2 answered SIP/1111-000161a1
DTMF[30809] channel.c: DTMF begin '*' received on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF begin passthrough '*' on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF end '*' received on SIP/1111-000161a1, duration 150 ms
DTMF[30809] channel.c: DTMF end accepted with begin '*' on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF end passthrough '*' on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF begin '1' received on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF begin passthrough '1' on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF end '1' received on SIP/1111-000161a1, duration 150 ms
DTMF[30809] channel.c: DTMF end accepted with begin '1' on SIP/1111-000161a1
DTMF[30809] channel.c: DTMF end passthrough '1' on SIP/1111-000161a1
VERBOSE[30809] features.c: [Dec 27 09:37:16] -- Feature Found: nway-start exten: nway-start
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:1] NoOp("SIP/1111-000161a1", "nway-start BRIDGEPEER: SIP/1211-000161a2 , CHANNEL: SIP/1111-000161a1") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:2] Set("SIP/1111-000161a1", "CONFID=0") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:3] Set("SIP/1111-000161a1", "CONFID=1") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:4] MeetMeCount("SIP/1111-000161a1", "11111,COUNT") in new stack
VERBOSE[30809] config.c: [Dec 27 09:37:16] == Parsing '/etc/asterisk/meetme.conf': [Dec 27 09:37:16] VERBOSE[30809] config.c: [Dec 27 09:37:16] == Found
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:5] GotoIf("SIP/1111-000161a1", "0 ? s,repeat") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:6] Set("SIP/1111-000161a1", "CONFNO=11111") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:7] ChannelRedirect("SIP/1111-000161a1", "SIP/1211-000161a2,dynamic-nway,11111,1") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:8] Set("SIP/1111-000161a1", "DYNAMIC_FEATURES=") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [s@macro-nway-start:9] Goto("SIP/1111-000161a1", "dynamic-nway,11111,1") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Goto (dynamic-nway,11111,1)
VERBOSE[30809] app_macro.c: [Dec 27 09:37:16] == Channel 'SIP/1111-000161a1' jumping out of macro 'nway-start'
VERBOSE[30809] app_macro.c: [Dec 27 09:37:16] == Channel 'SIP/1111-000161a1' jumping out of macro 'stdexten'
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [11111@dynamic-nway:1] Answer("SIP/1111-000161a1", "") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [11111@dynamic-nway:2] Set("SIP/1111-000161a1", "CONFNO=11111") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [11111@dynamic-nway:3] Set("SIP/1111-000161a1", "MEETME_EXIT_CONTEXT=dynamic-nway-invite") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [11111@dynamic-nway:4] Set("SIP/1111-000161a1", "DYNAMIC_FEATURES=") in new stack
VERBOSE[30809] pbx.c: [Dec 27 09:37:16] -- Executing [11111@dynamic-nway:5] MeetMe("SIP/1111-000161a1", "11111,pdMX") in new stack
VERBOSE[30809] res_musiconhold.c: [Dec 27 09:37:23] -- Started music on hold, class 'default', on SIP/1111-000161a1
VERBOSE[30809] res_musiconhold.c: [Dec 27 09:37:23] -- Stopped music on hold on SIP/1111-000161a1
VERBOSE[30809] res_musiconhold.c: [Dec 27 09:37:24] -- Started music on hold, class 'default', on SIP/1111-000161a1
VERBOSE[30809] res_musiconhold.c: [Dec 27 09:37:25] -- Stopped music on hold on SIP/1111-000161a1
VERBOSE[30809] chan_dahdi.c: [Dec 27 09:37:25] -- Hungup 'DAHDI/pseudo-896025403
неуспешный редирект:
1211 звонит на 1111, 1111 в процессе разговора жмет *1, отбой обоих.
VERBOSE[30832] pbx.c: [Dec 27 09:37:28] -- Executing [1111@numberplan-main:1] Macro("SIP/1211-000161a5", "stdexten,SIP,1111") in new stack
....
VERBOSE[30832] pbx.c: [Dec 27 09:37:28] -- Executing [s@macro-stdexten:9] Set("SIP/1211-000161a5", "__DYNAMIC_FEATURES=nway-start") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:28] -- Executing [s@macro-stdexten:10] Dial("SIP/1211-000161a5", "SIP/1111,300,gTtkw") in new stack
VERBOSE[30832] app_dial.c: [Dec 27 09:37:28] -- Called 1111
VERBOSE[30832] app_dial.c: [Dec 27 09:37:28] -- SIP/1111-000161a6 is ringing
VERBOSE[30832] app_dial.c: [Dec 27 09:37:29] -- SIP/1111-000161a6 answered SIP/1211-000161a5
DTMF[30832] channel.c: DTMF begin '*' received on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF begin passthrough '*' on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF end '*' received on SIP/1111-000161a6, duration 150 ms
DTMF[30832] channel.c: DTMF end accepted with begin '*' on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF end passthrough '*' on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF begin '1' received on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF begin passthrough '1' on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF end '1' received on SIP/1111-000161a6, duration 150 ms
DTMF[30832] channel.c: DTMF end accepted with begin '1' on SIP/1111-000161a6
DTMF[30832] channel.c: DTMF end passthrough '1' on SIP/1111-000161a6
VERBOSE[30832] features.c: [Dec 27 09:37:31] -- Feature Found: nway-start exten: nway-start
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:1] NoOp("SIP/1111-000161a6", "nway-start BRIDGEPEER: SIP/1211-000161a5 , CHANNEL: SIP/1111-000161a6") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:2] Set("SIP/1111-000161a6", "CONFID=0") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:3] Set("SIP/1111-000161a6", "CONFID=1") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:4] MeetMeCount("SIP/1111-000161a6", "11111,COUNT") in new stack
VERBOSE[30832] config.c: [Dec 27 09:37:31] == Parsing '/etc/asterisk/meetme.conf': [Dec 27 09:37:31] VERBOSE[30832] config.c: [Dec 27 09:37:31] == Found
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:5] GotoIf("SIP/1111-000161a6", "0 ? s,repeat") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:6] Set("SIP/1111-000161a6", "CONFNO=11111") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:7] ChannelRedirect("SIP/1111-000161a6", "SIP/1211-000161a5,dynamic-nway,11111,1") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:8] Set("SIP/1111-000161a6", "DYNAMIC_FEATURES=") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [s@macro-nway-start:9] Goto("SIP/1111-000161a6", "dynamic-nway,11111,1") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Goto (dynamic-nway,11111,1)
VERBOSE[30832] app_macro.c: [Dec 27 09:37:31] == Channel 'SIP/1111-000161a6' jumping out of macro 'nway-start'
VERBOSE[30832] app_macro.c: [Dec 27 09:37:31] == Spawn extension (dynamic-nway, 11111, 1) exited non-zero on 'SIP/1211-000161a5' in macro 'stdexten'
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] == Spawn extension (dynamic-nway, 11111, 1) exited non-zero on 'SIP/1211-000161a5'
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [11111@dynamic-nway:1] Answer("SIP/1211-000161a5", "") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [11111@dynamic-nway:2] Set("SIP/1211-000161a5", "CONFNO=11111") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [11111@dynamic-nway:3] Set("SIP/1211-000161a5", "MEETME_EXIT_CONTEXT=dynamic-nway-invite") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [11111@dynamic-nway:4] Set("SIP/1211-000161a5", "DYNAMIC_FEATURES=") in new stack
VERBOSE[30832] pbx.c: [Dec 27 09:37:31] -- Executing [11111@dynamic-nway:5] MeetMe("SIP/1211-000161a5", "11111,pdMX") in new stack
VERBOSE[30832] app_meetme.c: [Dec 27 09:37:31] -- Created MeetMe conference 1023 for conference '11111'
VERBOSE[30832] file.c: [Dec 27 09:37:31] -- <SIP/1211-000161a5> Playing 'conf-onlyperson.alaw' (language 'ru')
VERBOSE[30832] res_musiconhold.c: [Dec 27 09:37:32] -- Started music on hold, class 'default', on SIP/1211-000161a5
VERBOSE[30832] res_musiconhold.c: [Dec 27 09:37:32] -- Stopped music on hold on SIP/1211-000161a5
VERBOSE[30832] chan_dahdi.c: [Dec 27 09:37:32] -- Hungup 'DAHDI/pseudo-225260949'
VERBOSE[30832] pbx.c: [Dec 27 09:37:32] == Spawn extension (dynamic-nway, 11111, 5) exited non-zero on 'SIP/1211-000161a5'
update 21/01/2013
в общем, не дождавшись помощи от звездных гуру, отвечаю сам себе:
редирект сделал через внешний AGI скрипт.
приведу лишь отличия
features.conf
[applicationmap]
nway-start => *1,self,Macro,nway-start
nway-inv => **,self,Macro,nway-ok
nway-noinv => *#,self,Macro,nway-notok
extensions.conf
....
[dynamic-nway]
exten => _XXXXX,1,Answer
same => n,Set(CONFNO=${EXTEN})
same => n,Set(MEETME_EXIT_CONTEXT=dynamic-nway-invite)
same => n,Set(DYNAMIC_FEATURES=)
same => n,MeetMe(${CONFNO},1dpMXx)
exten => h,1,NoOp(Exit from Conference)
same => n,MeetMeCount(${CONFNO},COUNT)
same => n,ExecIf($[ ${COUNT} = 1 ] ?MeetMeAdmin(${CONFNO},K))
[macro-nway-start]
exten => s,1,NoOp()
same => n,Set(CONFID=0)
same => n(repeat),Set(CONFID=$[ ${CONFID} + 1 ])
same => n,MeetMeCount(${CALLERID(num)}${CONFID},COUNT)
same => n,GotoIf($[ ${COUNT} > 0 ] ? s,repeat)
same => n,Set(CONFNO=${CALLERID(num)}${CONFID})
same => n,AGI(n-way-conf.php)
...
n-way-conf.php
#!/usr/bin/php
<?php
require('/usr/share/php5/phpagi/phpagi.php');
set_time_limit(0);
$agi = new AGI();
$CHANNEL=$agi->request['agi_channel'];
$BRIDGEPEER=$agi->get_variable('BRIDGEPEER', $getvalue = true);
$CONFNO=$agi->get_variable('CONFNO', $getvalue = true);
$agimngr = new AGI_AsteriskManager();
$agimngr->connect();
$agimngr->Redirect($BRIDGEPEER,$CHANNEL,$CONFNO,'dynamic-nway',1);
?>
теперь редирект может сделать не только caller, но и callee
и решился вопрос: как отключать последнего участника конференции.
P.S. приведенные конфиги без подробностей и вырезаны из контекста.
А точно не работает то?
zzuz ( 2012-12-26 18:06:04 +0400 )редактироватьточно, проверял.
aleokos ( 2012-12-26 20:05:37 +0400 )редактироватьНе верю.
zzuz ( 2012-12-26 20:11:38 +0400 )редактироватьну умница,че. только непонятно зачем для этого agi. можно было просто через System.
meral ( 2013-01-21 14:11:23 +0400 )редактироватьНе лишайте автора гордости за 9 строк сложнейшего кода. Думаю через несколько часов можно будет на github'е его лицезреть)
zzuz ( 2013-01-21 14:14:09 +0400 )редактироватьпоследнего отключать просто. когда у вас ктото дисконектится по h проверять сколько осталося. если один - вырубать.
meral ( 2013-01-21 14:15:46 +0400 )редактироватьagi для того чтобы форков не плодить. хотя, конечно их там не много, но мне так показалось кашернее
aleokos ( 2013-01-21 14:46:49 +0400 )редактироватьдействительно по h отлично можно выключать. Вот только сообщение "Вас только что удалили.." просто убивает наповал :)
aleokos ( 2013-01-21 15:02:16 +0400 )редактироватьмужик, имей совесть. после каждого твоего редактирования всем участникам темы приходит простыня ответа.
meral ( 2013-01-21 17:32:19 +0400 )редактироватьagi точно также форкает скрипт. не питайте иллюзий.
meral ( 2013-01-21 17:33:03 +0400 )редактироватьредактировать больше не буду, иллюзий не питаю.
aleokos ( 2013-01-21 21:18:36 +0400 )редактировать