Ver código fonte

ref: recreate peerconnections to enable e2ee

Delays e2e encryption initialization until any encryption key is set.
Recreates peerconnections in order to enable insertable streams
only if the e2ee is used. This is to avoid bug around insertable streams
which may cause audio issue when the main JavaScript thread is loaded:

https://bugs.chromium.org/p/chromium/issues/detail?id=1103280
master
paweldomas 5 anos atrás
pai
commit
1c4622c865

+ 51
- 9
JitsiConference.js Ver arquivo

234
     this.videoSIPGWHandler = new VideoSIPGW(this.room);
234
     this.videoSIPGWHandler = new VideoSIPGW(this.room);
235
     this.recordingManager = new RecordingManager(this.room);
235
     this.recordingManager = new RecordingManager(this.room);
236
     this._conferenceJoinAnalyticsEventSent = false;
236
     this._conferenceJoinAnalyticsEventSent = false;
237
-
238
-    if (this.isE2EESupported()) {
239
-        this._e2eEncryption = new E2EEncryption(this, { salt: this.options.name });
240
-    }
241
 }
237
 }
242
 
238
 
243
 // FIXME convert JitsiConference to ES6 - ASAP !
239
 // FIXME convert JitsiConference to ES6 - ASAP !
1880
         }));
1876
         }));
1881
 
1877
 
1882
     try {
1878
     try {
1883
-        jingleSession.initialize(this.room, this.rtc, this.options.config);
1879
+        jingleSession.initialize(this.room, this.rtc, {
1880
+            ...this.options.config,
1881
+            enableInsertableStreams: Boolean(this._e2eEncryption)
1882
+        });
1884
     } catch (error) {
1883
     } catch (error) {
1885
         GlobalOnErrorHandler.callErrorHandler(error);
1884
         GlobalOnErrorHandler.callErrorHandler(error);
1886
     }
1885
     }
2639
     this.p2pJingleSession = jingleSession;
2638
     this.p2pJingleSession = jingleSession;
2640
     this._sendConferenceJoinAnalyticsEvent();
2639
     this._sendConferenceJoinAnalyticsEvent();
2641
 
2640
 
2642
-    this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
2641
+    this.p2pJingleSession.initialize(
2642
+        this.room,
2643
+        this.rtc, {
2644
+            ...this.options.config,
2645
+            enableInsertableStreams: Boolean(this._e2eEncryption)
2646
+        });
2643
 
2647
 
2644
     logger.info('Starting CallStats for P2P connection...');
2648
     logger.info('Starting CallStats for P2P connection...');
2645
 
2649
 
2995
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2999
         'Created new P2P JingleSession', this.room.myroomjid, remoteJid);
2996
     this._sendConferenceJoinAnalyticsEvent();
3000
     this._sendConferenceJoinAnalyticsEvent();
2997
 
3001
 
2998
-    this.p2pJingleSession.initialize(this.room, this.rtc, this.options.config);
3002
+    this.p2pJingleSession.initialize(
3003
+        this.room,
3004
+        this.rtc, {
3005
+            ...this.options.config,
3006
+            enableInsertableStreams: Boolean(this._e2eEncryption)
3007
+        });
2999
 
3008
 
3000
     logger.info('Starting CallStats for P2P connection...');
3009
     logger.info('Starting CallStats for P2P connection...');
3001
 
3010
 
3345
     return browser.supportsInsertableStreams() && !(config.testing && config.testing.disableE2EE);
3354
     return browser.supportsInsertableStreams() && !(config.testing && config.testing.disableE2EE);
3346
 };
3355
 };
3347
 
3356
 
3357
+/**
3358
+ * Initializes the E2E encryption module. Currently any active media session muste be restarted due to
3359
+ * the limitation that the insertable streams constraint can only be set when a new PeerConnection instance is created.
3360
+ *
3361
+ * @private
3362
+ * @returns {void}
3363
+ */
3364
+JitsiConference.prototype._initializeE2EEncryption = function() {
3365
+    this._e2eEncryption = new E2EEncryption(this, { salt: this.options.name });
3366
+
3367
+    // Need to re-create the peerconnections in order to apply the insertable streams constraint
3368
+    this.p2pJingleSession && this.stopP2PSession();
3369
+
3370
+    const jvbJingleSession = this.jvbJingleSession;
3371
+
3372
+    jvbJingleSession && jvbJingleSession.terminate(
3373
+        null /* success callback => we don't care */,
3374
+        error => {
3375
+            logger.warn(`An error occurred while trying to terminate ${jvbJingleSession}`, error);
3376
+        }, {
3377
+            reason: 'success',
3378
+            reasonDescription: 'restart required',
3379
+            requestRestart: true,
3380
+            sendSessionTerminate: true
3381
+        });
3382
+
3383
+    this._maybeStartOrStopP2P(false);
3384
+};
3385
+
3348
 /**
3386
 /**
3349
  * Sets the key to be used for End-To-End encryption.
3387
  * Sets the key to be used for End-To-End encryption.
3350
  *
3388
  *
3352
  * @returns {void}
3390
  * @returns {void}
3353
  */
3391
  */
3354
 JitsiConference.prototype.setE2EEKey = function(key) {
3392
 JitsiConference.prototype.setE2EEKey = function(key) {
3355
-    if (!this._e2eEncryption) {
3356
-        logger.warn('Cannot set E2EE key: there is no defined context, platform is likely unsupported.');
3393
+    if (!this.isE2EESupported()) {
3394
+        logger.warn('Cannot set E2EE key: platform is not supported.');
3357
 
3395
 
3358
         return;
3396
         return;
3359
     }
3397
     }
3360
 
3398
 
3399
+    if (!this._e2eEncryption) {
3400
+        this._initializeE2EEncryption();
3401
+    }
3402
+
3361
     this._e2eEncryption.setKey(key);
3403
     this._e2eEncryption.setKey(key);
3362
 };
3404
 };
3363
 
3405
 

+ 3
- 1
modules/RTC/RTC.js Ver arquivo

499
      * @param {boolean} isP2P Indicates whether or not the new TPC will be used
499
      * @param {boolean} isP2P Indicates whether or not the new TPC will be used
500
      *      in a peer to peer type of session.
500
      *      in a peer to peer type of session.
501
      * @param {object} options The config options.
501
      * @param {object} options The config options.
502
+     * @param {boolean} options.enableInsertableStreams - Set to true when the insertable streams constraints is to be
503
+     * enabled on the PeerConnection.
502
      * @param {boolean} options.disableSimulcast If set to 'true' will disable
504
      * @param {boolean} options.disableSimulcast If set to 'true' will disable
503
      *      the simulcast.
505
      *      the simulcast.
504
      * @param {boolean} options.disableRtx If set to 'true' will disable the
506
      * @param {boolean} options.disableRtx If set to 'true' will disable the
522
 
524
 
523
         // FIXME: We should rename iceConfig to pcConfig.
525
         // FIXME: We should rename iceConfig to pcConfig.
524
 
526
 
525
-        if (browser.supportsInsertableStreams() && !(this.options.testing && this.options.testing.disableE2EE)) {
527
+        if (options.enableInsertableStreams) {
526
             logger.debug('E2EE - setting insertable streams constraints');
528
             logger.debug('E2EE - setting insertable streams constraints');
527
             iceConfig.encodedInsertableStreams = true;
529
             iceConfig.encodedInsertableStreams = true;
528
             iceConfig.forceEncodedAudioInsertableStreams = true; // legacy, to be removed in M85.
530
             iceConfig.forceEncodedAudioInsertableStreams = true; // legacy, to be removed in M85.

+ 2
- 0
modules/xmpp/JingleSession.js Ver arquivo

175
      * @param {Object} options
175
      * @param {Object} options
176
      * @param {string} [options.reason] XMPP Jingle error condition
176
      * @param {string} [options.reason] XMPP Jingle error condition
177
      * @param {string} [options.reasonDescription] some meaningful error message
177
      * @param {string} [options.reasonDescription] some meaningful error message
178
+     * @param {boolean} [options.requestRestart=false] set to true to ask Jicofo to start a new session one this once is
179
+     * terminated.
178
      * @param {boolean} [options.sendSessionTerminate=true] set to false to skip
180
      * @param {boolean} [options.sendSessionTerminate=true] set to false to skip
179
      * sending session-terminate. It may not make sense to send it if the XMPP
181
      * sending session-terminate. It may not make sense to send it if the XMPP
180
      * connection has been closed already or if the remote peer has disconnected
182
      * connection has been closed already or if the remote peer has disconnected

+ 6
- 1
modules/xmpp/JingleSessionPC.js Ver arquivo

47
  * @property {boolean} disableH264 - Described in the config.js[1].
47
  * @property {boolean} disableH264 - Described in the config.js[1].
48
  * @property {boolean} disableRtx - Described in the config.js[1].
48
  * @property {boolean} disableRtx - Described in the config.js[1].
49
  * @property {boolean} disableSimulcast - Described in the config.js[1].
49
  * @property {boolean} disableSimulcast - Described in the config.js[1].
50
+ * @property {boolean} enableInsertableStreams - Set to true when the insertable streams constraints is to be enabled
51
+ * on the PeerConnection.
50
  * @property {boolean} enableLayerSuspension - Described in the config.js[1].
52
  * @property {boolean} enableLayerSuspension - Described in the config.js[1].
51
  * @property {boolean} failICE - it's an option used in the tests. Set to
53
  * @property {boolean} failICE - it's an option used in the tests. Set to
52
  * <tt>true</tt> to block any real candidates and make the ICE fail.
54
  * <tt>true</tt> to block any real candidates and make the ICE fail.
326
             pcOptions.maxstats = DEFAULT_MAX_STATS;
328
             pcOptions.maxstats = DEFAULT_MAX_STATS;
327
         }
329
         }
328
         pcOptions.capScreenshareBitrate = false;
330
         pcOptions.capScreenshareBitrate = false;
331
+        pcOptions.enableInsertableStreams = options.enableInsertableStreams;
332
+
329
         if (this.isP2P) {
333
         if (this.isP2P) {
330
             // simulcast needs to be disabled for P2P (121) calls
334
             // simulcast needs to be disabled for P2P (121) calls
331
             pcOptions.disableSimulcast = true;
335
             pcOptions.disableSimulcast = true;
1455
                 && sessionTerminate.c(
1459
                 && sessionTerminate.c(
1456
                     'bridge-session', {
1460
                     'bridge-session', {
1457
                         xmlns: 'http://jitsi.org/protocol/focus',
1461
                         xmlns: 'http://jitsi.org/protocol/focus',
1458
-                        id: this._bridgeSessionId
1462
+                        id: this._bridgeSessionId,
1463
+                        restart: options && options.requestRestart === true
1459
                     }).up();
1464
                     }).up();
1460
 
1465
 
1461
             // Calling tree() to print something useful
1466
             // Calling tree() to print something useful

Carregando…
Cancelar
Salvar