Voicemail: local and base64 fixes.
This commit is contained in:
parent
242ab77ccb
commit
f99b2e8c30
|
|
@ -300,7 +300,7 @@
|
|||
$message_decoded = base64_decode($row['message_base64']);
|
||||
file_put_contents($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $message_decoded);
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE); //determine mime type (requires PHP >= 5.3.0, must be manually enabled on Windows)
|
||||
$file_mime = finfo_file($finfo, $path.'/msg_'.$this->voicemail_message_uuid.'.???');
|
||||
$file_mime = finfo_file($finfo, $path.'/msg_'.$this->voicemail_message_uuid.'.ext');
|
||||
finfo_close($finfo);
|
||||
switch ($file_mime) {
|
||||
case 'audio/x-wav':
|
||||
|
|
|
|||
|
|
@ -346,7 +346,15 @@
|
|||
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. "\n");
|
||||
|
||||
--loop through the voicemail destinations
|
||||
y = 1;
|
||||
for key,row in pairs(destinations) do
|
||||
--determine uuid
|
||||
if (y == 1) then
|
||||
voicemail_message_uuid = uuid;
|
||||
else
|
||||
voicemail_message_uuid = api:execute("create_uuid");
|
||||
end
|
||||
y = y + 1;
|
||||
--save the message to the voicemail messages
|
||||
if (tonumber(message_length) > 2) then
|
||||
caller_id_name = string.gsub(caller_id_name,"'","''");
|
||||
|
|
@ -368,7 +376,7 @@
|
|||
table.insert(sql, ") ");
|
||||
table.insert(sql, "VALUES ");
|
||||
table.insert(sql, "( ");
|
||||
table.insert(sql, "'"..uuid.."', ");
|
||||
table.insert(sql, "'"..voicemail_message_uuid.."', ");
|
||||
table.insert(sql, "'"..domain_uuid.."', ");
|
||||
table.insert(sql, "'"..row.voicemail_uuid_copy.."', ");
|
||||
table.insert(sql, "'"..start_epoch.."', ");
|
||||
|
|
@ -435,7 +443,7 @@
|
|||
|
||||
--copy the voicemail to each destination
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||
os.execute("cp "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.." "..voicemail_dir.."/"..voicemail_id_copy.."/msg_"..uuid.."."..vm_message_ext);
|
||||
os.execute("cp "..voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext.." "..voicemail_dir.."/"..voicemail_id_copy.."/msg_"..voicemail_message_uuid.."."..vm_message_ext);
|
||||
end
|
||||
|
||||
--set the message waiting event
|
||||
|
|
@ -449,14 +457,9 @@
|
|||
|
||||
--send the email with the voicemail recording attached
|
||||
if (tonumber(message_length) > 2) then
|
||||
send_email(voicemail_id_copy, uuid);
|
||||
send_email(voicemail_id_copy, voicemail_message_uuid);
|
||||
end
|
||||
end
|
||||
|
||||
--remove initial recording file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
end
|
||||
end --for
|
||||
|
||||
else
|
||||
--voicemail not enabled or does not exist
|
||||
|
|
|
|||
|
|
@ -149,29 +149,36 @@
|
|||
result = session:recordFile(storage_path.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
|
||||
else
|
||||
mkdir(voicemail_dir.."/"..voicemail_id);
|
||||
shout_exists = trim(api:execute("module_exists", "mod_shout"));
|
||||
freeswitch.consoleLog("notice", "shout exists: " .. shout_exists .. "\n");
|
||||
if (shout_exists == "true") then
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, max_len_seconds, silence_threshold, silence_seconds);
|
||||
else
|
||||
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 (vm_message_ext == "mp3") then
|
||||
shout_exists = trim(api:execute("module_exists", "mod_shout"));
|
||||
if (shout_exists == "true") then
|
||||
freeswitch.consoleLog("notice", "using mod_shout for mp3 encoding\n");
|
||||
--record in mp3 directly
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3", 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);
|
||||
--create initial wav recording
|
||||
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav", max_len_seconds, silence_threshold, silence_seconds);
|
||||
--use lame to encode, if available
|
||||
if (file_exists("/usr/bin/lame")) then
|
||||
freeswitch.consoleLog("notice", "using lame for mp3 encoding\n");
|
||||
--convert the wav to an mp3 (lame required)
|
||||
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 mp3 exists
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".mp3")) then
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid..".wav");
|
||||
else
|
||||
vm_message_ext = "wav";
|
||||
end
|
||||
else
|
||||
freeswitch.consoleLog("notice", "neither mod_shout or lame found, defaulting to wav\n");
|
||||
vm_message_ext = "wav";
|
||||
end
|
||||
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");
|
||||
|
||||
--stop epoch
|
||||
stop_epoch = os.time();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
dofile(scripts_dir.."/resources/functions/base64.lua");
|
||||
|
||||
--set the voicemail message path
|
||||
message_location = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
message_location = voicemail_dir.."/"..id.."/msg_"..uuid.."."..vm_message_ext;
|
||||
|
||||
--save the recording to the file system
|
||||
if (string.len(row["message_base64"]) > 32) then
|
||||
|
|
@ -187,10 +187,5 @@
|
|||
db_voicemail_uuid = '';
|
||||
end
|
||||
end
|
||||
if (storage_type == "base64") then
|
||||
--delete voicemail recording file
|
||||
if (file_exists(file)) then
|
||||
os.remove(file);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue