03
2019
04
15:26:14

asterisk extension calls between res_pjsip and chan_sip



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

As you know, asterisk has integrated pjsip for sip signalling since asterisk-11. pjsip has advantages of faster and flexiblility than chan_sip.

If you are used to use chan_sip, you' d better to migrate your projects from chan_sip to res_pjsip. But at the beginning, sometimes, you also need to use both of them.

This article tries to illustate how to handle this job.



1. compile and install asterisk-13.5.0 with pjsip enabled, you can refer to the following steps 

"How to Install Asterisk 13 and PJSIP on CentOS 6"

http://blogs.digium.com/2015/02/24/install-asterisk-13-pjsip-centos-6/



2. configure chan_sip and pjsip extensions

the following conf file contents is not full file that i displayed here, it is the only must!

chan_sip to use port 5060 as sip signalling as default:



1) /etc/asterisk/sip.conf

[general]

udpbindaddr=0.0.0.0



2) res_pjsip to use port 5070 as sip signalling:

/etc/asterisk/pjsip.conf

[transport-udp]

type=transport

protocol=udp    ;udp,tcp,tls,ws,wss

bind=0.0.0.0:5070



3) create two pjsip extension 6001, and 6002 (also in pjsip.conf)

[6001]

type=endpoint

transport=transport-udp

context=from-internal

disallow=all

allow=ulaw

allow=alaw

allow=gsm

auth=auth6001

aors=6001



[auth6001]

type=auth

auth_type=userpass

password=6001

username=6001



[6001]

type=aor

max_contacts=1

;contact=sip:6001@192.168.66:5060



[6002]

type=endpoint

transport=transport-udp

context=from-internal

disallow=all

allow=ulaw

allow=alaw

auth=auth6002

aors=6002



[auth6002]

type=auth

auth_type=userpass

password=6002

username=6002



[6002]

type=aor

max_contacts=2



4) create two chan_sip extension 805, 806

extensions_additional.conf



[ext-local]

include => ext-local-custom

exten => 805,1,Macro(exten-vm,novm,805)

exten => 805,hint,SIP/805

exten => 806,1,Macro(exten-vm,novm,806)

exten => 806,hint,SIP/806



sip_additional.conf



[805]

username=805

type=friend

TermType=0

secret=freepbx321ext

record_out=Adhoc

record_in=Adhoc

qualify=yes

port=5060

pickupgroup=1

nat=yes

mailbox=805@device

host=dynamic

dtmfmode=rfc2833

DispReg=0

context=from-internal

canreinvite=no

calllimit=2

callgroup=1

callerid=device <805>



[806]

username=806

type=friend

TermType=0

secret=freepbx321ext

record_out=Adhoc

record_in=Adhoc

qualify=yes

port=5060

pickupgroup=1

nat=yes

mailbox=806@device

host=dynamic

dtmfmode=rfc2833

DispReg=0

context=from-internal

canreinvite=no

calllimit=2

callgroup=1

callerid=device <806>



5) destination for pjsip extensions

extensions_additional.conf



[ext-pjsip]

exten => _6XXX,1,Dial(PJSIP/${EXTEN})



6) dialplan for 'from-internal' of extensions.conf

[from-internal]

;allow phones to use applications

include => app-userlogonoff

include => app-directory

include => app-dnd

include => app-callforward

include => app-callwaiting

include => app-messagecenter

include => app-calltrace

include => parkedcalls

include => from-internal-custom

;allow phones to dial other extensions

include => ext-fax

include => ext-local

include => ext-group

include => ext-queues

include => ext-zapbarge

include => ext-meetme

include => ext-record

include => ext-test

include => ext-pjsip

;allow phones to access trunks

include => outbound-allroutes

exten => s,1,Macro(hangupcall)

exten => h,1,Macro(hangupcall)



[default]

include => ext-local

include => ext-pjsip

exten => s,1,Playback(vm-goodbye)

exten => s,2,Macro(hangupcall)



sip_additonal.conf should be included in sip.conf

extensions_additional.conf should be included in extensions.conf



3. examine extensions in the dialplan

you can reload asterisk

[root@zhenwen ~]# asterisk -vvvr

zhenwen*CLI> core reload 

zhenwen*CLI> module show like res_pjsip.so

Module                         Description                              Use Count  Status      Support Level

res_pjsip.so                   Basic SIP resource                       24         Running              core

1 modules loaded

zhenwen*CLI> module show like chan_sip.so

Module                         Description                              Use Count  Status      Support Level

chan_sip.so                    Session Initiation Protocol (SIP)        0          Running              core

1 modules loaded



now register 4 ip phones to asterisk server (which ip addredd is to 192.168.1.66)  with exetension 805, 806, 6001, 6002 . 

zhenwen*CLI> sip show peers

Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                      

805/805                   192.168.1.124                            D  Yes        Yes            2158     OK (100 ms)                                  

806/806                   192.168.1.124                            D  Yes        Yes            7458     OK (100 ms)                                  

2 sip peers [Monitored: 2 online, 0 offline Unmonitored: 0 online, 0 offline]



zhenwen*CLI> pjsip show endpoints

 Endpoint:  <Endpoint/CID.....................................>  <State.....>  <Channels.>

    I/OAuth:  <AuthId/UserName...........................................................>

        Aor:  <Aor............................................>  <MaxContact>

      Contact:  <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>

  Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress..................>

   Identify:  <Identify/Endpoint.........................................................>

        Match:  <criteria.........................>

    Channel:  <ChannelId......................................>  <State.....>  <Time.....>

        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>

==========================================================================================





 Endpoint:  6001                                                 Not in use    0 of inf

     InAuth:  auth6001/6001

        Aor:  6001                                               1

      Contact:  6001/sip:6001@192.168.1.30:10860;rinstance 184588825f Unknown         nan

  Transport:  transport-udp             udp      0      0  0.0.0.0:5070





 Endpoint:  6002                                                 Not in use    0 of inf

     InAuth:  auth6002/6002

        Aor:  6002                                               2

      Contact:  6002/sip:6002@192.168.1.30:65515;rinstance 2096239e2c Unknown         nan

  Transport:  transport-udp             udp      0      0  0.0.0.0:5070





Objects found: 2



4. make calls between extensions.

1) chan_sip extensions: 805 --> 806

dial 806 from 805, then 805 answers the call.



2) res_pjsip extensions: 6001-->6002

dial 6002 from 6001, then 6002 answers the call.



3) see channels in the system

zhenwen*CLI> core show channels

Channel              Location             State   Application(Data)             

SIP/805-00000024     s@macro-dial:11      Up      Dial(SIP/806,45,Wwtm)         

SIP/806-00000025     (None)               Up      AppDial((Outgoing Line))      

PJSIP/6002-00000022  (None)               Up      AppDial((Outgoing Line))      

PJSIP/6001-00000021  6002@from-internal:1 Up      Dial(PJSIP/6002)              

4 active channels

2 active calls

52 calls processed

zhenwen*CLI> 

the two calls are setup.



4) call between res_pjsip extension and chan_sip extension

hangup the above calls.

dial 805 from 6001. then 6001 answers the call;

dial 6002 from 806, then 806 answers the call. 

now we see the channels:



zhenwen*CLI> core show channels

Channel              Location             State   Application(Data)             

SIP/805-00000028     6001@from-internal:1 Up      Dial(PJSIP/6001)              

SIP/806-00000029     (None)               Up      AppDial((Outgoing Line))      

PJSIP/6002-00000026  s@macro-dial:11      Up      Dial(SIP/806,45,Wwtm)         

PJSIP/6001-00000025  (None)               Up      AppDial((Outgoing Line))      

4 active channels

2 active calls

56 calls processed

zhenwen*CLI> 



5. uses pjsip extension as queue member



1) configure queue 200, login 6001 to the queue.



zhenwen*CLI> queue add member PJSIP/6001 to 200

Added interface 'PJSIP/6002' to queue '200'



zhenwen*CLI> queue show

default has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s

   No Members

   No Callers



200 has 0 calls (max 30) in 'leastrecent' strategy (4s holdtime, 42s talktime), W:0, C:1, A:0, SL:0.0% within 0s

   Members: 

      PJSIP/6001 (ringinuse enabled) (dynamic) (In use) has taken 1 calls (last was 150806 secs ago)

   No Callers



2) make call to 200

dial 200 from 805, then 6001 rings, answer 6001.



zhenwen*CLI> queue show

default has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s

   No Members

   No Callers



200 has 0 calls (max 30) in 'leastrecent' strategy (3s holdtime, 42s talktime), W:0, C:1, A:0, SL:0.0% within 0s

   Members: 

      PJSIP/6001 (ringinuse enabled) (dynamic) (in call) (In use) has taken no calls yet

   No Callers





zhenwen*CLI> 



zhenwen*CLI> core show channels

Channel              Location             State   Application(Data)             

SIP/805-0000002a     200@q200:4           Up      Queue(200,t,,,60)             

PJSIP/6001-00000027  200@from-internal:1  Up      AppQueue((Outgoing Line))     

2 active channels

1 active call

57 calls processed

zhenwen*CLI> 





6. uses asterisk cli to make outbound call

use cli command 'channel originate' to dial extensions.



zhenwen*CLI> channel originate PJSIP/6001 extension 805@ext-local

zhenwen*CLI> channel originate SIP/806 extension 6002@ext-pjsip

  == Using SIP RTP CoS mark 5

    -- Called 806

    -- SIP/806-0000002c is ringing

    -- SIP/806-0000002c is ringing

    -- SIP/806-0000002c answered

    -- Executing [6002@ext-pjsip:1] Dial("SIP/806-0000002c", "PJSIP/6002") in new stack

    -- Called PJSIP/6002

    -- PJSIP/6002-00000029 is ringing

    -- PJSIP/6002-00000029 answered SIP/806-0000002c

    -- Channel PJSIP/6002-00000029 joined 'simple_bridge' basic-bridge <035b50ce-a644-443a-b1ca-07161c3477a3>

    -- Channel SIP/806-0000002c joined 'simple_bridge' basic-bridge <035b50ce-a644-443a-b1ca-07161c3477a3>

zhenwen*CLI> 

zhenwen*CLI> core show channels

Channel              Location             State   Application(Data)             

SIP/805-0000002b     (None)               Up      AppDial((Outgoing Line))      

SIP/806-0000002c     6002@ext-pjsip:1     Up      Dial(PJSIP/6002)              

PJSIP/6002-00000029  (None)               Up      AppDial((Outgoing Line))      

PJSIP/6001-00000028  s@macro-dial:11      Up      Dial(SIP/805,45,Wwtm)         

4 active channels

2 active calls

59 calls processed



7. uses asterisk manager to make calls

login to asterisk manager,

then send the following command:

Action: Originate

Channel: SIP/805

Context: default

Exten: 6001

Priority: 1

Callerid: 805

Timeout: 30000



asterisk cli displays:

  == Using SIP RTP CoS mark 5

    -- Called 805

    -- SIP/805-0000002d is ringing

    -- SIP/805-0000002d is ringing

    -- SIP/805-0000002d answered

    -- Executing [6001@default:1] Dial("SIP/805-0000002d", "PJSIP/6001") in new stack

    -- Called PJSIP/6001

    -- PJSIP/6001-0000002a is ringing

    -- PJSIP/6001-0000002a answered SIP/805-0000002d

    -- Channel PJSIP/6001-0000002a joined 'simple_bridge' basic-bridge <381573a4-c31e-40e4-b657-309a06cec842>

    -- Channel SIP/805-0000002d joined 'simple_bridge' basic-bridge <381573a4-c31e-40e4-b657-309a06cec842>



zhenwen*CLI> core show channels

Channel              Location             State   Application(Data)             

SIP/805-0000002d     6001@default:1       Up      Dial(PJSIP/6001)              

PJSIP/6001-0000002a  (None)               Up      AppDial((Outgoing Line))      

2 active channels

1 active call

60 calls processed

zhenwen*CLI> 



8. dial into meetme room

we configure a meetme room in extensions.conf

[ext-meetme]

; general confrooms with no pin requered , 2017-08-03 Yin Zhenwen

exten => _2XXX!,1,Answer

exten => _2XXX!,n,MeetMe(${EXTEN},qdsMF)



now, we use 4 phones to dial 2806 into the same room.

zhenwen*CLI> meetme list 2806

User #: 01         6001 6001                 Channel: PJSIP/6001-0000002b     (unmonitored) 00:00:44

User #: 02         6002 6002                 Channel: PJSIP/6002-0000002c     (unmonitored) 00:00:30

User #: 03          805 device               Channel: SIP/805-0000002e     (unmonitored) 00:00:19

User #: 04          806 device               Channel: SIP/806-0000002f     (unmonitored) 00:00:09

4 users in that conference.

zhenwen*CLI> 



ok, the room has 4 talkers.



---------

summerize: we have configured and tested calls between res_pjsip and chan_sip extensions at the following scenario:

1) dial from extensions

2) dial to queue

3) dial from cli command

4) dial from manager command

5) dial into meetme room


--------------------- 

作者:far_away_12 

来源:CSDN 

原文:https://blog.csdn.net/Yin_Zhenwen/article/details/77891617 

版权声明:本文为博主原创文章,转载请附上博文链接!


本文链接:http://www.hqyman.cn/post/484.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: