Преглед изворни кода

Merge pull request #583 from jitsi/sRD_failure

ref(JitsiLocalTrack): get rid of 'setMutedInProgress'
dev1
Saúl Ibarra Corretgé пре 8 година
родитељ
комит
ef5ea406df

+ 0
- 18
modules/RTC/JitsiLocalTrack.js Прегледај датотеку

@@ -321,15 +321,6 @@ export default class JitsiLocalTrack extends JitsiTrack {
321 321
 
322 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 324
         // A function that will print info about muted status transition
334 325
         const logMuteInfo = () => logger.info(`Mute ${this}: ${muted}`);
335 326
 
@@ -400,15 +391,6 @@ export default class JitsiLocalTrack extends JitsiTrack {
400 391
 
401 392
         return promise
402 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 394
             .then(() => this.emit(TRACK_MUTE_CHANGED, this));
413 395
     }
414 396
 

+ 9
- 3
modules/RTC/LocalSdpMunger.js Прегледај датотеку

@@ -66,12 +66,18 @@ export default class LocalSdpMunger {
66 66
 
67 67
         for (const videoTrack of localVideos) {
68 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 78
             logger.debug(
73 79
                 `${this.tpc} ${videoTrack} muted: ${muted
74
-                    }, is mute/unmute in progress: ${setMutedInProgress
80
+                    }, is in PeerConnection: ${isInPeerConnection
75 81
                     } => should fake sdp ? : ${shouldFakeSdp}`);
76 82
 
77 83
             if (!shouldFakeSdp) {

+ 22
- 0
modules/RTC/TraceablePeerConnection.js Прегледај датотеку

@@ -119,6 +119,14 @@ export default function TraceablePeerConnection(
119 119
      */
120 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 131
      * @typedef {Object} TPCGroupInfo
124 132
      * @property {string} semantics the SSRC groups semantics
@@ -1291,6 +1299,7 @@ TraceablePeerConnection.prototype.addTrackUnmute = function(track) {
1291 1299
  */
1292 1300
 TraceablePeerConnection.prototype._addStream = function(mediaStream) {
1293 1301
     this.peerconnection.addStream(mediaStream);
1302
+    this._addedStreams.add(mediaStream);
1294 1303
 };
1295 1304
 
1296 1305
 /**
@@ -1303,6 +1312,7 @@ TraceablePeerConnection.prototype._removeStream = function(mediaStream) {
1303 1312
     } else {
1304 1313
         this.peerconnection.removeStream(mediaStream);
1305 1314
     }
1315
+    this._addedStreams.delete(mediaStream);
1306 1316
 };
1307 1317
 
1308 1318
 /**
@@ -1328,6 +1338,16 @@ TraceablePeerConnection.prototype._assertTrackBelongs
1328 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 1352
  * Remove local track from this TPC.
1333 1353
  * @param {JitsiLocalTrack} localTrack the track to be removed from this TPC.
@@ -1761,6 +1781,8 @@ TraceablePeerConnection.prototype.close = function() {
1761 1781
     }
1762 1782
     this.remoteTracks.clear();
1763 1783
 
1784
+    this._addedStreams.clear();
1785
+
1764 1786
     if (!this.rtc._removePeerConnection(this)) {
1765 1787
         logger.error('RTC._removePeerConnection returned false');
1766 1788
     }

+ 4
- 2
modules/xmpp/JingleSessionPC.js Прегледај датотеку

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

Loading…
Откажи
Сачувај