Chitholian
Chitholian

Reputation: 472

What is the Asterisk Dial() Option to Call Subroutine on "Ringing" Status Received from Called Party?

I need to execute AGI scripts when following events occur:

  1. An incoming call (it is simple just call AGI() function).
  2. When a call is "Ringing" (I cannot figure it out!). <-- Problem, how to do this?
  3. When a call is "Answered" (I do it using U(answer^${CALLID}) option in Dial()).
  4. When a call hangs up (I do it using h special extension).

My dialplan looks like this:

[from_origin]
exten => _X.,1,NoOp(${CALLER_USERNAME} from ${CHANNEL(pjsip,remote_addr)})
 same => n,AGI(agi://127.0.0.1/incoming)
 same => n,Dial(${DIALSTR},45,U(answer^${CALLID}))
exten => h,1,AGI(agi://127.0.0.1/hangup,${CDR(uniqueid)})

[answer]
exten => s,1,Set(theCallID=${ARG1})
 same => n,AGI(agi://127.0.0.1/answered)
 same => n,Return()

Look, I have called 3 fast-agi scripts: incoming, answered and hangup. Now I need to call similar script like ringing when the called party is "ringing". How to achieve this ?

Upvotes: 0

Views: 1168

Answers (1)

arheops
arheops

Reputation: 15247

Ringing status is status of the channel(chan_pjsip.so) and it not sent outside channel code.

So no, you can't get it in Dial app. Because it can't be get for some channels types and Dial still should work for those types.

For some channels you can get it via AMI in event listening loop in NewState event. But there are no garantee it will be exactly at same time when you got ringing sip message.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerEvent_Newstate

Upvotes: 1

Related Questions