Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref/move feature flags init #2495

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions JitsiConnection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import JitsiConference from './JitsiConference';
import * as JitsiConnectionEvents from './JitsiConnectionEvents';
import FeatureFlags from './modules/flags/FeatureFlags';
import Statistics from './modules/statistics/statistics';
import XMPP from './modules/xmpp/xmpp';
import {
Expand All @@ -21,6 +22,10 @@ export default function JitsiConnection(appID, token, options) {
this.appID = appID;
this.token = token;
this.options = options;

// Initialize the feature flags so that they are advertised through the disco-info.
FeatureFlags.init(options.flags || {});

this.xmpp = new XMPP(options, token);

/* eslint-disable max-params */
Expand Down
4 changes: 0 additions & 4 deletions JitsiMeetJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,6 @@ export default {

Settings.init(options.externalStorage);
Statistics.init(options);
const flags = options.flags || {};

// Configure the feature flags.
FeatureFlags.init(flags);

// Initialize global window.connectionTimes
// FIXME do not use 'window'
Expand Down
20 changes: 6 additions & 14 deletions modules/flags/FeatureFlags.js → modules/flags/FeatureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

import browser from '../browser';

/**
* A global module for accessing information about different feature flags state.
*/
class FeatureFlags {
private _runInLiteMode: boolean;
private _ssrcRewriting: boolean;

/**
* Configures the module.
*
* @param {object} flags - The feature flags.
* @param {boolean=} flags.runInLiteMode - Enables lite mode for testing to disable media decoding.
* @param {boolean=} flags.ssrcRewritingEnabled - Use SSRC rewriting.
* @param {boolean=} flags.enableJoinAsVisitor - Enable joining as a visitor.
*/
init(flags) {
init(flags: { runInLiteMode?: boolean | undefined; ssrcRewritingEnabled?: boolean | undefined; }) {
this._runInLiteMode = Boolean(flags.runInLiteMode);
this._ssrcRewriting = Boolean(flags.ssrcRewritingEnabled);
this._joinAsVisitor = Boolean(flags.enableJoinAsVisitor ?? true);
}

/**
Expand All @@ -26,25 +26,17 @@ class FeatureFlags {
*
* @returns {boolean}
*/
isRunInLiteModeEnabled() {
isRunInLiteModeEnabled(): boolean {
return this._runInLiteMode && browser.supportsInsertableStreams();
}

/**
* Checks if the clients supports re-writing of the SSRCs on the media streams by the bridge.
* @returns {boolean}
*/
isSsrcRewritingSupported() {
isSsrcRewritingSupported(): boolean {
return this._ssrcRewriting;
}

/**
* Checks if the clients supports joining as a visitor.
* @returns {boolean}
*/
isJoinAsVisitorSupported() {
return this._joinAsVisitor;
}
}

export default new FeatureFlags();
3 changes: 1 addition & 2 deletions modules/xmpp/moderator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import $ from 'jquery';
import { $iq } from 'strophe.js';

import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
import FeatureFlags from '../flags/FeatureFlags';
import Settings from '../settings/Settings';
import Listenable from '../util/Listenable';

Expand Down Expand Up @@ -190,7 +189,7 @@ export default class Moderator extends Listenable {
conferenceRequest.sessionId = sessionId;
}

if (FeatureFlags.isJoinAsVisitorSupported() && !config.iAmRecorder && !config.iAmSipGateway) {
if (!config.iAmRecorder && !config.iAmSipGateway) {
conferenceRequest.properties['visitors-version'] = 1;

if (this.options.preferVisitor) {
Expand Down
4 changes: 1 addition & 3 deletions modules/xmpp/xmpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ export default class XMPP extends Listenable {
// the version added in moderator.js, this one here is mostly defined
// for keeping stats, since it is not made available to jocofo at
// the time of the initial conference-request.
if (FeatureFlags.isJoinAsVisitorSupported()) {
this.caps.addFeature('http://jitsi.org/visitors-1');
}
this.caps.addFeature('http://jitsi.org/visitors-1');
}

/**
Expand Down
Loading