|
|
@@ -1,211 +1,224 @@
|
|
1
|
1
|
/* global Strophe */
|
|
2
|
2
|
import * as JitsiConferenceEvents from "./JitsiConferenceEvents";
|
|
3
|
|
-
|
|
4
|
|
-/**
|
|
5
|
|
- * Represents a participant in (a member of) a conference.
|
|
6
|
|
- * @param jid the conference XMPP jid
|
|
7
|
|
- * @param conference
|
|
8
|
|
- * @param displayName
|
|
9
|
|
- * @param isHidden indicates if this participant is a hidden participant
|
|
10
|
|
- */
|
|
11
|
|
-function JitsiParticipant(jid, conference, displayName, isHidden){
|
|
12
|
|
- this._jid = jid;
|
|
13
|
|
- this._id = Strophe.getResourceFromJid(jid);
|
|
14
|
|
- this._conference = conference;
|
|
15
|
|
- this._displayName = displayName;
|
|
16
|
|
- this._supportsDTMF = false;
|
|
17
|
|
- this._tracks = [];
|
|
18
|
|
- this._role = 'none';
|
|
19
|
|
- this._status = null;
|
|
20
|
|
- this._availableDevices = {
|
|
21
|
|
- audio: undefined,
|
|
22
|
|
- video: undefined
|
|
23
|
|
- };
|
|
24
|
|
- this._isHidden = isHidden;
|
|
25
|
|
- this._properties = {};
|
|
26
|
|
-}
|
|
27
|
|
-
|
|
28
|
|
-/**
|
|
29
|
|
- * @returns {JitsiConference} The conference that this participant belongs to.
|
|
30
|
|
- */
|
|
31
|
|
-JitsiParticipant.prototype.getConference = function() {
|
|
32
|
|
- return this._conference;
|
|
33
|
|
-};
|
|
34
|
|
-
|
|
35
|
|
-/**
|
|
36
|
|
- * Gets the value of a property of this participant.
|
|
37
|
|
- */
|
|
38
|
|
-JitsiParticipant.prototype.getProperty = function(name) {
|
|
39
|
|
- return this._properties[name];
|
|
40
|
|
-};
|
|
41
|
|
-
|
|
42
|
|
-/**
|
|
43
|
|
- * Sets the value of a property of this participant, and fires an event if the
|
|
44
|
|
- * value has changed.
|
|
45
|
|
- * @name the name of the property.
|
|
46
|
|
- * @value the value to set.
|
|
47
|
|
- */
|
|
48
|
|
-JitsiParticipant.prototype.setProperty = function(name, value) {
|
|
49
|
|
- var oldValue = this._properties[name];
|
|
50
|
|
- this._properties[name] = value;
|
|
51
|
|
-
|
|
52
|
|
- if (value !== oldValue) {
|
|
53
|
|
- this._conference.eventEmitter.emit(
|
|
54
|
|
- JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
|
|
55
|
|
- this,
|
|
56
|
|
- name,
|
|
57
|
|
- oldValue,
|
|
58
|
|
- value);
|
|
|
3
|
+import * as MediaType from "./service/RTC/MediaType";
|
|
|
4
|
+
|
|
|
5
|
+/**
|
|
|
6
|
+ * Represents a participant in (i.e. a member of) a conference.
|
|
|
7
|
+ */
|
|
|
8
|
+export default class JitsiParticipant {
|
|
|
9
|
+ /**
|
|
|
10
|
+ * Initializes a new JitsiParticipant instance.
|
|
|
11
|
+ *
|
|
|
12
|
+ * @constructor
|
|
|
13
|
+ * @param jid the conference XMPP jid
|
|
|
14
|
+ * @param conference
|
|
|
15
|
+ * @param displayName
|
|
|
16
|
+ * @param {Boolean} hidden - True if the new JitsiParticipant instance is to
|
|
|
17
|
+ * represent a hidden participant; otherwise, false.
|
|
|
18
|
+ */
|
|
|
19
|
+ constructor(jid, conference, displayName, hidden) {
|
|
|
20
|
+ this._jid = jid;
|
|
|
21
|
+ this._id = Strophe.getResourceFromJid(jid);
|
|
|
22
|
+ this._conference = conference;
|
|
|
23
|
+ this._displayName = displayName;
|
|
|
24
|
+ this._supportsDTMF = false;
|
|
|
25
|
+ this._tracks = [];
|
|
|
26
|
+ this._role = 'none';
|
|
|
27
|
+ this._status = null;
|
|
|
28
|
+ this._availableDevices = {
|
|
|
29
|
+ audio: undefined,
|
|
|
30
|
+ video: undefined
|
|
|
31
|
+ };
|
|
|
32
|
+ this._hidden = hidden;
|
|
|
33
|
+ this._properties = {};
|
|
59
|
34
|
}
|
|
60
|
|
-};
|
|
61
|
35
|
|
|
62
|
|
-/**
|
|
63
|
|
- * @returns {Array.<JitsiTrack>} The list of media tracks for this participant.
|
|
64
|
|
- */
|
|
65
|
|
-JitsiParticipant.prototype.getTracks = function() {
|
|
66
|
|
- return this._tracks.slice();
|
|
67
|
|
-};
|
|
68
|
|
-
|
|
69
|
|
-/**
|
|
70
|
|
- * @returns {String} The ID of this participant.
|
|
71
|
|
- */
|
|
72
|
|
-JitsiParticipant.prototype.getId = function() {
|
|
73
|
|
- return this._id;
|
|
74
|
|
-};
|
|
75
|
|
-
|
|
76
|
|
-/**
|
|
77
|
|
- * @returns {String} The JID of this participant.
|
|
78
|
|
- */
|
|
79
|
|
-JitsiParticipant.prototype.getJid = function() {
|
|
80
|
|
- return this._jid;
|
|
81
|
|
-};
|
|
82
|
|
-
|
|
83
|
|
-/**
|
|
84
|
|
- * @returns {String} The human-readable display name of this participant.
|
|
85
|
|
- */
|
|
86
|
|
-JitsiParticipant.prototype.getDisplayName = function() {
|
|
87
|
|
- return this._displayName;
|
|
88
|
|
-};
|
|
89
|
|
-
|
|
90
|
|
-/**
|
|
91
|
|
- * @returns {String} The status of the participant.
|
|
92
|
|
- */
|
|
93
|
|
-JitsiParticipant.prototype.getStatus = function () {
|
|
94
|
|
- return this._status;
|
|
95
|
|
-};
|
|
96
|
|
-
|
|
97
|
|
-/**
|
|
98
|
|
- * @returns {Boolean} Whether this participant is a moderator or not.
|
|
99
|
|
- */
|
|
100
|
|
-JitsiParticipant.prototype.isModerator = function() {
|
|
101
|
|
- return this._role === 'moderator';
|
|
102
|
|
-};
|
|
|
36
|
+ /**
|
|
|
37
|
+ * @returns {JitsiConference} The conference that this participant belongs
|
|
|
38
|
+ * to.
|
|
|
39
|
+ */
|
|
|
40
|
+ getConference() {
|
|
|
41
|
+ return this._conference;
|
|
|
42
|
+ }
|
|
103
|
43
|
|
|
104
|
|
-/**
|
|
105
|
|
- * @returns {Boolean} Whether this participant is a hidden participant. Some
|
|
106
|
|
- * special system participants may want to join hidden (like for example the
|
|
107
|
|
- * recorder).
|
|
108
|
|
- */
|
|
109
|
|
-JitsiParticipant.prototype.isHidden = function() {
|
|
110
|
|
- return this._isHidden;
|
|
111
|
|
-};
|
|
|
44
|
+ /**
|
|
|
45
|
+ * Gets the value of a property of this participant.
|
|
|
46
|
+ */
|
|
|
47
|
+ getProperty(name) {
|
|
|
48
|
+ return this._properties[name];
|
|
|
49
|
+ }
|
|
112
|
50
|
|
|
113
|
|
-// Gets a link to an etherpad instance advertised by the participant?
|
|
114
|
|
-//JitsiParticipant.prototype.getEtherpad = function() {
|
|
115
|
|
-//
|
|
116
|
|
-//}
|
|
|
51
|
+ /**
|
|
|
52
|
+ * Sets the value of a property of this participant, and fires an event if
|
|
|
53
|
+ * the value has changed.
|
|
|
54
|
+ * @name the name of the property.
|
|
|
55
|
+ * @value the value to set.
|
|
|
56
|
+ */
|
|
|
57
|
+ setProperty(name, value) {
|
|
|
58
|
+ var oldValue = this._properties[name];
|
|
|
59
|
+
|
|
|
60
|
+ if (value !== oldValue) {
|
|
|
61
|
+ this._properties[name] = value;
|
|
|
62
|
+ this._conference.eventEmitter.emit(
|
|
|
63
|
+ JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
|
|
|
64
|
+ this,
|
|
|
65
|
+ name,
|
|
|
66
|
+ oldValue,
|
|
|
67
|
+ value);
|
|
|
68
|
+ }
|
|
|
69
|
+ }
|
|
117
|
70
|
|
|
|
71
|
+ /**
|
|
|
72
|
+ * @returns {Array.<JitsiTrack>} The list of media tracks for this
|
|
|
73
|
+ * participant.
|
|
|
74
|
+ */
|
|
|
75
|
+ getTracks() {
|
|
|
76
|
+ return this._tracks.slice();
|
|
|
77
|
+ }
|
|
118
|
78
|
|
|
119
|
|
-/*
|
|
120
|
|
- * @returns {Boolean} Whether this participant has muted their audio.
|
|
121
|
|
- */
|
|
122
|
|
-JitsiParticipant.prototype.isAudioMuted = function() {
|
|
123
|
|
- return this.getTracks().reduce(function (track, isAudioMuted) {
|
|
124
|
|
- return isAudioMuted && (track.isVideoTrack() || track.isMuted());
|
|
125
|
|
- }, true);
|
|
126
|
|
-};
|
|
127
|
|
-
|
|
128
|
|
-/*
|
|
129
|
|
- * @returns {Boolean} Whether this participant has muted their video.
|
|
130
|
|
- */
|
|
131
|
|
-JitsiParticipant.prototype.isVideoMuted = function() {
|
|
132
|
|
- return this.getTracks().reduce(function (track, isVideoMuted) {
|
|
133
|
|
- return isVideoMuted && (track.isAudioTrack() || track.isMuted());
|
|
134
|
|
- }, true);
|
|
135
|
|
-};
|
|
136
|
|
-
|
|
137
|
|
-/*
|
|
138
|
|
- * @returns {???} The latest statistics reported by this participant
|
|
139
|
|
- * (i.e. info used to populate the GSM bars)
|
|
140
|
|
- * TODO: do we expose this or handle it internally?
|
|
141
|
|
- */
|
|
142
|
|
-JitsiParticipant.prototype.getLatestStats = function() {
|
|
|
79
|
+ /**
|
|
|
80
|
+ * @returns {String} The ID of this participant.
|
|
|
81
|
+ */
|
|
|
82
|
+ getId() {
|
|
|
83
|
+ return this._id;
|
|
|
84
|
+ }
|
|
143
|
85
|
|
|
144
|
|
-};
|
|
|
86
|
+ /**
|
|
|
87
|
+ * @returns {String} The JID of this participant.
|
|
|
88
|
+ */
|
|
|
89
|
+ getJid() {
|
|
|
90
|
+ return this._jid;
|
|
|
91
|
+ }
|
|
145
|
92
|
|
|
146
|
|
-/**
|
|
147
|
|
- * @returns {String} The role of this participant.
|
|
148
|
|
- */
|
|
149
|
|
-JitsiParticipant.prototype.getRole = function() {
|
|
150
|
|
- return this._role;
|
|
151
|
|
-};
|
|
|
93
|
+ /**
|
|
|
94
|
+ * @returns {String} The human-readable display name of this participant.
|
|
|
95
|
+ */
|
|
|
96
|
+ getDisplayName() {
|
|
|
97
|
+ return this._displayName;
|
|
|
98
|
+ }
|
|
152
|
99
|
|
|
153
|
|
-/*
|
|
154
|
|
- * @returns {Boolean} Whether this participant is
|
|
155
|
|
- * the conference focus (i.e. jicofo).
|
|
156
|
|
- */
|
|
157
|
|
-JitsiParticipant.prototype.isFocus = function() {
|
|
|
100
|
+ /**
|
|
|
101
|
+ * @returns {String} The status of the participant.
|
|
|
102
|
+ */
|
|
|
103
|
+ getStatus () {
|
|
|
104
|
+ return this._status;
|
|
|
105
|
+ }
|
|
158
|
106
|
|
|
159
|
|
-};
|
|
|
107
|
+ /**
|
|
|
108
|
+ * @returns {Boolean} Whether this participant is a moderator or not.
|
|
|
109
|
+ */
|
|
|
110
|
+ isModerator() {
|
|
|
111
|
+ return this._role === 'moderator';
|
|
|
112
|
+ }
|
|
160
|
113
|
|
|
161
|
|
-/*
|
|
162
|
|
- * @returns {Boolean} Whether this participant is
|
|
163
|
|
- * a conference recorder (i.e. jirecon).
|
|
164
|
|
- */
|
|
165
|
|
-JitsiParticipant.prototype.isRecorder = function() {
|
|
|
114
|
+ /**
|
|
|
115
|
+ * @returns {Boolean} Whether this participant is a hidden participant. Some
|
|
|
116
|
+ * special system participants may want to join hidden (like for example the
|
|
|
117
|
+ * recorder).
|
|
|
118
|
+ */
|
|
|
119
|
+ isHidden() {
|
|
|
120
|
+ return this._hidden;
|
|
|
121
|
+ }
|
|
166
|
122
|
|
|
167
|
|
-};
|
|
|
123
|
+ // Gets a link to an etherpad instance advertised by the participant?
|
|
|
124
|
+ //getEtherpad() {
|
|
|
125
|
+ //}
|
|
168
|
126
|
|
|
169
|
|
-/*
|
|
170
|
|
- * @returns {Boolean} Whether this participant is a SIP gateway (i.e. jigasi).
|
|
171
|
|
- */
|
|
172
|
|
-JitsiParticipant.prototype.isSipGateway = function() {
|
|
|
127
|
+ /**
|
|
|
128
|
+ * @returns {Boolean} Whether this participant has muted their audio.
|
|
|
129
|
+ */
|
|
|
130
|
+ isAudioMuted() {
|
|
|
131
|
+ return this._isMediaTypeMuted(MediaType.AUDIO);
|
|
|
132
|
+ }
|
|
173
|
133
|
|
|
174
|
|
-};
|
|
|
134
|
+ /**
|
|
|
135
|
+ * Determines whether all JitsiTracks which are of a specific MediaType and
|
|
|
136
|
+ * which belong to this JitsiParticipant are muted.
|
|
|
137
|
+ *
|
|
|
138
|
+ * @param {MediaType} mediaType - The MediaType of the JitsiTracks to be
|
|
|
139
|
+ * checked.
|
|
|
140
|
+ * @private
|
|
|
141
|
+ * @returns {Boolean} True if all JitsiTracks which are of the specified
|
|
|
142
|
+ * mediaType and which belong to this JitsiParticipant are muted; otherwise,
|
|
|
143
|
+ * false.
|
|
|
144
|
+ */
|
|
|
145
|
+ _isMediaTypeMuted(mediaType) {
|
|
|
146
|
+ return this.getTracks().reduce(
|
|
|
147
|
+ (muted, track) =>
|
|
|
148
|
+ muted && (track.getType() !== mediaType || track.isMuted()),
|
|
|
149
|
+ true);
|
|
|
150
|
+ }
|
|
175
|
151
|
|
|
176
|
|
-/**
|
|
177
|
|
- * @returns {Boolean} Whether this participant
|
|
178
|
|
- * is currently sharing their screen.
|
|
179
|
|
- */
|
|
180
|
|
-JitsiParticipant.prototype.isScreenSharing = function() {
|
|
|
152
|
+ /**
|
|
|
153
|
+ * @returns {Boolean} Whether this participant has muted their video.
|
|
|
154
|
+ */
|
|
|
155
|
+ isVideoMuted() {
|
|
|
156
|
+ return this._isMediaTypeMuted(MediaType.VIDEO);
|
|
|
157
|
+ }
|
|
181
|
158
|
|
|
182
|
|
-};
|
|
|
159
|
+ /**
|
|
|
160
|
+ * @returns {???} The latest statistics reported by this participant (i.e.
|
|
|
161
|
+ * info used to populate the GSM bars)
|
|
|
162
|
+ * TODO: do we expose this or handle it internally?
|
|
|
163
|
+ */
|
|
|
164
|
+ getLatestStats() {
|
|
|
165
|
+ }
|
|
183
|
166
|
|
|
184
|
|
-/**
|
|
185
|
|
- * @returns {String} The user agent of this participant
|
|
186
|
|
- * (i.e. browser userAgent string).
|
|
187
|
|
- */
|
|
188
|
|
-JitsiParticipant.prototype.getUserAgent = function() {
|
|
|
167
|
+ /**
|
|
|
168
|
+ * @returns {String} The role of this participant.
|
|
|
169
|
+ */
|
|
|
170
|
+ getRole() {
|
|
|
171
|
+ return this._role;
|
|
|
172
|
+ }
|
|
189
|
173
|
|
|
190
|
|
-};
|
|
|
174
|
+ /**
|
|
|
175
|
+ * @returns {Boolean} Whether this participant is the conference focus (i.e.
|
|
|
176
|
+ * jicofo).
|
|
|
177
|
+ */
|
|
|
178
|
+ isFocus() {
|
|
|
179
|
+ }
|
|
191
|
180
|
|
|
192
|
|
-/**
|
|
193
|
|
- * Kicks the participant from the conference (requires certain privileges).
|
|
194
|
|
- */
|
|
195
|
|
-JitsiParticipant.prototype.kick = function() {
|
|
|
181
|
+ /**
|
|
|
182
|
+ * @returns {Boolean} Whether this participant is a conference recorder
|
|
|
183
|
+ * (i.e. jirecon).
|
|
|
184
|
+ */
|
|
|
185
|
+ isRecorder() {
|
|
|
186
|
+ }
|
|
196
|
187
|
|
|
197
|
|
-};
|
|
|
188
|
+ /**
|
|
|
189
|
+ * @returns {Boolean} Whether this participant is a SIP gateway (i.e.
|
|
|
190
|
+ * jigasi).
|
|
|
191
|
+ */
|
|
|
192
|
+ isSipGateway() {
|
|
|
193
|
+ }
|
|
198
|
194
|
|
|
199
|
|
-/**
|
|
200
|
|
- * Asks this participant to mute themselves.
|
|
201
|
|
- */
|
|
202
|
|
-JitsiParticipant.prototype.askToMute = function() {
|
|
|
195
|
+ /**
|
|
|
196
|
+ * @returns {Boolean} Whether this participant is currently sharing their
|
|
|
197
|
+ * screen.
|
|
|
198
|
+ */
|
|
|
199
|
+ isScreenSharing() {
|
|
|
200
|
+ }
|
|
203
|
201
|
|
|
204
|
|
-};
|
|
|
202
|
+ /**
|
|
|
203
|
+ * @returns {String} The user agent of this participant (i.e. browser
|
|
|
204
|
+ * userAgent string).
|
|
|
205
|
+ */
|
|
|
206
|
+ getUserAgent() {
|
|
|
207
|
+ }
|
|
205
|
208
|
|
|
206
|
|
-JitsiParticipant.prototype.supportsDTMF = function () {
|
|
207
|
|
- return this._supportsDTMF;
|
|
208
|
|
-};
|
|
|
209
|
+ /**
|
|
|
210
|
+ * Kicks the participant from the conference (requires certain privileges).
|
|
|
211
|
+ */
|
|
|
212
|
+ kick() {
|
|
|
213
|
+ }
|
|
209
|
214
|
|
|
|
215
|
+ /**
|
|
|
216
|
+ * Asks this participant to mute themselves.
|
|
|
217
|
+ */
|
|
|
218
|
+ askToMute() {
|
|
|
219
|
+ }
|
|
210
|
220
|
|
|
211
|
|
-module.exports = JitsiParticipant;
|
|
|
221
|
+ supportsDTMF() {
|
|
|
222
|
+ return this._supportsDTMF;
|
|
|
223
|
+ }
|
|
|
224
|
+}
|