Advertisement
Borik

Untitled

Jan 30th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local event = event
  2. local freeswitch = freeswitch
  3. freeswitch.consoleLog("info", event:serialize())
  4. local api = freeswitch.API()
  5.  
  6. local function haveValue (a)
  7.         return a and a ~= ""
  8. end
  9.  
  10. local function getValueByUuid(uuid, var)
  11.         local val = api:executeString("uuid_getvar " .. uuid .. " " .. var)
  12.         freeswitch.consoleLog("info", uuid..": "..var.."="..val.."\n")
  13.         return val
  14. end
  15.  
  16. local function viaExternal(uuid)
  17.         return getValueByUuid(uuid, "sofia_profile_name") == "external"
  18. end
  19.  
  20. local other_uuid = tostring(event:getHeader("Other-Leg-Unique-ID"))
  21. local uuid = tostring(event:getHeader("Unique-ID"))
  22. if haveValue(uuid) and haveValue(other_uuid) then
  23.         local recording_file_name = getValueByUuid(uuid, "record_file_name")
  24.         if haveValue(recording_file_name) and viaExternal(uuid) and viaExternal(other_uuid) then
  25.                 api:executeString("uuid_broadcast " .. uuid .. " stop_record_session::" .. recording_file_name)
  26.         end
  27.         local other_recording_file_name = getValueByUuid(other_uuid, "record_file_name")
  28.         if haveValue(other_recording_file_name) and viaExternal(uuid) and viaExternal(other_uuid) then
  29.                 api:executeString("uuid_broadcast " .. other_uuid .. " stop_record_session::" .. other_recording_file_name)
  30.         end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement