DTMF problem with voice intermixed


I am using the release of Asterisk 1.4.42 and discovered that if Asterisk receives a DTMF RTP event followed by an audio RTP packet each with different timestamps, it will end the digit and thus produce incorrect digits. According to searches, this problem seems to have been fixed in Asterisk 1.4 in earlier releases, but that change seems to have been lost. The problem seems to be in rtp.c in the ast_rtp_read function. An if near the bottom:

if (rtp->dtmf_timeout && rtp->dtmf_timeout < timestamp)

does not take into account that the timestamp might be different for a non-RTP event packet. To make the server happy, I added “&& payloadtype==101” to the IF. Not an elegant solution, was hoping someone could post a better solution.