|
|
@@ -19,6 +19,11 @@ const DEFAULT_RTC_MUTE_TIMEOUT = 2000;
|
|
19
|
19
|
/**
|
|
20
|
20
|
* Class is responsible for emitting
|
|
21
|
21
|
* JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED events.
|
|
|
22
|
+ */
|
|
|
23
|
+export default class ParticipantConnectionStatus {
|
|
|
24
|
+
|
|
|
25
|
+/**
|
|
|
26
|
+ * Creates new instance of <tt>ParticipantConnectionStatus</tt>.
|
|
22
|
27
|
*
|
|
23
|
28
|
* @constructor
|
|
24
|
29
|
* @param {RTC} rtc the RTC service instance
|
|
|
@@ -26,7 +31,7 @@ const DEFAULT_RTC_MUTE_TIMEOUT = 2000;
|
|
26
|
31
|
* @param {number} rtcMuteTimeout (optional) custom value for
|
|
27
|
32
|
* {@link ParticipantConnectionStatus.rtcMuteTimeout}.
|
|
28
|
33
|
*/
|
|
29
|
|
-function ParticipantConnectionStatus(rtc, conference, rtcMuteTimeout) {
|
|
|
34
|
+constructor(rtc, conference, rtcMuteTimeout) {
|
|
30
|
35
|
this.rtc = rtc;
|
|
31
|
36
|
this.conference = conference;
|
|
32
|
37
|
/**
|
|
|
@@ -54,7 +59,7 @@ function ParticipantConnectionStatus(rtc, conference, rtcMuteTimeout) {
|
|
54
|
59
|
* Initializes <tt>ParticipantConnectionStatus</tt> and bind required event
|
|
55
|
60
|
* listeners.
|
|
56
|
61
|
*/
|
|
57
|
|
-ParticipantConnectionStatus.prototype.init = function() {
|
|
|
62
|
+init() {
|
|
58
|
63
|
|
|
59
|
64
|
this._onEndpointConnStatusChanged
|
|
60
|
65
|
= this.onEndpointConnStatusChanged.bind(this);
|
|
|
@@ -89,13 +94,13 @@ ParticipantConnectionStatus.prototype.init = function() {
|
|
89
|
94
|
// signalling mute/unmute events.
|
|
90
|
95
|
this._onSignallingMuteChanged = this.onSignallingMuteChanged.bind(this);
|
|
91
|
96
|
}
|
|
92
|
|
-};
|
|
|
97
|
+}
|
|
93
|
98
|
|
|
94
|
99
|
/**
|
|
95
|
100
|
* Removes all event listeners and disposes of all resources held by this
|
|
96
|
101
|
* instance.
|
|
97
|
102
|
*/
|
|
98
|
|
-ParticipantConnectionStatus.prototype.dispose = function () {
|
|
|
103
|
+dispose() {
|
|
99
|
104
|
|
|
100
|
105
|
this.rtc.removeListener(
|
|
101
|
106
|
RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
|
|
|
@@ -115,7 +120,7 @@ ParticipantConnectionStatus.prototype.dispose = function () {
|
|
115
|
120
|
Object.keys(this.trackTimers).forEach(function (participantId) {
|
|
116
|
121
|
this.clearTimeout(participantId);
|
|
117
|
122
|
}.bind(this));
|
|
118
|
|
-};
|
|
|
123
|
+}
|
|
119
|
124
|
|
|
120
|
125
|
/**
|
|
121
|
126
|
* Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
|
|
|
@@ -124,8 +129,7 @@ ParticipantConnectionStatus.prototype.dispose = function () {
|
|
124
|
129
|
* @param endpointId {string} the endpoint ID(MUC nickname/resource JID)
|
|
125
|
130
|
* @param isActive {boolean} true if the connection is OK or false otherwise
|
|
126
|
131
|
*/
|
|
127
|
|
-ParticipantConnectionStatus.prototype.onEndpointConnStatusChanged
|
|
128
|
|
-= function(endpointId, isActive) {
|
|
|
132
|
+onEndpointConnStatusChanged(endpointId, isActive) {
|
|
129
|
133
|
|
|
130
|
134
|
logger.debug(
|
|
131
|
135
|
'Detector RTCEvents.ENDPOINT_CONN_STATUS_CHANGED('
|
|
|
@@ -147,10 +151,9 @@ ParticipantConnectionStatus.prototype.onEndpointConnStatusChanged
|
|
147
|
151
|
this._changeConnectionStatus(endpointId, isActive);
|
|
148
|
152
|
}
|
|
149
|
153
|
}
|
|
150
|
|
-};
|
|
|
154
|
+}
|
|
151
|
155
|
|
|
152
|
|
-ParticipantConnectionStatus.prototype._changeConnectionStatus
|
|
153
|
|
-= function (endpointId, newStatus) {
|
|
|
156
|
+_changeConnectionStatus(endpointId, newStatus) {
|
|
154
|
157
|
var participant = this.conference.getParticipantById(endpointId);
|
|
155
|
158
|
if (!participant) {
|
|
156
|
159
|
// This will happen when participant exits the conference with broken
|
|
|
@@ -185,7 +188,7 @@ ParticipantConnectionStatus.prototype._changeConnectionStatus
|
|
185
|
188
|
JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
|
|
186
|
189
|
endpointId, newStatus);
|
|
187
|
190
|
}
|
|
188
|
|
-};
|
|
|
191
|
+}
|
|
189
|
192
|
|
|
190
|
193
|
/**
|
|
191
|
194
|
* Reset the postponed "connection interrupted" event which was previously
|
|
|
@@ -194,12 +197,12 @@ ParticipantConnectionStatus.prototype._changeConnectionStatus
|
|
194
|
197
|
* @param participantId the participant for which the "connection interrupted"
|
|
195
|
198
|
* timeout was scheduled
|
|
196
|
199
|
*/
|
|
197
|
|
-ParticipantConnectionStatus.prototype.clearTimeout = function (participantId) {
|
|
|
200
|
+clearTimeout(participantId) {
|
|
198
|
201
|
if (this.trackTimers[participantId]) {
|
|
199
|
202
|
window.clearTimeout(this.trackTimers[participantId]);
|
|
200
|
203
|
this.trackTimers[participantId] = null;
|
|
201
|
204
|
}
|
|
202
|
|
-};
|
|
|
205
|
+}
|
|
203
|
206
|
|
|
204
|
207
|
/**
|
|
205
|
208
|
* Bind signalling mute event listeners for video {JitsiRemoteTrack} when
|
|
|
@@ -208,8 +211,7 @@ ParticipantConnectionStatus.prototype.clearTimeout = function (participantId) {
|
|
208
|
211
|
* @param {JitsiTrack} remoteTrack the {JitsiTrack} which is being added to
|
|
209
|
212
|
* the conference.
|
|
210
|
213
|
*/
|
|
211
|
|
-ParticipantConnectionStatus.prototype.onRemoteTrackAdded
|
|
212
|
|
-= function(remoteTrack) {
|
|
|
214
|
+onRemoteTrackAdded(remoteTrack) {
|
|
213
|
215
|
if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
|
|
214
|
216
|
|
|
215
|
217
|
logger.debug(
|
|
|
@@ -219,7 +221,7 @@ ParticipantConnectionStatus.prototype.onRemoteTrackAdded
|
|
219
|
221
|
JitsiTrackEvents.TRACK_MUTE_CHANGED,
|
|
220
|
222
|
this._onSignallingMuteChanged);
|
|
221
|
223
|
}
|
|
222
|
|
-};
|
|
|
224
|
+}
|
|
223
|
225
|
|
|
224
|
226
|
/**
|
|
225
|
227
|
* Removes all event listeners bound to the remote video track and clears any
|
|
|
@@ -228,8 +230,7 @@ ParticipantConnectionStatus.prototype.onRemoteTrackAdded
|
|
228
|
230
|
* @param {JitsiRemoteTrack} remoteTrack the remote track which is being removed
|
|
229
|
231
|
* from the conference.
|
|
230
|
232
|
*/
|
|
231
|
|
-ParticipantConnectionStatus.prototype.onRemoteTrackRemoved
|
|
232
|
|
-= function(remoteTrack) {
|
|
|
233
|
+onRemoteTrackRemoved(remoteTrack) {
|
|
233
|
234
|
if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
|
|
234
|
235
|
logger.debug(
|
|
235
|
236
|
'Detector on remote track removed: ',
|
|
|
@@ -239,7 +240,7 @@ ParticipantConnectionStatus.prototype.onRemoteTrackRemoved
|
|
239
|
240
|
this._onSignallingMuteChanged);
|
|
240
|
241
|
this.clearTimeout(remoteTrack.getParticipantId());
|
|
241
|
242
|
}
|
|
242
|
|
-};
|
|
|
243
|
+}
|
|
243
|
244
|
|
|
244
|
245
|
/**
|
|
245
|
246
|
* Handles RTC 'onmute' event for the video track.
|
|
|
@@ -247,7 +248,7 @@ ParticipantConnectionStatus.prototype.onRemoteTrackRemoved
|
|
247
|
248
|
* @param {JitsiRemoteTrack} track the video track for which 'onmute' event will
|
|
248
|
249
|
* be processed.
|
|
249
|
250
|
*/
|
|
250
|
|
-ParticipantConnectionStatus.prototype.onTrackRtcMuted = function(track) {
|
|
|
251
|
+onTrackRtcMuted(track) {
|
|
251
|
252
|
var participantId = track.getParticipantId();
|
|
252
|
253
|
var participant = this.conference.getParticipantById(participantId);
|
|
253
|
254
|
logger.debug('Detector track RTC muted: ', participantId);
|
|
|
@@ -268,7 +269,7 @@ ParticipantConnectionStatus.prototype.onTrackRtcMuted = function(track) {
|
|
268
|
269
|
this.clearTimeout(participantId);
|
|
269
|
270
|
}.bind(this), this.rtcMuteTimeout);
|
|
270
|
271
|
}
|
|
271
|
|
-};
|
|
|
272
|
+}
|
|
272
|
273
|
|
|
273
|
274
|
/**
|
|
274
|
275
|
* Handles RTC 'onunmute' event for the video track.
|
|
|
@@ -276,7 +277,7 @@ ParticipantConnectionStatus.prototype.onTrackRtcMuted = function(track) {
|
|
276
|
277
|
* @param {JitsiRemoteTrack} track the video track for which 'onunmute' event
|
|
277
|
278
|
* will be processed.
|
|
278
|
279
|
*/
|
|
279
|
|
-ParticipantConnectionStatus.prototype.onTrackRtcUnmuted = function(track) {
|
|
|
280
|
+onTrackRtcUnmuted(track) {
|
|
280
|
281
|
logger.debug('Detector track RTC unmuted: ', track);
|
|
281
|
282
|
var participantId = track.getParticipantId();
|
|
282
|
283
|
if (!track.isMuted() &&
|
|
|
@@ -288,7 +289,7 @@ ParticipantConnectionStatus.prototype.onTrackRtcUnmuted = function(track) {
|
|
288
|
289
|
this._changeConnectionStatus(participantId, true);
|
|
289
|
290
|
}
|
|
290
|
291
|
this.clearTimeout(participantId);
|
|
291
|
|
-};
|
|
|
292
|
+}
|
|
292
|
293
|
|
|
293
|
294
|
/**
|
|
294
|
295
|
* Here the signalling "mute"/"unmute" events are processed.
|
|
|
@@ -296,8 +297,7 @@ ParticipantConnectionStatus.prototype.onTrackRtcUnmuted = function(track) {
|
|
296
|
297
|
* @param {JitsiRemoteTrack} track the remote video track for which
|
|
297
|
298
|
* the signalling mute/unmute event will be processed.
|
|
298
|
299
|
*/
|
|
299
|
|
-ParticipantConnectionStatus.prototype.onSignallingMuteChanged
|
|
300
|
|
-= function (track) {
|
|
|
300
|
+onSignallingMuteChanged (track) {
|
|
301
|
301
|
logger.debug(
|
|
302
|
302
|
'Detector on track signalling mute changed: ', track, track.isMuted());
|
|
303
|
303
|
var isMuted = track.isMuted();
|
|
|
@@ -313,6 +313,6 @@ ParticipantConnectionStatus.prototype.onSignallingMuteChanged
|
|
313
|
313
|
'Signalling got in sync - cancelling task for: ' + participantId);
|
|
314
|
314
|
this.clearTimeout(participantId);
|
|
315
|
315
|
}
|
|
316
|
|
-};
|
|
|
316
|
+}
|
|
317
|
317
|
|
|
318
|
|
-module.exports = ParticipantConnectionStatus;
|
|
|
318
|
+}
|