Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

JitsiConferenceEventManager.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. 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, () => {
  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. value => {
  45. // set isMutedByFocus when setAudioMute Promise ends
  46. conference.rtc.setAudioMute(value).then(
  47. () => {
  48. conference.isMutedByFocus = true;
  49. },
  50. () =>
  51. logger.warn(
  52. 'Error while audio muting due to focus request'));
  53. }
  54. );
  55. this.chatRoomForwarder.forward(XMPPEvents.SUBJECT_CHANGED,
  56. JitsiConferenceEvents.SUBJECT_CHANGED);
  57. this.chatRoomForwarder.forward(XMPPEvents.MUC_JOINED,
  58. JitsiConferenceEvents.CONFERENCE_JOINED);
  59. // send some analytics events
  60. chatRoom.addListener(XMPPEvents.MUC_JOINED,
  61. () => {
  62. this.conference.connectionIsInterrupted = false;
  63. Object.keys(chatRoom.connectionTimes).forEach(key => {
  64. const value = chatRoom.connectionTimes[key];
  65. Statistics.analytics.sendEvent(`conference.${key}`, { value });
  66. });
  67. Object.keys(chatRoom.xmpp.connectionTimes).forEach(key => {
  68. const value = chatRoom.xmpp.connectionTimes[key];
  69. Statistics.analytics.sendEvent(`xmpp.${key}`, { value });
  70. });
  71. });
  72. this.chatRoomForwarder.forward(XMPPEvents.ROOM_JOIN_ERROR,
  73. JitsiConferenceEvents.CONFERENCE_FAILED,
  74. JitsiConferenceErrors.CONNECTION_ERROR);
  75. this.chatRoomForwarder.forward(XMPPEvents.ROOM_CONNECT_ERROR,
  76. JitsiConferenceEvents.CONFERENCE_FAILED,
  77. JitsiConferenceErrors.CONNECTION_ERROR);
  78. this.chatRoomForwarder.forward(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR,
  79. JitsiConferenceEvents.CONFERENCE_FAILED,
  80. JitsiConferenceErrors.NOT_ALLOWED_ERROR);
  81. this.chatRoomForwarder.forward(XMPPEvents.ROOM_MAX_USERS_ERROR,
  82. JitsiConferenceEvents.CONFERENCE_FAILED,
  83. JitsiConferenceErrors.CONFERENCE_MAX_USERS);
  84. this.chatRoomForwarder.forward(XMPPEvents.PASSWORD_REQUIRED,
  85. JitsiConferenceEvents.CONFERENCE_FAILED,
  86. JitsiConferenceErrors.PASSWORD_REQUIRED);
  87. this.chatRoomForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED,
  88. JitsiConferenceEvents.CONFERENCE_FAILED,
  89. JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
  90. this.chatRoomForwarder.forward(XMPPEvents.BRIDGE_DOWN,
  91. JitsiConferenceEvents.CONFERENCE_FAILED,
  92. JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
  93. chatRoom.addListener(
  94. XMPPEvents.BRIDGE_DOWN,
  95. () => Statistics.analytics.sendEvent('conference.bridgeDown'));
  96. this.chatRoomForwarder.forward(XMPPEvents.RESERVATION_ERROR,
  97. JitsiConferenceEvents.CONFERENCE_FAILED,
  98. JitsiConferenceErrors.RESERVATION_ERROR);
  99. this.chatRoomForwarder.forward(XMPPEvents.GRACEFUL_SHUTDOWN,
  100. JitsiConferenceEvents.CONFERENCE_FAILED,
  101. JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
  102. chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
  103. (session, error) => {
  104. conference.eventEmitter.emit(
  105. JitsiConferenceEvents.CONFERENCE_FAILED,
  106. JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
  107. });
  108. chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
  109. () => {
  110. chatRoom.eventEmitter.emit(
  111. XMPPEvents.CONFERENCE_SETUP_FAILED,
  112. new Error('ICE fail'));
  113. });
  114. this.chatRoomForwarder.forward(XMPPEvents.MUC_DESTROYED,
  115. JitsiConferenceEvents.CONFERENCE_FAILED,
  116. JitsiConferenceErrors.CONFERENCE_DESTROYED);
  117. this.chatRoomForwarder.forward(XMPPEvents.CHAT_ERROR_RECEIVED,
  118. JitsiConferenceEvents.CONFERENCE_ERROR,
  119. JitsiConferenceErrors.CHAT_ERROR);
  120. this.chatRoomForwarder.forward(XMPPEvents.FOCUS_DISCONNECTED,
  121. JitsiConferenceEvents.CONFERENCE_FAILED,
  122. JitsiConferenceErrors.FOCUS_DISCONNECTED);
  123. chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
  124. () => {
  125. Statistics.analytics.sendEvent('conference.focusLeft');
  126. conference.eventEmitter.emit(
  127. JitsiConferenceEvents.CONFERENCE_FAILED,
  128. JitsiConferenceErrors.FOCUS_LEFT);
  129. });
  130. const eventLogHandler
  131. = reason => Statistics.sendEventToAll(`conference.error.${reason}`);
  132. chatRoom.addListener(XMPPEvents.SESSION_ACCEPT_TIMEOUT,
  133. eventLogHandler.bind(null, 'sessionAcceptTimeout'));
  134. this.chatRoomForwarder.forward(XMPPEvents.CONNECTION_INTERRUPTED,
  135. JitsiConferenceEvents.CONNECTION_INTERRUPTED);
  136. chatRoom.addListener(XMPPEvents.CONNECTION_INTERRUPTED,
  137. () => {
  138. Statistics.sendEventToAll('connection.interrupted');
  139. this.conference.connectionIsInterrupted = true;
  140. });
  141. this.chatRoomForwarder.forward(XMPPEvents.RECORDER_STATE_CHANGED,
  142. JitsiConferenceEvents.RECORDER_STATE_CHANGED);
  143. this.chatRoomForwarder.forward(XMPPEvents.PHONE_NUMBER_CHANGED,
  144. JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
  145. this.chatRoomForwarder.forward(XMPPEvents.CONNECTION_RESTORED,
  146. JitsiConferenceEvents.CONNECTION_RESTORED);
  147. chatRoom.addListener(XMPPEvents.CONNECTION_RESTORED,
  148. () => {
  149. Statistics.sendEventToAll('connection.restored');
  150. this.conference.connectionIsInterrupted = false;
  151. });
  152. this.chatRoomForwarder.forward(XMPPEvents.CONFERENCE_SETUP_FAILED,
  153. JitsiConferenceEvents.CONFERENCE_FAILED,
  154. JitsiConferenceErrors.SETUP_FAILED);
  155. chatRoom.setParticipantPropertyListener((node, from) => {
  156. const participant = conference.getParticipantById(from);
  157. if (!participant) {
  158. return;
  159. }
  160. participant.setProperty(
  161. node.tagName.substring('jitsi_participant_'.length),
  162. node.value);
  163. });
  164. this.chatRoomForwarder.forward(XMPPEvents.KICKED,
  165. JitsiConferenceEvents.KICKED);
  166. chatRoom.addListener(XMPPEvents.KICKED,
  167. () => {
  168. conference.room = null;
  169. conference.leave();
  170. });
  171. chatRoom.addListener(XMPPEvents.SUSPEND_DETECTED,
  172. conference.onSuspendDetected.bind(conference));
  173. this.chatRoomForwarder.forward(XMPPEvents.MUC_LOCK_CHANGED,
  174. JitsiConferenceEvents.LOCK_STATE_CHANGED);
  175. chatRoom.addListener(XMPPEvents.MUC_MEMBER_JOINED,
  176. conference.onMemberJoined.bind(conference));
  177. chatRoom.addListener(XMPPEvents.MUC_MEMBER_LEFT,
  178. conference.onMemberLeft.bind(conference));
  179. this.chatRoomForwarder.forward(XMPPEvents.MUC_LEFT,
  180. JitsiConferenceEvents.CONFERENCE_LEFT);
  181. chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
  182. conference.onDisplayNameChanged.bind(conference));
  183. chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, role => {
  184. conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
  185. conference.myUserId(), role);
  186. // log all events for the recorder operated by the moderator
  187. if (conference.statistics && conference.isModerator()) {
  188. conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
  189. (status, error) => {
  190. const logObject = {
  191. id: 'recorder_status',
  192. status
  193. };
  194. if (error) {
  195. logObject.error = error;
  196. }
  197. Statistics.sendLog(JSON.stringify(logObject));
  198. });
  199. }
  200. });
  201. chatRoom.addListener(XMPPEvents.MUC_ROLE_CHANGED,
  202. conference.onUserRoleChanged.bind(conference));
  203. chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
  204. (authEnabled, authIdentity) => {
  205. conference.authEnabled = authEnabled;
  206. conference.authIdentity = authIdentity;
  207. conference.eventEmitter.emit(
  208. JitsiConferenceEvents.AUTH_STATUS_CHANGED, authEnabled,
  209. authIdentity);
  210. });
  211. chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
  212. (jid, displayName, txt, myJid, ts) => {
  213. const id = Strophe.getResourceFromJid(jid);
  214. conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
  215. id, txt, ts);
  216. });
  217. chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
  218. (jid, status) => {
  219. const id = Strophe.getResourceFromJid(jid);
  220. const participant = conference.getParticipantById(id);
  221. if (!participant || participant._status === status) {
  222. return;
  223. }
  224. participant._status = status;
  225. conference.eventEmitter.emit(
  226. JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
  227. });
  228. conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
  229. ufrag => {
  230. Statistics.sendLog(
  231. JSON.stringify({ id: 'local_ufrag',
  232. value: ufrag }));
  233. });
  234. conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
  235. ufrag => {
  236. Statistics.sendLog(
  237. JSON.stringify({ id: 'remote_ufrag',
  238. value: ufrag }));
  239. });
  240. chatRoom.addPresenceListener('startmuted', (data, from) => {
  241. let isModerator = false;
  242. if (conference.myUserId() === from && conference.isModerator()) {
  243. isModerator = true;
  244. } else {
  245. const participant = conference.getParticipantById(from);
  246. if (participant && participant.isModerator()) {
  247. isModerator = true;
  248. }
  249. }
  250. if (!isModerator) {
  251. return;
  252. }
  253. const startAudioMuted = data.attributes.audio === 'true';
  254. const startVideoMuted = data.attributes.video === 'true';
  255. let updated = false;
  256. if (startAudioMuted !== conference.startMutedPolicy.audio) {
  257. conference.startMutedPolicy.audio = startAudioMuted;
  258. updated = true;
  259. }
  260. if (startVideoMuted !== conference.startMutedPolicy.video) {
  261. conference.startMutedPolicy.video = startVideoMuted;
  262. updated = true;
  263. }
  264. if (updated) {
  265. conference.eventEmitter.emit(
  266. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  267. conference.startMutedPolicy
  268. );
  269. }
  270. });
  271. chatRoom.addPresenceListener('videomuted', (values, from) => {
  272. conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
  273. values.value === 'true', from);
  274. });
  275. chatRoom.addPresenceListener('audiomuted', (values, from) => {
  276. conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
  277. values.value === 'true', from);
  278. });
  279. chatRoom.addPresenceListener('videoType', (data, from) => {
  280. conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
  281. });
  282. chatRoom.addPresenceListener('devices', (data, from) => {
  283. let isAudioAvailable = false;
  284. let isVideoAvailable = false;
  285. data.children.forEach(config => {
  286. if (config.tagName === 'audio') {
  287. isAudioAvailable = config.value === 'true';
  288. }
  289. if (config.tagName === 'video') {
  290. isVideoAvailable = config.value === 'true';
  291. }
  292. });
  293. let availableDevices;
  294. if (conference.myUserId() === from) {
  295. availableDevices = conference.availableDevices;
  296. } else {
  297. const participant = conference.getParticipantById(from);
  298. if (!participant) {
  299. return;
  300. }
  301. availableDevices = participant._availableDevices;
  302. }
  303. let updated = false;
  304. if (availableDevices.audio !== isAudioAvailable) {
  305. updated = true;
  306. availableDevices.audio = isAudioAvailable;
  307. }
  308. if (availableDevices.video !== isVideoAvailable) {
  309. updated = true;
  310. availableDevices.video = isVideoAvailable;
  311. }
  312. if (updated) {
  313. conference.eventEmitter.emit(
  314. JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
  315. from, availableDevices);
  316. }
  317. });
  318. if (conference.statistics) {
  319. // FIXME ICE related events should end up in RTCEvents eventually
  320. chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
  321. pc => {
  322. conference.statistics.sendIceConnectionFailedEvent(pc);
  323. });
  324. chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  325. (e, pc) => {
  326. conference.statistics.sendAddIceCandidateFailed(e, pc);
  327. });
  328. }
  329. };
  330. /**
  331. * Setups event listeners related to conference.rtc
  332. */
  333. JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
  334. const conference = this.conference;
  335. const rtc = conference.rtc;
  336. this.rtcForwarder
  337. = new EventEmitterForwarder(rtc, this.conference.eventEmitter);
  338. rtc.addListener(
  339. RTCEvents.REMOTE_TRACK_ADDED,
  340. conference.onRemoteTrackAdded.bind(conference));
  341. rtc.addListener(
  342. RTCEvents.REMOTE_TRACK_REMOVED,
  343. conference.onRemoteTrackRemoved.bind(conference));
  344. rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
  345. id => {
  346. if (conference.lastDominantSpeaker !== id && conference.room) {
  347. conference.lastDominantSpeaker = id;
  348. conference.eventEmitter.emit(
  349. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
  350. }
  351. if (conference.statistics && conference.myUserId() === id) {
  352. // We are the new dominant speaker.
  353. conference.statistics.sendDominantSpeakerEvent();
  354. }
  355. });
  356. rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, () => {
  357. const now = window.performance.now();
  358. logger.log('(TIME) data channel opened ', now);
  359. conference.room.connectionTimes['data.channel.opened'] = now;
  360. Statistics.analytics.sendEvent('conference.dataChannel.open',
  361. { value: now });
  362. });
  363. this.rtcForwarder.forward(RTCEvents.LASTN_CHANGED,
  364. JitsiConferenceEvents.IN_LAST_N_CHANGED);
  365. this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
  366. JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
  367. rtc.addListener(
  368. RTCEvents.AVAILABLE_DEVICES_CHANGED,
  369. devices => conference.room.updateDeviceAvailability(devices));
  370. rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
  371. (from, payload) => {
  372. const participant = conference.getParticipantById(from);
  373. if (participant) {
  374. conference.eventEmitter.emit(
  375. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  376. participant, payload);
  377. } else {
  378. logger.warn(
  379. 'Ignored ENDPOINT_MESSAGE_RECEIVED for not existing '
  380. + `participant: ${from}`,
  381. payload);
  382. }
  383. });
  384. if (conference.statistics) {
  385. rtc.addListener(RTCEvents.CREATE_ANSWER_FAILED,
  386. (e, pc) => {
  387. conference.statistics.sendCreateAnswerFailed(e, pc);
  388. });
  389. rtc.addListener(RTCEvents.CREATE_OFFER_FAILED,
  390. (e, pc) => {
  391. conference.statistics.sendCreateOfferFailed(e, pc);
  392. });
  393. rtc.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
  394. (e, pc) => {
  395. conference.statistics.sendSetLocalDescFailed(e, pc);
  396. });
  397. rtc.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
  398. (e, pc) => {
  399. conference.statistics.sendSetRemoteDescFailed(e, pc);
  400. });
  401. }
  402. };
  403. /**
  404. * Setups event listeners related to conference.xmpp
  405. */
  406. JitsiConferenceEventManager.prototype.setupXMPPListeners = function() {
  407. const conference = this.conference;
  408. conference.xmpp.caps.addListener(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
  409. from => {
  410. const participant
  411. = conference.getParticipantId(
  412. Strophe.getResourceFromJid(from));
  413. if (participant) {
  414. conference.eventEmitter.emit(
  415. JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED,
  416. participant);
  417. }
  418. });
  419. conference.xmpp.addListener(
  420. XMPPEvents.CALL_INCOMING,
  421. conference.onIncomingCall.bind(conference));
  422. conference.xmpp.addListener(
  423. XMPPEvents.CALL_ENDED,
  424. conference.onCallEnded.bind(conference));
  425. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  426. (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(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((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(() => {
  461. conference.eventEmitter.emit(
  462. JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
  463. });
  464. conference.statistics.addConnectionStatsListener(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(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(stats => {
  489. conference.getLocalTracks(MediaType.AUDIO).forEach(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;