Asterisk AMI: DTMF not received on SIP channel

2019-09-05 06:38发布

问题:

I'm sending DTMF to Asterisk using python and pyst. The code is:

def playDTMF(self, channel, digit):
        print "DTMF: Sending %s to %s" % (digit, channel)
        response = self.manager.send_action({
            "Action" : "PlayDTMF",
            "Channel" : channel,
            "Digit" : digit
        })
        print "DTMF: %s - %s" % (response['Response'], response['Message'])

Output of the script is good:

DTMF: Sending 1 to SIP/S3bc9c3c-00000081
DTMF: Success - DTMF successfully queued

But Asterisk reacts to it like that:

[Jul  2 17:48:53] DEBUG[6967] manager.c: Running action 'PlayDTMF'
[Jul  2 17:48:53] DEBUG[6967] channel.c: Set channel SIP/S3bc9c3c-00000081 to write format slin
[Jul  2 17:48:53] DEBUG[6967] channel.c: Scheduling timer at (50 requested / 50 actual) timer ticks per second
[Jul  2 17:48:53] DEBUG[6967] channel.c: Thread 140629726328576 Blocking 'SIP/S3bc9c3c-00000081', already blocked by thread 140628353554176 in procedure ast_
waitfor_nandfds

The interesting thing is that this happens only on SIP channel. On "Local" channel it works as expected:

[Jul  2 18:00:07] DTMF[7951]: channel.c:4083 __ast_read: DTMF begin '1' received on Local/901@AC000001-19ca;1
[Jul  2 18:00:07] DTMF[7951]: channel.c:4093 __ast_read: DTMF begin passthrough '1' on Local/901@AC000001-19ca;1

How can I let DTMF play properly on SIP channel?

UPD

Found this on Asterisk bugtracker: https://issues.asterisk.org/jira/browse/ASTERISK-13224

Seems that if I send DTMF to SIP channel phone just plays it for himself, and it doesn't go further to Asterisk. Is there any way to deal with it?

回答1:

use SendDTMF appliction. SendDTMF(digits[|timeout_ms])



回答2:

In your SIP.CONF, ensure you have

dtmfmode=rfc2833

for your appropriate SIP trunk. Often sending DTMF inband (audio) with SIP doesn't work as well as you might hope.