Wednesday, June 24, 2009

Getting the result of Netborder Call Progress Analyzer to an Asterisk variable

/* Parse contact header for continued conversation */
/* When we get 200 OK, we know which device (and IP) to contact for this call */
/* This is important when we have a SIP proxy between us and the phone */
if (outgoing) {
int cpdstart=0;
const char *cpdresult = __get_header(req,"CPD-Result",&cpdstart);

if (!ast_strlen_zero(cpdresult))
pbx_builtin_setvar_helper(p->owner, "CPDRESULT", cpdresult);
update_call_counter(p, DEC_CALL_RINGING);

Add the above bold code in chan_sip.c and you will get the Call Progress Detection result in asterisk Dial plan.

If you originate a call through AMI, with the dialplan,

exten => _8.,1,Answer
exten => _8.,2,Noop(${CPDRESULT})
exten => _8.,3,Echo


You will see in the asterisk console similar to this,


-- Executing [8dfgdfgdfgdfgdgdgdfgd@something:1] Answer("SIP/963258-10058d50", "") in new stack
-- Executing [8dfgdfgdfgdfgdgdgdfgd@something:2] NoOp("SIP/963258-10058d50", "Answering-Machine") in new stack
-- Executing [8dfgdfgdfgdfgdgdgdfgd@something:3] Echo("SIP/963258-10058d50", "") in new stack


In this case it is Answering-Machine.

No comments: