Advertisement
Borik

Untitled

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