[asterisk-dev] Originated Calls and Progress Detection

Dmitry Andrianov dimas at dataart.com
Sun Dec 9 14:20:16 CST 2007


Asterisk already has DSP code to detect call progress.
The code is located in main/dsp.c. It supports only a few countries us/ca/cr/br/uk

If you are working with Zap channels, you can activate call progress detection just an option in the Zapata.conf like

callprogress=yes
progzone=us

And Asterisk will do all the DSP works necessary. If you are working with SIP/whatever, you will probably need to fix the code in order to pass all frames to DSP routines.


From: asterisk-dev-bounces at lists.digium.com [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Whit Thiele
Sent: Sunday, December 09, 2007 10:34 PM
To: asterisk-dev at lists.digium.com
Subject: [asterisk-dev] Originated Calls and Progress Detection


Hi,

I am trying to accomplish something specific in the asterisk code base and was looking for some feedback on a better direction to take:

When using the manager "Originate" command, a there is a call to the method __ast_request_and_dial which goes into a while loop until the call is either answered (AST_STATE_UP) or hits the timeout.

During this while loop, I want to detect what is happening on the channel itself an try to determine if it is actually ringing, playing a SIT tone (or message) and therefore be able to accurately determine the final disposition of a failed call.

My first attempt (which is very much a hack) times the difference in receiving frames during the ast_waitfor() call  in an attempt to determine if there is actually Ringing and how many rings in total:

Here is the code for the modified ast_waitfor:

int ast_waitfor(struct ast_channel *c, int ms, int *dif)
{
        int oldms = ms; /* -1 if no timeout */

        ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
        int diz = oldms - ms;
        *dif = diz;
        ast_log(LOG_DEBUG, "WAIT DIF WAS '%d' \n",diz);
        if ((ms < 0) && (oldms < 0))
                ms = 0;
        return ms;
}


Here is the section in ast_request_and_dial:

// snip

int span = 0;
int ringcount = 0;
int isValidTO = 0;
                while (timeout && chan->_state != AST_STATE_UP) {
                        struct ast_frame *f;
                        span = 0;
                        res = ast_waitfor(chan, timeout, &span);
                        if (res <= 0) /* error, timeout, or done */
                                break;
                        if (timeout > -1)
                                timeout = res;

                        if (span > 500)
                                ringcount++;

                        if (ringcount > 3){
                                isValidTO = 1;
                                /* ast_log(LOG_DEBUG, "THIS IS A VALID CALL\n"); */
                                 *outstate = AST_CONTROL_RINGING;
                        }else{
                                *outstate = AST_CONTROL_CONGESTION;
                                /* ast_log(LOG_DEBUG, "NOT SURE THIS IS A VALID CALL\n"); */

                        }

// end snip


Obviously, this is NOT the way to accomplish this task. I need some direction on how to hook up some sort of DSP to try to determine the progress of these Manager originated calls while they are being dialed.

Regards,

Whit

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20071209/01bfffa2/attachment-0001.htm 


More information about the asterisk-dev mailing list