Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

JitsiConferenceEventManager.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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(
  212. XMPPEvents.MESSAGE_RECEIVED,
  213. // eslint-disable-next-line max-params
  214. (jid, displayName, txt, myJid, ts) => {
  215. const id = Strophe.getResourceFromJid(jid);
  216. conference.eventEmitter.emit(
  217. JitsiConferenceEvents.MESSAGE_RECEIVED,
  218. id, txt, ts);
  219. });
  220. chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
  221. (jid, status) => {
  222. const id = Strophe.getResourceFromJid(jid);
  223. const participant = conference.getParticipantById(id);
  224. if (!participant || participant._status === status) {
  225. return;
  226. }
  227. participant._status = status;
  228. conference.eventEmitter.emit(
  229. JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
  230. });
  231. conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
  232. ufrag => {
  233. Statistics.sendLog(
  234. JSON.stringify({ id: 'local_ufrag',
  235. value: ufrag }));
  236. });
  237. conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
  238. ufrag => {
  239. Statistics.sendLog(
  240. JSON.stringify({ id: 'remote_ufrag',
  241. value: ufrag }));
  242. });
  243. chatRoom.addPresenceListener('startmuted', (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', (values, from) => {
  275. conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
  276. values.value === 'true', from);
  277. });
  278. chatRoom.addPresenceListener('audiomuted', (values, from) => {
  279. conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
  280. values.value === 'true', from);
  281. });
  282. chatRoom.addPresenceListener('videoType', (data, from) => {
  283. conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
  284. });
  285. chatRoom.addPresenceListener('devices', (data, from) => {
  286. let isAudioAvailable = false;
  287. let isVideoAvailable = false;
  288. data.children.forEach(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. pc => {
  325. conference.statistics.sendIceConnectionFailedEvent(pc);
  326. });
  327. chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  328. (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. 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, () => {
  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(
  371. RTCEvents.AVAILABLE_DEVICES_CHANGED,
  372. devices => conference.room.updateDeviceAvailability(devices));
  373. rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
  374. (from, payload) => {
  375. const participant = conference.getParticipantById(from);
  376. if (participant) {
  377. conference.eventEmitter.emit(
  378. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  379. participant, payload);
  380. } else {
  381. logger.warn(
  382. 'Ignored ENDPOINT_MESSAGE_RECEIVED for not existing '
  383. + `participant: ${from}`,
  384. 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
  414. = conference.getParticipantId(
  415. Strophe.getResourceFromJid(from));
  416. if (participant) {
  417. conference.eventEmitter.emit(
  418. JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED,
  419. participant);
  420. }
  421. });
  422. conference.xmpp.addListener(
  423. XMPPEvents.CALL_INCOMING,
  424. conference.onIncomingCall.bind(conference));
  425. conference.xmpp.addListener(
  426. XMPPEvents.CALL_ENDED,
  427. conference.onCallEnded.bind(conference));
  428. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  429. (audioMuted, videoMuted) => {
  430. conference.startAudioMuted = audioMuted;
  431. conference.startVideoMuted = videoMuted;
  432. // mute existing local tracks because this is initial mute from
  433. // Jicofo
  434. conference.getLocalTracks().forEach(track => {
  435. switch (track.getType()) {
  436. case MediaType.AUDIO:
  437. conference.startAudioMuted && track.mute();
  438. break;
  439. case MediaType.VIDEO:
  440. conference.startVideoMuted && track.mute();
  441. break;
  442. }
  443. });
  444. conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
  445. });
  446. };
  447. /**
  448. * Setups event listeners related to conference.statistics
  449. */
  450. JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
  451. const conference = this.conference;
  452. if (!conference.statistics) {
  453. return;
  454. }
  455. conference.statistics.addAudioLevelListener((ssrc, level) => {
  456. const resource = conference.rtc.getResourceBySSRC(ssrc);
  457. if (!resource) {
  458. return;
  459. }
  460. conference.rtc.setAudioLevel(resource, level);
  461. });
  462. // Forward the "before stats disposed" event
  463. conference.statistics.addBeforeDisposedListener(() => {
  464. conference.eventEmitter.emit(
  465. JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
  466. });
  467. conference.statistics.addConnectionStatsListener(stats => {
  468. const ssrc2resolution = stats.resolution;
  469. const id2resolution = {};
  470. // preprocess resolutions: group by user id, skip incorrect
  471. // resolutions etc.
  472. Object.keys(ssrc2resolution).forEach(ssrc => {
  473. const resolution = ssrc2resolution[ssrc];
  474. if (!resolution.width || !resolution.height
  475. || resolution.width === -1 || resolution.height === -1) {
  476. return;
  477. }
  478. const id = conference.rtc.getResourceBySSRC(ssrc);
  479. if (!id) {
  480. return;
  481. }
  482. // ssrc to resolution map for user id
  483. const idResolutions = id2resolution[id] || {};
  484. idResolutions[ssrc] = resolution;
  485. id2resolution[id] = idResolutions;
  486. });
  487. stats.resolution = id2resolution;
  488. conference.eventEmitter.emit(
  489. JitsiConferenceEvents.CONNECTION_STATS, stats);
  490. });
  491. conference.statistics.addByteSentStatsListener(stats => {
  492. conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
  493. const ssrc = track.getSSRC();
  494. if (!ssrc || !stats.hasOwnProperty(ssrc)) {
  495. return;
  496. }
  497. track._setByteSent(stats[ssrc]);
  498. });
  499. });
  500. };
  501. module.exports = JitsiConferenceEventManager;