選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

JitsiConferenceEventManager.js 21KB

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