|
@@ -15,23 +15,6 @@ import VideoType from '../../service/RTC/VideoType';
|
15
|
15
|
|
16
|
16
|
const logger = getLogger(__filename);
|
17
|
17
|
|
18
|
|
-/**
|
19
|
|
- * Creates Promise for mute/unmute operation. Mute operations are chained, so
|
20
|
|
- * this function can be called as many times as needed in a row and operations
|
21
|
|
- * will be executed in a serialized fashion.
|
22
|
|
- *
|
23
|
|
- * @param {JitsiLocalTrack} track - The track that will be muted/unmuted.
|
24
|
|
- * @param {boolean} mute - Whether to mute or unmute the track.
|
25
|
|
- * @returns {Promise}
|
26
|
|
- */
|
27
|
|
-function createMuteUnmutePromise(track, mute) {
|
28
|
|
- const doMute = () => track._setMute(mute);
|
29
|
|
-
|
30
|
|
- track._mutePromise = track._mutePromise.then(doMute, doMute);
|
31
|
|
-
|
32
|
|
- return track._mutePromise;
|
33
|
|
-}
|
34
|
|
-
|
35
|
18
|
/**
|
36
|
19
|
* Represents a single media track(either audio or video).
|
37
|
20
|
* One <tt>JitsiLocalTrack</tt> corresponds to one WebRTC MediaStreamTrack.
|
|
@@ -102,13 +85,14 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
102
|
85
|
this.storedMSID = this.getMSID();
|
103
|
86
|
|
104
|
87
|
/**
|
105
|
|
- * The promise which indicates a mute or unmute operation is in
|
106
|
|
- * progress.
|
|
88
|
+ * The <tt>Promise</tt> which represents the progress of a previously
|
|
89
|
+ * queued/scheduled {@link _setMute} (from the point of view of
|
|
90
|
+ * {@link _queueSetMute}).
|
107
|
91
|
*
|
108
|
92
|
* @private
|
109
|
93
|
* @type {Promise}
|
110
|
94
|
*/
|
111
|
|
- this._mutePromise = Promise.resolve();
|
|
95
|
+ this._prevSetMute = Promise.resolve();
|
112
|
96
|
|
113
|
97
|
/**
|
114
|
98
|
* The facing mode of the camera from which this JitsiLocalTrack
|
|
@@ -306,7 +290,7 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
306
|
290
|
* @returns {Promise}
|
307
|
291
|
*/
|
308
|
292
|
mute() {
|
309
|
|
- return createMuteUnmutePromise(this, true);
|
|
293
|
+ return this._queueSetMute(true);
|
310
|
294
|
}
|
311
|
295
|
|
312
|
296
|
/**
|
|
@@ -315,7 +299,24 @@ export default class JitsiLocalTrack extends JitsiTrack {
|
315
|
299
|
* @returns {Promise}
|
316
|
300
|
*/
|
317
|
301
|
unmute() {
|
318
|
|
- return createMuteUnmutePromise(this, false);
|
|
302
|
+ return this._queueSetMute(false);
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ /**
|
|
306
|
+ * Initializes a new Promise to execute {@link _setMute}. May be called
|
|
307
|
+ * multiple times in a row and the invocations of {@link _setMute} and,
|
|
308
|
+ * consequently, {@link mute} and/or {@link unmute} will be resolved in a
|
|
309
|
+ * serialized fashion.
|
|
310
|
+ *
|
|
311
|
+ * @param {boolean} mute - Whether to mute or unmute this track.
|
|
312
|
+ * @returns {Promise}
|
|
313
|
+ */
|
|
314
|
+ _queueSetMute(mute) {
|
|
315
|
+ const setMute = this._setMute.bind(this, mute);
|
|
316
|
+
|
|
317
|
+ this._prevSetMute = this._prevSetMute.then(setMute, setMute);
|
|
318
|
+
|
|
319
|
+ return this._prevSetMute;
|
319
|
320
|
}
|
320
|
321
|
|
321
|
322
|
/**
|