modified lib-jitsi-meet dev repo
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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', value: ufrag}));
  232. });
  233. conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
  234. ufrag => {
  235. Statistics.sendLog(
  236. JSON.stringify({id: 'remote_ufrag', value: ufrag}));
  237. });
  238. chatRoom.addPresenceListener('startmuted', (data, from) => {
  239. let isModerator = false;
  240. if (conference.myUserId() === from && conference.isModerator()) {
  241. isModerator = true;
  242. } else {
  243. const participant = conference.getParticipantById(from);
  244. if (participant && participant.isModerator()) {
  245. isModerator = true;
  246. }
  247. }
  248. if (!isModerator) {
  249. return;
  250. }
  251. const startAudioMuted = data.attributes.audio === 'true';
  252. const startVideoMuted = data.attributes.video === 'true';
  253. let updated = false;
  254. if (startAudioMuted !== conference.startMutedPolicy.audio) {
  255. conference.startMutedPolicy.audio = startAudioMuted;
  256. updated = true;
  257. }
  258. if (startVideoMuted !== conference.startMutedPolicy.video) {
  259. conference.startMutedPolicy.video = startVideoMuted;
  260. updated = true;
  261. }
  262. if (updated) {
  263. conference.eventEmitter.emit(
  264. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  265. conference.startMutedPolicy
  266. );
  267. }
  268. });
  269. chatRoom.addPresenceListener('videomuted', (values, from) => {
  270. conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
  271. values.value == 'true', from);
  272. });
  273. chatRoom.addPresenceListener('audiomuted', (values, from) => {
  274. conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
  275. values.value == 'true', from);
  276. });
  277. chatRoom.addPresenceListener('videoType', (data, from) => {
  278. conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
  279. });
  280. chatRoom.addPresenceListener('devices', (data, from) => {
  281. let isAudioAvailable = false;
  282. let isVideoAvailable = false;
  283. data.children.forEach(config => {
  284. if (config.tagName === 'audio') {
  285. isAudioAvailable = config.value === 'true';
  286. }
  287. if (config.tagName === 'video') {
  288. isVideoAvailable = config.value === 'true';
  289. }
  290. });
  291. let availableDevices;
  292. if (conference.myUserId() === from) {
  293. availableDevices = conference.availableDevices;
  294. } else {
  295. const participant = conference.getParticipantById(from);
  296. if (!participant) {
  297. return;
  298. }
  299. availableDevices = participant._availableDevices;
  300. }
  301. let updated = false;
  302. if (availableDevices.audio !== isAudioAvailable) {
  303. updated = true;
  304. availableDevices.audio = isAudioAvailable;
  305. }
  306. if (availableDevices.video !== isVideoAvailable) {
  307. updated = true;
  308. availableDevices.video = isVideoAvailable;
  309. }
  310. if (updated) {
  311. conference.eventEmitter.emit(
  312. JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
  313. from, availableDevices);
  314. }
  315. });
  316. if(conference.statistics) {
  317. // FIXME ICE related events should end up in RTCEvents eventually
  318. chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
  319. pc => {
  320. conference.statistics.sendIceConnectionFailedEvent(pc);
  321. });
  322. chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  323. (e, pc) => {
  324. conference.statistics.sendAddIceCandidateFailed(e, pc);
  325. });
  326. }
  327. };
  328. /**
  329. * Setups event listeners related to conference.rtc
  330. */
  331. JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
  332. const conference = this.conference;
  333. const rtc = conference.rtc;
  334. this.rtcForwarder
  335. = new EventEmitterForwarder(rtc, this.conference.eventEmitter);
  336. rtc.addListener(
  337. RTCEvents.REMOTE_TRACK_ADDED,
  338. conference.onRemoteTrackAdded.bind(conference));
  339. rtc.addListener(
  340. RTCEvents.REMOTE_TRACK_REMOVED,
  341. conference.onRemoteTrackRemoved.bind(conference));
  342. rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
  343. id => {
  344. if(conference.lastDominantSpeaker !== id && conference.room) {
  345. conference.lastDominantSpeaker = id;
  346. conference.eventEmitter.emit(
  347. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
  348. }
  349. if (conference.statistics && conference.myUserId() === id) {
  350. // We are the new dominant speaker.
  351. conference.statistics.sendDominantSpeakerEvent();
  352. }
  353. });
  354. rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, () => {
  355. const now = window.performance.now();
  356. logger.log('(TIME) data channel opened ', now);
  357. conference.room.connectionTimes['data.channel.opened'] = now;
  358. Statistics.analytics.sendEvent('conference.dataChannel.open',
  359. {value: now});
  360. });
  361. this.rtcForwarder.forward(RTCEvents.LASTN_CHANGED,
  362. JitsiConferenceEvents.IN_LAST_N_CHANGED);
  363. this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
  364. JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
  365. rtc.addListener(
  366. RTCEvents.AVAILABLE_DEVICES_CHANGED,
  367. devices => conference.room.updateDeviceAvailability(devices));
  368. rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
  369. (from, payload) => {
  370. const participant = conference.getParticipantById(from);
  371. if (participant) {
  372. conference.eventEmitter.emit(
  373. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  374. participant, payload);
  375. } else {
  376. logger.warn(
  377. 'Ignored ENDPOINT_MESSAGE_RECEIVED for not existing '
  378. + `participant: ${from}`,
  379. payload);
  380. }
  381. });
  382. if (conference.statistics) {
  383. rtc.addListener(RTCEvents.CREATE_ANSWER_FAILED,
  384. (e, pc) => {
  385. conference.statistics.sendCreateAnswerFailed(e, pc);
  386. });
  387. rtc.addListener(RTCEvents.CREATE_OFFER_FAILED,
  388. (e, pc) => {
  389. conference.statistics.sendCreateOfferFailed(e, pc);
  390. });
  391. rtc.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
  392. (e, pc) => {
  393. conference.statistics.sendSetLocalDescFailed(e, pc);
  394. });
  395. rtc.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
  396. (e, pc) => {
  397. conference.statistics.sendSetRemoteDescFailed(e, pc);
  398. });
  399. }
  400. };
  401. /**
  402. * Setups event listeners related to conference.xmpp
  403. */
  404. JitsiConferenceEventManager.prototype.setupXMPPListeners = function() {
  405. const conference = this.conference;
  406. conference.xmpp.caps.addListener(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
  407. from => {
  408. const participant = conference.getParticipantId(
  409. Strophe.getResourceFromJid(from));
  410. if(participant) {
  411. conference.eventEmitter.emit(
  412. JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED,
  413. participant);
  414. }
  415. });
  416. conference.xmpp.addListener(
  417. XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
  418. conference.xmpp.addListener(
  419. XMPPEvents.CALL_ENDED, conference.onCallEnded.bind(conference));
  420. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  421. (audioMuted, videoMuted) => {
  422. conference.startAudioMuted = audioMuted;
  423. conference.startVideoMuted = videoMuted;
  424. // mute existing local tracks because this is initial mute from
  425. // Jicofo
  426. conference.getLocalTracks().forEach(track => {
  427. switch (track.getType()) {
  428. case MediaType.AUDIO:
  429. conference.startAudioMuted && track.mute();
  430. break;
  431. case MediaType.VIDEO:
  432. conference.startVideoMuted && track.mute();
  433. break;
  434. }
  435. });
  436. conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
  437. });
  438. };
  439. /**
  440. * Setups event listeners related to conference.statistics
  441. */
  442. JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
  443. const conference = this.conference;
  444. if(!conference.statistics) {
  445. return;
  446. }
  447. conference.statistics.addAudioLevelListener((ssrc, level) => {
  448. const resource = conference.rtc.getResourceBySSRC(ssrc);
  449. if (!resource) {
  450. return;
  451. }
  452. conference.rtc.setAudioLevel(resource, level);
  453. });
  454. // Forward the "before stats disposed" event
  455. conference.statistics.addBeforeDisposedListener(() => {
  456. conference.eventEmitter.emit(
  457. JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
  458. });
  459. conference.statistics.addConnectionStatsListener(stats => {
  460. const ssrc2resolution = stats.resolution;
  461. const id2resolution = {};
  462. // preprocess resolutions: group by user id, skip incorrect
  463. // resolutions etc.
  464. Object.keys(ssrc2resolution).forEach(ssrc => {
  465. const resolution = ssrc2resolution[ssrc];
  466. if (!resolution.width || !resolution.height
  467. || resolution.width == -1 || resolution.height == -1) {
  468. return;
  469. }
  470. const id = conference.rtc.getResourceBySSRC(ssrc);
  471. if (!id) {
  472. return;
  473. }
  474. // ssrc to resolution map for user id
  475. const idResolutions = id2resolution[id] || {};
  476. idResolutions[ssrc] = resolution;
  477. id2resolution[id] = idResolutions;
  478. });
  479. stats.resolution = id2resolution;
  480. conference.eventEmitter.emit(
  481. JitsiConferenceEvents.CONNECTION_STATS, stats);
  482. });
  483. conference.statistics.addByteSentStatsListener(stats => {
  484. conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
  485. const ssrc = track.getSSRC();
  486. if (!ssrc || !stats.hasOwnProperty(ssrc)) {
  487. return;
  488. }
  489. track._setByteSent(stats[ssrc]);
  490. });
  491. });
  492. };
  493. module.exports = JitsiConferenceEventManager;