您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

JitsiConferenceEventManager.js 21KB

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