|
@@ -16,8 +16,15 @@ var MediaType = require("./service/RTC/MediaType");
|
16
|
16
|
*/
|
17
|
17
|
function JitsiConferenceEventManager(conference) {
|
18
|
18
|
this.conference = conference;
|
19
|
|
- this.chatRoomForwarder = new EventEmitterForwarder(this.conference.room,
|
20
|
|
- this.conference.eventEmitter);
|
|
19
|
+
|
|
20
|
+ //Listeners related to the conference only
|
|
21
|
+ conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
|
22
|
+ function (track) {
|
|
23
|
+ if(!track.isLocal() || !conference.statistics)
|
|
24
|
+ return;
|
|
25
|
+ conference.statistics.sendMuteEvent(track.isMuted(),
|
|
26
|
+ track.getType());
|
|
27
|
+ });
|
21
|
28
|
}
|
22
|
29
|
|
23
|
30
|
/**
|
|
@@ -25,15 +32,18 @@ function JitsiConferenceEventManager(conference) {
|
25
|
32
|
*/
|
26
|
33
|
JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
27
|
34
|
var conference = this.conference;
|
|
35
|
+ var chatRoom = conference.room;
|
|
36
|
+ this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
|
|
37
|
+ this.conference.eventEmitter);
|
28
|
38
|
|
29
|
|
- conference.room.addListener(XMPPEvents.ICE_RESTARTING, function () {
|
|
39
|
+ chatRoom.addListener(XMPPEvents.ICE_RESTARTING, function () {
|
30
|
40
|
// All data channels have to be closed, before ICE restart
|
31
|
41
|
// otherwise Chrome will not trigger "opened" event for the channel
|
32
|
42
|
// established with the new bridge
|
33
|
43
|
conference.rtc.closeAllDataChannels();
|
34
|
44
|
});
|
35
|
45
|
|
36
|
|
- conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
|
|
46
|
+ chatRoom.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
|
37
|
47
|
function (data) {
|
38
|
48
|
var track = conference.rtc.createRemoteTrack(data);
|
39
|
49
|
if (track) {
|
|
@@ -41,7 +51,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
41
|
51
|
}
|
42
|
52
|
}
|
43
|
53
|
);
|
44
|
|
- conference.room.addListener(XMPPEvents.REMOTE_TRACK_REMOVED,
|
|
54
|
+ chatRoom.addListener(XMPPEvents.REMOTE_TRACK_REMOVED,
|
45
|
55
|
function (streamId, trackId) {
|
46
|
56
|
conference.getParticipants().forEach(function(participant) {
|
47
|
57
|
var tracks = participant.getTracks();
|
|
@@ -59,7 +69,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
59
|
69
|
}
|
60
|
70
|
);
|
61
|
71
|
|
62
|
|
- conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
|
|
72
|
+ chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
|
63
|
73
|
function (value) {
|
64
|
74
|
// set isMutedByFocus when setAudioMute Promise ends
|
65
|
75
|
conference.rtc.setAudioMute(value).then(
|
|
@@ -111,13 +121,20 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
111
|
121
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
112
|
122
|
JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
|
113
|
123
|
|
114
|
|
- conference.room.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
|
|
124
|
+ chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
|
115
|
125
|
function (session, error) {
|
116
|
126
|
conference.eventEmitter.emit(
|
117
|
127
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
118
|
128
|
JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
|
119
|
129
|
});
|
120
|
130
|
|
|
131
|
+ chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
|
|
132
|
+ function (pc) {
|
|
133
|
+ chatRoom.eventEmitter.emit(
|
|
134
|
+ XMPPEvents.CONFERENCE_SETUP_FAILED,
|
|
135
|
+ new Error("ICE fail"));
|
|
136
|
+ });
|
|
137
|
+
|
121
|
138
|
this.chatRoomForwarder.forward(XMPPEvents.MUC_DESTROYED,
|
122
|
139
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
123
|
140
|
JitsiConferenceErrors.CONFERENCE_DESTROYED);
|
|
@@ -130,7 +147,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
130
|
147
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
131
|
148
|
JitsiConferenceErrors.FOCUS_DISCONNECTED);
|
132
|
149
|
|
133
|
|
- conference.room.addListener(XMPPEvents.FOCUS_LEFT,
|
|
150
|
+ chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
|
134
|
151
|
function () {
|
135
|
152
|
if(!conference.connection._reload())
|
136
|
153
|
conference.eventEmitter.emit(
|
|
@@ -138,7 +155,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
138
|
155
|
JitsiConferenceErrors.FOCUS_LEFT);
|
139
|
156
|
});
|
140
|
157
|
|
141
|
|
- conference.room.addListener(XMPPEvents.ALLOCATE_FOCUS_MAX_RETRIES_ERROR,
|
|
158
|
+ chatRoom.addListener(XMPPEvents.ALLOCATE_FOCUS_MAX_RETRIES_ERROR,
|
142
|
159
|
function () {
|
143
|
160
|
conference.connection._reload();
|
144
|
161
|
});
|
|
@@ -159,7 +176,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
159
|
176
|
JitsiConferenceEvents.CONFERENCE_FAILED,
|
160
|
177
|
JitsiConferenceErrors.SETUP_FAILED);
|
161
|
178
|
|
162
|
|
- conference.room.setParticipantPropertyListener(function (node, from) {
|
|
179
|
+ chatRoom.setParticipantPropertyListener(function (node, from) {
|
163
|
180
|
var participant = conference.getParticipantById(from);
|
164
|
181
|
if (!participant) {
|
165
|
182
|
return;
|
|
@@ -173,15 +190,15 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
173
|
190
|
this.chatRoomForwarder.forward(XMPPEvents.KICKED,
|
174
|
191
|
JitsiConferenceEvents.KICKED);
|
175
|
192
|
|
176
|
|
- conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED,
|
|
193
|
+ chatRoom.addListener(XMPPEvents.MUC_MEMBER_JOINED,
|
177
|
194
|
conference.onMemberJoined.bind(conference));
|
178
|
|
- conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,
|
|
195
|
+ chatRoom.addListener(XMPPEvents.MUC_MEMBER_LEFT,
|
179
|
196
|
conference.onMemberLeft.bind(conference));
|
180
|
197
|
|
181
|
|
- conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
|
|
198
|
+ chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
|
182
|
199
|
conference.onDisplayNameChanged.bind(conference));
|
183
|
200
|
|
184
|
|
- conference.room.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
|
|
201
|
+ chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
|
185
|
202
|
conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
|
186
|
203
|
conference.myUserId(), role);
|
187
|
204
|
|
|
@@ -195,10 +212,10 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
195
|
212
|
}
|
196
|
213
|
});
|
197
|
214
|
|
198
|
|
- conference.room.addListener(XMPPEvents.MUC_ROLE_CHANGED,
|
|
215
|
+ chatRoom.addListener(XMPPEvents.MUC_ROLE_CHANGED,
|
199
|
216
|
conference.onUserRoleChanged.bind(conference));
|
200
|
217
|
|
201
|
|
- conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED,
|
|
218
|
+ chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
|
202
|
219
|
function (authEnabled, authIdentity) {
|
203
|
220
|
conference.authEnabled = authEnabled;
|
204
|
221
|
conference.authIdentity = authIdentity;
|
|
@@ -207,14 +224,14 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
207
|
224
|
authIdentity);
|
208
|
225
|
});
|
209
|
226
|
|
210
|
|
- conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED,
|
|
227
|
+ chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
|
211
|
228
|
function (jid, displayName, txt, myJid, ts) {
|
212
|
229
|
var id = Strophe.getResourceFromJid(jid);
|
213
|
230
|
conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
|
214
|
231
|
id, txt, ts);
|
215
|
232
|
});
|
216
|
233
|
|
217
|
|
- conference.room.addListener(XMPPEvents.PRESENCE_STATUS,
|
|
234
|
+ chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
|
218
|
235
|
function (jid, status) {
|
219
|
236
|
var id = Strophe.getResourceFromJid(jid);
|
220
|
237
|
var participant = conference.getParticipantById(id);
|
|
@@ -226,7 +243,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
226
|
243
|
JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
|
227
|
244
|
});
|
228
|
245
|
|
229
|
|
- conference.room.addPresenceListener("startmuted", function (data, from) {
|
|
246
|
+ chatRoom.addPresenceListener("startmuted", function (data, from) {
|
230
|
247
|
var isModerator = false;
|
231
|
248
|
if (conference.myUserId() === from && conference.isModerator()) {
|
232
|
249
|
isModerator = true;
|
|
@@ -264,21 +281,21 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
264
|
281
|
}
|
265
|
282
|
});
|
266
|
283
|
|
267
|
|
- conference.room.addPresenceListener("videomuted", function (values, from) {
|
|
284
|
+ chatRoom.addPresenceListener("videomuted", function (values, from) {
|
268
|
285
|
conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
|
269
|
286
|
values.value == "true", from);
|
270
|
287
|
});
|
271
|
288
|
|
272
|
|
- conference.room.addPresenceListener("audiomuted", function (values, from) {
|
|
289
|
+ chatRoom.addPresenceListener("audiomuted", function (values, from) {
|
273
|
290
|
conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
|
274
|
291
|
values.value == "true", from);
|
275
|
292
|
});
|
276
|
293
|
|
277
|
|
- conference.room.addPresenceListener("videoType", function(data, from) {
|
|
294
|
+ chatRoom.addPresenceListener("videoType", function(data, from) {
|
278
|
295
|
conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
|
279
|
296
|
});
|
280
|
297
|
|
281
|
|
- conference.room.addPresenceListener("devices", function (data, from) {
|
|
298
|
+ chatRoom.addPresenceListener("devices", function (data, from) {
|
282
|
299
|
var isAudioAvailable = false;
|
283
|
300
|
var isVideoAvailable = false;
|
284
|
301
|
data.children.forEach(function (config) {
|
|
@@ -322,40 +339,37 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
|
322
|
339
|
});
|
323
|
340
|
|
324
|
341
|
if(conference.statistics) {
|
325
|
|
- conference.room.addListener(XMPPEvents.DISPOSE_CONFERENCE,
|
|
342
|
+ chatRoom.addListener(XMPPEvents.DISPOSE_CONFERENCE,
|
326
|
343
|
function () {
|
327
|
344
|
conference.statistics.dispose();
|
328
|
345
|
});
|
329
|
346
|
|
330
|
|
- conference.room.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
|
|
347
|
+ chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
|
331
|
348
|
function (pc) {
|
332
|
349
|
conference.statistics.sendIceConnectionFailedEvent(pc);
|
333
|
|
- conference.room.eventEmitter.emit(
|
334
|
|
- XMPPEvents.CONFERENCE_SETUP_FAILED,
|
335
|
|
- new Error("ICE fail"));
|
336
|
350
|
});
|
337
|
351
|
|
338
|
|
- conference.room.addListener(XMPPEvents.CREATE_OFFER_FAILED,
|
|
352
|
+ chatRoom.addListener(XMPPEvents.CREATE_OFFER_FAILED,
|
339
|
353
|
function (e, pc) {
|
340
|
354
|
conference.statistics.sendCreateOfferFailed(e, pc);
|
341
|
355
|
});
|
342
|
356
|
|
343
|
|
- conference.room.addListener(XMPPEvents.CREATE_ANSWER_FAILED,
|
|
357
|
+ chatRoom.addListener(XMPPEvents.CREATE_ANSWER_FAILED,
|
344
|
358
|
function (e, pc) {
|
345
|
359
|
conference.statistics.sendCreateAnswerFailed(e, pc);
|
346
|
360
|
});
|
347
|
361
|
|
348
|
|
- conference.room.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
|
|
362
|
+ chatRoom.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
|
349
|
363
|
function (e, pc) {
|
350
|
364
|
conference.statistics.sendSetLocalDescFailed(e, pc);
|
351
|
365
|
});
|
352
|
366
|
|
353
|
|
- conference.room.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
|
|
367
|
+ chatRoom.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
|
354
|
368
|
function (e, pc) {
|
355
|
369
|
conference.statistics.sendSetRemoteDescFailed(e, pc);
|
356
|
370
|
});
|
357
|
371
|
|
358
|
|
- conference.room.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
|
|
372
|
+ chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
|
359
|
373
|
function (e, pc) {
|
360
|
374
|
conference.statistics.sendAddIceCandidateFailed(e, pc);
|
361
|
375
|
});
|
|
@@ -421,11 +435,13 @@ JitsiConferenceEventManager.prototype.setupXMPPListeners = function () {
|
421
|
435
|
// mute existing local tracks because this is initial mute from
|
422
|
436
|
// Jicofo
|
423
|
437
|
conference.getLocalTracks().forEach(function (track) {
|
424
|
|
- if (conference.startAudioMuted && track.isAudioTrack()) {
|
425
|
|
- track.mute();
|
426
|
|
- }
|
427
|
|
- if (conference.startVideoMuted && track.isVideoTrack()) {
|
428
|
|
- track.mute();
|
|
438
|
+ switch (track.getType()) {
|
|
439
|
+ case MediaType.AUDIO:
|
|
440
|
+ conference.startAudioMuted && track.mute();
|
|
441
|
+ break;
|
|
442
|
+ case MediaType.VIDEO:
|
|
443
|
+ conference.startVideoMuted && track.mute();
|
|
444
|
+ break;
|
429
|
445
|
}
|
430
|
446
|
});
|
431
|
447
|
|
|
@@ -442,8 +458,6 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function () {
|
442
|
458
|
return;
|
443
|
459
|
|
444
|
460
|
conference.statistics.addAudioLevelListener(function (ssrc, level) {
|
445
|
|
- var userId = null;
|
446
|
|
-
|
447
|
461
|
var resource = conference.rtc.getResourceBySSRC(ssrc);
|
448
|
462
|
if (!resource)
|
449
|
463
|
return;
|
|
@@ -482,14 +496,6 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function () {
|
482
|
496
|
conference.eventEmitter.emit(
|
483
|
497
|
JitsiConferenceEvents.CONNECTION_STATS, stats);
|
484
|
498
|
});
|
485
|
|
-
|
486
|
|
- conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
487
|
|
- function (track) {
|
488
|
|
- if(!track.isLocal())
|
489
|
|
- return;
|
490
|
|
- var type = (track.getType() === "audio")? "audio" : "video";
|
491
|
|
- conference.statistics.sendMuteEvent(track.isMuted(), type);
|
492
|
|
- });
|
493
|
499
|
};
|
494
|
500
|
|
495
|
501
|
module.exports = JitsiConferenceEventManager;
|