From 3ea2f005787c9f49c48febaeed9dc0340fe0a01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 28 Jun 2017 11:59:46 +0200 Subject: [PATCH 1/2] feat(p2p): refactor configuration options --- config.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/config.js b/config.js index ea211ce3d..ffcef10cd 100644 --- a/config.js +++ b/config.js @@ -20,13 +20,6 @@ var config = { // eslint-disable-line no-unused-vars //focusUserJid: 'focus@auth.jitsi-meet.example.com', // The real JID of focus participant - can be overridden here //defaultSipNumber: '', // Default SIP number - // The STUN servers that will be used in the peer to peer connections - p2pStunServers: [ - { urls: "stun:stun.l.google.com:19302" }, - { urls: "stun:stun1.l.google.com:19302" }, - { urls: "stun:stun2.l.google.com:19302" } - ], - // The ID of the jidesha extension for Chrome. desktopSharingChromeExtId: null, // Whether desktop sharing should be disabled on Chrome. @@ -92,13 +85,26 @@ var config = { // eslint-disable-line no-unused-vars disableRtx: false, // Sets the preferred resolution (height) for local video. Defaults to 720. resolution: 720, - // Enables peer to peer mode. When enabled system will try to establish - // direct connection given that there are exactly 2 participants in - // the room. If that succeeds the conference will stop sending data through - // the JVB and use the peer to peer connection instead. When 3rd participant - // joins the conference will be moved back to the JVB connection. - enableP2P: true - // How long we're going to wait, before going back to P2P after - // the 3rd participant has left the conference (to filter out page reload) - //backToP2PDelay: 5 + // Peer-To-Peer mode: used (if enabled) when there are just 2 participants. + p2p: { + // Enables peer to peer mode. When enabled system will try to establish + // direct connection given that there are exactly 2 participants in + // the room. If that succeeds the conference will stop sending data + // through the JVB and use the peer to peer connection instead. When 3rd + // participant joins the conference will be moved back to the JVB + // connection. + enabled: true, + // The STUN servers that will be used in the peer to peer connections + stunServers: [ + { urls: "stun:stun.l.google.com:19302" }, + { urls: "stun:stun1.l.google.com:19302" }, + { urls: "stun:stun2.l.google.com:19302" } + ], + // If set to true, it will prefer to use H.264 for P2P calls (if H.264 + // is supported). + preferH264: false + // How long we're going to wait, before going back to P2P after + // the 3rd participant has left the conference (to filter out page reload) + //backToP2PDelay: 5 + } }; From 4e5bc172c909c694ac1b81f18d04043a1bf308d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 28 Jun 2017 16:56:57 +0200 Subject: [PATCH 2/2] feat(config): allow overriding nested config objects This makes it possible for the following URL params to work: config.p2p.enabled=true&config.p2p.preferH264=true --- react/features/base/config/functions.js | 42 +++++++++++-------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/react/features/base/config/functions.js b/react/features/base/config/functions.js index e2c615ec1..7f562acb4 100644 --- a/react/features/base/config/functions.js +++ b/react/features/base/config/functions.js @@ -1,6 +1,7 @@ /* @flow */ import JSSHA from 'jssha'; +import _ from 'lodash'; import parseURLParams from './parseURLParams'; @@ -172,17 +173,11 @@ export function overrideConfigJSON( if (configObj) { const configJSON = json[configName]; - for (const key of Object.keys(configJSON)) { - const oldValue = configObj[key]; - const newValue = configJSON[key]; - - if (oldValue && typeof oldValue !== typeof newValue) { - logger.log( - `Overriding a ${configName - } property with a property of different type.`); - } - logger.info(`Overriding ${key} with: ${newValue}`); - configObj[key] = newValue; + if (!_.isEmpty(configJSON)) { + logger.info( + `Extending ${configName} ` + + `with: ${JSON.stringify(configJSON)}`); + _.merge(configObj, configJSON); } } } @@ -227,20 +222,21 @@ export function setConfigFromURLParams() { loggingConfig && (json.loggingConfig = {}); for (const param of Object.keys(params)) { - const objEnd = param.indexOf('.'); + let base = json; + const names = param.split('.'); + const last = names.pop(); - if (objEnd !== -1) { - const obj = param.substring(0, objEnd); - - if (json.hasOwnProperty(obj)) { - const key = param.substring(objEnd + 1); - - // Prevent passing some parameters which can inject scripts. - if (key && _KEYS_TO_IGNORE.indexOf(key) === -1) { - json[obj][key] = params[param]; - } - } + // Prevent passing some parameters which can inject scripts. + if (_KEYS_TO_IGNORE.indexOf(last) !== -1) { + // eslint-disable-next-line no-continue + continue; } + + for (const name of names) { + base = base[name] = base[name] || {}; + } + + base[last] = params[param]; } overrideConfigJSON(config, interfaceConfig, loggingConfig, json);