snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
91
resources/prosody-plugins/mod_jibri_session.lua
Normal file
91
resources/prosody-plugins/mod_jibri_session.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
-- mod_jibri_session
|
||||
--
|
||||
-- Enriches jibri `start` IQ stanzas with recording metadata before they reach
|
||||
-- jibri. It handles two passes:
|
||||
--
|
||||
-- 1. Client → jicofo (no `room` attr): reads the initiating user's identity
|
||||
-- from the XMPP session and writes it to
|
||||
-- app_data.file_recording_metadata.initiator {id, group}.
|
||||
--
|
||||
-- 2. Jicofo → jibri (`room` attr present): looks up the MUC room, reads its
|
||||
-- meetingId, and writes it to
|
||||
-- app_data.file_recording_metadata.conference_details.session_id.
|
||||
--
|
||||
-- Must be loaded on both the main virtual host and the jicofo virtual host.
|
||||
|
||||
local json = require 'cjson.safe';
|
||||
|
||||
local util = module:require 'util';
|
||||
local room_jid_match_rewrite = util.room_jid_match_rewrite;
|
||||
local get_room_from_jid = util.get_room_from_jid;
|
||||
|
||||
-- This needs to be attached to the main virtual host and the virtual host where jicofo is connected and authenticated.
|
||||
-- The first pass is the iq coming from the client where we get the creator and attach it to the app_data.
|
||||
-- The second pass is jicofo approving that and inviting jibri where we attach the session_id information to app_data
|
||||
local function attachJibriSessionId(event)
|
||||
local stanza = event.stanza;
|
||||
if stanza.name == "iq" then
|
||||
local jibri = stanza:get_child('jibri', 'http://jitsi.org/protocol/jibri');
|
||||
if jibri then
|
||||
if jibri.attr.action and jibri.attr.action:lower() == 'start' then
|
||||
|
||||
local update_app_data = false;
|
||||
local app_data = jibri.attr.app_data;
|
||||
if app_data then
|
||||
local err;
|
||||
app_data, err = json.decode(app_data);
|
||||
if err then
|
||||
module:log('warn', 'Failed to decode jibri app_data from %s: %s', stanza.attr.from, err);
|
||||
return;
|
||||
end
|
||||
else
|
||||
app_data = {};
|
||||
end
|
||||
if app_data.file_recording_metadata == nil then
|
||||
app_data.file_recording_metadata = {};
|
||||
end
|
||||
|
||||
if jibri.attr.room then
|
||||
local jibri_room = jibri.attr.room;
|
||||
jibri_room = room_jid_match_rewrite(jibri_room)
|
||||
local room = get_room_from_jid(jibri_room);
|
||||
if room then
|
||||
local conference_details = {};
|
||||
conference_details["session_id"] = room._data.meetingId;
|
||||
app_data.file_recording_metadata.conference_details = conference_details;
|
||||
update_app_data = true;
|
||||
end
|
||||
else
|
||||
-- no room is because the iq received by the initiator in the room
|
||||
local session = event.origin;
|
||||
-- if a token is provided, add data to app_data
|
||||
if session ~= nil then
|
||||
local initiator = {};
|
||||
|
||||
if session.jitsi_meet_context_user ~= nil then
|
||||
initiator.id = session.jitsi_meet_context_user.id;
|
||||
else
|
||||
initiator.id = session.granted_jitsi_meet_context_user_id;
|
||||
end
|
||||
|
||||
initiator.group
|
||||
= session.jitsi_meet_context_group or session.granted_jitsi_meet_context_group_id;
|
||||
|
||||
app_data.file_recording_metadata.initiator = initiator
|
||||
update_app_data = true;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if update_app_data then
|
||||
app_data = json.encode(app_data);
|
||||
jibri.attr.app_data = app_data;
|
||||
jibri:up()
|
||||
stanza:up()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module:hook('pre-iq/full', attachJibriSessionId);
|
||||
Reference in New Issue
Block a user