Summary:ASTERISK-09108: Inband DTMF Double digits being sent.
Reporter:Remi Quezada (remiq)Labels:
Date Opened:2007-03-26 16:46:38Date Closed:2010-04-27 12:45:50
Versions:Frequency of
Environment:Attachments:( 0) channel.patch
( 1) dsp.patch
Description:When dtmfmode is set to inband for SIP or when using IAX2, you can hear the DTMF digit twice in the audio stream.  This happens while Asterisk is parsing the DTMF.  For a fraction of a second, while the end user generated DTMF is being detected, the DTMF is passed inband.  Once the DTMF is detected Asterisk silences it and regenerates it.  Sensitive machines like auto attendants pick up both the brief end user generated tone as well as the full length asterisk generated tone and ultimately perceive each digit twice. I was able to eliminate this by not letting Asterisk silence and regenerate the DTMF digit.  I've attached a fix, I removed some code from channel.c and dsp.c .
Comments:By: Joshua C. Colp (jcolp) 2007-03-26 17:40:04

I wouldn't consider removing the code that generates inband DTMF tones a good solution...

By: Remi Quezada (remiq) 2007-04-02 15:01:48

What would be a good solution?

By: Ken Leland (kenlee) 2007-04-27 15:21:44

This patch renders asterisk incompatible with any out of band dtmf technology.  With DTMF regeneration totally disabled, DTMF generated out of band is never added to the audio stream when bridging with the PSTN.

I have reproduced the original problem tho.  It is easily experienced with a sip user set to inband.
-Dial a PSTN number from a sip phone using inband DTMF.
-Press and hold a digit on the sip phone.  On the PSTN phone you will hear a very brief, end user generated, tone.
-Let go of the digit on the sip phone.  On the PSTN phone you will hear the asterisk generated tone.

Perhaps a fix would be to conditionally turn off silence and regeneration.  If the DTMF will leave asterisk inband i do not see the sense in silencing it and regenerating it.  Only if the two bridged channels have a difference of opinion between in band and out of band DTMF transmission should you need to silence or regenerate.

By: Ken Leland (kenlee) 2007-05-01 16:38:19

The standard minimum duration for DTMF seems to be 40 ms.  Below I have listed several references that support that figure.  

Excerpt from Asterisk source code (dsp.c)(Asterisk 1.2.14):
/* Basic DTMF specs:
* Minimum tone on = 40ms

It might be valuable to this problem to know:

A) How long a tone needs to be transmitted for Asterisk to detect the DTMF.
dtmf_detect.c:128: * Minimum tone on = 40ms
This comment suggests 40ms but i have been unable to confirm this in the code.

B) In the worst case how long will Asterisk allow DTMF to be transmitted before detecting and silencing it?  It seems logical this could be related to the packetization characteristics of the sip phone.

Thanks in advance for any thoughts or suggestions.

By: Ken Leland (kenlee) 2007-05-08 09:54:16

There have been some asterisk-users mail about this:

By: Justin F Rush (justinrush) 2007-05-23 11:28:57

I've seen a lot of discussion of this issue, but no real resolution. This is definitely a problem in 1.2, and I'm starting to get multiple reports each day.

If the aforementioned patch is not a good solution, is there any official solution or relatively safe workaround?

By: Joshua C. Colp (jcolp) 2007-08-03 09:51:58

1.2 has now entered a security fixes only state. If this issue (which it shouldn't be with our vldtmf changes) is still applicable to 1.4 please reopen.