You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JitsiConferenceEventManager.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /* global __filename, Strophe */
  2. import AuthenticationEvents
  3. from './service/authentication/AuthenticationEvents';
  4. import EventEmitterForwarder from './modules/util/EventEmitterForwarder';
  5. import { getLogger } from 'jitsi-meet-logger';
  6. import * as JitsiConferenceErrors from './JitsiConferenceErrors';
  7. import * as JitsiConferenceEvents from './JitsiConferenceEvents';
  8. import * as MediaType from './service/RTC/MediaType';
  9. import RTCEvents from './service/RTC/RTCEvents';
  10. import Statistics from './modules/statistics/statistics';
  11. import XMPPEvents from './service/xmpp/XMPPEvents';
  12. const logger = getLogger(__filename);
  13. /**
  14. * Setups all event listeners related to conference
  15. * @param conference {JitsiConference} the conference
  16. */
  17. function JitsiConferenceEventManager(conference) {
  18. this.conference = conference;
  19. // Listeners related to the conference only
  20. conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  21. function(track) {
  22. if(!track.isLocal() || !conference.statistics) {
  23. return;
  24. }
  25. conference.statistics.sendMuteEvent(track.isMuted(),
  26. track.getType());
  27. });
  28. }
  29. /**
  30. * Setups event listeners related to conference.chatRoom
  31. */
  32. JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
  33. const conference = this.conference;
  34. const chatRoom = conference.room;
  35. this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
  36. this.conference.eventEmitter);
  37. chatRoom.addListener(XMPPEvents.ICE_RESTARTING, function() {
  38. // All data channels have to be closed, before ICE restart
  39. // otherwise Chrome will not trigger "opened" event for the channel
  40. // established with the new bridge
  41. conference.rtc.closeAllDataChannels();
  42. });
  43. chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
  44. function(value) {
  45. // set isMutedByFocus when setAudioMute Promise ends
  46. conference.rtc.setAudioMute(value).then(
  47. function() {
  48. conference.isMutedByFocus = true;
  49. },
  50. function() {
  51. logger.warn(
  52. 'Error while audio muting due to focus request');
  53. });
  54. }
  55. );
  56. this.chatRoomForwarder.forward(XMPPEvents.SUBJECT_CHANGED,
  57. JitsiConferenceEvents.SUBJECT_CHANGED);
  58. this.chatRoomForwarder.forward(XMPPEvents.MUC_JOINED,
  59. JitsiConferenceEvents.CONFERENCE_JOINED);
  60. // send some analytics events
  61. chatRoom.addListener(XMPPEvents.MUC_JOINED,
  62. () => {
  63. this.conference.connectionIsInterrupted = false;
  64. Object.keys(chatRoom.connectionTimes).forEach(key => {
  65. const value = chatRoom.connectionTimes[key];
  66. Statistics.analytics.sendEvent('conference.' + key,
  67. {value});
  68. });
  69. Object.keys(chatRoom.xmpp.connectionTimes).forEach(key => {
  70. const value = chatRoom.xmpp.connectionTimes[key];
  71. Statistics.analytics.sendEvent('xmpp.' + key,
  72. {value});
  73. });
  74. });
  75. this.chatRoomForwarder.forward(XMPPEvents.ROOM_JOIN_ERROR,
  76. JitsiConferenceEvents.CONFERENCE_FAILED,
  77. JitsiConferenceErrors.CONNECTION_ERROR);
  78. this.chatRoomForwarder.forward(XMPPEvents.ROOM_CONNECT_ERROR,
  79. JitsiConferenceEvents.CONFERENCE_FAILED,
  80. JitsiConferenceErrors.CONNECTION_ERROR);
  81. this.chatRoomForwarder.forward(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR,
  82. JitsiConferenceEvents.CONFERENCE_FAILED,
  83. JitsiConferenceErrors.NOT_ALLOWED_ERROR);
  84. this.chatRoomForwarder.forward(XMPPEvents.ROOM_MAX_USERS_ERROR,
  85. JitsiConferenceEvents.CONFERENCE_FAILED,
  86. JitsiConferenceErrors.CONFERENCE_MAX_USERS);
  87. this.chatRoomForwarder.forward(XMPPEvents.PASSWORD_REQUIRED,
  88. JitsiConferenceEvents.CONFERENCE_FAILED,
  89. JitsiConferenceErrors.PASSWORD_REQUIRED);
  90. this.chatRoomForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED,
  91. JitsiConferenceEvents.CONFERENCE_FAILED,
  92. JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
  93. this.chatRoomForwarder.forward(XMPPEvents.BRIDGE_DOWN,
  94. JitsiConferenceEvents.CONFERENCE_FAILED,
  95. JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
  96. chatRoom.addListener(XMPPEvents.BRIDGE_DOWN,
  97. function() {
  98. Statistics.analytics.sendEvent('conference.bridgeDown');
  99. });
  100. this.chatRoomForwarder.forward(XMPPEvents.RESERVATION_ERROR,
  101. JitsiConferenceEvents.CONFERENCE_FAILED,
  102. JitsiConferenceErrors.RESERVATION_ERROR);
  103. this.chatRoomForwarder.forward(XMPPEvents.GRACEFUL_SHUTDOWN,
  104. JitsiConferenceEvents.CONFERENCE_FAILED,
  105. JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
  106. chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
  107. function(session, error) {
  108. conference.eventEmitter.emit(
  109. JitsiConferenceEvents.CONFERENCE_FAILED,
  110. JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
  111. });
  112. chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
  113. function() {
  114. chatRoom.eventEmitter.emit(
  115. XMPPEvents.CONFERENCE_SETUP_FAILED,
  116. new Error('ICE fail'));
  117. });
  118. this.chatRoomForwarder.forward(XMPPEvents.MUC_DESTROYED,
  119. JitsiConferenceEvents.CONFERENCE_FAILED,
  120. JitsiConferenceErrors.CONFERENCE_DESTROYED);
  121. this.chatRoomForwarder.forward(XMPPEvents.CHAT_ERROR_RECEIVED,
  122. JitsiConferenceEvents.CONFERENCE_ERROR,
  123. JitsiConferenceErrors.CHAT_ERROR);
  124. this.chatRoomForwarder.forward(XMPPEvents.FOCUS_DISCONNECTED,
  125. JitsiConferenceEvents.CONFERENCE_FAILED,
  126. JitsiConferenceErrors.FOCUS_DISCONNECTED);
  127. chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
  128. function() {
  129. Statistics.analytics.sendEvent('conference.focusLeft');
  130. conference.eventEmitter.emit(
  131. JitsiConferenceEvents.CONFERENCE_FAILED,
  132. JitsiConferenceErrors.FOCUS_LEFT);
  133. });
  134. const eventLogHandler = function(reason) {
  135. Statistics.sendEventToAll('conference.error.' + reason);
  136. };
  137. chatRoom.addListener(XMPPEvents.SESSION_ACCEPT_TIMEOUT,
  138. eventLogHandler.bind(null, 'sessionAcceptTimeout'));
  139. this.chatRoomForwarder.forward(XMPPEvents.CONNECTION_INTERRUPTED,
  140. JitsiConferenceEvents.CONNECTION_INTERRUPTED);
  141. chatRoom.addListener(XMPPEvents.CONNECTION_INTERRUPTED,
  142. () => {
  143. Statistics.sendEventToAll('connection.interrupted');
  144. this.conference.connectionIsInterrupted = true;
  145. });
  146. this.chatRoomForwarder.forward(XMPPEvents.RECORDER_STATE_CHANGED,
  147. JitsiConferenceEvents.RECORDER_STATE_CHANGED);
  148. this.chatRoomForwarder.forward(XMPPEvents.PHONE_NUMBER_CHANGED,
  149. JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
  150. this.chatRoomForwarder.forward(XMPPEvents.CONNECTION_RESTORED,
  151. JitsiConferenceEvents.CONNECTION_RESTORED);
  152. chatRoom.addListener(XMPPEvents.CONNECTION_RESTORED,
  153. () => {
  154. Statistics.sendEventToAll('connection.restored');
  155. this.conference.connectionIsInterrupted = false;
  156. });
  157. this.chatRoomForwarder.forward(XMPPEvents.CONFERENCE_SETUP_FAILED,
  158. JitsiConferenceEvents.CONFERENCE_FAILED,
  159. JitsiConferenceErrors.SETUP_FAILED);
  160. chatRoom.setParticipantPropertyListener(function(node, from) {
  161. const participant = conference.getParticipantById(from);
  162. if (!participant) {
  163. return;
  164. }
  165. participant.setProperty(
  166. node.tagName.substring('jitsi_participant_'.length),
  167. node.value);
  168. });
  169. this.chatRoomForwarder.forward(XMPPEvents.KICKED,
  170. JitsiConferenceEvents.KICKED);
  171. chatRoom.addListener(XMPPEvents.KICKED,
  172. function() {
  173. conference.room = null;
  174. conference.leave();
  175. });
  176. chatRoom.addListener(XMPPEvents.SUSPEND_DETECTED,
  177. conference.onSuspendDetected.bind(conference));
  178. this.chatRoomForwarder.forward(XMPPEvents.MUC_LOCK_CHANGED,
  179. JitsiConferenceEvents.LOCK_STATE_CHANGED);
  180. chatRoom.addListener(XMPPEvents.MUC_MEMBER_JOINED,
  181. conference.onMemberJoined.bind(conference));
  182. chatRoom.addListener(XMPPEvents.MUC_MEMBER_LEFT,
  183. conference.onMemberLeft.bind(conference));
  184. this.chatRoomForwarder.forward(XMPPEvents.MUC_LEFT,
  185. JitsiConferenceEvents.CONFERENCE_LEFT);
  186. chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
  187. conference.onDisplayNameChanged.bind(conference));
  188. chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function(role) {
  189. conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
  190. conference.myUserId(), role);
  191. // log all events for the recorder operated by the moderator
  192. if (conference.statistics && conference.isModerator()) {
  193. conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
  194. function(status, error) {
  195. const logObject = {
  196. id: 'recorder_status',
  197. status
  198. };
  199. if (error) {
  200. logObject.error = error;
  201. }
  202. Statistics.sendLog(JSON.stringify(logObject));
  203. });
  204. }
  205. });
  206. chatRoom.addListener(XMPPEvents.MUC_ROLE_CHANGED,
  207. conference.onUserRoleChanged.bind(conference));
  208. chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
  209. function(authEnabled, authIdentity) {
  210. conference.authEnabled = authEnabled;
  211. conference.authIdentity = authIdentity;
  212. conference.eventEmitter.emit(
  213. JitsiConferenceEvents.AUTH_STATUS_CHANGED, authEnabled,
  214. authIdentity);
  215. });
  216. chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
  217. function(jid, displayName, txt, myJid, ts) {
  218. const id = Strophe.getResourceFromJid(jid);
  219. conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
  220. id, txt, ts);
  221. });
  222. chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
  223. function(jid, status) {
  224. const id = Strophe.getResourceFromJid(jid);
  225. const participant = conference.getParticipantById(id);
  226. if (!participant || participant._status === status) {
  227. return;
  228. }
  229. participant._status = status;
  230. conference.eventEmitter.emit(
  231. JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
  232. });
  233. conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
  234. function(ufrag) {
  235. Statistics.sendLog(
  236. JSON.stringify({id: 'local_ufrag', value: ufrag}));
  237. });
  238. conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
  239. function(ufrag) {
  240. Statistics.sendLog(
  241. JSON.stringify({id: 'remote_ufrag', value: ufrag}));
  242. });
  243. chatRoom.addPresenceListener('startmuted', function(data, from) {
  244. let isModerator = false;
  245. if (conference.myUserId() === from && conference.isModerator()) {
  246. isModerator = true;
  247. } else {
  248. const participant = conference.getParticipantById(from);
  249. if (participant && participant.isModerator()) {
  250. isModerator = true;
  251. }
  252. }
  253. if (!isModerator) {
  254. return;
  255. }
  256. const startAudioMuted = data.attributes.audio === 'true';
  257. const startVideoMuted = data.attributes.video === 'true';
  258. let updated = false;
  259. if (startAudioMuted !== conference.startMutedPolicy.audio) {
  260. conference.startMutedPolicy.audio = startAudioMuted;
  261. updated = true;
  262. }
  263. if (startVideoMuted !== conference.startMutedPolicy.video) {
  264. conference.startMutedPolicy.video = startVideoMuted;
  265. updated = true;
  266. }
  267. if (updated) {
  268. conference.eventEmitter.emit(
  269. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  270. conference.startMutedPolicy
  271. );
  272. }
  273. });
  274. chatRoom.addPresenceListener('videomuted', function(values, from) {
  275. conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
  276. values.value == 'true', from);
  277. });
  278. chatRoom.addPresenceListener('audiomuted', function(values, from) {
  279. conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
  280. values.value == 'true', from);
  281. });
  282. chatRoom.addPresenceListener('videoType', function(data, from) {
  283. conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
  284. });
  285. chatRoom.addPresenceListener('devices', function(data, from) {
  286. let isAudioAvailable = false;
  287. let isVideoAvailable = false;
  288. data.children.forEach(function(config) {
  289. if (config.tagName === 'audio') {
  290. isAudioAvailable = config.value === 'true';
  291. }
  292. if (config.tagName === 'video') {
  293. isVideoAvailable = config.value === 'true';
  294. }
  295. });
  296. let availableDevices;
  297. if (conference.myUserId() === from) {
  298. availableDevices = conference.availableDevices;
  299. } else {
  300. const participant = conference.getParticipantById(from);
  301. if (!participant) {
  302. return;
  303. }
  304. availableDevices = participant._availableDevices;
  305. }
  306. let updated = false;
  307. if (availableDevices.audio !== isAudioAvailable) {
  308. updated = true;
  309. availableDevices.audio = isAudioAvailable;
  310. }
  311. if (availableDevices.video !== isVideoAvailable) {
  312. updated = true;
  313. availableDevices.video = isVideoAvailable;
  314. }
  315. if (updated) {
  316. conference.eventEmitter.emit(
  317. JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
  318. from, availableDevices);
  319. }
  320. });
  321. if(conference.statistics) {
  322. // FIXME ICE related events should end up in RTCEvents eventually
  323. chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
  324. function(pc) {
  325. conference.statistics.sendIceConnectionFailedEvent(pc);
  326. });
  327. chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  328. function(e, pc) {
  329. conference.statistics.sendAddIceCandidateFailed(e, pc);
  330. });
  331. }
  332. };
  333. /**
  334. * Setups event listeners related to conference.rtc
  335. */
  336. JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
  337. const conference = this.conference;
  338. const rtc = conference.rtc;
  339. this.rtcForwarder
  340. = new EventEmitterForwarder(rtc, this.conference.eventEmitter);
  341. rtc.addListener(
  342. RTCEvents.REMOTE_TRACK_ADDED,
  343. conference.onRemoteTrackAdded.bind(conference));
  344. rtc.addListener(
  345. RTCEvents.REMOTE_TRACK_REMOVED,
  346. conference.onRemoteTrackRemoved.bind(conference));
  347. rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
  348. function(id) {
  349. if(conference.lastDominantSpeaker !== id && conference.room) {
  350. conference.lastDominantSpeaker = id;
  351. conference.eventEmitter.emit(
  352. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
  353. }
  354. if (conference.statistics && conference.myUserId() === id) {
  355. // We are the new dominant speaker.
  356. conference.statistics.sendDominantSpeakerEvent();
  357. }
  358. });
  359. rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, function() {
  360. const now = window.performance.now();
  361. logger.log('(TIME) data channel opened ', now);
  362. conference.room.connectionTimes['data.channel.opened'] = now;
  363. Statistics.analytics.sendEvent('conference.dataChannel.open',
  364. {value: now});
  365. });
  366. this.rtcForwarder.forward(RTCEvents.LASTN_CHANGED,
  367. JitsiConferenceEvents.IN_LAST_N_CHANGED);
  368. this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
  369. JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
  370. rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED,
  371. function(devices) {
  372. conference.room.updateDeviceAvailability(devices);
  373. });
  374. rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
  375. function(from, payload) {
  376. const participant = conference.getParticipantById(from);
  377. if (participant) {
  378. conference.eventEmitter.emit(
  379. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  380. participant, payload);
  381. } else {
  382. logger.warn(
  383. 'Ignored ENDPOINT_MESSAGE_RECEIVED '
  384. + 'for not existing participant: ' + from, payload);
  385. }
  386. });
  387. if (conference.statistics) {
  388. rtc.addListener(RTCEvents.CREATE_ANSWER_FAILED,
  389. (e, pc) => {
  390. conference.statistics.sendCreateAnswerFailed(e, pc);
  391. });
  392. rtc.addListener(RTCEvents.CREATE_OFFER_FAILED,
  393. (e, pc) => {
  394. conference.statistics.sendCreateOfferFailed(e, pc);
  395. });
  396. rtc.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
  397. (e, pc) => {
  398. conference.statistics.sendSetLocalDescFailed(e, pc);
  399. });
  400. rtc.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
  401. (e, pc) => {
  402. conference.statistics.sendSetRemoteDescFailed(e, pc);
  403. });
  404. }
  405. };
  406. /**
  407. * Setups event listeners related to conference.xmpp
  408. */
  409. JitsiConferenceEventManager.prototype.setupXMPPListeners = function() {
  410. const conference = this.conference;
  411. conference.xmpp.caps.addListener(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
  412. from => {
  413. const participant = conference.getParticipantId(
  414. Strophe.getResourceFromJid(from));
  415. if(participant) {
  416. conference.eventEmitter.emit(
  417. JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED,
  418. participant);
  419. }
  420. });
  421. conference.xmpp.addListener(
  422. XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
  423. conference.xmpp.addListener(
  424. XMPPEvents.CALL_ENDED, conference.onCallEnded.bind(conference));
  425. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  426. function(audioMuted, videoMuted) {
  427. conference.startAudioMuted = audioMuted;
  428. conference.startVideoMuted = videoMuted;
  429. // mute existing local tracks because this is initial mute from
  430. // Jicofo
  431. conference.getLocalTracks().forEach(function(track) {
  432. switch (track.getType()) {
  433. case MediaType.AUDIO:
  434. conference.startAudioMuted && track.mute();
  435. break;
  436. case MediaType.VIDEO:
  437. conference.startVideoMuted && track.mute();
  438. break;
  439. }
  440. });
  441. conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
  442. });
  443. };
  444. /**
  445. * Setups event listeners related to conference.statistics
  446. */
  447. JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
  448. const conference = this.conference;
  449. if(!conference.statistics) {
  450. return;
  451. }
  452. conference.statistics.addAudioLevelListener(function(ssrc, level) {
  453. const resource = conference.rtc.getResourceBySSRC(ssrc);
  454. if (!resource) {
  455. return;
  456. }
  457. conference.rtc.setAudioLevel(resource, level);
  458. });
  459. // Forward the "before stats disposed" event
  460. conference.statistics.addBeforeDisposedListener(function() {
  461. conference.eventEmitter.emit(
  462. JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
  463. });
  464. conference.statistics.addConnectionStatsListener(function(stats) {
  465. const ssrc2resolution = stats.resolution;
  466. const id2resolution = {};
  467. // preprocess resolutions: group by user id, skip incorrect
  468. // resolutions etc.
  469. Object.keys(ssrc2resolution).forEach(function(ssrc) {
  470. const resolution = ssrc2resolution[ssrc];
  471. if (!resolution.width || !resolution.height
  472. || resolution.width == -1 || resolution.height == -1) {
  473. return;
  474. }
  475. const id = conference.rtc.getResourceBySSRC(ssrc);
  476. if (!id) {
  477. return;
  478. }
  479. // ssrc to resolution map for user id
  480. const idResolutions = id2resolution[id] || {};
  481. idResolutions[ssrc] = resolution;
  482. id2resolution[id] = idResolutions;
  483. });
  484. stats.resolution = id2resolution;
  485. conference.eventEmitter.emit(
  486. JitsiConferenceEvents.CONNECTION_STATS, stats);
  487. });
  488. conference.statistics.addByteSentStatsListener(function(stats) {
  489. conference.getLocalTracks(MediaType.AUDIO).forEach(function(track) {
  490. const ssrc = track.getSSRC();
  491. if (!ssrc || !stats.hasOwnProperty(ssrc)) {
  492. return;
  493. }
  494. track._setByteSent(stats[ssrc]);
  495. });
  496. });
  497. };
  498. module.exports = JitsiConferenceEventManager;