login | register
Sat 04 of Jul, 2009 [05:34 UTC]

voip-info.org

History

NVBackgroundDetect

Created by: justin_newman,Last modification on Tue 03 of Mar, 2009 [02:10 UTC] by jq53333

Background with Fax Detection for IAX/SIP/ZAP

Including non-silence and digit detection. Search the web for the code.

Synopsis

 Background a file with talk and fax detect (on IAX and SIP too)

Description

 NVBackgroundDetect(filename[|options[|sildur[|mindur[|maxdur]]]])

Plays filename, waiting for interruption from fax tones (on IAX/SIP too), a digit, or non-silence. Audio is monitored in the receive direction. If digits interrupt, they must be the start of a valid extension unless the option is included to ignore. If fax is detected, it will jump to the 'fax' extension. If a period of non-silence is greater than 'mindur' ms, yet less than 'maxdur' ms is followed by silence at least 'sildur' ms then the app is aborted and processing jumps to the 'talk' extension. If all undetected, control will continue at the next priority.

Parameters

     options:
       'n':  Attempt on-hook if unanswered (default=no)
       'x':  DTMF digits terminate without extension (default=no)
       'd':  Ignore DTMF digit detection (default=no)
       'f':  Ignore fax detection (default=no)
       't':  Ignore talk detection (default=no)
     sildur:  Silence ms after mindur/maxdur before aborting (default=1000)
     mindur:  Minimum non-silence ms needed (default=100)
     maxdur:  Maximum non-silence ms allowed (default=0/forever)

Return codes

Returns -1 on hangup, and 0 on successful completion with no exit conditions.

Notes

This code is NOT included with Asterisk at this point, however it is free. To get it, search the web.

This should only work on channels that are using ULAW/ALAW.

Requirements

  • Asterisk development or stable

Sample Usage (extensions.conf)

[context-incoming]
; Answer and do some detection work
exten => s,1,Answer
exten => s,2,NVBackgroundDetect(welcome)
exten => s,3,Hangup

; If user presses "1", dial main line
exten => 1,1,Dial(SIP/5500)
exten => 1,2,Hangup

; If this is a fax, dial fax line
exten => fax,1,Dial(SIP/5501)
exten => fax,2,Hangup

; If user is talking, send him to Debra
exten => talk,1,Dial(SIP/5502)
exten => talk,2,Hangup

Installation

Easiest way to get up and running:

(1) Drop the code in your /usr/src/asterisk/apps directory

(2) Edit the Makefile in the apps directory. Add the following line:
    APPS+=app_nv_backgrounddetect.so

(3) Go to /usr/src/asterisk and run "make", then run "make install"

   If you encounter compiler errors like:

         error: struct ast_channel has no member cid

   Edit app_nv_faxdetect.c and enable the CALLERID_FIELD #define statement:

        #define CALLERID_FIELD cid.cid_num

  Comment out the other, existing definition.

(4) Start or restart Asterisk

(5) Type "show application nvbackgrounddetect" from the CLI and you should see it


Future Improvements

We are working on answering machine detection for this module.

See also



Comments

Comments Filter
222

333NV*Detect on FreeBSD

by kFuQ, Friday 07 of July, 2006 [03:58:04 UTC]
add
#include <stdio.h>

right above file.h line in both the faxdetect and backgrounddetect .c files



note: if so many people are having to add stdio.h, then why isn't it coming "stock" ?

222

333

by lschweiss, Tuesday 06 of June, 2006 [15:14:13 UTC]
222

333More code mods for 1.2.4?

by rdk, Friday 03 of February, 2006 [13:22:38 UTC]
Hi!

With 1.2.4, I needed to add the following to includes to get the code to compile successfully on FC4:

  1. include <stdio.h>
  2. include <string.h>
  3. include <stdlib.h>
  4. include <unistd.h>

The unistd.h include, defines various UNIX defs such that some pthread defines are enabled. I also added the above includes to app_nv_faxdetect.c as well.
222

333NVBackgroundDetect on Debian Sarge

by icheb, Saturday 10 of December, 2005 [22:11:11 UTC]
It works the same as the NVFaxDetect, compile it in the same way.
So far it worked like a charm.

This is how I got this done for NVBackgroundDetect:

Marcel Prisi on Monday 21 of November, 2005 21:12:27
I successfully installed this app on Debian Sarge using the following method, keeping the official packages :

Install the official sarge asterisk packages : apt-get install asterisk asterisk-dev
Download app_nv_faxdetect.c, edit and replace "#define CALLERID_FIELD cid.cid_num" by "#define CALLERID_FIELD callerid"
Compile it using "gcc -D_GNU_SOURCE -shared -o app_nv_faxdetect.so app_nv_faxdetect.c"
Copy the resulting app_nv_faxdetect.so to /usr/lib/asterisk/modules/

Restart asterisk and enjoy :-)

222

333NVBackgroundDetect on Asterisk 1.2 (and/or AMP or @home Beta)

by justin_newman, Thursday 24 of November, 2005 [00:06:39 UTC]
If you are unable to build NVFaxDetect and/or NVBackgroundDetect on Asterisk
1.2 (and/or AMP or @home Beta), make the following changes:

1) Above the following line near the top, in both files:

   #include <asterisk/lock.h>

   Add:

   #include <stdio.h>

2) In NVBackgroundDetect, to get rid of the trigraph warning, search for
"??)" and replace it with "?)".

3) Rebuild Asterisk from /usr/src/asterisk with "make && make install".

4) Restart Asterisk with "restart now" from the CLI.

The new release will have this modification.

Justin