Read dtmf using asterisk-java

倖福魔咒の 提交于 2019-12-11 13:02:26

问题


I am writing a java application to dial a number and get user's pin by DTMF. I am using asterisk-java connect to an asterisk VOIP server and dial the number but I don't know how to stream a file and read user's input as DTMF. Here's my code:

OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/1001");
originateAction.setContext("default");
originateAction.setCallerId("Server");
originateAction.setPriority(1);

// connect to Asterisk and log in
managerConnection.login();
// send the originate action and wait for a maximum of 30 seconds for Asterisk
// to send a reply
ManagerResponse originateResponse = managerConnection.sendAction(originateAction, 30000);

// print out whether the originate succeeded or not
System.out.println(originateResponse.getResponse());

// and finally log off and disconnect
managerConnection.logoff();

回答1:


You are using AMI.

There are no way get dtmf in AMI without dialplan support. You can get event via ami using something like this in dialplan

exten => s,1,Read(variable,filetoplay)
exten => s,2,UserEvent(variable: variable)

Or you can use fastagi to control call execution and collect dtmf



来源:https://stackoverflow.com/questions/23472983/read-dtmf-using-asterisk-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!