2015.05.05 19:54
https://wiki.asterisk.org/wiki/display/AST/T.38+Fax+Gateway
Initial support for handling of T.38 sessions was merged into the Asterisk 1.4 codebase. Inside of Asterisk 1.4, it is possible to perform what is referred to as T.38 passthrough. T.38 Passthrough allows Asterisk to carry T.38 UDPTL from one T.38-speaking endpoint to another T.38-speaking endpoint. Asterisk does not modify the media. Asterisk 1.6, in addition to its T.38 passthrough capabilities, introduced T.38 termination support, such that T.38 fax sessions could be initiated from locally stored TIFF files (SendFax) or that T.38 fax sessions could be terminated into locally stored TIFF files (ReceiveFax). The basic faxing capabilities of Asterisk 1.8 remained the same as 1.6.
The limitation of these versions of Asterisk is that while 1.6 - 1.8 are fully capable of passing through or terminating T.38 sessions, there is no capability for T.38 gateway. Older versions of Asterisk cannot directly pass a fax from the PSTN or a non-T.38 endpoint to a T.38 endpoint. Instead, older versions of Asterisk require that two separate calls be established - e.g. one to receive the Fax into a TIFF file (ReceiveFax), and an entirely separate call to send the Fax from a TIFF file to a fax machine (SendFax), or vice versa.
Asterisk 10 overcomes this limitation and provides full T.38 Fax Gateway support. T.38 Gateway provides a number of advantages over the older, two-step store-and-forward method (generally referred to as T.37). Advantages include: end-to-end confirmation of receipt (with two separate calls the callee doesn't necessarily know the caller was trying to send them a fax), reduced time to fax (not receiving and then sending separately cuts the time in half), and increased reliability (no concerns about the reliability of local file storage or the TIFF interpreters).
In order to affect this new T.38 Gateway capability, an additional option, gateway, has been added to the FAXOPT Dialplan Function. Enabling this option can be done like:
exten => 1,1,NoOp() exten => 1,n,Set(FAXOPT(gateway)=yes) exten => 1,n,Dial(SIP/mypeer,20)
Here, we use the gateway option in combination with the Dial application:
T.38 Gateway mode should be used when one leg of a call is not capable of T.38 mode. In the event that both legs are capable and Gateway mode is configured, then the Gateway will step out of the way, allowing transparent T.38 passthrough.
The T.38 Gateway code uses an audiohook to monitor the line for the presence of fax. The monitoring checks for both V.21 preamble and T.38 Re-INVITE from the remote party. If neither is detected within a 10 second window, the Gateway shuts down, removing the audiohook from the channel, and allows the call to complete transparently.
It is also possible to use Gateway mode in combination with local Termination mode for calls received by Asterisk - if, for example the second call leg to a peer or number is not possible. In order to accomplish this, Gateway mode must be disabled on the current channel, or the ReceiveFax application will not be run. This can be accomplished like:
exten => 1,1,NoOp() exten => 1,n,Set(FAXOPT(gateway)=yes) exten => 1,n,Dial(SIP/mypeer,20) exten => 1,n,Verbose(Failed to dial 'SIP/mypeer': ${DIALSTATUS}) exten => 1,n,Set(FAXOPT(gateway)=no) exten => 1,n,ReceiveFax(myreceivedfile.tiff,d)
By default, gateway mode will remain enabled throughout the life of a channel. An optional timeout can be enabled to automatically disable gateway mode if there is no fax activity a given time after two channels are bridged. Enabling a timeout also has the side effect of reserving fax resources for a channel. The timeout can be enabled by passing second parameter (a timeout in seconds) when setting FAXOPT(gateway)
.
exten => 1,1,NoOp() exten => 1,n,Set(FAXOPT(gateway)=yes,10) ; disable gateway if there is no fax activity in 10 seconds exten => 1,n,Dial(SIP/mypeer,20)