Fix call screen to end recording with dtmf and silence

This commit is contained in:
FusionPBX 2024-09-30 10:05:00 -06:00 committed by GitHub
parent ae15319487
commit 3ad177e6c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 6 deletions

View File

@ -306,14 +306,40 @@ log = require "resources.functions.log".ring_group
--call screen enabled
if (ring_group_call_screen_enabled == 'true') then
--local codecs = session:getVariable("codec_string")
local codecs = session:getVariable("rtp_use_codec_string");
--put the codecs into an array
local codec_array = explode(",",codecs);
--exclude video codecs and resave the new list to a string
local new_codec_array = {}
for index, value in ipairs(codec_array) do
if (value ~= "H264" and value ~= 'VP8') then
table.insert(new_codec_array, value)
end
end
local new_codecs = table.concat(new_codec_array, ",");
--set a new allowed codec string
session:setVariable("absolute_codec_string", new_codecs);
--callback function detecting dtmf
function on_dtmf(s, _type, obj, arg)
local k, v = nil, nil
if (_type == "dtmf") then
dtmf_entered = 1;
return 'break'
else
return ''
end
end
--answer the call if not answered
if (not session_answer) then
session:answer();
end
--flush dtmf digits from the input buffer
session:flushDigits();
--set the variables
min_digits = 1;
max_digits = 1;
@ -328,8 +354,8 @@ log = require "resources.functions.log".ring_group
--recording settings
max_length_seconds = 30;
silence_threshold = 30;
silence_seconds = 3;
silence_threshold = settings:get('recordings', 'recording_silence_threshold', 'numeric') or 200;
silence_seconds = settings:get('recordings', 'recording_silence_seconds', 'numeric') or 3;
--create the call scree file name
call_sreen_name = 'call_screen.'..uuid..'.'..record_ext;
@ -339,10 +365,12 @@ log = require "resources.functions.log".ring_group
mkdir(record_path);
end
--set callback function for when a caller sends DTMF
session:setInputCallback('on_dtmf', '');
--record the name and reason for calling
if (session:ready()) then
result = session:recordFile(record_path..'/'..call_sreen_name, max_length_seconds, silence_threshold, silence_seconds);
--session:execute("record", record_path..'/'..call_sreen_name.." 180 200");
end
end