[asterisk-dev] Originated Calls and Progress Detection
Whit Thiele
dev at whit.ca
Sun Dec 9 13:34:13 CST 2007
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/2005718c/attachment.htm
More information about the asterisk-dev
mailing list