Browse Source

Update modules/xmpp/SDP.js

Co-Authored-By: Saúl Ibarra Corretgé <s@saghul.net>
dev1
Jaya Allamsetty 5 years ago
parent
commit
b012353d68

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

49
         ];
49
         ];
50
     }
50
     }
51
 
51
 
52
-    /**
53
-     * Obtains local tracks for given {@link MediaType}.
54
-     * @param {MediaType} mediaType - audio or video.
55
-     * @return {Array<JitsiLocalTrack>} - array containing the local tracks
56
-     * attached to the peerconnection of the given media type.
57
-     */
58
-    _getLocalTracks(mediaType) {
59
-        const tracks = Array.from(this.pc.localTracks.values());
60
-
61
-        return tracks.filter(track => track.getType() === mediaType);
62
-    }
63
-
64
     /**
52
     /**
65
      * Obtains stream encodings that need to be configured on the given track.
53
      * Obtains stream encodings that need to be configured on the given track.
66
      * @param {JitsiLocalTrack} localTrack
54
      * @param {JitsiLocalTrack} localTrack
301
     }
289
     }
302
 
290
 
303
     /**
291
     /**
304
-     *
305
-     * @param {boolean} active
306
-     */
292
+    * Enables/disables audio transmission on the peer connection. When
293
+    * disabled the audio transceiver direction will be set to 'inactive'
294
+    * which means that no data will be sent nor accepted, but
295
+    * the connection should be kept alive.
296
+    * @param {boolean} active - true to enable audio media transmission or
297
+    * false to disable.
298
+    * @returns {false} - returns false always so that renegotiation is not automatically
299
+    * triggered after this operation.
300
+    */
307
     setAudioTransferActive(active) {
301
     setAudioTransferActive(active) {
308
         return this.setMediaTransferActive('audio', active);
302
         return this.setMediaTransferActive('audio', active);
309
     }
303
     }
310
 
304
 
311
     /**
305
     /**
312
      * Set the simulcast stream encoding properties on the RTCRtpSender.
306
      * Set the simulcast stream encoding properties on the RTCRtpSender.
313
-     * @param {*} track - the current track in use for which the encodings are to be set.
307
+     * @param {JitsiLocalTrack} track - the current track in use for which
308
+     * the encodings are to be set.
314
      */
309
      */
315
     setEncodings(track) {
310
     setEncodings(track) {
316
         const transceiver = this.pc.peerconnection.getTransceivers()
311
         const transceiver = this.pc.peerconnection.getTransceivers()
322
     }
317
     }
323
 
318
 
324
     /**
319
     /**
325
-     *
326
-     * @param {*} mediaType
327
-     * @param {boolean} active
320
+     * Enables/disables media transmission on the peerconnection by changing the direction
321
+     * on the transceiver for the specified media type.
322
+     * @param {String} mediaType - 'audio' or 'video'
323
+     * @param {boolean} active - true to enable media transmission or false
324
+     * to disable.
325
+     * @returns {false} - returns false always so that renegotiation is not automatically
326
+     * triggered after this operation
328
      */
327
      */
329
     setMediaTransferActive(mediaType, active) {
328
     setMediaTransferActive(mediaType, active) {
330
         const transceivers = this.pc.peerconnection.getTransceivers()
329
         const transceivers = this.pc.peerconnection.getTransceivers()
331
             .filter(t => t.receiver && t.receiver.track && t.receiver.track.kind === mediaType);
330
             .filter(t => t.receiver && t.receiver.track && t.receiver.track.kind === mediaType);
331
+        const localTracks = Array.from(this.pc.localTracks.values())
332
+            .filter(track => track.getType() === mediaType);
332
 
333
 
333
         if (active) {
334
         if (active) {
334
             transceivers.forEach(transceiver => {
335
             transceivers.forEach(transceiver => {
335
-                if (this._getLocalTracks(mediaType).length > 0) {
336
+                if (localTracks.length) {
336
                     transceiver.direction = 'sendrecv';
337
                     transceiver.direction = 'sendrecv';
337
                     const parameters = transceiver.sender.getParameters();
338
                     const parameters = transceiver.sender.getParameters();
338
 
339
 
352
             });
353
             });
353
         }
354
         }
354
 
355
 
355
-        return true;
356
+        return false;
356
     }
357
     }
357
 
358
 
358
     /**
359
     /**
359
-     *
360
-     * @param {boolean} active
361
-     */
360
+    * Enables/disables video media transmission on the peer connection. When
361
+    * disabled the SDP video media direction in the local SDP will be adjusted to
362
+    * 'inactive' which means that no data will be sent nor accepted, but
363
+    * the connection should be kept alive.
364
+    * @param {boolean} active - true to enable video media transmission or
365
+    * false to disable.
366
+    * @returns {false} - returns false always so that renegotiation is not automatically
367
+    * triggered after this operation.
368
+    */
362
     setVideoTransferActive(active) {
369
     setVideoTransferActive(active) {
363
         return this.setMediaTransferActive('video', active);
370
         return this.setMediaTransferActive('video', active);
364
     }
371
     }

+ 1
- 1
modules/browser/BrowserCapabilities.js View File

279
      * @returns {boolean}
279
      * @returns {boolean}
280
      */
280
      */
281
     usesAdapter() {
281
     usesAdapter() {
282
-        return !this.isFirefox() && !this.isReactNative();
282
+        return this.usesNewGumFlow();
283
     }
283
     }
284
 
284
 
285
     /**
285
     /**

+ 3
- 5
modules/xmpp/JingleSessionPC.js View File

521
             const remoteDescription = this.peerconnection.remoteDescription;
521
             const remoteDescription = this.peerconnection.remoteDescription;
522
 
522
 
523
             this.room.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, this);
523
             this.room.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, this);
524
-            if (browser.usesUnifiedPlan() && state.toString() === 'stable'
524
+            if (browser.usesUnifiedPlan() && state === 'stable'
525
                 && remoteDescription && typeof remoteDescription.sdp === 'string') {
525
                 && remoteDescription && typeof remoteDescription.sdp === 'string') {
526
                 logger.debug(`onnegotiationneeded fired on ${this.peerconnection} in state: ${state}`);
526
                 logger.debug(`onnegotiationneeded fired on ${this.peerconnection} in state: ${state}`);
527
                 const workFunction = finishedCallback => {
527
                 const workFunction = finishedCallback => {
533
 
533
 
534
                             this.notifyMySSRCUpdate(oldSdp, newSdp);
534
                             this.notifyMySSRCUpdate(oldSdp, newSdp);
535
                             finishedCallback();
535
                             finishedCallback();
536
-                        })
537
-                        .catch(() => {
538
-                            finishedCallback();
539
-                        });
536
+                        },
537
+                        finishedCallback /* will be called with en error */);
540
                 };
538
                 };
541
 
539
 
542
                 this.modificationQueue.push(
540
                 this.modificationQueue.push(

+ 1
- 1
modules/xmpp/SDP.js View File

570
 // construct an SDP from a jingle stanza
570
 // construct an SDP from a jingle stanza
571
 SDP.prototype.fromJingle = function(jingle) {
571
 SDP.prototype.fromJingle = function(jingle) {
572
     const self = this;
572
     const self = this;
573
-    const sessionId = (new Date()).getTime();
573
+    const sessionId = Date.now();
574
 
574
 
575
     // Use a unique session id for every TPC.
575
     // Use a unique session id for every TPC.
576
     this.raw = 'v=0\r\n'
576
     this.raw = 'v=0\r\n'

Loading…
Cancel
Save