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

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