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) unify conference options
Saúl Ibarra Corretgé465e7f145866
diff --git a/conference.js b/conference.jsindex 60f8a05d3f..c7a6bb6a26 100644--- a/conference.js+++ b/conference.js@@ -39,6 +39,7 @@ import {conferenceWillJoin,conferenceWillLeave,dataChannelOpened,+ getConferenceOptions,kickedOut,lockStateChanged,onStartMutedPolicyChanged,@@ -111,7 +112,6 @@ import {trackRemoved} from './react/features/base/tracks';import { downloadJSON } from './react/features/base/util/downloadJSON';-import { getConferenceOptions } from './react/features/conference/functions';import { showDesktopPicker } from './react/features/desktop-picker';import { appendSuffix } from './react/features/display-name';import {@@ -132,6 +132,7 @@ import { setScreenAudioShareState, isScreenAudioShared } from './react/features/import { toggleScreenshotCaptureEffect } from './react/features/screenshot-capture';import { AudioMixerEffect } from './react/features/stream-effects/audio-mixer/AudioMixerEffect';import { createPresenterEffect } from './react/features/stream-effects/presenter';+import { createRnnoiseProcessor } from './react/features/stream-effects/rnnoise';import { endpointMessageReceived } from './react/features/subtitles';import UIEvents from './service/UI/UIEvents';@@ -1357,7 +1358,11 @@ export default {},_getConferenceOptions() {- return getConferenceOptions(APP.store.getState());+ const options = getConferenceOptions(APP.store.getState());++ options.createVADProcessor = createRnnoiseProcessor;++ return options;},/**diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.jsindex 711e646a9a..5d77125177 100644--- a/react/features/base/conference/actions.js+++ b/react/features/base/conference/actions.js@@ -6,7 +6,6 @@ import {createStartMutedConfigurationEvent,sendAnalytics} from '../../analytics';-import { getName } from '../../app/functions';import { endpointMessageReceived } from '../../subtitles';import { getReplaceParticipant } from '../config/functions';import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';@@ -14,7 +13,6 @@ import { JitsiConferenceEvents } from '../lib-jitsi-meet';import { MEDIA_TYPE, setAudioMuted, setVideoMuted } from '../media';import {dominantSpeakerChanged,- getLocalParticipant,getNormalizedDisplayName,participantConnectionStatusChanged,participantKicked,@@ -24,11 +22,7 @@ import {participantUpdated} from '../participants';import { getLocalTracks, replaceLocalTrack, trackAdded, trackRemoved } from '../tracks';-import {- getBackendSafePath,- getBackendSafeRoomName,- getJitsiMeetGlobalNS-} from '../util';+import { getBackendSafeRoomName } from '../util';import {AUTH_STATUS_CHANGED,@@ -61,6 +55,7 @@ import {_addLocalTracksToConference,commonUserJoinedHandling,commonUserLeftHandling,+ getConferenceOptions,getCurrentConference,sendLocalParticipant} from './functions';@@ -434,22 +429,7 @@ export function createConference() {throw new Error('Cannot join a conference without a room name!');}- const config = state['features/base/config'];- const { tenant } = state['features/base/jwt'];- const { email, name: nick } = getLocalParticipant(state);-- const conference- = connection.initJitsiConference(-- getBackendSafeRoomName(room), {- ...config,- applicationName: getName(),- getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats,- confID: `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`,- siteID: tenant,- statisticsDisplayName: config.enableDisplayNameInStats ? nick : undefined,- statisticsId: config.enableEmailInStats ? email : undefined- });+ const conference = connection.initJitsiConference(getBackendSafeRoomName(room), getConferenceOptions(state));connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;diff --git a/react/features/base/conference/functions.js b/react/features/base/conference/functions.jsindex d80e71fb2f..17017dfc6c 100644--- a/react/features/base/conference/functions.js+++ b/react/features/base/conference/functions.js@@ -2,6 +2,7 @@import _ from 'lodash';+import { getName } from '../../app/functions';import { JitsiTrackErrors } from '../lib-jitsi-meet';import {getLocalParticipant,@@ -11,7 +12,7 @@ import {participantLeft} from '../participants';import { toState } from '../redux';-import { safeDecodeURIComponent } from '../util';+import { getBackendSafePath, getJitsiMeetGlobalNS, safeDecodeURIComponent } from '../util';import {AVATAR_URL_COMMAND,@@ -198,6 +199,53 @@ export function getConferenceNameForTitle(stateful: Function | Object) {return safeStartCase(safeDecodeURIComponent(getConferenceState(toState(stateful)).room));}+/**+ * Returns an object aggregating the conference options.+ *+ * @param {Object|Function} stateful - The redux store state.+ * @returns {Object} - Options object.+ */+export function getConferenceOptions(stateful: Function | Object) {+ const state = toState(stateful);++ const config = state['features/base/config'];+ const { locationURL } = state['features/base/connection'];+ const { tenant } = state['features/base/jwt'];+ const { email, name: nick } = getLocalParticipant(state);+ const options = { ...config };++ if (tenant) {+ options.siteID = tenant;+ }++ if (options.enableDisplayNameInStats && nick) {+ options.statisticsDisplayName = nick;+ }++ if (options.enableEmailInStats && email) {+ options.statisticsId = email;+ }++ if (locationURL) {+ options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;+ }++ options.applicationName = getName();++ // Disable analytics, if requessted.+ if (options.disableThirdPartyRequests) {+ delete config.analytics.scriptURLs;+ delete config.analytics.amplitudeAPPKey;+ delete config.analytics.googleAnalyticsTrackingId;+ delete options.callStatsID;+ delete options.callStatsSecret;+ } else {+ options.getWiFiStatsMethod = getWiFiStatsMethod;+ }++ return options;+}+/*** Returns the UTC timestamp when the first participant joined the conference.*@@ -244,6 +292,21 @@ export function getRoomName(state: Object): string {return getConferenceState(state).room;}+/**+ * Returns the result of getWiFiStats from the global NS or does nothing+ * (returns empty result).+ * Fixes a concurrency problem where we need to pass a function when creating+ * a JitsiConference, but that method is added to the context later.+ *+ * @returns {Promise}+ * @private+ */+function getWiFiStatsMethod() {+ const gloabalNS = getJitsiMeetGlobalNS();++ return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');+}+/*** Handle an error thrown by the backend (i.e. {@code lib-jitsi-meet}) while* manipulating a conference participant (e.g. Pin or select participant).diff --git a/react/features/conference/functions.web.js b/react/features/conference/functions.web.jsindex 2b9aa3916a..a2db54596d 100644--- a/react/features/conference/functions.web.js+++ b/react/features/conference/functions.web.js@@ -1,29 +1,9 @@-import { getName } from '../app/functions.web';import { isSuboptimalBrowser } from '../base/environment';import { translateToHTML } from '../base/i18n';-import { getLocalParticipant } from '../base/participants';-import { toState } from '../base/redux';-import { getBackendSafePath, getJitsiMeetGlobalNS } from '../base/util';import { showWarningNotification } from '../notifications';-import { createRnnoiseProcessor } from '../stream-effects/rnnoise';export * from './functions.any';-/**- * Returns the result of getWiFiStats from the global NS or does nothing-(returns empty result).- * Fixes a concurrency problem where we need to pass a function when creating- * a JitsiConference, but that method is added to the context later.- *- * @returns {Promise}- * @private- */-const getWiFiStatsMethod = () => {- const gloabalNS = getJitsiMeetGlobalNS();-- return gloabalNS.getWiFiStats ? gloabalNS.getWiFiStats() : Promise.resolve('{}');-};-/*** Shows the suboptimal experience notification if needed.*@@ -49,48 +29,3 @@ export function maybeShowSuboptimalExperienceNotification(dispatch, t) {);}}--/**- * Returns an object aggregating the conference options.- *- * @param {Object|Function} stateful - The redux store state.- * @returns {Object} - Options object.- */-export function getConferenceOptions(stateful) {- const state = toState(stateful);-- const options = state['features/base/config'];- const { locationURL } = state['features/base/connection'];- const { tenant } = state['features/base/jwt'];-- const { email, name: nick } = getLocalParticipant(state);-- if (tenant) {- options.siteID = tenant;- }-- if (options.enableDisplayNameInStats && nick) {- options.statisticsDisplayName = nick;- }-- if (options.enableEmailInStats && email) {- options.statisticsId = email;- }-- if (locationURL) {- options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`;- }-- options.applicationName = getName();- options.getWiFiStatsMethod = getWiFiStatsMethod;- options.createVADProcessor = createRnnoiseProcessor;-- // Disable CallStats, if requessted.- if (options.disableThirdPartyRequests) {- delete options.callStatsID;- delete options.callStatsSecret;- delete options.getWiFiStatsMethod;- }-- return options;-}diff --git a/react/features/prejoin/components/PrejoinApp.js b/react/features/prejoin/components/PrejoinApp.jsindex 623f69d09c..579a771991 100644--- a/react/features/prejoin/components/PrejoinApp.js+++ b/react/features/prejoin/components/PrejoinApp.js@@ -5,10 +5,10 @@ import React from 'react';import { batch } from 'react-redux';import { BaseApp } from '../../../features/base/app';+import { getConferenceOptions } from '../../base/conference/functions';import { setConfig } from '../../base/config';import { DialogContainer } from '../../base/dialog';import { createPrejoinTracks } from '../../base/tracks';-import { getConferenceOptions } from '../../conference/functions';import { initPrejoin, makePrecallTest } from '../actions';import Prejoin from './Prejoin';