[Home]

Summary:ASTERISK-12262: [patch] T38 gateway for asterisk 1.4
Reporter:Daniel Ferenci (dafe_von_cetin)Labels:
Date Opened:2008-06-26 10:06:58Date Closed:2008-07-29 10:15:15
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Addons/New Feature
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) asterisk-1.4.20.1_t38.diff
( 1) asterisk-1.6.trunk_t38.diff
Description:Hi all,

I'm sending you patch containing backport of T38 terminate functionality from asterisk 1.6 + backported app_fax.c (with T38) application + new application app_faxgateway.c ("FaxGateway").

Feature is using spands library (I used spandsp-0.0.4pre18 and spandsp-0.0.5pre4).

Tests:
Tested on SIP and SS7 channels.
Tested gateway modes T30<->T38.
Tested with Linksys SPA2102.

I don't think I've tested everything so changes are possible.

Best regards
Daniel.


****** ADDITIONAL INFORMATION ******

There are two known bugs that I was not able to fix yet.
1. 100% CPU usage when gatewaying

I used profiler (gprof)and found that ast_waitfor_n used about 95% of the whole time. I don't know what is the problem inside ast_waitfor_n.

2. Problem when using ast_indicate and ast_set_write_format in the same application.
ast_indicate installs playtones generator (indications.c) that sets its own write format  - AST_FORMAT_SLINEAR and makes a backup of write format of the channel.
application itself uses ast_set_write_format AST_FORMAT_SLINEAR.
When calling ast_write it comes to this point:
if (chan->generatordata) {
               if (ast_test_flag(chan, AST_FLAG_WRITE_INT))
                       ast_deactivate_generator(chan);
ast_deactivate_generator calls playtones_release that resets format back to original format of the channel (in my case AST_FORMAT_ALAW).
This causes that path from AST_FORMAT_SLINEAR to AST_FORMAT_ALAW stops existing and ast_write returns with error (because channel requires AST_FORMAT_ALAW but the frame is AST_FORMAT_SLINEAR).

Is there anybody  with simillar experiences? Can you please help?
Thank you in adavance.

Comments:By: Jason Parker (jparker) 2008-06-26 11:08:25

Any new features would need to be against svn trunk.

Could you please create a new patch against svn trunk?  Also, I'd like to see the origins of this code described in a little more detail.  You stated that it's a backport, but I'm not aware of this functionality already existing in Asterisk.

By: Daniel Ferenci (dafe_von_cetin) 2008-07-04 05:52:20

I'm attaching faxgateway patch for the trunk version of the asterisk.
T38->T38 mode doesn't work yet on trunk.

Here is the deeper description of the patch for version 1.4 and the later patch for trunk version:

By termination of T38 call I understand a way how T38 call can be initiated/terminated by signaling protocol (for example by SIP) and then processed by other data protocols UDPTL, T38. Asterisk 1.6 contains functionality that enables user to create a T38 call, change call to T38 call, pick up a T38 call.
However asterisk (neither 1.4 nor 1.6) itself doesn't understand T.38 protocol. app_faxgateway uses spandsp for this purpose.
SpanDsp is able to receive the T38 data and make a tiff out of a call, to provide a gateway between T30 and T38 protocols.

asterisk-1.4.20.1_t38.diff contains code from asterisk-1.6 except app_faxgateway.c that is new feature and small bugfix in chan_sip.c.

I'm not sure if this is what you wanted if not please reply and I will try to answer.

By: dovid (dovid) 2008-07-04 09:50:33

In order for this patch to work is there anything that needs to be set in sip.conf ? (I know about the 100% usage but I can try it on a test box).

By: Daniel Ferenci (dafe_von_cetin) 2008-07-04 10:27:01

Yes in order to switch on udptl (and thus T38) support for SIP, it is neccessary to add following into sip configuration file:
t38pt_udptl = yes
You can switch t38pt_udptl on in general or individualy per each sip device.

Then it is neccessary to have file udptl.conf in asterisk configuration directory.
I used the one with default content.

By: dovid (dovid) 2008-07-04 10:56:32

dafe_von_cetin: Are you available online ? I have a few more questions and don't want to go back and forth here.

By: Daniel Ferenci (dafe_von_cetin) 2008-07-05 00:10:15

Hi All, you can reach me at Mail + Jabber: daniel dot ferenci at googlemail dot com.

By: Alisher (licedey) 2008-07-07 12:30:16

I tried this patch in gateway mode T38<->T.30

Fax -------->[FXS ---* box1]---------T.38 VOIP-------[*box2 FXS]----Fax

It didn't work. The faxes are sent in G.711 ulaw.

By: Daniel Ferenci (dafe_von_cetin) 2008-07-07 12:40:28

Have you tried the 1.4 patch or trunk patch?
Can you switch the logs on? Can you send them?
Have you set t38pt_udptl = yes for Fax -------->[FXS ---* box1]?
Have you sniff it?
Are you sure that Fax has initiated communication in T38?

By: Alisher (licedey) 2008-07-08 03:38:36

I tried 1.4 patch with the 1.4.20.1 asterisk version.

I set both global and trunk t38pt_udptl=yes setting. Also I checked loaded modules app_faxgateway and app_fax were loaded. In the sip debug there were no T.38. I also took tests with ATA that supports T.38, it worked.

Could there be problem with dtmfmode or rx tx gain? Currently I use INBAND dtmf for SIP trunks.



By: Daniel Ferenci (dafe_von_cetin) 2008-07-08 06:54:14

Hi,
an important note: app_faxgateway doesn't work transparently.
You have to state it explicitly in extensions.conf or extensions.ael in the same way like for example Dial application.

For example:
exten =>_X.,1,FaxGateway(SIP/operator/${EXTEN})

Fax Gateway contains automatic switch over functionality.
It means if it detects incoming (by CED or CNG signals) Fax Call (just over g711!) then it tries to change call to the T38.

By: Alisher (licedey) 2008-07-09 11:23:28

I set FaxGateway(SIP/trunk/${EXTEN}) on caller server and Dial(Zap/4) on callee.
In CLI I can see that it tries to gateway T.38, call gets through, but fax fails, on the fax machine logs I can see that if fails to pickup the modulation, just CNGs and FSK. Usually,with ATAs it picks up V.29 or V.27 modulation at transmits faxes at 2400,4800 or 9600bps.

By: Daniel Ferenci (dafe_von_cetin) 2008-07-10 01:44:18

Thank you for the report.
First of all what version you have tested on?
There are problems with trunk version.
But patch for 1.4.20.1 should be stable.

Then please try to switch on logs to debug level and sent me the output.
Thank you in advance.
Daniel.

By: Martin Vit (festr) 2008-07-17 10:42:24

can i use FaxGateway(Zap/g1/xxx) for voice call? I'm testing

sip -> Zap/g1/xxx without fax (only testing dial). It consume 100% CPU and there are no voice (sniffed SIP traffic - it is OK). Log:

[Jul 17 17:45:04] DEBUG[5533]: channel.c:2808 set_format: Set channel Zap/33-1 to write format ulaw
[Jul 17 17:45:04] DEBUG[5533]: channel.c:2808 set_format: Set channel Zap/33-1 to read format ulaw
[Jul 17 17:45:04] DEBUG[5533]: channel.c:1804 ast_settimeout: Scheduling timer at 160 sample intervals
[Jul 17 17:45:04] DEBUG[4769]: chan_zap.c:9074 pri_dchannel: Queuing frame from PRI_EVENT_PROCEEDING on channel 0/2 span 1
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:623 transmit: faxGw - something happend on peer
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:639 transmit: faxGw - AST_FRAME_CONTROL
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:598 transmit: faxGw - waiting for activity on channels
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:623 transmit: faxGw - something happend on peer
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:598 transmit: faxGw - waiting for activity on channels
[Jul 17 17:45:04] DEBUG[4769]: chan_zap.c:1442 zt_enable_ec: Enabled echo cancellation on channel 2
[Jul 17 17:45:04] DEBUG[4768]: chan_sip.c:2109 __sip_autodestruct: Auto destroying SIP dialog '0343fbf87ed9df7e11ec99b8555a55ec@212.71.155.130'
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:623 transmit: faxGw - something happend on peer
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:639 transmit: faxGw - AST_FRAME_CONTROL
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:660 transmit: faxGw - AST_CONTROL_ANSWER
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:711 transmit: faxGw - connections build - ready 1 and erady to talk - 1
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:716 transmit: faxGw - ready to do gatewaing
[Jul 17 17:45:04] DEBUG[5532]: chan_sip.c:3796 sip_answer: SIP answering channel: SIP/222350122-0821f4f8
[Jul 17 17:45:04] DEBUG[5532]: chan_sip.c:6899 transmit_response_with_sdp: Setting framing from config on incoming call
[Jul 17 17:45:04] NOTICE[5532]: app_faxgateway.c:729 transmit: faxGw - original call answered
[Jul 17 17:45:04] NOTICE[5532]: app_faxgateway.c:761 transmit: Doing T.38 gateway [ 1,0]
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:382 ast_t38_gateway: faxGw - ast_t38_gateway entry
[Jul 17 17:45:04] DEBUG[5532]: app_faxgateway.c:399 ast_t38_gateway: chan 0x81fdb88  peer 0x81eb818 channels[0] 0x81eb818 channels[1] 0x81fdb88
[Jul 17 17:45:04] DEBUG[5532]: channel.c:2808 set_format: Set channel SIP/222350122-0821f4f8 to read format slin
[Jul 17 17:45:04] DEBUG[5532]: channel.c:2808 set_format: Set channel SIP/222350122-0821f4f8 to write format slin
[Jul 17 17:45:04] NOTICE[5532]: app_faxgateway.c:430 ast_t38_gateway: T.38 gateway started
[Jul 17 17:45:04] DEBUG[4768]: chan_sip.c:2208 __sip_ack: Stopping retransmission on '2126975476-5060-32@172.24.92.239' of Response 311: Match Found
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
[Jul 17 17:45:04] DEBUG[5532]: rtp.c:2771 ast_rtp_write: Ooh, format changed from unknown to alaw
[Jul 17 17:45:04] DEBUG[5532]: rtp.c:2788 ast_rtp_write: Created smoother: format: 8 ms: 20 len: 160
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
[Jul 17 17:45:04] WARNING[5532]: utils.c:1070 tvfix: warning negative timestamp 135410627.-1230240852
------

negative timestamps are logging until hangup.

By: wubbla (wubbla) 2008-07-17 10:45:04

Hi!
I am experiencing exactly the same behavior as festr.

By: Tilghman Lesher (tilghman) 2008-07-29 10:15:06

We do not accept new features added to the 1.4 series.  The 1.4 series was feature-frozen at the time of initial release.