Search

Tuesday, April 13, 2010

Detect incoming fax on sip channels

 

To detect incoming fax on sip channel, we need to install nvfaxdetect (vs zap channel can support fax detection natively)

 

cd /usr/src

wget http://nerdvittles.com/aah15/app_nv_faxdetect.c

 

Howerver, you might need to make some modifications in the source code to order to compile the nvfaxdetect.

 

  • Search for and comment out all lines with: "LOCAL_USER_ADD(u);".
  • Search for and comment out all lines with: "LOCAL_USER_REMOVE(u);".
  • Search for and comment out all lines with: "STANDARD_HANGUP_LOCALUSERS;".
  • Add the following line to the very end of the file (change the second parameter/description to something that is applicable): "AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax Detection Application");".
  • #include <stdio.h>

After source code modification, we can proceed to Make.

  • Type "cd /usr/src/asterisk" (or respective Asterisk directory)
  • Type "make".
  • Type "make install".
  • Restart Asterisk by asterisk -rx "restart now"".
  • Verify by "show application like NVFaxDetect"  in the Asterisk CLI
  • If NVFaxDetect is installed, you should see below messages:
  •   -= Info about application 'NVFaxDetect' =-
  • [Synopsis]
    Detects fax sounds on all channel types (IAX and SIP too)
  • [Description]
      NVFaxDetect([waitdur[|options[|sildur[|mindur[|maxdur]]]]]):
    This application listens for fax tones (on IAX and SIP channels too)
    for waitdur seconds of time. In addition, it can be interrupted by digits,
    or non-silence. Audio is only 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 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.
          waitdur:  Maximum number of seconds to wait (default=4)
          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)
    Returns -1 on hangup, and 0 on successful completion with no exit conditions.
We can use NVFaxDetect in dial plan similar to below.
exten => 120,n,NVFaxDetect(4|dt)
exten => 120,n,MoOp(CALLERID)
exten => 120,n,Macro(take-msg,${CALLERID(num)}, ${EXTEN}) // send to voicemail if voice
; if fax, send to a real fax maachine
exten => fax,1,NoOp
exten => fax,n,StopPlaytones
exten => fax,n,Dial(IAX2/zonefax29)

1 comment:

  1. I installed asterisk 13 and this don't work, error in compile time.

    ReplyDelete