SIP Fax detection with Asterisk

Here it goes again, still the same problems for detecting voice based fax calls on Asterisk 1.6.

I know that « we should use T38 » or « get a decent SIP provider » are all along the way but hey! I’m using Free with it’s freephonie service in France and we’re even getting multiple ADSL connections (from different companies that are in the same building) and bridged them together to an Asterisk server.

It’s very handy, we get SIP trunking for a very small fee : free 🙂 but in fact it’s in a whole package for 30€ per month : ADSL2+, Free telephony, HD TV (tax included)

So, I wanted to post about the recent « patch » I prepared after upgrading to Asterisk

Why upgrade to a beta version ? Simple, since there was advertised Fax detection support for T38 (which should work, I didn’t test since I don’t have a decent provider with T38 support 😉 ).

Looking at the chan_sip.c code I figured out it was very easy to tweak the fax detection code to also do detection on SIP audio channels,but … I was plain wrong ! In fact it could have worked but it’s much more difficult than it seems. To make a long story short, I looked more deeply at the NV Faxdetect applications (from Justin Newman) and in fact they use a similar approach that the one I finally got through : use Asterisk DSP to actually do the detection and then branch on the dialplan to « fax » extension (code already done in 1.6.2 for T38 only).

Removing specific T38 tests I almost got through after spending 3 hours to finally get to a point that was very near NV Faxdetect : I first had to switch to slinear before using DSP (or it wouldn’t detect faxes at all, if someone knows why please tell me 🙂 ) and then switch back to alaw or ulaw (what came first) to get the call through.

Seing that I needed to patch chan_sip.c alot with very dirty hacks I finally decided to go back on app_nv_faxdetect.c and app_nv_backgrounddetect.c and simply patch them (with very little effort surprisingly) and got them to work perfectly with Asterisk (the patch should certainly apply to later 1.6.2.x version relatively cleanly, just make sure to apply it on vanilla sources *before* ./configure and make menuselect ; issue a make distclean if you didn’t)

I remembered I used to leave some mails to Justin, asking me to wait for a new version to come out and many people on seemed to have tried to patch it (or at least asked to) and noone managed to get a working version for 1.6.x.

Here it goes, but I’m very surprised I had to change very little portions of code (nothing really important, only definition and variable name changes) and everything has been working very well here for more than 2 weeks, with more than a dozen faxes correctly detected.

If you need to, leave me a comment since I started to test at home (yes I also have an Asterisk box at home 😉 ) and I patched a version for Asterisk that compiled and worked flawlessly.

Be sure to grab the patch attached here and enjoy your fax detection on voice part of SIP channels 🙂


See you for other Asterisk weirdnesses, I have some more to post !!

9 réponses sur “SIP Fax detection with Asterisk”

  1. Bonjour, j’ai testé votre patch avec la version d’asterisk sur freebsd et impossible de compiler Asterisk AGX.

    auriez-vous d’autres infos, je n’ai besoin que de nv_faxdetect comme fonction, j’utilisais Asterisk Agx, mais il n’existe pas pour les versions 1.6.

    Merci d’avance

    1. Bonjour Hubert,

      J’ai du redescendre de version d’Asterisk ici pour des raisons de stabilité et le patch marche également sur 1.6.1.x.
      Il faut l’appliquer sur les sources fraichement décompressées avant de faire le configure sinon le menuselect n’est pas forcément bien généré.
      Par contre il s’utilise à part de AGX, enfin en tout cas ce n’est pas prévu pour.
      Pouvez-vous tester sans AGX et me dire si vous arrivez à le compiler ?

      Bon courage,

  2. The patched version complains about the delimiter (Asterisk doesn’t like pipe any more and wants a comma instead)

    I believe changing these lines could fix it:
    + filename = strsep(&p, « | »);
    + options = strsep(&p, « | »);
    + silstr = strsep(&p, « | »);
    + minstr = strsep(&p, « | »);
    + maxstr = strsep(&p, « | »);

  3. Hi,
    I have been trying to use spandsp with asterisk 1.6.2 but doesnot work. can you please give a direction ?


Les commentaires sont fermés.