Bläddra i källkod

Merge pull request #583 from jitsi/sRD_failure

ref(JitsiLocalTrack): get rid of 'setMutedInProgress'
dev1
Saúl Ibarra Corretgé 8 år sedan
förälder
incheckning
ef5ea406df

+ 0
- 18
modules/RTC/JitsiLocalTrack.js Visa fil

321
 
321
 
322
         let promise = Promise.resolve();
322
         let promise = Promise.resolve();
323
 
323
 
324
-        /**
325
-         * Set to <tt>true</tt> when there's ongoing "mute/unmute" operation in
326
-         * progress. Used by {@link LocalSdpMunger}.
327
-         *
328
-         * @public
329
-         * @type {boolean}
330
-         */
331
-        this.setMutedInProgress = true;
332
-
333
         // A function that will print info about muted status transition
324
         // A function that will print info about muted status transition
334
         const logMuteInfo = () => logger.info(`Mute ${this}: ${muted}`);
325
         const logMuteInfo = () => logger.info(`Mute ${this}: ${muted}`);
335
 
326
 
400
 
391
 
401
         return promise
392
         return promise
402
             .then(() => this._sendMuteStatus(muted))
393
             .then(() => this._sendMuteStatus(muted))
403
-            .then(
404
-                /* onFulfilled */ () => {
405
-                    this.setMutedInProgress = false;
406
-                },
407
-                /* onRejected */ error => {
408
-                    this.setMutedInProgress = false;
409
-
410
-                    throw error;
411
-                })
412
             .then(() => this.emit(TRACK_MUTE_CHANGED, this));
394
             .then(() => this.emit(TRACK_MUTE_CHANGED, this));
413
     }
395
     }
414
 
396
 

+ 9
- 3
modules/RTC/LocalSdpMunger.js Visa fil

66
 
66
 
67
         for (const videoTrack of localVideos) {
67
         for (const videoTrack of localVideos) {
68
             const muted = videoTrack.isMuted();
68
             const muted = videoTrack.isMuted();
69
-            const { setMutedInProgress } = videoTrack;
70
-            const shouldFakeSdp = muted || setMutedInProgress;
69
+            const mediaStream = videoTrack.getOriginalStream();
70
+
71
+            // During the mute/unmute operation there are periods of time when
72
+            // the track's underlying MediaStream is not added yet to
73
+            // the PeerConnection. The SDP needs to be munged in such case.
74
+            const isInPeerConnection
75
+                = mediaStream && this.tpc.isMediaStreamInPc(mediaStream);
76
+            const shouldFakeSdp = muted || !isInPeerConnection;
71
 
77
 
72
             logger.debug(
78
             logger.debug(
73
                 `${this.tpc} ${videoTrack} muted: ${muted
79
                 `${this.tpc} ${videoTrack} muted: ${muted
74
-                    }, is mute/unmute in progress: ${setMutedInProgress
80
+                    }, is in PeerConnection: ${isInPeerConnection
75
                     } => should fake sdp ? : ${shouldFakeSdp}`);
81
                     } => should fake sdp ? : ${shouldFakeSdp}`);
76
 
82
 
77
             if (!shouldFakeSdp) {
83
             if (!shouldFakeSdp) {

+ 22
- 0
modules/RTC/TraceablePeerConnection.js Visa fil

119
      */
119
      */
120
     this.localTracks = new Map();
120
     this.localTracks = new Map();
121
 
121
 
122
+    /**
123
+     * Keeps tracks of the WebRTC <tt>MediaStream</tt>s that have been added to
124
+     * the underlying WebRTC PeerConnection.
125
+     * @type {Set}
126
+     * @private
127
+     */
128
+    this._addedStreams = new Set();
129
+
122
     /**
130
     /**
123
      * @typedef {Object} TPCGroupInfo
131
      * @typedef {Object} TPCGroupInfo
124
      * @property {string} semantics the SSRC groups semantics
132
      * @property {string} semantics the SSRC groups semantics
1291
  */
1299
  */
1292
 TraceablePeerConnection.prototype._addStream = function(mediaStream) {
1300
 TraceablePeerConnection.prototype._addStream = function(mediaStream) {
1293
     this.peerconnection.addStream(mediaStream);
1301
     this.peerconnection.addStream(mediaStream);
1302
+    this._addedStreams.add(mediaStream);
1294
 };
1303
 };
1295
 
1304
 
1296
 /**
1305
 /**
1303
     } else {
1312
     } else {
1304
         this.peerconnection.removeStream(mediaStream);
1313
         this.peerconnection.removeStream(mediaStream);
1305
     }
1314
     }
1315
+    this._addedStreams.delete(mediaStream);
1306
 };
1316
 };
1307
 
1317
 
1308
 /**
1318
 /**
1328
     return doesBelong;
1338
     return doesBelong;
1329
 };
1339
 };
1330
 
1340
 
1341
+/**
1342
+ * Tells if the given WebRTC <tt>MediaStream</tt> has been added to
1343
+ * the underlying WebRTC PeerConnection.
1344
+ * @param {MediaStream} mediaStream
1345
+ * @returns {boolean}
1346
+ */
1347
+TraceablePeerConnection.prototype.isMediaStreamInPc = function(mediaStream) {
1348
+    return this._addedStreams.has(mediaStream);
1349
+};
1350
+
1331
 /**
1351
 /**
1332
  * Remove local track from this TPC.
1352
  * Remove local track from this TPC.
1333
  * @param {JitsiLocalTrack} localTrack the track to be removed from this TPC.
1353
  * @param {JitsiLocalTrack} localTrack the track to be removed from this TPC.
1761
     }
1781
     }
1762
     this.remoteTracks.clear();
1782
     this.remoteTracks.clear();
1763
 
1783
 
1784
+    this._addedStreams.clear();
1785
+
1764
     if (!this.rtc._removePeerConnection(this)) {
1786
     if (!this.rtc._removePeerConnection(this)) {
1765
         logger.error('RTC._removePeerConnection returned false');
1787
         logger.error('RTC._removePeerConnection returned false');
1766
     }
1788
     }

+ 4
- 2
modules/xmpp/JingleSessionPC.js Visa fil

1746
 
1746
 
1747
         if (Object.keys(addedMedia).length) {
1747
         if (Object.keys(addedMedia).length) {
1748
             logger.error(
1748
             logger.error(
1749
-                `Some SSRC were added on ${operationName}`, addedMedia);
1749
+                `${this} - some SSRC were added on ${operationName}`,
1750
+                addedMedia);
1750
 
1751
 
1751
             return false;
1752
             return false;
1752
         }
1753
         }
1756
 
1757
 
1757
         if (Object.keys(removedMedia).length) {
1758
         if (Object.keys(removedMedia).length) {
1758
             logger.error(
1759
             logger.error(
1759
-                `Some SSRCs were removed on ${operationName}`, removedMedia);
1760
+                `${this} - some SSRCs were removed on ${operationName}`,
1761
+                removedMedia);
1760
 
1762
 
1761
             return false;
1763
             return false;
1762
         }
1764
         }

Laddar…
Avbryt
Spara