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.
UPDATE FOR ASTERISK 1.4.24+ USERS
Working version for Asterisk 1.4.24+
http://www.austechpartnerships.com/app_nv_1.4.2x_07052010.tar.gz
Tested with 1.4.26, 1.4.26.1, 1.4.31.
Also includes NVBackgroundDetect but was untested. Module compiles and loads into Asterisk properly so presumptions would be that it works as well.
Files included in tarball:
app_nv_backgrounddetect.c
app_nv_backgrounddetect.c.1.4.2x.patch
app_nv_faxdetect.c
app_nv_faxdetect.c.1.4.2x.patch
app_nv_Makefile.patch
README
Enjoy!!!
//Drew Thomson
See also
- NewmanTelOnAsterisk14 – Instructions to modify Newman Telecom modules for use on Asterisk 1.4.0
- NVFaxDetect – Detects fax, talk, DMTF, and other tones on IAX, SIP, ZAP, and other channels
- NVLineDetect – Detects answer, busy, congestion, dialtone, dead, and others on IAX, SIP, ZAP, and other channels
- NVFaxEmail – Integration of SpanDSP, RxFax, and e-mail; quick and simple to use without scripts
- Asterisk fax
- Asterisk Fax to email
- T.38 – The present future for fax over IP (FoIP)
- Answering Machine Detect
- VBS Fax Server