Skip to content

Commit

Permalink
feat: Handles hidden-from-recorder from jwt. (jitsi#10973)
Browse files Browse the repository at this point in the history
* feat: Handles hidden-from-recorder from jwt.

Hides the participant that has this flag in jwt from the recorder. A hidden meeting moderator.
Makes sure follows me works and no tracks are being added.

* squash: Skips showing notification when disabling
local audio and video.

* squash: Fixes comments.

* squash: Updates with ljm changes.
  • Loading branch information
damencho authored Feb 17, 2022
1 parent 40353cf commit 59e51f1
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 26 deletions.
29 changes: 27 additions & 2 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/Au
import { createPresenterEffect } from './react/features/stream-effects/presenter';
import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';
import { endpointMessageReceived } from './react/features/subtitles';
import { muteLocal } from './react/features/video-menu/actions.any';
import UIEvents from './service/UI/UIEvents';

const logger = Logger.getLogger(__filename);
Expand Down Expand Up @@ -1144,7 +1145,8 @@ export default {
* Used by Jibri to detect when it's alone and the meeting should be terminated.
*/
get membersCount() {
return room.getParticipants().filter(p => !p.isHidden()).length + 1;
return room.getParticipants()
.filter(p => !p.isHidden() || !(config.iAmRecorder && p.isHiddenFromRecorder())).length + 1;
},

/**
Expand Down Expand Up @@ -2063,6 +2065,10 @@ export default {
APP.store.dispatch(updateRemoteParticipantFeatures(user));
});
room.on(JitsiConferenceEvents.USER_JOINED, (id, user) => {
if (config.iAmRecorder && user.isHiddenFromRecorder()) {
return;
}

// The logic shared between RN and web.
commonUserJoinedHandling(APP.store, room, user);

Expand Down Expand Up @@ -2112,6 +2118,14 @@ export default {
return;
}

if (config.iAmRecorder) {
const participant = room.getParticipantById(track.getParticipantId());

if (participant.isHiddenFromRecorder()) {
return;
}
}

APP.store.dispatch(trackAdded(track));
});

Expand Down Expand Up @@ -2599,13 +2613,24 @@ export default {
* @returns {void}
*/
_onConferenceJoined() {
const { dispatch } = APP.store;

APP.UI.initConference();

if (!config.disableShortcuts) {
APP.keyboardshortcut.init();
}

APP.store.dispatch(conferenceJoined(room));
dispatch(conferenceJoined(room));

const jwt = APP.store.getState()['features/base/jwt'];

if (jwt?.user?.hiddenFromRecorder) {
dispatch(muteLocal(true, MEDIA_TYPE.AUDIO));
dispatch(muteLocal(true, MEDIA_TYPE.VIDEO));
dispatch(setAudioUnmutePermissions(true, true));
dispatch(setVideoUnmutePermissions(true, true));
}
},

/**
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,7 @@ var config = {
forceJVB121Ratio
forceTurnRelay
hiddenDomain
hiddenFromRecorderFeatureEnabled
ignoreStartMuted
websocketKeepAlive
websocketKeepAliveUrl
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"jquery-i18next": "1.2.1",
"js-md5": "0.6.1",
"jwt-decode": "2.2.0",
"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1360.0.0+9eb93e0e/lib-jitsi-meet.tgz",
"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1361.0.0+9e98e989/lib-jitsi-meet.tgz",
"libflacjs": "github:mmig/libflac.js#93d37e7f811f01cf7d8b6a603e38bd3c3810907d",
"lodash": "4.17.21",
"moment": "2.29.1",
Expand Down
9 changes: 7 additions & 2 deletions react/features/base/jwt/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ function _undoOverwriteLocalParticipant(
* avatarURL: ?string,
* email: ?string,
* id: ?string,
* name: ?string
* name: ?string,
* hidden-from-recorder: ?boolean
* }}
*/
function _user2participant({ avatar, avatarUrl, email, id, name }) {
function _user2participant({ avatar, avatarUrl, email, id, name, 'hidden-from-recorder': hiddenFromRecorder }) {
const participant = {};

if (typeof avatarUrl === 'string') {
Expand All @@ -241,5 +242,9 @@ function _user2participant({ avatar, avatarUrl, email, id, name }) {
participant.name = name.trim();
}

if (hiddenFromRecorder === 'true' || hiddenFromRecorder === true) {
participant.hiddenFromRecorder = true;
}

return Object.keys(participant).length ? participant : undefined;
}
12 changes: 8 additions & 4 deletions react/features/base/media/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ export function setAudioMuted(muted: boolean, ensureTrack: boolean = false) {
* Action to disable/enable the audio mute icon.
*
* @param {boolean} blocked - True if the audio mute icon needs to be disabled.
* @param {boolean|undefined} skipNotification - True if we want to skip showing the notification.
* @returns {Function}
*/
export function setAudioUnmutePermissions(blocked: boolean) {
export function setAudioUnmutePermissions(blocked: boolean, skipNotification: boolean = false) {
return {
type: SET_AUDIO_UNMUTE_PERMISSIONS,
blocked
blocked,
skipNotification
};
}

Expand Down Expand Up @@ -155,12 +157,14 @@ export function setVideoMuted(
* Action to disable/enable the video mute icon.
*
* @param {boolean} blocked - True if the video mute icon needs to be disabled.
* @param {boolean|undefined} skipNotification - True if we want to skip showing the notification.
* @returns {Function}
*/
export function setVideoUnmutePermissions(blocked: boolean) {
export function setVideoUnmutePermissions(blocked: boolean, skipNotification: boolean = false) {
return {
type: SET_VIDEO_UNMUTE_PERMISSIONS,
blocked
blocked,
skipNotification
};
}

Expand Down
8 changes: 4 additions & 4 deletions react/features/base/media/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ MiddlewareRegistry.register(store => next => action => {
}

case SET_AUDIO_UNMUTE_PERMISSIONS: {
const { blocked } = action;
const { blocked, skipNotification } = action;
const state = store.getState();
const tracks = state['features/base/tracks'];
const isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);

if (blocked && isAudioMuted) {
if (blocked && isAudioMuted && !skipNotification) {
store.dispatch(showWarningNotification({
descriptionKey: 'notify.audioUnmuteBlockedDescription',
titleKey: 'notify.audioUnmuteBlockedTitle'
Expand All @@ -111,13 +111,13 @@ MiddlewareRegistry.register(store => next => action => {
}

case SET_VIDEO_UNMUTE_PERMISSIONS: {
const { blocked } = action;
const { blocked, skipNotification } = action;
const state = store.getState();
const tracks = state['features/base/tracks'];
const isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
const isMediaShared = isScreenMediaShared(state);

if (blocked && isVideoMuted && !isMediaShared) {
if (blocked && isVideoMuted && !isMediaShared && !skipNotification) {
store.dispatch(showWarningNotification({
descriptionKey: 'notify.videoUnmuteBlockedDescription',
titleKey: 'notify.videoUnmuteBlockedTitle'
Expand Down
32 changes: 24 additions & 8 deletions react/features/follow-me/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,32 @@ function _onFollowMeCommand(attributes = {}, id, store) {

const participantSendingCommand = getParticipantById(state, id);

// The Command(s) API will send us our own commands and we don't want
// to act upon them.
if (participantSendingCommand.local) {
return;
}
if (participantSendingCommand) {
// The Command(s) API will send us our own commands and we don't want
// to act upon them.
if (participantSendingCommand.local) {
return;
}

if (participantSendingCommand.role !== 'moderator') {
logger.warn('Received follow-me command not from moderator');
if (participantSendingCommand.role !== 'moderator') {
logger.warn('Received follow-me command not from moderator');

return;
return;
}
} else {
// This is the case of jibri receiving commands from a hidden participant.
const { iAmRecorder } = state['features/base/config'];
const { conference } = state['features/base/conference'];

// As this participant is not stored in redux store we do the checks on the JitsiParticipant from lib-jitsi-meet
const participant = conference.getParticipantById(id);

if (!iAmRecorder || !participant || participant.getRole() !== 'moderator'
|| !participant.isHiddenFromRecorder()) {
logger.warn('Something went wrong with follow-me command');

return;
}
}

if (!isFollowMeActive(state)) {
Expand Down

0 comments on commit 59e51f1

Please sign in to comment.