Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

JitsiConferenceEventManager.js 21KB

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