[Freeswitch-users] Bridging after sending dtmf

Alex Zarubin ZAlex at webley.com
Sat Mar 17 01:57:47 MSK 2012


Hello,

Here are two dialplan examples of the simple thing I'm failing to do -
bridge inbound (external profile) and outbound (internal profile) sip
calls after sending some dtmf sequence to the outbound leg. In both
cases (and several more I've tried) calls are bridged right after
outbound leg picks up and dtmf are sent after the bridge. I would
greatly appreciate your help/hints.

Thank you.

Alex

----------------------------------------------------------------------
Example 1.

<include>
  <extension name="bridge_pre_exec">
    <condition field="destination_number" expression="^preexec$">
      <action application="log" data="INFO bridge_pre_exec request
(${dtmfseq}) (${destination}) (${destip})"/>
      <action application="answer"/>
      <action application="set"
data="bridge_pre_execute_bleg_app=send_dtmf"/>
      <action application="set"
data="bridge_pre_execute_bleg_data=w#w${dtmfseq}"/>
      <action application="bridge"
data="sofia/internal/${destination}@${destip}"/>
      <action application="hangup"/>
    </condition>
  </extension>
</include>
----------------------------------------------------------------------

Example 2.

<include>
  <extension name="lua_async">
    <condition field="destination_number" expression="^luaasync$">
      <action application="log" data="INFO luaasync request (${dtmfseq})
(${destination}) (${destip})"/>
      <action application="set" data="api_result=${bgapi(lua
lua_async.lua ${dtmfseq} ${destination} ${destip} ${uuid}
${caller_id_number})}"/> 
      <action application="answer"/>
      <action application="park"/>
      <action application="hangup"/>
    </condition>
  </extension>
</include>

Script lua_async.lua :

dtmfseq = argv[1];
phone = argv[2];
destip = argv[3];
leg1uuid = argv[4];
cid = argv[5];

ands = ") and (";
logline = "Lua called with (" .. dtmfseq .. ands .. phone .. ands ..
destip .. ands .. leg1uuid .. ands .. cid .. ")\n";
freeswitch.console_log("info", logline);

api = freeswitch.API();

sofia_destination = "[origination_caller_id_number=" .. cid ..
"]sofia/internal/" .. phone .. "@" .. destip;
new_session = freeswitch.Session(sofia_destination);
dispo = "None";

while (new_session:ready() and dispo ~= "ANSWER") do                 
 dispo = new_session:getVariable("endpoint_disposition")

 freeswitch.consoleLog("INFO", "disposition is '" .. dispo .. "'\n")
 os.execute("sleep 1")
end -- while

leg2uuid = new_session:get_uuid();
logline = "Lua leg2uuid (" .. leg2uuid .. ")\n";
freeswitch.console_log("info", logline);

new_session:setAutoHangup(false);

exestr_cmd = "uuid_send_dtmf " .. leg2uuid .. " w#w" .. dtmfseq;
logline = "Lua calling api:executeString(" .. exestr_cmd .. ")\n";
freeswitch.console_log("info", logline);
api:executeString(exestr_cmd);
freeswitch.console_log("info", "Lua after api:executeString(...)\n");

exestr_cmd = "uuid_bridge " .. leg1uuid .. " " .. leg2uuid;
logline = "Lua calling api:executeString(" .. exestr_cmd .. ")\n";
freeswitch.console_log("info", logline);
api:executeString(exestr_cmd);
freeswitch.console_log("info", "Lua after api:executeString(...)\n");

 
This message and any attachments to it are intended only for the addressee(s) identified above and may contain CONFIDENTIAL information. It is not intended for transmission to, or receipt by, any unauthorized persons.  If you are not an intended recipient or an agent responsible for delivering it to an intended recipient, you have received this e-mail in error and any dissemination, distribution, or copying of this message or any attachment to it is strictly prohibited. If you have received this email in error, please (i) do not read it, (ii) reply to the sender that you received the message in error, and (iii) erase or destroy the message from your system.



Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list