-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmod_jibri_autostart.lua
66 lines (56 loc) · 1.98 KB
/
mod_jibri_autostart.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local LOGLEVEL = "info"
local is_admin = require "core.usermanager".is_admin
local is_healthcheck_room = module:require "util".is_healthcheck_room
local timer = require "util.timer"
local st = require "util.stanza"
local uuid = require "util.uuid".generate
module:log(LOGLEVEL, "loaded")
-- -----------------------------------------------------------------------------
local function _is_admin(jid)
return is_admin(jid, module.host)
end
-- -----------------------------------------------------------------------------
local function _start_recording(room, session, occupant_jid)
-- dont start recording if already triggered
if room.is_recorder_triggered then
return
end
-- get occupant current status
local occupant = room:get_occupant_by_real_jid(occupant_jid)
-- check recording permission
if occupant == nil or occupant.role ~= "moderator" then
return
elseif
session.jitsi_meet_context_features ~= nil and
session.jitsi_meet_context_features["recording"] ~= true
then
return
end
-- start recording
local iq = st.iq({
type = "set",
id = uuid() .. ":sendIQ",
from = occupant_jid,
to = room.jid .. "/focus"
})
:tag("jibri", {
xmlns = "http://jitsi.org/protocol/jibri",
action = "start",
recording_mode = "file",
app_data = '{"file_recording_metadata":{"share":true}}'})
module:send(iq)
room.is_recorder_triggered = true
end
-- -----------------------------------------------------------------------------
module:hook("muc-occupant-joined", function (event)
local room = event.room
local session = event.origin
local occupant = event.occupant
if is_healthcheck_room(room.jid) or _is_admin(occupant.jid) then
return
end
-- wait for the affiliation to set then start recording if applicable
timer.add_task(3, function()
_start_recording(room, session, occupant.jid)
end)
end)