diff options
Diffstat (limited to 'misc/freeswitch/scripts/dialplan_default.lua')
-rw-r--r-- | misc/freeswitch/scripts/dialplan_default.lua | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/misc/freeswitch/scripts/dialplan_default.lua b/misc/freeswitch/scripts/dialplan_default.lua index 7caff57..8fb9057 100644 --- a/misc/freeswitch/scripts/dialplan_default.lua +++ b/misc/freeswitch/scripts/dialplan_default.lua @@ -8,13 +8,28 @@ function hangup_hook_caller(s, status, arg) if tostring(status) == 'transfer' then if start_caller and start_caller.destination then log:info('CALL_TRANSFERRED - destination was: ', start_caller.destination.type, '=', start_caller.destination.id,', number: ' .. tostring(start_caller.destination.number) .. ', to: ' .. start_caller:to_s('sip_refer_to')); - start_caller.auth_account = start_dialplan:object_find(start_caller.destination.type, start_caller.destination.id); + start_caller.auth_account = start_caller.dialplan:object_find(start_caller.destination.type, start_caller.destination.id); start_caller.forwarding_number = start_caller.destination.number; start_caller.forwarding_service = 'transfer'; end end end +function input_call_back_caller(s, object_type, object_data, arg) + if object_type == 'dtmf' then + require 'dialplan.dtmf' + local dtmf = dialplan.dtmf.Dtmf:new{ log = log, router = dtmf_router }:detect(start_caller, start_caller.dtmf, object_data.digit, object_data.duration); + end +end + +function input_call_back_callee(s, object_type, object_data, arg) + if object_type == 'dtmf' then + require 'dialplan.dtmf' + local dtmf = dialplan.dtmf.Dtmf:new{ log = log, router = dtmf_router }:detect(start_caller, start_caller.dtmf_callee, object_data.digit, object_data.duration, true); + end +end + + -- initialize logging require 'common.log' log = common.log.Log:new{ prefix = '### [' .. session:get_uuid() .. '] ' }; @@ -36,8 +51,17 @@ require 'dialplan.dialplan' local start_dialplan = dialplan.dialplan.Dialplan:new{ log = log, caller = start_caller, database = database }; start_dialplan:configuration_read(); +start_caller.dialplan = start_dialplan; start_caller.local_node_id = start_dialplan.node_id; start_caller:init_channel_variables(); +start_caller.dtmf = { + updated = os.time(), + digits = ''; +}; +start_caller.dtmf_callee = { + updated = os.time(), + digits = ''; +}; if start_dialplan.config.parameters.dump_variables then start_caller:execute('info', 'notice'); @@ -72,6 +96,17 @@ if start_caller.from_node then else start_destination = { type = 'unknown' } start_caller.session:setHangupHook('hangup_hook_caller', 'destination_number'); + + require 'dialplan.router' + dtmf_router = dialplan.router.Router:new{ log = log, database = database, caller = start_caller, variables = start_caller }; + start_dialplan.dtmf_detection = #dtmf_router:read_table('dtmf') > 0; + + if start_dialplan.dtmf_detection then + start_dialplan.detect_dtmf_after_bridge_caller = true; + start_dialplan.detect_dtmf_after_bridge_callee = true; + start_caller.session:setInputCallback('input_call_back_caller', 'start_dialplan'); + end + start_dialplan:run(start_destination); end |