Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(conference) Mute user when startMuted policy update is received in conference meta data (#16025)
Jaya Allamsettyf24e02425fb0
diff --git a/conference.js b/conference.jsindex 363427d3fd..c51919ba30 100644--- a/conference.js+++ b/conference.js@@ -131,7 +131,6 @@ import {createLocalTracksF,getLocalJitsiAudioTrack,getLocalJitsiVideoTrack,- getLocalTracks,getLocalVideoTrack,isLocalTrackMuted,isUserInteractionRequiredForUnmute@@ -1829,35 +1828,6 @@ export default {onStartMutedPolicyChanged(audio, video));});- room.on(JitsiConferenceEvents.STARTED_MUTED, () => {- const audioMuted = room.isStartAudioMuted();- const videoMuted = room.isStartVideoMuted();- const localTracks = getLocalTracks(APP.store.getState()['features/base/tracks']);- const promises = [];-- APP.store.dispatch(setAudioMuted(audioMuted));- APP.store.dispatch(setVideoMuted(videoMuted));-- // Remove the tracks from the peerconnection.- for (const track of localTracks) {- // Always add the track on Safari because of a known issue where audio playout doesn't happen- // if the user joins audio and video muted, i.e., if there is no local media capture.- if (audioMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.AUDIO && !browser.isWebKitBased()) {- promises.push(this.useAudioStream(null));- }- if (videoMuted && track.jitsiTrack?.getType() === MEDIA_TYPE.VIDEO) {- promises.push(this.useVideoStream(null));- }- }-- Promise.allSettled(promises)- .then(() => {- APP.store.dispatch(showNotification({- titleKey: 'notify.mutedTitle',- descriptionKey: 'notify.muted'- }, NOTIFICATION_TIMEOUT_TYPE.SHORT));- });- });room.on(JitsiConferenceEvents.DATA_CHANNEL_OPENED, () => {diff --git a/package-lock.json b/package-lock.jsonindex 92ab92b76a..9c1c51574c 100644--- a/package-lock.json+++ b/package-lock.json@@ -61,7 +61,7 @@"js-md5": "0.6.1","js-sha512": "0.8.0","jwt-decode": "2.2.0",- "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1984.0.0+dd4c41be/lib-jitsi-meet.tgz",+ "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1987.0.0+575f6738/lib-jitsi-meet.tgz","lodash-es": "4.17.21","moment": "2.29.4","moment-duration-format": "2.2.2",@@ -16982,8 +16982,8 @@},"node_modules/lib-jitsi-meet": {"version": "0.0.0",- "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1984.0.0+dd4c41be/lib-jitsi-meet.tgz",- "integrity": "sha512-2kGN8tLIg1U2K8TWD0tIksvBKScEydp6CikN3j2pnYpQ20Lh3EXc/p0AA6XtyhteHtqwPGAtSKIwTB+VKNnUIQ==",+ "resolved": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1987.0.0+575f6738/lib-jitsi-meet.tgz",+ "integrity": "sha512-oGn+n0A8lh2OKGLMI/BcDVDq7OZ9lpmLBvv76FzVImjj23Cl8uRGKZIK5RZCRFfBgAHqRPsUjj4jgadd7Er6Kg==","license": "Apache-2.0","dependencies": {"@jitsi/js-utils": "2.2.1",@@ -37440,8 +37440,8 @@}},"lib-jitsi-meet": {- "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1984.0.0+dd4c41be/lib-jitsi-meet.tgz",- "integrity": "sha512-2kGN8tLIg1U2K8TWD0tIksvBKScEydp6CikN3j2pnYpQ20Lh3EXc/p0AA6XtyhteHtqwPGAtSKIwTB+VKNnUIQ==",+ "version": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1987.0.0+575f6738/lib-jitsi-meet.tgz",+ "integrity": "sha512-oGn+n0A8lh2OKGLMI/BcDVDq7OZ9lpmLBvv76FzVImjj23Cl8uRGKZIK5RZCRFfBgAHqRPsUjj4jgadd7Er6Kg==","requires": {"@jitsi/js-utils": "2.2.1","@jitsi/logger": "2.0.2",diff --git a/package.json b/package.jsonindex 64a00d8517..55c7454798 100644--- a/package.json+++ b/package.json@@ -67,7 +67,7 @@"js-md5": "0.6.1","js-sha512": "0.8.0","jwt-decode": "2.2.0",- "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1984.0.0+dd4c41be/lib-jitsi-meet.tgz",+ "lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v1987.0.0+575f6738/lib-jitsi-meet.tgz","lodash-es": "4.17.21","moment": "2.29.4","moment-duration-format": "2.2.2",diff --git a/react/features/base/conference/actions.any.ts b/react/features/base/conference/actions.any.tsindex 738ebf6437..4f3292f64c 100644--- a/react/features/base/conference/actions.any.ts+++ b/react/features/base/conference/actions.any.ts@@ -1,5 +1,3 @@-import { createStartMutedConfigurationEvent } from '../../analytics/AnalyticsEvents';-import { sendAnalytics } from '../../analytics/functions';import { IReduxState, IStore } from '../../app/types';import { readyToClose } from '../../mobile/external-api/actions';import { transcriberJoined, transcriberLeft } from '../../transcribing/actions';@@ -12,9 +10,7 @@ import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection/constants';import { hasAvailableDevices } from '../devices/functions.any';import JitsiMeetJS, { JitsiConferenceEvents, JitsiE2ePingEvents } from '../lib-jitsi-meet';import {- setAudioMuted,setAudioUnmutePermissions,- setVideoMuted,setVideoUnmutePermissions} from '../media/actions';import { MEDIA_TYPE, MediaType } from '../media/constants';@@ -32,7 +28,6 @@ import { IJitsiParticipant } from '../participants/types';import { toState } from '../redux/functions';import {destroyLocalTracks,- replaceLocalTrack,trackAdded,trackRemoved} from '../tracks/actions.any';@@ -181,39 +176,6 @@ function _addConferenceListeners(conference: IJitsiConference, dispatch: IStore[// Dispatches into features/base/media follow:- conference.on(- JitsiConferenceEvents.STARTED_MUTED,- () => {- const audioMuted = Boolean(conference.isStartAudioMuted());- const videoMuted = Boolean(conference.isStartVideoMuted());- const localTracks = getLocalTracks(state['features/base/tracks']);-- sendAnalytics(createStartMutedConfigurationEvent('remote', audioMuted, videoMuted));- logger.log(`Start muted: ${audioMuted ? 'audio, ' : ''}${videoMuted ? 'video' : ''}`);-- // XXX Jicofo tells lib-jitsi-meet to start with audio and/or video- // muted i.e. Jicofo expresses an intent. Lib-jitsi-meet has turned- // Jicofo's intent into reality by actually muting the respective- // tracks. The reality is expressed in base/tracks already so what- // is left is to express Jicofo's intent in base/media.- // TODO Maybe the app needs to learn about Jicofo's intent and- // transfer that intent to lib-jitsi-meet instead of lib-jitsi-meet- // acting on Jicofo's intent without the app's knowledge.- dispatch(setAudioMuted(audioMuted));- dispatch(setVideoMuted(videoMuted));-- // Remove the tracks from peerconnection as well.- for (const track of localTracks) {- const trackType = track.jitsiTrack.getType();-- // Do not remove the audio track on RN. Starting with iOS 15 it will fail to unmute otherwise.- if ((audioMuted && trackType === MEDIA_TYPE.AUDIO && navigator.product !== 'ReactNative')- || (videoMuted && trackType === MEDIA_TYPE.VIDEO)) {- dispatch(replaceLocalTrack(track.jitsiTrack, null, conference));- }- }- });-conference.on(JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,(disableAudioMuteChange: boolean) => {@@ -826,10 +788,8 @@ export function nonParticipantMessageReceived(id: string, json: Object) {/*** Updates the known state of start muted policies.*- * @param {boolean} audioMuted - Whether or not members will join the conference- * as audio muted.- * @param {boolean} videoMuted - Whether or not members will join the conference- * as video muted.+ * @param {boolean} audioMuted - Whether or not members will join the conference as audio muted.+ * @param {boolean} videoMuted - Whether or not members will join the conference as video muted.* @returns {{* type: SET_START_MUTED_POLICY,* startAudioMutedPolicy: boolean,@@ -1040,10 +1000,8 @@ export function setRoom(room?: string) {/*** Sets whether or not members should join audio and/or video muted.*- * @param {boolean} startAudioMuted - Whether or not members will join the- * conference as audio muted.- * @param {boolean} startVideoMuted - Whether or not members will join the- * conference as video muted.+ * @param {boolean} startAudioMuted - Whether or not members will join the conference as audio muted.+ * @param {boolean} startVideoMuted - Whether or not members will join the conference as video muted.* @returns {Function}*/export function setStartMutedPolicy(@@ -1055,9 +1013,6 @@ export function setStartMutedPolicy(audio: startAudioMuted,video: startVideoMuted});-- dispatch(- onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));};}diff --git a/react/features/base/conference/middleware.any.ts b/react/features/base/conference/middleware.any.tsindex faf394efb4..90cef62353 100644--- a/react/features/base/conference/middleware.any.ts+++ b/react/features/base/conference/middleware.any.ts@@ -70,6 +70,7 @@ import {} from './functions';import logger from './logger';import { IConferenceMetadata } from './reducer';+import './subscriber';/*** Handler for before unload event.diff --git a/react/features/base/conference/reducer.ts b/react/features/base/conference/reducer.tsindex 398a233c58..b8ddee54a8 100644--- a/react/features/base/conference/reducer.ts+++ b/react/features/base/conference/reducer.ts@@ -105,8 +105,6 @@ export interface IJitsiConference {isLobbySupported: Function;isP2PActive: Function;isSIPCallingSupported: Function;- isStartAudioMuted: Function;- isStartVideoMuted: Function;join: Function;joinLobby: Function;kickParticipant: Function;diff --git a/react/features/base/conference/subscriber.ts b/react/features/base/conference/subscriber.tsnew file mode 100644index 0000000000..ac778635e5--- /dev/null+++ b/react/features/base/conference/subscriber.ts@@ -0,0 +1,61 @@+import { IStore } from '../../app/types';+import { showNotification } from '../../notifications/actions';+import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';+import StateListenerRegistry from '../redux/StateListenerRegistry';+import { setAudioMuted, setVideoMuted } from '../media/actions';+import { VIDEO_MUTISM_AUTHORITY } from '../media/constants';++let hasShownNotification = false;++/**+ * Handles changes in the start muted policy for audio and video tracks in the meta data set for the conference.+ */+StateListenerRegistry.register(+ /* selector */ state => state['features/base/conference'].startAudioMutedPolicy,+ /* listener */ (startAudioMutedPolicy, store) => {+ _updateTrackMuteState(store, true);+ });++StateListenerRegistry.register(+ /* selector */ state => state['features/base/conference'].startVideoMutedPolicy,+ /* listener */(startVideoMutedPolicy, store) => {+ _updateTrackMuteState(store, false);+ });++/**+ * Updates the mute state of the track based on the start muted policy.+ *+ * @param {IStore} store - The redux store.+ * @param {boolean} isAudio - Whether the track is audio or video.+ * @returns {void}+ */+function _updateTrackMuteState(store: IStore, isAudio: boolean) {+ const { dispatch, getState } = store;+ const mutedPolicyKey = isAudio ? 'startAudioMutedPolicy' : 'startVideoMutedPolicy';+ const mutedPolicyValue = getState()['features/base/conference'][mutedPolicyKey];++ // Currently, the policy only supports force muting others, not unmuting them.+ if (!mutedPolicyValue) {+ return;+ }++ let muteStateUpdated = false;+ const { muted } = isAudio ? getState()['features/base/media'].audio : getState()['features/base/media'].video;++ if (isAudio && !Boolean(muted)) {+ dispatch(setAudioMuted(mutedPolicyValue, true));+ muteStateUpdated = true;+ } else if (!isAudio && !Boolean(muted)) {+ // TODO: Add a new authority for video mutism for the moderator case.+ dispatch(setVideoMuted(mutedPolicyValue, VIDEO_MUTISM_AUTHORITY.USER, true));+ muteStateUpdated = true;+ }++ if (!hasShownNotification && muteStateUpdated) {+ hasShownNotification = true;+ dispatch(showNotification({+ titleKey: 'notify.mutedTitle',+ descriptionKey: 'notify.muted'+ }, NOTIFICATION_TIMEOUT_TYPE.SHORT));+ }+}diff --git a/tests/specs/3way/startMuted.spec.ts b/tests/specs/3way/startMuted.spec.tsindex 2217417707..a405873f30 100644--- a/tests/specs/3way/startMuted.spec.ts+++ b/tests/specs/3way/startMuted.spec.ts@@ -42,14 +42,14 @@ describe('StartMuted', () => {const { p2 } = ctx;await p2.waitForIceConnected();- // await p2.waitForSendReceiveData({ checkSend: false });+ await p2.waitForSendReceiveData({ checkSend: false });await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p2);await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2);await p1.waitForAudioMuted(p2, true);- // await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p1, true);- // await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p1, true);+ await p2.getFilmstrip().assertAudioMuteIconIsDisplayed(p1, true);+ await p2.getParticipantsPane().assertVideoMuteIconIsDisplayed(p1, true);// Enable video on p2 and check if p2 appears unmuted on p1.await Promise.all([@@ -76,7 +76,6 @@ describe('StartMuted', () => {await p3.getParticipantsPane().assertVideoMuteIconIsDisplayed(p2, true);});-it('config options test', async () => {await hangupAllParticipants();@@ -92,14 +91,20 @@ describe('StartMuted', () => {};await ensureOneParticipant(ctx, options);- await joinSecondParticipant(ctx, { skipInMeetingChecks: true });+ await joinSecondParticipant(ctx, {+ ...options,+ skipInMeetingChecks: true+ });const { p2 } = ctx;await p2.waitForIceConnected();await p2.waitForSendReceiveData({ checkSend: false });- await joinThirdParticipant(ctx, { skipInMeetingChecks: true });+ await joinThirdParticipant(ctx, {+ ...options,+ skipInMeetingChecks: true+ });const { p3 } = ctx;@@ -110,10 +115,8 @@ describe('StartMuted', () => {const p2ID = await p2.getEndpointId();-p1.log(`Start configOptionsTest, second participant: ${p2ID}`);-// Participant 3 should be muted, 1 and 2 unmuted.await p3.getFilmstrip().assertAudioMuteIconIsDisplayed(p3);await p3.getParticipantsPane().assertVideoMuteIconIsDisplayed(p3);