Advertisement
Borik

Untitled

Jan 30th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 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.         return api:executeString("uuid_getvar " .. uuid .. " " .. var)
  12. end
  13.  
  14. local function viaExternal(uuid)
  15.         return getValueByUuid(uuid, "sofia_profile_name") == "external"
  16. end
  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