Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(visitor): Do not add media tracks in visitor mode. When gUM resolves after the user has joined as a visitor, skip adding the local tracks to the conference.

Jaya Allamsettyd7afaf871fd3
diff --git a/conference.js b/conference.js
index 8057dabaf1..f394fda2bd 100644
--- a/conference.js
+++ b/conference.js
@@ -162,6 +162,7 @@ import { endpointMessageReceived } from './react/features/subtitles/actions.any'
import { handleToggleVideoMuted } from './react/features/toolbox/actions.any';
import { muteLocal } from './react/features/video-menu/actions.any';
import { setIAmVisitor } from './react/features/visitors/actions';
+import { iAmVisitor } from './react/features/visitors/functions';
import UIEvents from './service/UI/UIEvents';
const logger = Logger.getLogger(__filename);
@@ -804,13 +805,14 @@ export default {
* @returns {Promise}
*/
async init({ roomName }) {
+ const state = APP.store.getState();
const initialOptions = {
startAudioOnly: config.startAudioOnly,
startScreenSharing: config.startScreenSharing,
- startWithAudioMuted: getStartWithAudioMuted(APP.store.getState())
- || isUserInteractionRequiredForUnmute(APP.store.getState()),
- startWithVideoMuted: getStartWithVideoMuted(APP.store.getState())
- || isUserInteractionRequiredForUnmute(APP.store.getState())
+ startWithAudioMuted: getStartWithAudioMuted(state)
+ || isUserInteractionRequiredForUnmute(state),
+ startWithVideoMuted: getStartWithVideoMuted(state)
+ || isUserInteractionRequiredForUnmute(state)
};
this.roomName = roomName;
@@ -840,7 +842,7 @@ export default {
return tracks;
};
- if (isPrejoinPageVisible(APP.store.getState())) {
+ if (isPrejoinPageVisible(state)) {
_connectionPromise = connect(roomName).then(c => {
// we want to initialize it early, in case of errors to be able
// to gather logs
@@ -863,7 +865,7 @@ export default {
// they may remain as empty strings.
this._initDeviceList(true);
- if (isPrejoinPageVisible(APP.store.getState())) {
+ if (isPrejoinPageVisible(state)) {
return APP.store.dispatch(initPrejoin(tracks, errors));
}
@@ -873,7 +875,7 @@ export default {
let localTracks = handleStartAudioMuted(initialOptions, tracks);
- // in case where gum is slow and resolves after the startAudio/VideoMuted coming from jicofo, we can be
+ // In case where gUM is slow and resolves after the startAudio/VideoMuted coming from jicofo, we can be
// join unmuted even though jicofo had instruct us to mute, so let's respect that before passing the tracks
if (!browser.isWebKitBased()) {
if (room?.isStartAudioMuted()) {
@@ -885,6 +887,11 @@ export default {
localTracks = localTracks.filter(track => track.getType() !== MEDIA_TYPE.VIDEO);
}
+ // Do not add the tracks if the user has joined the call as a visitor.
+ if (iAmVisitor(state)) {
+ return Promise.resolve();
+ }
+
return this._setLocalAudioVideoStreams(localTracks);
}
diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.ts
index 9d64b24ec6..d6f171eb57 100644
--- a/react/features/base/conference/middleware.any.ts
+++ b/react/features/base/conference/middleware.any.ts
@@ -15,6 +15,7 @@ import { readyToClose } from '../../mobile/external-api/actions';
import { showErrorNotification, showWarningNotification } from '../../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
import { setIAmVisitor } from '../../visitors/actions';
+import { iAmVisitor } from '../../visitors/functions';
import { overwriteConfig } from '../config/actions';
import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../connection/actionTypes';
import { connect, connectionDisconnected, disconnect } from '../connection/actions';
@@ -575,14 +576,19 @@ function _setRoom({ dispatch, getState }: IStore, next: Function, action: AnyAct
* @returns {Promise}
*/
function _syncConferenceLocalTracksWithState({ getState }: IStore, action: AnyAction) {
- const conference = getCurrentConference(getState);
+ const state = getState();
+ const conference = getCurrentConference(state);
let promise;
if (conference) {
const track = action.track.jitsiTrack;
if (action.type === TRACK_ADDED) {
- promise = _addLocalTracksToConference(conference, [ track ]);
+ // If gUM is slow and tracks are created after the user has already joined the conference, avoid
+ // adding the tracks to the conference if the user is a visitor.
+ if (!iAmVisitor(state)) {
+ promise = _addLocalTracksToConference(conference, [ track ]);
+ }
} else {
promise = _removeLocalTracksFromConference(conference, [ track ]);
}