Вот команды которые я использовал:
1) Из консоли астериска "originate PJSIP/some_external_number@siptrunk extension 6001@from-internal"
2) Из своего кода с использованием AMI {'Action': 'Originate', 'ActionID': '2', 'Channel': 'PJSIP/some_external_number@siptrunk', 'Context': 'from-internal', 'Exten': '6001', 'Priority': 1, 'Callerid': 'two_phones', 'Timeout': 30000}
3) Так-же использовал команду с Local {'Action': 'Originate', 'ActionID': '2', 'Channel': 'Local/some_external_number@from-internal', 'Context': 'from-internal', 'Exten': '6001', 'Priority': 1, 'Callerid': 'two_phones', 'Timeout': 40000}
Конфиги:
Код: Выделить всё
pjsip.conf
[zoiper]
type = endpoint
context = from-internal
disallow = all
allow = ulaw
aors = zoiper
auth = authzoiper
[zoiper]
type = aor
max_contacts = 1
[authzoiper]
type=auth
auth_type=userpass
password=some_pass
username=zoiper
[siptrunk]
type=endpoint
transport=simpletrans
context=from-internal
direct_media=no
disallow=all
allow=ulaw
outbound_auth=siptrunk
aors=siptrunk
[siptrunk]
type=aor
contact=sip:192.168.0.101:5060
[siptrunk]
type=auth
auth_type=userpass
username=some_name
password=some_pass
[siptrunk]
type=registration
outbound_auth=siptrunk
server_uri=sip:some_name@192.168.0.101:5060
client_uri=sip:some_name@192.168.0.101
[siptrunk]
type=identify
endpoint=siptrunk
match=192.168.0.101
extensions.conf
[from-internal]
include=>to-ld
exten=>6001,1,Set(CHANNEL(hangup_handler_push)=hdlr,s,1(args))
exten=>6001,n,dial(PJSIP/zoiper,20)
[hdlr]
exten => s,1,Verbose(0, Executed First)
same => n,Verbose(0, (${EXTEN}))
same => n,NoOp(dialstatus=${DIALSTATUS},causecode=${HANGUPCAUSE})
same => n,Set(HANGUPCAUSE_STRING=${HANGUPCAUSE_KEYS()})
same => n,Verbose(15, ${HANGUPCAUSE_STRING})
; start loop
same => n(hu_begin),NoOp()
; check exit condition (no more array to check)
same => n,GotoIf($[${LEN(${HANGUPCAUSE_STRING})}=0]?hu_exit)
; pull the next item
same => n,Set(ARRAY(item)=${HANGUPCAUSE_STRING})
same => n,Set(HANGUPCAUSE_STRING=${HANGUPCAUSE_STRING:${LEN(${item})}})
; display the channel name and cause codes
same => n,Verbose(0, Got Channel ID ${item} with Technology Cause Code ${HANGUPCAUSE(${item},tech)}, Asterisk Cause Code ${HANGUPCAUSE(${item},ast)})
; check exit condition (no more array to check)
same => n,GotoIf($[${LEN(${HANGUPCAUSE_STRING})}=0]?hu_exit)
; we still have entries to process, so strip the leading comma
same => n,Set(HANGUPCAUSE_STRING=${HANGUPCAUSE_STRING:1})
; go back to the beginning of the loop
same => n,Goto(hu_begin)
same => n(hu_exit),NoOp()
same => n,Return()
[to-ld]
include=>from-siptrunk
exten=>_0XXXXXXXXX,1,Progress
exten=>_0XXXXXXXXX,n,Dial(PJSIP/${EXTEN}@siptrunk,20)
exten=>_0XXXXXXXXX,n,NoOp(dialstatus=${DIALSTATUS},causecode=${HANGUPCAUSE})
exten=>_0XXXXXXXXX,n,Hangup
[from-siptrunk]
include=aasiptrunk
[aasiptrunk]
exten=>_0XXXXXXXXX,1,NoOp(${EXTEN})
exten=>_0XXXXXXXXX,n,Dial(PJSIP/${EXTEN}@siptrunk,20)
Вывод из консоли c Local вместо PJSIP:
Manager 'hello' logged on from 127.0.0.1
-- Called some_external_number@from-internal
-- Executing [some_external_number@from-internal:1] Dial("Local/some_external_number@from-internal-00000000;2", "PJSIP/some_external_number@siptrunk,20") in new stack
-- Called PJSIP/some_external_number@siptrunk
-- PJSIP/siptrunk-00000000 is making progress passing it to Local/some_external_number@from-internal-00000000;2
> 0x7f896400e130 -- Strict RTP learning after remote address set to: some_ip:16886
-- Local/some_external_number@from-internal-00000000;1 is making progress
-- PJSIP/siptrunk-00000000 is making progress passing it to Local/some_external_number@from-internal-00000000;2
-- Local/some_external_number@from-internal-00000000;1 is making progress
> 0x7f896400e130 -- Strict RTP qualifying stream type: audio
> 0x7f896400e130 -- Strict RTP switching source address to 192.168.0.101:16886
> 0x7f896400e130 -- Strict RTP learning complete - Locking on source address 192.168.0.101:16886
-- PJSIP/siptrunk-00000000 answered Local/some_external_number@from-internal-00000000;2
-- Local/some_external_number@from-internal-00000000;1 answered
-- Executing [6001@from-internal:1] Set("Local/some_external_number@from-internal-00000000;1", "CHANNEL(hangup_handler_push)=hdlr,s,1(args)") in new stack
-- Channel PJSIP/siptrunk-00000000 joined 'simple_bridge' basic-bridge <9613fd36-f765-4540-a0e3-5bf72fb681ac>
-- Executing [6001@from-internal:2] Dial("Local/some_external_number@from-internal-00000000;1", "PJSIP/zoiper,20") in new stack
-- Channel Local/some_external_number@from-internal-00000000;2 joined 'simple_bridge' basic-bridge <9613fd36-f765-4540-a0e3-5bf72fb681ac>
-- Called PJSIP/zoiper
-- Local/some_external_number@from-internal-00000000;1 requested media update control 26, passing it to PJSIP/zoiper-00000001
-- Local/some_external_number@from-internal-00000000;1 requested media update control 26, passing it to PJSIP/zoiper-00000001
-- PJSIP/zoiper-00000001 is ringing
-- PJSIP/zoiper-00000001 is ringing
-- PJSIP/zoiper-00000001 answered Local/some_external_number@from-internal-00000000;1
> 0x7f8964074e00 -- Strict RTP learning after remote address set to: 192.168.1.64:8000
-- Channel PJSIP/zoiper-00000001 joined 'simple_bridge' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>
-- Channel Local/some_external_number@from-internal-00000000;1 joined 'simple_bridge' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>
> 0x7f8964074e00 -- Strict RTP switching to RTP target address 192.168.1.64:8000 as source
> Move-swap optimizing Local/some_external_number@from-internal-00000000;1 <-- PJSIP/siptrunk-00000000.
-- Channel PJSIP/siptrunk-00000000 left 'simple_bridge' basic-bridge <9613fd36-f765-4540-a0e3-5bf72fb681ac>
-- Channel Local/some_external_number@from-internal-00000000;1 left 'simple_bridge' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>
-- Channel PJSIP/siptrunk-00000000 swapped with Local/some_external_number@from-internal-00000000;1 into 'simple_bridge' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>
> Bridge b3cddced-7a48-4598-bd8e-90f266b692d2: switching from simple_bridge technology to native_rtp
> Locally RTP bridged 'PJSIP/siptrunk-00000000' and 'PJSIP/zoiper-00000001' in stack
-- Channel Local/some_external_number@from-internal-00000000;2 left 'simple_bridge' basic-bridge <9613fd36-f765-4540-a0e3-5bf72fb681ac>
== Spawn extension (from-internal, some_external_number, 1) exited non-zero on 'Local/some_external_number@from-internal-00000000;2'
== Spawn extension (from-internal, 6001, 2) exited non-zero on 'Local/some_external_number@from-internal-00000000;1'
-- Local/some_external_number@from-internal-00000000;1 Internal Gosub(hdlr,s,1(args)) start
-- Executing [s@hdlr:1] Verbose("Local/some_external_number@from-internal-00000000;1", "0, Executed First") in new stack
Executed First
-- Executing [s@hdlr:2] Verbose("Local/some_external_number@from-internal-00000000;1", "0, (s)") in new stack
(s)
-- Executing [s@hdlr:3] NoOp("Local/some_external_number@from-internal-00000000;1", "dialstatus=ANSWER,causecode=16") in new stack
-- Executing [s@hdlr:4] Set("Local/some_external_number@from-internal-00000000;1", "HANGUPCAUSE_STRING=PJSIP/zoiper-00000001") in new stack
-- Executing [s@hdlr:5] Verbose("Local/some_external_number@from-internal-00000000;1", "15, PJSIP/zoiper-00000001") in new stack
> PJSIP/zoiper-00000001
-- Executing [s@hdlr:6] NoOp("Local/some_external_number@from-internal-00000000;1", "") in new stack
-- Executing [s@hdlr:7] GotoIf("Local/some_external_number@from-internal-00000000;1", "0?hu_exit") in new stack
-- Executing [s@hdlr:8] Set("Local/some_external_number@from-internal-00000000;1", "ARRAY(item)=PJSIP/zoiper-00000001") in new stack
-- Executing [s@hdlr:9] Set("Local/some_external_number@from-internal-00000000;1", "HANGUPCAUSE_STRING=") in new stack
-- Executing [s@hdlr:10] Verbose("Local/some_external_number@from-internal-00000000;1", "0, Got Channel ID PJSIP/zoiper-00000001 with Technology Cause Code SIP 180 Ringing, Asterisk Cause Code Normal Clearing") in new stack
Got Channel ID PJSIP/zoiper-00000001 with Technology Cause Code SIP 200 OK, Asterisk Cause Code Normal Clearing
-- Executing [s@hdlr:11] GotoIf("Local/some_external_number@from-internal-00000000;1", "1?hu_exit") in new stack
-- Goto (hdlr,s,14)
-- Executing [s@hdlr:14] NoOp("Local/some_external_number@from-internal-00000000;1", "") in new stack
-- Executing [s@hdlr:15] Return("Local/some_external_number@from-internal-00000000;1", "") in new stack
== Spawn extension (from-internal, 6001, 2) exited non-zero on 'Local/some_external_number@from-internal-00000000;1'
-- Local/some_external_number@from-internal-00000000;1 Internal Gosub(hdlr,s,1(args)) complete GOSUB_RETVAL=
-- Channel PJSIP/siptrunk-00000000 left 'native_rtp' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>
-- Channel PJSIP/zoiper-00000001 left 'native_rtp' basic-bridge <b3cddced-7a48-4598-bd8e-90f266b692d2>