|
@@ -1,15 +1,40 @@
|
1
|
|
-
|
2
|
1
|
import { Strophe } from 'strophe.js';
|
3
|
2
|
|
4
|
|
-
|
|
3
|
+import JitsiConference from './JitsiConference';
|
5
|
4
|
import * as JitsiConferenceEvents from './JitsiConferenceEvents';
|
|
5
|
+import JitsiTrack from './modules/RTC/JitsiTrack';
|
6
|
6
|
import { MediaType } from './service/RTC/MediaType';
|
7
|
7
|
|
|
8
|
+export interface ISourceInfo {
|
|
9
|
+ muted: boolean;
|
|
10
|
+ videoType: string;
|
|
11
|
+}
|
|
12
|
+
|
8
|
13
|
/**
|
9
|
14
|
* Represents a participant in (i.e. a member of) a conference.
|
10
|
15
|
*/
|
11
|
16
|
export default class JitsiParticipant {
|
12
|
17
|
|
|
18
|
+ private _jid: string;
|
|
19
|
+ private _id: string;
|
|
20
|
+ private _conference: JitsiConference;
|
|
21
|
+ private _displayName: string;
|
|
22
|
+ private _supportsDTMF: boolean;
|
|
23
|
+ private _tracks: JitsiTrack[];
|
|
24
|
+ private _role: string;
|
|
25
|
+ private _status?: string;
|
|
26
|
+ private _hidden: boolean;
|
|
27
|
+ private _statsID?: string;
|
|
28
|
+ private _properties: Map<string, any>;
|
|
29
|
+ private _identity?: object;
|
|
30
|
+ private _isReplacing?: boolean;
|
|
31
|
+ private _isReplaced?: boolean;
|
|
32
|
+ private _isSilent?: boolean;
|
|
33
|
+ private _features: Set<string>;
|
|
34
|
+ private _sources: Map<MediaType, Map<string, ISourceInfo>>;
|
|
35
|
+ private _botType?: string;
|
|
36
|
+ private _connectionJid?: string;
|
|
37
|
+
|
13
|
38
|
/* eslint-disable max-params */
|
14
|
39
|
|
15
|
40
|
/**
|
|
@@ -28,7 +53,18 @@ export default class JitsiParticipant {
|
28
|
53
|
* @param {boolean?} isReplaced - whether this is a participant to be kicked and replaced into the meeting.
|
29
|
54
|
* @param {boolean?} isSilent - whether participant has joined without audio
|
30
|
55
|
*/
|
31
|
|
- constructor(jid, conference, displayName, hidden, statsID, status, identity, isReplacing, isReplaced, isSilent) {
|
|
56
|
+ constructor(
|
|
57
|
+ jid: string,
|
|
58
|
+ conference: JitsiConference,
|
|
59
|
+ displayName: string,
|
|
60
|
+ hidden: boolean,
|
|
61
|
+ statsID?: string,
|
|
62
|
+ status?: string,
|
|
63
|
+ identity?: object,
|
|
64
|
+ isReplacing?: boolean,
|
|
65
|
+ isReplaced?: boolean,
|
|
66
|
+ isSilent?: boolean
|
|
67
|
+ ) {
|
32
|
68
|
this._jid = jid;
|
33
|
69
|
this._id = Strophe.getResourceFromJid(jid);
|
34
|
70
|
this._conference = conference;
|
|
@@ -48,11 +84,11 @@ export default class JitsiParticipant {
|
48
|
84
|
|
49
|
85
|
/**
|
50
|
86
|
* Remote sources associated with the participant in the following format.
|
51
|
|
- * Map<mediaType, Map<sourceName, sourceInfo>>
|
|
87
|
+ * Map<mediaType, Map<sourceName, ISourceInfo>>
|
52
|
88
|
*
|
53
|
89
|
* mediaType - 'audio' or 'video'.
|
54
|
90
|
* sourceName - name of the remote source.
|
55
|
|
- * sourceInfo: {
|
|
91
|
+ * ISourceInfo: {
|
56
|
92
|
* muted: boolean;
|
57
|
93
|
* videoType: string;
|
58
|
94
|
* }
|
|
@@ -69,10 +105,10 @@ export default class JitsiParticipant {
|
69
|
105
|
* @returns {Boolean} True if all JitsiTracks which are of the specified mediaType and which belong to this
|
70
|
106
|
* JitsiParticipant are muted; otherwise, false.
|
71
|
107
|
*/
|
72
|
|
- _isMediaTypeMuted(mediaType) {
|
|
108
|
+ _isMediaTypeMuted(mediaType: MediaType): boolean {
|
73
|
109
|
return this.getTracks().reduce(
|
74
|
110
|
(muted, track) =>
|
75
|
|
- muted && (track.getType() !== mediaType || track.isMuted()),
|
|
111
|
+ muted && (track.getType() !== mediaType || (track as any).isMuted()),
|
76
|
112
|
true);
|
77
|
113
|
}
|
78
|
114
|
|
|
@@ -84,9 +120,9 @@ export default class JitsiParticipant {
|
84
|
120
|
* @param {string} videoType The video type of the source.
|
85
|
121
|
* @returns {void}
|
86
|
122
|
*/
|
87
|
|
- _setSources(mediaType, muted, sourceName, videoType) {
|
|
123
|
+ _setSources(mediaType: MediaType, muted: boolean, sourceName: string, videoType: string): void {
|
88
|
124
|
let sourceByMediaType = this._sources.get(mediaType);
|
89
|
|
- const sourceInfo = {
|
|
125
|
+ const sourceInfo: ISourceInfo = {
|
90
|
126
|
muted,
|
91
|
127
|
videoType
|
92
|
128
|
};
|
|
@@ -107,7 +143,7 @@ export default class JitsiParticipant {
|
107
|
143
|
*
|
108
|
144
|
* @returns {string|undefined} - The bot type of the participant.
|
109
|
145
|
*/
|
110
|
|
- getBotType() {
|
|
146
|
+ getBotType(): string | undefined {
|
111
|
147
|
return this._botType;
|
112
|
148
|
}
|
113
|
149
|
|
|
@@ -115,7 +151,7 @@ export default class JitsiParticipant {
|
115
|
151
|
* @returns {JitsiConference} The conference that this participant belongs
|
116
|
152
|
* to.
|
117
|
153
|
*/
|
118
|
|
- getConference() {
|
|
154
|
+ getConference(): JitsiConference {
|
119
|
155
|
return this._conference;
|
120
|
156
|
}
|
121
|
157
|
|
|
@@ -124,14 +160,14 @@ export default class JitsiParticipant {
|
124
|
160
|
*
|
125
|
161
|
* @returns {string|undefined} - The connection jid of the participant.
|
126
|
162
|
*/
|
127
|
|
- getConnectionJid() {
|
|
163
|
+ getConnectionJid(): string | undefined {
|
128
|
164
|
return this._connectionJid;
|
129
|
165
|
}
|
130
|
166
|
|
131
|
167
|
/**
|
132
|
168
|
* @returns {String} The human-readable display name of this participant.
|
133
|
169
|
*/
|
134
|
|
- getDisplayName() {
|
|
170
|
+ getDisplayName(): string {
|
135
|
171
|
return this._displayName;
|
136
|
172
|
}
|
137
|
173
|
|
|
@@ -139,14 +175,14 @@ export default class JitsiParticipant {
|
139
|
175
|
* Returns a set with the features for the participant.
|
140
|
176
|
* @returns {Promise<Set<String>>}
|
141
|
177
|
*/
|
142
|
|
- getFeatures() {
|
|
178
|
+ getFeatures(): Promise<Set<string>> {
|
143
|
179
|
return Promise.resolve(this._features);
|
144
|
180
|
}
|
145
|
181
|
|
146
|
182
|
/**
|
147
|
183
|
* @returns {String} The ID of this participant.
|
148
|
184
|
*/
|
149
|
|
- getId() {
|
|
185
|
+ getId(): string {
|
150
|
186
|
return this._id;
|
151
|
187
|
}
|
152
|
188
|
|
|
@@ -156,28 +192,28 @@ export default class JitsiParticipant {
|
156
|
192
|
*
|
157
|
193
|
* @returns {object|undefined} - XMPP user identity.
|
158
|
194
|
*/
|
159
|
|
- getIdentity() {
|
|
195
|
+ getIdentity(): object | undefined {
|
160
|
196
|
return this._identity;
|
161
|
197
|
}
|
162
|
198
|
|
163
|
199
|
/**
|
164
|
200
|
* @returns {String} The JID of this participant.
|
165
|
201
|
*/
|
166
|
|
- getJid() {
|
|
202
|
+ getJid(): string {
|
167
|
203
|
return this._jid;
|
168
|
204
|
}
|
169
|
205
|
|
170
|
206
|
/**
|
171
|
207
|
* Gets the value of a property of this participant.
|
172
|
208
|
*/
|
173
|
|
- getProperty(name) {
|
|
209
|
+ getProperty(name: string): any {
|
174
|
210
|
return this._properties.get(name);
|
175
|
211
|
}
|
176
|
212
|
|
177
|
213
|
/**
|
178
|
214
|
* @returns {String} The role of this participant.
|
179
|
215
|
*/
|
180
|
|
- getRole() {
|
|
216
|
+ getRole(): string {
|
181
|
217
|
return this._role;
|
182
|
218
|
}
|
183
|
219
|
|
|
@@ -185,21 +221,21 @@ export default class JitsiParticipant {
|
185
|
221
|
* Returns the sources associated with this participant.
|
186
|
222
|
* @returns Map<string, Map<string, Object>>
|
187
|
223
|
*/
|
188
|
|
- getSources() {
|
|
224
|
+ getSources(): Map<MediaType, Map<string, ISourceInfo>> {
|
189
|
225
|
return this._sources;
|
190
|
226
|
}
|
191
|
227
|
|
192
|
228
|
/**
|
193
|
229
|
* @returns {String} The stats ID of this participant.
|
194
|
230
|
*/
|
195
|
|
- getStatsID() {
|
|
231
|
+ getStatsID(): string {
|
196
|
232
|
return this._statsID;
|
197
|
233
|
}
|
198
|
234
|
|
199
|
235
|
/**
|
200
|
236
|
* @returns {String} The status of the participant.
|
201
|
237
|
*/
|
202
|
|
- getStatus() {
|
|
238
|
+ getStatus(): string {
|
203
|
239
|
return this._status;
|
204
|
240
|
}
|
205
|
241
|
|
|
@@ -207,7 +243,7 @@ export default class JitsiParticipant {
|
207
|
243
|
* @returns {Array.<JitsiTrack>} The list of media tracks for this
|
208
|
244
|
* participant.
|
209
|
245
|
*/
|
210
|
|
- getTracks() {
|
|
246
|
+ getTracks(): JitsiTrack[] {
|
211
|
247
|
return this._tracks.slice();
|
212
|
248
|
}
|
213
|
249
|
|
|
@@ -216,7 +252,7 @@ export default class JitsiParticipant {
|
216
|
252
|
* @returns {Array.<JitsiTrack>} an array of media tracks for this
|
217
|
253
|
* participant, for given media type.
|
218
|
254
|
*/
|
219
|
|
- getTracksByMediaType(mediaType) {
|
|
255
|
+ getTracksByMediaType(mediaType: MediaType): JitsiTrack[] {
|
220
|
256
|
return this.getTracks().filter(track => track.getType() === mediaType);
|
221
|
257
|
}
|
222
|
258
|
|
|
@@ -226,14 +262,14 @@ export default class JitsiParticipant {
|
226
|
262
|
* @return {boolean} <tt>true</tt> if this <tt>participant</tt> contains the
|
227
|
263
|
* <tt>feature</tt>.
|
228
|
264
|
*/
|
229
|
|
- hasFeature(feature) {
|
|
265
|
+ hasFeature(feature: string): boolean {
|
230
|
266
|
return this._features.has(feature);
|
231
|
267
|
}
|
232
|
268
|
|
233
|
269
|
/**
|
234
|
270
|
* @returns {Boolean} Whether this participant has muted their audio.
|
235
|
271
|
*/
|
236
|
|
- isAudioMuted() {
|
|
272
|
+ isAudioMuted(): boolean {
|
237
|
273
|
return this._isMediaTypeMuted(MediaType.AUDIO);
|
238
|
274
|
}
|
239
|
275
|
|
|
@@ -242,7 +278,7 @@ export default class JitsiParticipant {
|
242
|
278
|
* special system participants may want to join hidden (like for example the
|
243
|
279
|
* recorder).
|
244
|
280
|
*/
|
245
|
|
- isHidden() {
|
|
281
|
+ isHidden(): boolean {
|
246
|
282
|
return this._hidden;
|
247
|
283
|
}
|
248
|
284
|
|
|
@@ -251,14 +287,14 @@ export default class JitsiParticipant {
|
251
|
287
|
* special system participants may want to join hidden (like for example the
|
252
|
288
|
* recorder).
|
253
|
289
|
*/
|
254
|
|
- isHiddenFromRecorder() {
|
255
|
|
- return this._identity?.user?.['hidden-from-recorder'] === 'true';
|
|
290
|
+ isHiddenFromRecorder(): boolean {
|
|
291
|
+ return (this._identity as any)?.user?.['hidden-from-recorder'] === 'true';
|
256
|
292
|
}
|
257
|
293
|
|
258
|
294
|
/**
|
259
|
295
|
* @returns {Boolean} Whether this participant is a moderator or not.
|
260
|
296
|
*/
|
261
|
|
- isModerator() {
|
|
297
|
+ isModerator(): boolean {
|
262
|
298
|
return this._role === 'moderator';
|
263
|
299
|
}
|
264
|
300
|
|
|
@@ -266,7 +302,7 @@ export default class JitsiParticipant {
|
266
|
302
|
* @returns {Boolean} Wheter this participants will be replaced by another
|
267
|
303
|
* participant in the meeting.
|
268
|
304
|
*/
|
269
|
|
- isReplaced() {
|
|
305
|
+ isReplaced(): boolean {
|
270
|
306
|
return this._isReplaced;
|
271
|
307
|
}
|
272
|
308
|
|
|
@@ -274,21 +310,21 @@ export default class JitsiParticipant {
|
274
|
310
|
* @returns {Boolean} Whether this participant replaces another participant
|
275
|
311
|
* from the meeting.
|
276
|
312
|
*/
|
277
|
|
- isReplacing() {
|
|
313
|
+ isReplacing(): boolean {
|
278
|
314
|
return this._isReplacing;
|
279
|
315
|
}
|
280
|
316
|
|
281
|
317
|
/**
|
282
|
318
|
* @returns {Boolean} Whether this participant has joined without audio.
|
283
|
319
|
*/
|
284
|
|
- isSilent() {
|
|
320
|
+ isSilent(): boolean {
|
285
|
321
|
return this._isSilent;
|
286
|
322
|
}
|
287
|
323
|
|
288
|
324
|
/**
|
289
|
325
|
* @returns {Boolean} Whether this participant has muted their video.
|
290
|
326
|
*/
|
291
|
|
- isVideoMuted() {
|
|
327
|
+ isVideoMuted(): boolean {
|
292
|
328
|
return this._isMediaTypeMuted(MediaType.VIDEO);
|
293
|
329
|
}
|
294
|
330
|
|
|
@@ -296,7 +332,7 @@ export default class JitsiParticipant {
|
296
|
332
|
* Sets the bot type for the participant.
|
297
|
333
|
* @param {String} newBotType - The new bot type to set.
|
298
|
334
|
*/
|
299
|
|
- setBotType(newBotType) {
|
|
335
|
+ setBotType(newBotType: string): void {
|
300
|
336
|
this._botType = newBotType;
|
301
|
337
|
}
|
302
|
338
|
|
|
@@ -304,7 +340,7 @@ export default class JitsiParticipant {
|
304
|
340
|
* Sets the connection jid for the participant.
|
305
|
341
|
* @param {String} newJid - The connection jid to set.
|
306
|
342
|
*/
|
307
|
|
- setConnectionJid(newJid) {
|
|
343
|
+ setConnectionJid(newJid: string): void {
|
308
|
344
|
this._connectionJid = newJid;
|
309
|
345
|
}
|
310
|
346
|
|
|
@@ -312,7 +348,7 @@ export default class JitsiParticipant {
|
312
|
348
|
* Set new features.
|
313
|
349
|
* @param {Set<String>|undefined} newFeatures - Sets new features.
|
314
|
350
|
*/
|
315
|
|
- setFeatures(newFeatures) {
|
|
351
|
+ setFeatures(newFeatures?: Set<string>): void {
|
316
|
352
|
this._features = newFeatures || new Set();
|
317
|
353
|
}
|
318
|
354
|
|
|
@@ -320,15 +356,15 @@ export default class JitsiParticipant {
|
320
|
356
|
* Sets whether participant is being replaced by another based on jwt.
|
321
|
357
|
* @param {boolean} newIsReplaced - whether is being replaced.
|
322
|
358
|
*/
|
323
|
|
- setIsReplaced(newIsReplaced) {
|
|
359
|
+ setIsReplaced(newIsReplaced: boolean): void {
|
324
|
360
|
this._isReplaced = newIsReplaced;
|
325
|
361
|
}
|
326
|
362
|
|
327
|
363
|
/**
|
328
|
364
|
* Sets whether participant is replacing another based on jwt.
|
329
|
|
- * @param {String} newIsReplacing - whether is replacing.
|
|
365
|
+ * @param {boolean} newIsReplacing - whether is replacing.
|
330
|
366
|
*/
|
331
|
|
- setIsReplacing(newIsReplacing) {
|
|
367
|
+ setIsReplacing(newIsReplacing: boolean): void {
|
332
|
368
|
this._isReplacing = newIsReplacing;
|
333
|
369
|
}
|
334
|
370
|
|
|
@@ -336,7 +372,7 @@ export default class JitsiParticipant {
|
336
|
372
|
* Sets whether participant has joined without audio.
|
337
|
373
|
* @param {boolean} newIsSilent - whether is silent.
|
338
|
374
|
*/
|
339
|
|
- setIsSilent(newIsSilent) {
|
|
375
|
+ setIsSilent(newIsSilent: boolean): void {
|
340
|
376
|
this._isSilent = newIsSilent;
|
341
|
377
|
}
|
342
|
378
|
|
|
@@ -346,7 +382,7 @@ export default class JitsiParticipant {
|
346
|
382
|
* @name the name of the property.
|
347
|
383
|
* @value the value to set.
|
348
|
384
|
*/
|
349
|
|
- setProperty(name, value) {
|
|
385
|
+ setProperty(name: string, value: any): void {
|
350
|
386
|
const oldValue = this._properties.get(name);
|
351
|
387
|
|
352
|
388
|
if (value !== oldValue) {
|
|
@@ -364,14 +400,14 @@ export default class JitsiParticipant {
|
364
|
400
|
* Sets a new participant role.
|
365
|
401
|
* @param {String} newRole - the new role.
|
366
|
402
|
*/
|
367
|
|
- setRole(newRole) {
|
|
403
|
+ setRole(newRole: string): void {
|
368
|
404
|
this._role = newRole;
|
369
|
405
|
}
|
370
|
406
|
|
371
|
407
|
/**
|
372
|
408
|
*
|
373
|
409
|
*/
|
374
|
|
- supportsDTMF() {
|
|
410
|
+ supportsDTMF(): boolean {
|
375
|
411
|
return this._supportsDTMF;
|
376
|
412
|
}
|
377
|
413
|
}
|