|
@@ -3,8 +3,6 @@
|
3
|
3
|
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
4
|
4
|
var RTC = require("./modules/RTC/RTC");
|
5
|
5
|
var XMPPEvents = require("./service/xmpp/XMPPEvents");
|
6
|
|
-var AuthenticationEvents = require("./service/authentication/AuthenticationEvents");
|
7
|
|
-var RTCEvents = require("./service/RTC/RTCEvents");
|
8
|
6
|
var EventEmitter = require("events");
|
9
|
7
|
var JitsiConferenceEvents = require("./JitsiConferenceEvents");
|
10
|
8
|
var JitsiConferenceErrors = require("./JitsiConferenceErrors");
|
|
@@ -17,7 +15,7 @@ var JitsiTrackError = require("./JitsiTrackError");
|
17
|
15
|
var Settings = require("./modules/settings/Settings");
|
18
|
16
|
var ComponentsVersions = require("./modules/version/ComponentsVersions");
|
19
|
17
|
var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
|
20
|
|
-var MediaType = require("./service/RTC/MediaType");
|
|
18
|
+var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
|
21
|
19
|
|
22
|
20
|
/**
|
23
|
21
|
* Creates a JitsiConference object with the given name and properties.
|
|
@@ -47,7 +45,8 @@ function JitsiConference(options) {
|
47
|
45
|
this.options.config.disableThirdPartyRequests,
|
48
|
46
|
roomName: this.options.name
|
49
|
47
|
});
|
50
|
|
- setupListeners(this);
|
|
48
|
+ this.eventManager = new JitsiConferenceEventManager(this);
|
|
49
|
+ this._setupListeners();
|
51
|
50
|
this.participants = {};
|
52
|
51
|
this.lastDominantSpeaker = null;
|
53
|
52
|
this.dtmfManager = null;
|
|
@@ -89,7 +88,6 @@ JitsiConference.prototype._init = function (options) {
|
89
|
88
|
this.settings);
|
90
|
89
|
this.componentsVersions = new ComponentsVersions(this.room);
|
91
|
90
|
this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
|
92
|
|
-
|
93
|
91
|
}
|
94
|
92
|
|
95
|
93
|
/**
|
|
@@ -97,10 +95,15 @@ JitsiConference.prototype._init = function (options) {
|
97
|
95
|
* @param options {object} options to be overriden
|
98
|
96
|
*/
|
99
|
97
|
JitsiConference.prototype.reload = function (options) {
|
100
|
|
- this.leave().then(function(){
|
101
|
|
- this._init(options || {});
|
102
|
|
- this.join();
|
103
|
|
- }.bind(this));
|
|
98
|
+ this.statistics.stopCallStats();
|
|
99
|
+ this.rtc.closeAllDataChannels();
|
|
100
|
+ this._leaveRoomAndRemoveParticipants();
|
|
101
|
+ this._init(options || {});
|
|
102
|
+ this.eventManager.setupChatRoomListeners();
|
|
103
|
+ //if we have new xmpp instance we should set it's listeners again.
|
|
104
|
+ if(options.connection)
|
|
105
|
+ this.eventManager.setupXMPPListeners();
|
|
106
|
+ this.join();
|
104
|
107
|
}
|
105
|
108
|
|
106
|
109
|
/**
|
|
@@ -1061,429 +1064,12 @@ JitsiConference.prototype._onTrackAttach = function(track, container) {
|
1061
|
1064
|
|
1062
|
1065
|
/**
|
1063
|
1066
|
* Setups the listeners needed for the conference.
|
1064
|
|
- * @param conference the conference
|
1065
|
1067
|
*/
|
1066
|
|
-function setupListeners(conference) {
|
1067
|
|
- conference.xmpp.addListener(
|
1068
|
|
- XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
|
1069
|
|
-
|
1070
|
|
- conference.room.addListener(XMPPEvents.ICE_RESTARTING, function () {
|
1071
|
|
- // All data channels have to be closed, before ICE restart
|
1072
|
|
- // otherwise Chrome will not trigger "opened" event for the channel
|
1073
|
|
- // established with the new bridge
|
1074
|
|
- conference.rtc.closeAllDataChannels();
|
1075
|
|
- });
|
1076
|
|
-
|
1077
|
|
- conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
|
1078
|
|
- function (data) {
|
1079
|
|
- var track = conference.rtc.createRemoteTrack(data);
|
1080
|
|
- if (track) {
|
1081
|
|
- conference.onTrackAdded(track);
|
1082
|
|
- }
|
1083
|
|
- }
|
1084
|
|
- );
|
1085
|
|
- conference.room.addListener(XMPPEvents.REMOTE_TRACK_REMOVED,
|
1086
|
|
- function (streamId, trackId) {
|
1087
|
|
- conference.getParticipants().forEach(function(participant) {
|
1088
|
|
- var tracks = participant.getTracks();
|
1089
|
|
- for(var i = 0; i < tracks.length; i++) {
|
1090
|
|
- if(tracks[i]
|
1091
|
|
- && tracks[i].getStreamId() == streamId
|
1092
|
|
- && tracks[i].getTrackId() == trackId) {
|
1093
|
|
- var track = participant._tracks.splice(i, 1)[0];
|
1094
|
|
- conference.eventEmitter.emit(
|
1095
|
|
- JitsiConferenceEvents.TRACK_REMOVED, track);
|
1096
|
|
- return;
|
1097
|
|
- }
|
1098
|
|
- }
|
1099
|
|
- });
|
1100
|
|
- }
|
1101
|
|
- );
|
1102
|
|
-
|
1103
|
|
- conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
|
1104
|
|
- function (value) {
|
1105
|
|
- // set isMutedByFocus when setAudioMute Promise ends
|
1106
|
|
- conference.rtc.setAudioMute(value).then(
|
1107
|
|
- function() {
|
1108
|
|
- conference.isMutedByFocus = true;
|
1109
|
|
- },
|
1110
|
|
- function() {
|
1111
|
|
- logger.warn(
|
1112
|
|
- "Error while audio muting due to focus request");
|
1113
|
|
- });
|
1114
|
|
- }
|
1115
|
|
- );
|
1116
|
|
-
|
1117
|
|
- conference.room.addListener(XMPPEvents.SUBJECT_CHANGED, function (subject) {
|
1118
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.SUBJECT_CHANGED,
|
1119
|
|
- subject);
|
1120
|
|
- });
|
1121
|
|
-
|
1122
|
|
- conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
1123
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
|
1124
|
|
- });
|
1125
|
|
- conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
|
1126
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
|
1127
|
|
- JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
1128
|
|
- });
|
1129
|
|
- conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
|
1130
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
|
1131
|
|
- JitsiConferenceErrors.CONNECTION_ERROR, pres);
|
1132
|
|
- });
|
1133
|
|
- conference.room.addListener(XMPPEvents.ROOM_MAX_USERS_ERROR,
|
1134
|
|
- function (pres) {
|
1135
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
|
1136
|
|
- JitsiConferenceErrors.CONFERENCE_MAX_USERS, pres);
|
1137
|
|
- });
|
1138
|
|
- conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
|
1139
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
|
1140
|
|
- });
|
1141
|
|
- conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
|
1142
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
|
1143
|
|
- });
|
1144
|
|
- conference.room.addListener(XMPPEvents.BRIDGE_DOWN, function () {
|
1145
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
|
1146
|
|
- });
|
1147
|
|
- conference.room.addListener(XMPPEvents.RESERVATION_ERROR, function (code, msg) {
|
1148
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.RESERVATION_ERROR, code, msg);
|
1149
|
|
- });
|
1150
|
|
- conference.room.addListener(XMPPEvents.GRACEFUL_SHUTDOWN, function () {
|
1151
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
|
1152
|
|
- });
|
1153
|
|
- conference.room.addListener(XMPPEvents.JINGLE_FATAL_ERROR, function (session, error) {
|
1154
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
|
1155
|
|
- });
|
1156
|
|
- conference.room.addListener(XMPPEvents.MUC_DESTROYED, function (reason) {
|
1157
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONFERENCE_DESTROYED, reason);
|
1158
|
|
- });
|
1159
|
|
- conference.room.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, function (err, msg) {
|
1160
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_ERROR, JitsiConferenceErrors.CHAT_ERROR, err, msg);
|
1161
|
|
- });
|
1162
|
|
- conference.room.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focus, retrySec) {
|
1163
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_DISCONNECTED, focus, retrySec);
|
1164
|
|
- });
|
1165
|
|
- conference.room.addListener(XMPPEvents.FOCUS_LEFT, function () {
|
1166
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_LEFT);
|
1167
|
|
- });
|
1168
|
|
- conference.room.setParticipantPropertyListener(function (node, from) {
|
1169
|
|
- var participant = conference.getParticipantById(from);
|
1170
|
|
- if (!participant) {
|
1171
|
|
- return;
|
1172
|
|
- }
|
1173
|
|
-
|
1174
|
|
- participant.setProperty(
|
1175
|
|
- node.tagName.substring("jitsi_participant_".length),
|
1176
|
|
- node.value);
|
1177
|
|
- });
|
1178
|
|
-// FIXME
|
1179
|
|
-// conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
1180
|
|
-// conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
|
1181
|
|
-// });
|
1182
|
|
-
|
1183
|
|
- conference.room.addListener(XMPPEvents.KICKED, function () {
|
1184
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.KICKED);
|
1185
|
|
- });
|
1186
|
|
-
|
1187
|
|
- conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
|
1188
|
|
- conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
|
1189
|
|
-
|
1190
|
|
- conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, conference.onDisplayNameChanged.bind(conference));
|
1191
|
|
-
|
1192
|
|
- conference.room.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
|
1193
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, conference.myUserId(), role);
|
1194
|
|
-
|
1195
|
|
- // log all events for the recorder operated by the moderator
|
1196
|
|
- if (conference.statistics && conference.isModerator()) {
|
1197
|
|
- conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
|
1198
|
|
- function (status, error) {
|
1199
|
|
- Statistics.sendLog(
|
1200
|
|
- "[Recorder] status: " + status
|
1201
|
|
- + (error? " error: " + error : ""));
|
1202
|
|
- });
|
1203
|
|
- }
|
1204
|
|
- });
|
1205
|
|
- conference.room.addListener(XMPPEvents.MUC_ROLE_CHANGED, conference.onUserRoleChanged.bind(conference));
|
1206
|
|
-
|
1207
|
|
- conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
|
1208
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
|
1209
|
|
- });
|
1210
|
|
-
|
1211
|
|
- conference.room.addListener(XMPPEvents.RECORDER_STATE_CHANGED,
|
1212
|
|
- function (state) {
|
1213
|
|
- conference.eventEmitter.emit(
|
1214
|
|
- JitsiConferenceEvents.RECORDER_STATE_CHANGED, state);
|
1215
|
|
- });
|
1216
|
|
-
|
1217
|
|
- conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
|
1218
|
|
- conference.eventEmitter.emit(
|
1219
|
|
- JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
|
1220
|
|
- });
|
1221
|
|
-
|
1222
|
|
- conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
|
1223
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
|
1224
|
|
- });
|
1225
|
|
- conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED,
|
1226
|
|
- function (error) {
|
1227
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
|
1228
|
|
- JitsiConferenceErrors.SETUP_FAILED, error);
|
1229
|
|
- });
|
1230
|
|
-
|
1231
|
|
- conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
|
1232
|
|
- conference.authEnabled = authEnabled;
|
1233
|
|
- conference.authIdentity = authIdentity;
|
1234
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.AUTH_STATUS_CHANGED, authEnabled, authIdentity);
|
1235
|
|
- });
|
1236
|
|
-
|
1237
|
|
- conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
|
1238
|
|
- var id = Strophe.getResourceFromJid(jid);
|
1239
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts);
|
1240
|
|
- });
|
1241
|
|
-
|
1242
|
|
- conference.room.addListener(XMPPEvents.PRESENCE_STATUS, function (jid, status) {
|
1243
|
|
- var id = Strophe.getResourceFromJid(jid);
|
1244
|
|
- var participant = conference.getParticipantById(id);
|
1245
|
|
- if (!participant || participant._status === status) {
|
1246
|
|
- return;
|
1247
|
|
- }
|
1248
|
|
- participant._status = status;
|
1249
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
|
1250
|
|
- });
|
1251
|
|
-
|
1252
|
|
- conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
|
1253
|
|
- if(conference.lastDominantSpeaker !== id && conference.room) {
|
1254
|
|
- conference.lastDominantSpeaker = id;
|
1255
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
|
1256
|
|
- }
|
1257
|
|
- if (conference.statistics && conference.myUserId() === id) {
|
1258
|
|
- // We are the new dominant speaker.
|
1259
|
|
- conference.statistics.sendDominantSpeakerEvent();
|
1260
|
|
- }
|
1261
|
|
- });
|
1262
|
|
-
|
1263
|
|
- conference.rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, function () {
|
1264
|
|
- var now = window.performance.now();
|
1265
|
|
- logger.log("(TIME) data channel opened ", now);
|
1266
|
|
- conference.room.connectionTimes["data.channel.opened"] = now;
|
1267
|
|
- });
|
1268
|
|
-
|
1269
|
|
- conference.rtc.addListener(RTCEvents.LASTN_CHANGED, function (oldValue, newValue) {
|
1270
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
|
1271
|
|
- });
|
1272
|
|
-
|
1273
|
|
- conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
|
1274
|
|
- function (lastNEndpoints, endpointsEnteringLastN) {
|
1275
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
|
1276
|
|
- lastNEndpoints, endpointsEnteringLastN);
|
1277
|
|
- });
|
1278
|
|
-
|
1279
|
|
- conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
|
1280
|
|
- function (audioMuted, videoMuted) {
|
1281
|
|
- conference.startAudioMuted = audioMuted;
|
1282
|
|
- conference.startVideoMuted = videoMuted;
|
1283
|
|
-
|
1284
|
|
- // mute existing local tracks because this is initial mute from
|
1285
|
|
- // Jicofo
|
1286
|
|
- conference.getLocalTracks().forEach(function (track) {
|
1287
|
|
- if (conference.startAudioMuted && track.isAudioTrack()) {
|
1288
|
|
- track.mute();
|
1289
|
|
- }
|
1290
|
|
- if (conference.startVideoMuted && track.isVideoTrack()) {
|
1291
|
|
- track.mute();
|
1292
|
|
- }
|
1293
|
|
- });
|
1294
|
|
-
|
1295
|
|
- conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
|
1296
|
|
- });
|
1297
|
|
-
|
1298
|
|
- conference.room.addPresenceListener("startmuted", function (data, from) {
|
1299
|
|
- var isModerator = false;
|
1300
|
|
- if (conference.myUserId() === from && conference.isModerator()) {
|
1301
|
|
- isModerator = true;
|
1302
|
|
- } else {
|
1303
|
|
- var participant = conference.getParticipantById(from);
|
1304
|
|
- if (participant && participant.isModerator()) {
|
1305
|
|
- isModerator = true;
|
1306
|
|
- }
|
1307
|
|
- }
|
1308
|
|
-
|
1309
|
|
- if (!isModerator) {
|
1310
|
|
- return;
|
1311
|
|
- }
|
1312
|
|
-
|
1313
|
|
- var startAudioMuted = data.attributes.audio === 'true';
|
1314
|
|
- var startVideoMuted = data.attributes.video === 'true';
|
1315
|
|
-
|
1316
|
|
- var updated = false;
|
1317
|
|
-
|
1318
|
|
- if (startAudioMuted !== conference.startMutedPolicy.audio) {
|
1319
|
|
- conference.startMutedPolicy.audio = startAudioMuted;
|
1320
|
|
- updated = true;
|
1321
|
|
- }
|
1322
|
|
-
|
1323
|
|
- if (startVideoMuted !== conference.startMutedPolicy.video) {
|
1324
|
|
- conference.startMutedPolicy.video = startVideoMuted;
|
1325
|
|
- updated = true;
|
1326
|
|
- }
|
1327
|
|
-
|
1328
|
|
- if (updated) {
|
1329
|
|
- conference.eventEmitter.emit(
|
1330
|
|
- JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
|
1331
|
|
- conference.startMutedPolicy
|
1332
|
|
- );
|
1333
|
|
- }
|
1334
|
|
- });
|
1335
|
|
-
|
1336
|
|
- conference.rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
|
1337
|
|
- conference.room.updateDeviceAvailability(devices);
|
1338
|
|
- });
|
1339
|
|
-
|
1340
|
|
- conference.room.addPresenceListener("videomuted", function (values, from) {
|
1341
|
|
- conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
|
1342
|
|
- values.value == "true", from);
|
1343
|
|
- });
|
1344
|
|
-
|
1345
|
|
- conference.room.addPresenceListener("audiomuted", function (values, from) {
|
1346
|
|
- conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
|
1347
|
|
- values.value == "true", from);
|
1348
|
|
- });
|
1349
|
|
-
|
1350
|
|
- conference.room.addPresenceListener("videoType", function(data, from) {
|
1351
|
|
- conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
|
1352
|
|
- });
|
1353
|
|
-
|
1354
|
|
- conference.room.addPresenceListener("devices", function (data, from) {
|
1355
|
|
- var isAudioAvailable = false;
|
1356
|
|
- var isVideoAvailable = false;
|
1357
|
|
- data.children.forEach(function (config) {
|
1358
|
|
- if (config.tagName === 'audio') {
|
1359
|
|
- isAudioAvailable = config.value === 'true';
|
1360
|
|
- }
|
1361
|
|
- if (config.tagName === 'video') {
|
1362
|
|
- isVideoAvailable = config.value === 'true';
|
1363
|
|
- }
|
1364
|
|
- });
|
1365
|
|
-
|
1366
|
|
- var availableDevices;
|
1367
|
|
- if (conference.myUserId() === from) {
|
1368
|
|
- availableDevices = conference.availableDevices;
|
1369
|
|
- } else {
|
1370
|
|
- var participant = conference.getParticipantById(from);
|
1371
|
|
- if (!participant) {
|
1372
|
|
- return;
|
1373
|
|
- }
|
1374
|
|
-
|
1375
|
|
- availableDevices = participant._availableDevices;
|
1376
|
|
- }
|
1377
|
|
-
|
1378
|
|
- var updated = false;
|
1379
|
|
-
|
1380
|
|
- if (availableDevices.audio !== isAudioAvailable) {
|
1381
|
|
- updated = true;
|
1382
|
|
- availableDevices.audio = isAudioAvailable;
|
1383
|
|
- }
|
1384
|
|
-
|
1385
|
|
- if (availableDevices.video !== isVideoAvailable) {
|
1386
|
|
- updated = true;
|
1387
|
|
- availableDevices.video = isVideoAvailable;
|
1388
|
|
- }
|
1389
|
|
-
|
1390
|
|
- if (updated) {
|
1391
|
|
- conference.eventEmitter.emit(
|
1392
|
|
- JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
|
1393
|
|
- from, availableDevices);
|
1394
|
|
- }
|
1395
|
|
- });
|
1396
|
|
-
|
1397
|
|
- if(conference.statistics) {
|
1398
|
|
- //FIXME: Maybe remove event should not be associated with the conference.
|
1399
|
|
- conference.statistics.addAudioLevelListener(function (ssrc, level) {
|
1400
|
|
- var userId = null;
|
1401
|
|
-
|
1402
|
|
- var resource = conference.rtc.getResourceBySSRC(ssrc);
|
1403
|
|
- if (!resource)
|
1404
|
|
- return;
|
1405
|
|
-
|
1406
|
|
- conference.rtc.setAudioLevel(resource, level);
|
1407
|
|
- });
|
1408
|
|
- conference.statistics.addConnectionStatsListener(function (stats) {
|
1409
|
|
- var ssrc2resolution = stats.resolution;
|
1410
|
|
-
|
1411
|
|
- var id2resolution = {};
|
1412
|
|
-
|
1413
|
|
- // preprocess resolutions: group by user id, skip incorrect
|
1414
|
|
- // resolutions etc.
|
1415
|
|
- Object.keys(ssrc2resolution).forEach(function (ssrc) {
|
1416
|
|
- var resolution = ssrc2resolution[ssrc];
|
1417
|
|
-
|
1418
|
|
- if (!resolution.width || !resolution.height ||
|
1419
|
|
- resolution.width == -1 || resolution.height == -1) {
|
1420
|
|
- return;
|
1421
|
|
- }
|
1422
|
|
-
|
1423
|
|
- var id = conference.rtc.getResourceBySSRC(ssrc);
|
1424
|
|
- if (!id) {
|
1425
|
|
- return;
|
1426
|
|
- }
|
1427
|
|
-
|
1428
|
|
- // ssrc to resolution map for user id
|
1429
|
|
- var idResolutions = id2resolution[id] || {};
|
1430
|
|
- idResolutions[ssrc] = resolution;
|
1431
|
|
-
|
1432
|
|
- id2resolution[id] = idResolutions;
|
1433
|
|
- });
|
1434
|
|
-
|
1435
|
|
- stats.resolution = id2resolution;
|
1436
|
|
-
|
1437
|
|
- conference.eventEmitter.emit(
|
1438
|
|
- JitsiConferenceEvents.CONNECTION_STATS, stats);
|
1439
|
|
- });
|
1440
|
|
- conference.room.addListener(XMPPEvents.DISPOSE_CONFERENCE,
|
1441
|
|
- function () {
|
1442
|
|
- conference.statistics.dispose();
|
1443
|
|
- });
|
1444
|
|
-
|
1445
|
|
- conference.room.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
|
1446
|
|
- function (pc) {
|
1447
|
|
- conference.statistics.sendIceConnectionFailedEvent(pc);
|
1448
|
|
- conference.room.eventEmitter.emit(
|
1449
|
|
- XMPPEvents.CONFERENCE_SETUP_FAILED,
|
1450
|
|
- new Error("ICE fail"));
|
1451
|
|
- });
|
1452
|
|
-
|
1453
|
|
- conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
1454
|
|
- function (track) {
|
1455
|
|
- if(!track.isLocal())
|
1456
|
|
- return;
|
1457
|
|
- var type = (track.getType() === "audio")? "audio" : "video";
|
1458
|
|
- conference.statistics.sendMuteEvent(track.isMuted(), type);
|
1459
|
|
- });
|
1460
|
|
-
|
1461
|
|
- conference.room.addListener(XMPPEvents.CREATE_OFFER_FAILED, function (e, pc) {
|
1462
|
|
- conference.statistics.sendCreateOfferFailed(e, pc);
|
1463
|
|
- });
|
1464
|
|
-
|
1465
|
|
- conference.room.addListener(XMPPEvents.CREATE_ANSWER_FAILED, function (e, pc) {
|
1466
|
|
- conference.statistics.sendCreateAnswerFailed(e, pc);
|
1467
|
|
- });
|
1468
|
|
-
|
1469
|
|
- conference.room.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
|
1470
|
|
- function (e, pc) {
|
1471
|
|
- conference.statistics.sendSetLocalDescFailed(e, pc);
|
1472
|
|
- }
|
1473
|
|
- );
|
1474
|
|
-
|
1475
|
|
- conference.room.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
|
1476
|
|
- function (e, pc) {
|
1477
|
|
- conference.statistics.sendSetRemoteDescFailed(e, pc);
|
1478
|
|
- }
|
1479
|
|
- );
|
1480
|
|
-
|
1481
|
|
- conference.room.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
|
1482
|
|
- function (e, pc) {
|
1483
|
|
- conference.statistics.sendAddIceCandidateFailed(e, pc);
|
1484
|
|
- }
|
1485
|
|
- );
|
1486
|
|
- }
|
|
1068
|
+JitsiConference.prototype._setupListeners = function () {
|
|
1069
|
+ this.eventManager.setupXMPPListeners();
|
|
1070
|
+ this.eventManager.setupChatRoomListeners();
|
|
1071
|
+ this.eventManager.setupRTCListeners();
|
|
1072
|
+ this.eventManager.setupStatisticsListeners();
|
1487
|
1073
|
}
|
1488
|
1074
|
|
1489
|
1075
|
|