Browse Source

ref(TPCUtils): don't modify encoding.active

...in setMediaTransferActive. The sender video constraints
are controlling the 'encoding.active' flag and this code
would interfere. It's right now not used anyway as P2P is
disabled in the unified mode. If this modification is
necessary we'll add it back when working on unified P2P
in such a way that will play nicely with the sender constraints code.
master
paweldomas 4 years ago
parent
commit
d562bbc1c4
2 changed files with 25 additions and 32 deletions
  1. 11
    24
      modules/RTC/TPCUtils.js
  2. 14
    8
      modules/RTC/TraceablePeerConnection.js

+ 11
- 24
modules/RTC/TPCUtils.js View File

375
     * the connection should be kept alive.
375
     * the connection should be kept alive.
376
     * @param {boolean} active - true to enable audio media transmission or
376
     * @param {boolean} active - true to enable audio media transmission or
377
     * false to disable.
377
     * false to disable.
378
-    * @returns {Promise<void>} - resolved when done.
378
+    * @returns {void}
379
     */
379
     */
380
     setAudioTransferActive(active) {
380
     setAudioTransferActive(active) {
381
-        return this.setMediaTransferActive('audio', active);
381
+        this.setMediaTransferActive('audio', active);
382
     }
382
     }
383
 
383
 
384
     /**
384
     /**
403
      * @param {String} mediaType - 'audio' or 'video'
403
      * @param {String} mediaType - 'audio' or 'video'
404
      * @param {boolean} active - true to enable media transmission or false
404
      * @param {boolean} active - true to enable media transmission or false
405
      * to disable.
405
      * to disable.
406
-     * @returns {Promise<void>} - resolved when done.
406
+     * @returns {void}
407
      */
407
      */
408
     setMediaTransferActive(mediaType, active) {
408
     setMediaTransferActive(mediaType, active) {
409
         const transceivers = this.pc.peerconnection.getTransceivers()
409
         const transceivers = this.pc.peerconnection.getTransceivers()
410
             .filter(t => t.receiver && t.receiver.track && t.receiver.track.kind === mediaType);
410
             .filter(t => t.receiver && t.receiver.track && t.receiver.track.kind === mediaType);
411
         const localTracks = this.pc.getLocalTracks(mediaType);
411
         const localTracks = this.pc.getLocalTracks(mediaType);
412
 
412
 
413
-        const setParamPromises = [];
414
-
415
-        if (active) {
416
-            transceivers.forEach(transceiver => {
413
+        transceivers.forEach(transceiver => {
414
+            if (active) {
417
                 if (localTracks.length) {
415
                 if (localTracks.length) {
416
+                    // FIXME should adjust only the direction of the local sender or FF will fall into renegotiate loop
418
                     transceiver.direction = 'sendrecv';
417
                     transceiver.direction = 'sendrecv';
419
-                    const parameters = transceiver.sender.getParameters();
420
-
421
-                    if (parameters && parameters.encodings && parameters.encodings.length) {
422
-                        parameters.encodings.forEach(encoding => {
423
-                            encoding.active = true;
424
-                        });
425
-                        setParamPromises.push(transceiver.sender.setParameters(parameters));
426
-                    }
427
                 } else {
418
                 } else {
428
                     transceiver.direction = 'recvonly';
419
                     transceiver.direction = 'recvonly';
429
                 }
420
                 }
430
-            });
431
-        } else {
432
-            transceivers.forEach(transceiver => {
421
+            } else {
433
                 transceiver.direction = 'inactive';
422
                 transceiver.direction = 'inactive';
434
-            });
435
-        }
436
-
437
-        return Promise.all(setParamPromises);
423
+            }
424
+        });
438
     }
425
     }
439
 
426
 
440
     /**
427
     /**
444
     * the connection should be kept alive.
431
     * the connection should be kept alive.
445
     * @param {boolean} active - true to enable video media transmission or
432
     * @param {boolean} active - true to enable video media transmission or
446
     * false to disable.
433
     * false to disable.
447
-    * @returns {Promise<void>} - resolved when done.
434
+    * @returns {void}
448
     */
435
     */
449
     setVideoTransferActive(active) {
436
     setVideoTransferActive(active) {
450
-        return this.setMediaTransferActive('video', active);
437
+        this.setMediaTransferActive('video', active);
451
     }
438
     }
452
 }
439
 }

+ 14
- 8
modules/RTC/TraceablePeerConnection.js View File

1946
  */
1946
  */
1947
 TraceablePeerConnection.prototype.setAudioTransferActive = function(active) {
1947
 TraceablePeerConnection.prototype.setAudioTransferActive = function(active) {
1948
     logger.debug(`${this} audio transfer active: ${active}`);
1948
     logger.debug(`${this} audio transfer active: ${active}`);
1949
-    if (browser.usesUnifiedPlan()) {
1950
-        return this.tpcUtils.setAudioTransferActive(active)
1951
-            .then(() => false);
1952
-    }
1953
     const changed = this.audioTransferActive !== active;
1949
     const changed = this.audioTransferActive !== active;
1954
 
1950
 
1955
     this.audioTransferActive = active;
1951
     this.audioTransferActive = active;
1956
 
1952
 
1953
+    if (browser.usesUnifiedPlan()) {
1954
+        this.tpcUtils.setAudioTransferActive(active);
1955
+
1956
+        // false means no renegotiation up the chain which is not needed in the Unified mode
1957
+        return false;
1958
+    }
1959
+
1957
     return changed;
1960
     return changed;
1958
 };
1961
 };
1959
 
1962
 
2224
  */
2227
  */
2225
 TraceablePeerConnection.prototype.setVideoTransferActive = function(active) {
2228
 TraceablePeerConnection.prototype.setVideoTransferActive = function(active) {
2226
     logger.debug(`${this} video transfer active: ${active}`);
2229
     logger.debug(`${this} video transfer active: ${active}`);
2227
-    if (browser.usesUnifiedPlan()) {
2228
-        return this.tpcUtils.setVideoTransferActive(active)
2229
-            .then(() => false);
2230
-    }
2231
     const changed = this.videoTransferActive !== active;
2230
     const changed = this.videoTransferActive !== active;
2232
 
2231
 
2233
     this.videoTransferActive = active;
2232
     this.videoTransferActive = active;
2234
 
2233
 
2234
+    if (browser.usesUnifiedPlan()) {
2235
+        this.tpcUtils.setVideoTransferActive(active);
2236
+
2237
+        // false means no renegotiation up the chain which is not needed in the Unified mode
2238
+        return false;
2239
+    }
2240
+
2235
     return changed;
2241
     return changed;
2236
 };
2242
 };
2237
 
2243
 

Loading…
Cancel
Save