[Freeswitch-users] Stop recording during hold and resume on unhold

Arik Halperin arik.halperin at s3code.com
Mon Aug 26 16:07:21 UTC 2019


Hello,

I have 2 legs of a call, when one of them goes on hold the other leg hears hold music but session recording continues on all channels.
This means that the recording produced, contains the hold music+any audio the user is uttering during this period.
I would like to stop the recording during the period of the hold.

How can I do it using Lua? 

Currently I’m catching the hold and untold events using hook events:


<hook event="CHANNEL_HOLD" script = "channel_hold.lua"/>
 <hook event="CHANNEL_UNHOLD" script = "channel_unhold.lua”/>

Tried the following code and similar, but it does not work:

local recording_dir='/usr/local/freeswitch/recordings/'
local uuid = event:getHeader("Unique-ID")
session = freeswitch.Session(uuid)
freeswitch.consoleLog("crit", uuid .. " on hold:"..session:getState())
local x_session_id = session:getVariable("sip_h_X-SESSION-ID");
record_path  = recording_dir .. x_session_id .. '.mp3'

freeswitch.consoleLog("crit","Stopping session on:"..record_path)
api = freeswitch.API();
session:execute("set", "uuid_record "..session:get_uuid().." stop "..record_path)

Also tried, record_session_stop and did not work either.

Thanks,
Arik Halperin




More information about the FreeSWITCH-users mailing list