Summary:ASTERISK-18569: Extend the use of Wait to intergrate with res_fax and detect fax/voice
Reporter:Gregory Hinton Nietsky (irroot)Labels:
Date Opened:2011-09-17 12:10:07Date Closed:2011-10-05 07:13:53
Versions:Frequency of
Environment:VariousAttachments:( 0) faxdetect.patch
Generic Fax Detect CNG/T.38 (Wait For Fax)

This application sets FAXOPT(status) To SUCCESS | FAILURE | ERROR
FAXOPT(statusstr) will be set to CNG | T38 on SUCCESS or reason on FAILURE


   Specifies the number of seconds we attempt to detect a fax tone on
   the channel
   Either the tone name defined in the "indications.conf" configuration
   file, or a directly specified list of frequencies and durations.
   If not specified silence is generated.
   Number of ms noise detected before proceeding with the dialplan.

exten => s,n,WaitFax(4,ring,150)
exten => s,n,GotoIf($[${FAXOPT(status)} = SUCCESS]?fax,${ARG1},2)

This will wait 4s playing ring tone and will break the loop when 150ms of voice is detected or 4s expires.

this allows a dialplan fax detection with or without channel faxdetect.

the problem with fax detect in the channel this happens when the channel is answered it may be routed to a fax machine already when it answers and then bounces to the fax exten to get routed back to the fax it will be busy.
Comments:By: Kevin P. Fleming (kpfleming) 2011-09-23 11:54:04.919-0500

I'm still not sure I understand why this would be the solution to any particular problem.

The issue with faxdetect being enabled on a channel when it does not need to be can be solved by extending the CHANNEL() dialplan function to be able to enable/disable faxdetect from the dialplan on a specific channel.

I do agree, though, that it would be ideal if faxdetect functionality did not have to live in the channel drivers; it results in a lot of code duplication, and many channel drivers don't have it that really do need it. I don't think that WaitFAX is the solution, because there are valid application for faxdetect triggering long after the initial few seconds of a call.

How about this as an alternative? Build a framehook-based method of doing faxdetect that can be used on *any* channel, and added/removed from a channel via the dialplan (just like the T.38 gateway framehook can be). If the framehook sees a FAX trigger (CNG, T.38 negotiation, maybe others) then it would redirect the channel to a context/extension (defaulting to 'fax' in the current context), and set one or two channel variables to indicate what it saw (including which 'direction' the trigger was seen (read or write)).

If we had this, then we could remove faxdetect from all the channel drivers that have it and also be able to provide faxdetect on the drivers that don't have it. The only downside to this would be that some channel drivers *might* be able to do CNG detection more efficiently than using a software DSP... but we can cross that bridge when we come to it.

By: Gregory Hinton Nietsky (irroot) 2011-09-26 12:38:13.471-0500

Indeed ill be working on this thx for the feedback

By: Gregory Hinton Nietsky (irroot) 2011-09-26 12:38:41.880-0500

Need to put some dev work in

By: Gregory Hinton Nietsky (irroot) 2011-10-02 03:09:07.860-0500

Add a "faxdetect" framehook into res_fax that can be used as generic faxdetect from dialplan or channel drivers.

remove function OOH323 and move its purpose to func CHANNEL where it bellongs.

this patch does not take into account some channel specific requrements and needs to be more flexiable but is a working first version for comment

By: Gregory Hinton Nietsky (irroot) 2011-10-02 03:23:29.597-0500

Patch against trunk not branch

By: Gregory Hinton Nietsky (irroot) 2011-10-05 07:13:53.557-0500

Should have closed on SVN commit