bigbluebutton-Github/bigbluebutton-html5/imports/api/users-settings/server/methods/addUserSettings.js
prlanzarin 8feb934169 feat(audio): add experimental transparent listen only mode
This is an initial, experimental implementation of the feature proposed in
https://github.com/bigbluebutton/bigbluebutton/issues/14021.

The intention is to phase out the explicit listen only mode with two
overarching goals:
  - Reduce UX friction and increase familiarity: the existence of a separate
  listen only mode is a source of confusion for the majority of users
  Reduce average server-side CPU usage while also making it possible for
  having full audio-only meetings.

The proof-of-concept works based on the assumption that a "many
concurrent active talkers" scenario is both rare and not useful. With
that in mind, this including two server-side triggers:
 - On microphone inactivity (currently mute action that is sustained for
   4 seconds, configurable): FreeSWITCH channels are held (which translates
   to much lower CPU usage, virtually 0%). Receiving channels are switched,
   server side, to a listening mode (SFU, mediasoup).
   * This required an extension to mediasoup two allow re-assigning producers
     to already established consumers. No re-negotiation is done.
 - On microphone activity (currently unmute action, immediate):
   FreeSWITCH channels are unheld, listening mode is deactivated and the
   mute state is updated accordingly (in this order).

This is *off by default*. It needs to be enabled in two places:
  - `/etc/bigbluebutton/bbb-webrtc-sfu/production.yml` ->
    `transparentListenOnly: true`
  - End users:
    * Server wide: `/etc/bigbluebutton/bbb-html5.yml` ->
      `public.media.transparentListenOnly: true`
    * Per user: `userdata-bbb_transparent_listen_only=true`
2023-08-07 19:43:18 -03:00

132 lines
3.7 KiB
JavaScript

import { check } from 'meteor/check';
import addUserSetting from '/imports/api/users-settings/server/modifiers/addUserSetting';
import logger from '/imports/startup/server/logger';
import { extractCredentials } from '/imports/api/common/server/helpers';
const oldParameters = {
askForFeedbackOnLogout: 'bbb_ask_for_feedback_on_logout',
autoJoin: 'bbb_auto_join_audio',
autoShareWebcam: 'bbb_auto_share_webcam',
clientTitle: 'bbb_client_title',
customStyle: 'bbb_custom_style',
customStyleUrl: 'bbb_custom_style_url',
displayBrandingArea: 'bbb_display_branding_area',
enableVideo: 'bbb_enable_video',
forceListenOnly: 'bbb_force_listen_only',
hidePresentationOnJoin: 'bbb_hide_presentation',
listenOnlyMode: 'bbb_listen_only_mode',
multiUserPenOnly: 'bbb_multi_user_pen_only',
multiUserTools: 'bbb_multi_user_tools',
presenterTools: 'bbb_presenter_tools',
shortcuts: 'bbb_shortcuts',
skipCheck: 'bbb_skip_check_audio',
};
const oldParametersKeys = Object.keys(oldParameters);
const currentParameters = [
// APP
'bbb_ask_for_feedback_on_logout',
'bbb_override_default_locale',
'bbb_auto_join_audio',
'bbb_client_title',
'bbb_force_listen_only',
'bbb_listen_only_mode',
'bbb_skip_check_audio',
'bbb_skip_check_audio_on_first_join',
'bbb_fullaudio_bridge',
'bbb_transparent_listen_only',
// BRANDING
'bbb_display_branding_area',
// SHORTCUTS
'bbb_shortcuts',
// KURENTO
'bbb_auto_share_webcam',
'bbb_preferred_camera_profile',
'bbb_enable_video',
'bbb_record_video',
'bbb_skip_video_preview',
'bbb_skip_video_preview_on_first_join',
'bbb_mirror_own_webcam',
// PRESENTATION
'bbb_force_restore_presentation_on_new_events',
// WHITEBOARD
'bbb_multi_user_pen_only',
'bbb_presenter_tools',
'bbb_multi_user_tools',
// SKINNING/THEMMING
'bbb_custom_style',
'bbb_custom_style_url',
// LAYOUT
'bbb_hide_presentation_on_join',
'bbb_show_participants_on_login',
'bbb_show_public_chat_on_login',
'bbb_hide_actions_bar',
'bbb_hide_nav_bar',
'bbb_change_layout',
];
function valueParser(val) {
try {
const parsedValue = JSON.parse(val.toLowerCase().trim());
return parsedValue;
} catch (error) {
logger.warn(`addUserSettings:Parameter ${val} could not be parsed (was not json)`);
return val;
}
}
export default function addUserSettings(settings) {
try {
check(settings, [Object]);
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
check(meetingId, String);
check(userId, String);
let parameters = {};
settings.forEach((el) => {
const settingKey = Object.keys(el).shift();
const normalizedKey = settingKey.trim();
if (currentParameters.includes(normalizedKey)) {
if (!Object.keys(parameters).includes(normalizedKey)) {
parameters = {
[normalizedKey]: valueParser(el[settingKey]),
...parameters,
};
} else {
parameters[normalizedKey] = el[settingKey];
}
return;
}
if (oldParametersKeys.includes(normalizedKey)) {
const matchingNewKey = oldParameters[normalizedKey];
if (!Object.keys(parameters).includes(matchingNewKey)) {
parameters = {
[matchingNewKey]: valueParser(el[settingKey]),
...parameters,
};
}
return;
}
logger.warn(`Parameter ${normalizedKey} not handled`);
});
const settingsAdded = [];
Object.entries(parameters).forEach((el) => {
const setting = el[0];
const value = el[1];
settingsAdded.push(addUserSetting(meetingId, userId, setting, value));
});
return settingsAdded;
} catch (err) {
logger.error(`Exception while invoking method addUserSettings ${err.stack}`);
}
}