mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Update the base64 code.
This commit is contained in:
@@ -96,8 +96,7 @@
|
||||
end);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
|
||||
greeting_location = storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
|
||||
end
|
||||
|
||||
--play the greeting
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
message_length = row["message_length"];
|
||||
message_status = row["message_status"];
|
||||
message_priority = row["message_priority"];
|
||||
message_base64 = row["message_base64"];
|
||||
end);
|
||||
end
|
||||
|
||||
@@ -95,6 +96,9 @@
|
||||
table.insert(sql, "voicemail_message_uuid, ");
|
||||
table.insert(sql, "domain_uuid, ");
|
||||
table.insert(sql, "voicemail_uuid, ");
|
||||
if (storage_type == "base64") then
|
||||
table.insert(sql, "message_base64, ");
|
||||
end
|
||||
table.insert(sql, "created_epoch, ");
|
||||
table.insert(sql, "caller_id_name, ");
|
||||
table.insert(sql, "caller_id_number, ");
|
||||
@@ -107,6 +111,9 @@
|
||||
table.insert(sql, "'".. voicemail_message_uuid .."', ");
|
||||
table.insert(sql, "'".. domain_uuid .."', ");
|
||||
table.insert(sql, "'".. forward_voicemail_uuid .."', ");
|
||||
if (storage_type == "base64") then
|
||||
table.insert(sql, "'".. message_base64 .."', ");
|
||||
end
|
||||
table.insert(sql, "'".. created_epoch .."', ");
|
||||
table.insert(sql, "'".. caller_id_name .."', ");
|
||||
table.insert(sql, "'".. caller_id_number .."', ");
|
||||
@@ -118,7 +125,17 @@
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
|
||||
end
|
||||
dbh:query(sql);
|
||||
if (storage_type == "base64") then
|
||||
array = explode("://", database["system"]);
|
||||
local luasql = require "luasql.postgres";
|
||||
local env = assert (luasql.postgres());
|
||||
local dbh = env:connect(array[2]);
|
||||
res, serr = dbh:execute(sql);
|
||||
dbh:close();
|
||||
env:close();
|
||||
else
|
||||
dbh:query(sql);
|
||||
end
|
||||
|
||||
--set the message waiting event
|
||||
local event = freeswitch.Event("message_waiting");
|
||||
|
||||
@@ -82,21 +82,26 @@
|
||||
end);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
message_location = storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
end
|
||||
|
||||
--play the message
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
stream_seek = true;
|
||||
if (vm_message_ext == "mp3") then
|
||||
if (api:executeString("module_exists mod_vlc") == "true") then
|
||||
session:streamFile("vlc://"..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
if (storage_type == "http_cache") then
|
||||
message_location = storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
session:streamFile(storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
else
|
||||
if (vm_message_ext == "mp3") then
|
||||
if (api:executeString("module_exists mod_vlc") == "true") then
|
||||
session:streamFile("vlc://"..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
else
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
end
|
||||
else
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
end
|
||||
else
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
end
|
||||
stream_seek = false;
|
||||
session:streamFile("silence_stream://1000");
|
||||
|
||||
@@ -64,14 +64,17 @@
|
||||
file:write(base64.decode(row["greeting_base64"]));
|
||||
file:close();
|
||||
end
|
||||
--custom greeting
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
end);
|
||||
end
|
||||
elseif (storage_type == "http_cache") then
|
||||
--need additional work
|
||||
session:streamFile(storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
else
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
end
|
||||
|
||||
--custom greeting
|
||||
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
|
||||
--sleep
|
||||
session:streamFile("silence_stream://200");
|
||||
else
|
||||
--default greeting
|
||||
|
||||
@@ -110,11 +110,11 @@
|
||||
session:execute(action, data);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--clear the variables
|
||||
action = "";
|
||||
data = "";
|
||||
|
||||
|
||||
--inrement the option count
|
||||
count = count + 1;
|
||||
end); --end results
|
||||
@@ -127,8 +127,8 @@
|
||||
session:transfer(dtmf_digits.." XML "..context);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -146,21 +146,25 @@
|
||||
max_len_seconds = 300;
|
||||
silence_threshold = 30;
|
||||
silence_seconds = 5;
|
||||
mkdir(voicemail_dir.."/"..voicemail_id);
|
||||
if (vm_message_ext == "mp3") then
|
||||
--make the recording
|
||||
--session:execute("record", "vlc://#standard{access=file,mux=mp3,dst="..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.."}");
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav", max_len_seconds, silence_threshold, silence_seconds);
|
||||
--convert the wav to an mp3
|
||||
--apt-get install lame
|
||||
resample = "/usr/bin/lame -b 32 --resample 8 -m s "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3";
|
||||
session:execute("system", resample);
|
||||
--delete the wav file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3")) then
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav");
|
||||
end
|
||||
if (storage_path == "http_cache") then
|
||||
result = session:recordFile(storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
|
||||
else
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
|
||||
mkdir(voicemail_dir.."/"..voicemail_id);
|
||||
if (vm_message_ext == "mp3") then
|
||||
--make the recording
|
||||
--session:execute("record", "vlc://#standard{access=file,mux=mp3,dst="..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.."}");
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav", max_len_seconds, silence_threshold, silence_seconds);
|
||||
--convert the wav to an mp3
|
||||
--apt-get install lame
|
||||
resample = "/usr/bin/lame -b 32 --resample 8 -m s "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3";
|
||||
session:execute("system", resample);
|
||||
--delete the wav file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3")) then
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav");
|
||||
end
|
||||
else
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
|
||||
end
|
||||
end
|
||||
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user