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.

JitsiConference.js 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. /* global Strophe, $, Promise */
  2. /* jshint -W101 */
  3. var logger = require("jitsi-meet-logger").getLogger(__filename);
  4. var RTC = require("./modules/RTC/RTC");
  5. var XMPPEvents = require("./service/xmpp/XMPPEvents");
  6. var AuthenticationEvents = require("./service/authentication/AuthenticationEvents");
  7. var RTCEvents = require("./service/RTC/RTCEvents");
  8. var EventEmitter = require("events");
  9. var JitsiConferenceEvents = require("./JitsiConferenceEvents");
  10. var JitsiConferenceErrors = require("./JitsiConferenceErrors");
  11. var JitsiParticipant = require("./JitsiParticipant");
  12. var Statistics = require("./modules/statistics/statistics");
  13. var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
  14. var JitsiTrackEvents = require("./JitsiTrackEvents");
  15. var JitsiTrackErrors = require("./JitsiTrackErrors");
  16. var Settings = require("./modules/settings/Settings");
  17. var ComponentsVersions = require("./modules/version/ComponentsVersions");
  18. /**
  19. * Creates a JitsiConference object with the given name and properties.
  20. * Note: this constructor is not a part of the public API (objects should be
  21. * created using JitsiConnection.createConference).
  22. * @param options.config properties / settings related to the conference that will be created.
  23. * @param options.name the name of the conference
  24. * @param options.connection the JitsiConnection object for this JitsiConference.
  25. * @constructor
  26. */
  27. function JitsiConference(options) {
  28. if(!options.name || options.name.toLowerCase() !== options.name) {
  29. logger.error("Invalid conference name (no conference name passed or it"
  30. + "contains invalid characters like capital letters)!");
  31. return;
  32. }
  33. this.options = options;
  34. this.connection = this.options.connection;
  35. this.xmpp = this.connection.xmpp;
  36. this.eventEmitter = new EventEmitter();
  37. var confID = this.options.name + '@' + this.xmpp.options.hosts.muc;
  38. this.settings = new Settings();
  39. this.room = this.xmpp.createRoom(this.options.name, this.options.config,
  40. this.settings);
  41. this.componentsVersions = new ComponentsVersions(this.room);
  42. this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
  43. this.rtc = new RTC(this.room, options);
  44. this.statistics = new Statistics(this.xmpp, {
  45. callStatsID: this.options.config.callStatsID,
  46. callStatsSecret: this.options.config.callStatsSecret,
  47. disableThirdPartyRequests: this.options.config.disableThirdPartyRequests
  48. });
  49. setupListeners(this);
  50. JitsiMeetJS._gumFailedHandler.push(function(error) {
  51. this.statistics.sendGetUserMediaFailed(error);
  52. }.bind(this));
  53. this.participants = {};
  54. this.lastDominantSpeaker = null;
  55. this.dtmfManager = null;
  56. this.somebodySupportsDTMF = false;
  57. this.authEnabled = false;
  58. this.authIdentity;
  59. this.startAudioMuted = false;
  60. this.startVideoMuted = false;
  61. this.startMutedPolicy = {audio: false, video: false};
  62. this.availableDevices = {
  63. audio: undefined,
  64. video: undefined
  65. };
  66. this.isMutedByFocus = false;
  67. }
  68. /**
  69. * Joins the conference.
  70. * @param password {string} the password
  71. */
  72. JitsiConference.prototype.join = function (password) {
  73. if(this.room)
  74. this.room.join(password);
  75. };
  76. /**
  77. * Check if joined to the conference.
  78. */
  79. JitsiConference.prototype.isJoined = function () {
  80. return this.room && this.room.joined;
  81. };
  82. /**
  83. * Leaves the conference.
  84. * @returns {Promise}
  85. */
  86. JitsiConference.prototype.leave = function () {
  87. var conference = this;
  88. // leave the conference
  89. if (conference.xmpp && conference.room) {
  90. conference.xmpp.leaveRoom(conference.room.roomjid);
  91. }
  92. conference.room = null;
  93. // remove local tracks
  94. return Promise.all(
  95. conference.getLocalTracks().map(function (track) {
  96. return conference.removeTrack(track);
  97. })
  98. ).then(function () {
  99. // remove all participants
  100. conference.getParticipants().forEach(function (participant) {
  101. conference.onMemberLeft(participant.getJid());
  102. });
  103. });
  104. };
  105. /**
  106. * Returns name of this conference.
  107. */
  108. JitsiConference.prototype.getName = function () {
  109. return this.options.name;
  110. };
  111. /**
  112. * Check if authentication is enabled for this conference.
  113. */
  114. JitsiConference.prototype.isAuthEnabled = function () {
  115. return this.authEnabled;
  116. };
  117. /**
  118. * Check if user is logged in.
  119. */
  120. JitsiConference.prototype.isLoggedIn = function () {
  121. return !!this.authIdentity;
  122. };
  123. /**
  124. * Get authorized login.
  125. */
  126. JitsiConference.prototype.getAuthLogin = function () {
  127. return this.authIdentity;
  128. };
  129. /**
  130. * Check if external authentication is enabled for this conference.
  131. */
  132. JitsiConference.prototype.isExternalAuthEnabled = function () {
  133. return this.room && this.room.moderator.isExternalAuthEnabled();
  134. };
  135. /**
  136. * Get url for external authentication.
  137. * @param {boolean} [urlForPopup] if true then return url for login popup,
  138. * else url of login page.
  139. * @returns {Promise}
  140. */
  141. JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
  142. return new Promise(function (resolve, reject) {
  143. if (!this.isExternalAuthEnabled()) {
  144. reject();
  145. return;
  146. }
  147. if (urlForPopup) {
  148. this.room.moderator.getPopupLoginUrl(resolve, reject);
  149. } else {
  150. this.room.moderator.getLoginUrl(resolve, reject);
  151. }
  152. }.bind(this));
  153. };
  154. /**
  155. * Returns the local tracks.
  156. */
  157. JitsiConference.prototype.getLocalTracks = function () {
  158. if (this.rtc) {
  159. return this.rtc.localStreams;
  160. } else {
  161. return [];
  162. }
  163. };
  164. /**
  165. * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
  166. * in JitsiConferenceEvents.
  167. * @param eventId the event ID.
  168. * @param handler handler for the event.
  169. *
  170. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  171. */
  172. JitsiConference.prototype.on = function (eventId, handler) {
  173. if(this.eventEmitter)
  174. this.eventEmitter.on(eventId, handler);
  175. };
  176. /**
  177. * Removes event listener
  178. * @param eventId the event ID.
  179. * @param [handler] optional, the specific handler to unbind
  180. *
  181. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  182. */
  183. JitsiConference.prototype.off = function (eventId, handler) {
  184. if(this.eventEmitter)
  185. this.eventEmitter.removeListener(eventId, handler);
  186. };
  187. // Common aliases for event emitter
  188. JitsiConference.prototype.addEventListener = JitsiConference.prototype.on;
  189. JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off;
  190. /**
  191. * Receives notifications from other participants about commands / custom events
  192. * (sent by sendCommand or sendCommandOnce methods).
  193. * @param command {String} the name of the command
  194. * @param handler {Function} handler for the command
  195. */
  196. JitsiConference.prototype.addCommandListener = function (command, handler) {
  197. if(this.room)
  198. this.room.addPresenceListener(command, handler);
  199. };
  200. /**
  201. * Removes command listener
  202. * @param command {String} the name of the command
  203. */
  204. JitsiConference.prototype.removeCommandListener = function (command) {
  205. if(this.room)
  206. this.room.removePresenceListener(command);
  207. };
  208. /**
  209. * Sends text message to the other participants in the conference
  210. * @param message the text message.
  211. */
  212. JitsiConference.prototype.sendTextMessage = function (message) {
  213. if(this.room)
  214. this.room.sendMessage(message);
  215. };
  216. /**
  217. * Send presence command.
  218. * @param name {String} the name of the command.
  219. * @param values {Object} with keys and values that will be sent.
  220. **/
  221. JitsiConference.prototype.sendCommand = function (name, values) {
  222. if(this.room) {
  223. this.room.addToPresence(name, values);
  224. this.room.sendPresence();
  225. }
  226. };
  227. /**
  228. * Send presence command one time.
  229. * @param name {String} the name of the command.
  230. * @param values {Object} with keys and values that will be sent.
  231. **/
  232. JitsiConference.prototype.sendCommandOnce = function (name, values) {
  233. this.sendCommand(name, values);
  234. this.removeCommand(name);
  235. };
  236. /**
  237. * Removes presence command.
  238. * @param name {String} the name of the command.
  239. **/
  240. JitsiConference.prototype.removeCommand = function (name) {
  241. if(this.room)
  242. this.room.removeFromPresence(name);
  243. };
  244. /**
  245. * Sets the display name for this conference.
  246. * @param name the display name to set
  247. */
  248. JitsiConference.prototype.setDisplayName = function(name) {
  249. if(this.room){
  250. // remove previously set nickname
  251. this.room.removeFromPresence("nick");
  252. this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
  253. this.room.sendPresence();
  254. }
  255. };
  256. /**
  257. * Set new subject for this conference. (available only for moderator)
  258. * @param {string} subject new subject
  259. */
  260. JitsiConference.prototype.setSubject = function (subject) {
  261. if (this.room && this.isModerator()) {
  262. this.room.setSubject(subject);
  263. }
  264. };
  265. /**
  266. * Adds JitsiLocalTrack object to the conference.
  267. * @param track the JitsiLocalTrack object.
  268. * @returns {Promise<JitsiLocalTrack>}
  269. * @throws will throw and error if track is video track
  270. * and there is already another video track in the conference.
  271. */
  272. JitsiConference.prototype.addTrack = function (track) {
  273. if(track.disposed)
  274. {
  275. throw new Error(JitsiTrackErrors.TRACK_IS_DISPOSED);
  276. }
  277. if (track.isVideoTrack()) {
  278. if (this.rtc.getLocalVideoStream()) {
  279. throw new Error("cannot add second video track to the conference");
  280. }
  281. this.removeCommand("videoType");
  282. this.sendCommand("videoType", {
  283. value: track.videoType,
  284. attributes: {
  285. xmlns: 'http://jitsi.org/jitmeet/video'
  286. }
  287. });
  288. }
  289. track.ssrcHandler = function (conference, ssrcMap) {
  290. if(ssrcMap[this.getMSID()]){
  291. this._setSSRC(ssrcMap[this.getMSID()]);
  292. conference.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  293. this.ssrcHandler);
  294. }
  295. }.bind(track, this);
  296. this.room.addListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  297. track.ssrcHandler);
  298. return new Promise(function (resolve) {
  299. this.room.addStream(track.getOriginalStream(), function () {
  300. this.rtc.addLocalStream(track);
  301. if (track.startMuted) {
  302. track.mute();
  303. }
  304. // ensure that we're sharing proper "is muted" state
  305. if (track.isAudioTrack()) {
  306. this.room.setAudioMute(track.isMuted());
  307. } else {
  308. this.room.setVideoMute(track.isMuted());
  309. }
  310. track.muteHandler = this._fireMuteChangeEvent.bind(this, track);
  311. track.audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
  312. track.addEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  313. track.muteHandler);
  314. track.addEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  315. track.audioLevelHandler);
  316. //FIXME: This dependacy is not necessary. This is quick fix.
  317. track._setConference(this);
  318. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  319. resolve(track);
  320. }.bind(this));
  321. }.bind(this));
  322. };
  323. /**
  324. * Fires TRACK_AUDIO_LEVEL_CHANGED change conference event.
  325. * @param audioLevel the audio level
  326. */
  327. JitsiConference.prototype._fireAudioLevelChangeEvent = function (audioLevel) {
  328. this.eventEmitter.emit(
  329. JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
  330. this.myUserId(), audioLevel);
  331. };
  332. /**
  333. * Fires TRACK_MUTE_CHANGED change conference event.
  334. * @param track the JitsiTrack object related to the event.
  335. */
  336. JitsiConference.prototype._fireMuteChangeEvent = function (track) {
  337. // check if track was muted by focus and now is unmuted by user
  338. if (this.isMutedByFocus && track.isAudioTrack() && !track.isMuted()) {
  339. this.isMutedByFocus = false;
  340. // unmute local user on server
  341. this.room.muteParticipant(this.room.myroomjid, false);
  342. }
  343. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  344. };
  345. /**
  346. * Removes JitsiLocalTrack object to the conference.
  347. * @param track the JitsiLocalTrack object.
  348. * @returns {Promise}
  349. */
  350. JitsiConference.prototype.removeTrack = function (track) {
  351. if(track.disposed)
  352. {
  353. throw new Error(JitsiTrackErrors.TRACK_IS_DISPOSED);
  354. }
  355. if(!this.room){
  356. if(this.rtc) {
  357. this.rtc.removeLocalStream(track);
  358. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  359. }
  360. return Promise.resolve();
  361. }
  362. return new Promise(function (resolve) {
  363. this.room.removeStream(track.getOriginalStream(), function(){
  364. track._setSSRC(null);
  365. //FIXME: This dependacy is not necessary. This is quick fix.
  366. track._setConference(this);
  367. this.rtc.removeLocalStream(track);
  368. track.removeEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  369. track.muteHandler);
  370. track.removeEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  371. track.audioLevelHandler);
  372. this.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  373. track.ssrcHandler);
  374. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  375. resolve();
  376. }.bind(this), {
  377. mtype: track.getType(),
  378. type: "remove",
  379. ssrc: track.ssrc});
  380. }.bind(this));
  381. };
  382. /**
  383. * Get role of the local user.
  384. * @returns {string} user role: 'moderator' or 'none'
  385. */
  386. JitsiConference.prototype.getRole = function () {
  387. return this.room.role;
  388. };
  389. /**
  390. * Check if local user is moderator.
  391. * @returns {boolean} true if local user is moderator, false otherwise.
  392. */
  393. JitsiConference.prototype.isModerator = function () {
  394. return this.room.isModerator();
  395. };
  396. /**
  397. * Set password for the room.
  398. * @param {string} password new password for the room.
  399. * @returns {Promise}
  400. */
  401. JitsiConference.prototype.lock = function (password) {
  402. if (!this.isModerator()) {
  403. return Promise.reject();
  404. }
  405. var conference = this;
  406. return new Promise(function (resolve, reject) {
  407. conference.room.lockRoom(password || "", function () {
  408. resolve();
  409. }, function (err) {
  410. reject(err);
  411. }, function () {
  412. reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
  413. });
  414. });
  415. };
  416. /**
  417. * Remove password from the room.
  418. * @returns {Promise}
  419. */
  420. JitsiConference.prototype.unlock = function () {
  421. return this.lock();
  422. };
  423. /**
  424. * Elects the participant with the given id to be the selected participant or the speaker.
  425. * @param id the identifier of the participant
  426. */
  427. JitsiConference.prototype.selectParticipant = function(participantId) {
  428. if (this.rtc) {
  429. this.rtc.selectedEndpoint(participantId);
  430. }
  431. };
  432. /**
  433. *
  434. * @param id the identifier of the participant
  435. */
  436. JitsiConference.prototype.pinParticipant = function(participantId) {
  437. if (this.rtc) {
  438. this.rtc.pinEndpoint(participantId);
  439. }
  440. };
  441. /**
  442. * Returns the list of participants for this conference.
  443. * @return Array<JitsiParticipant> a list of participant identifiers containing all conference participants.
  444. */
  445. JitsiConference.prototype.getParticipants = function() {
  446. return Object.keys(this.participants).map(function (key) {
  447. return this.participants[key];
  448. }, this);
  449. };
  450. /**
  451. * @returns {JitsiParticipant} the participant in this conference with the specified id (or
  452. * undefined if there isn't one).
  453. * @param id the id of the participant.
  454. */
  455. JitsiConference.prototype.getParticipantById = function(id) {
  456. return this.participants[id];
  457. };
  458. /**
  459. * Kick participant from this conference.
  460. * @param {string} id id of the participant to kick
  461. */
  462. JitsiConference.prototype.kickParticipant = function (id) {
  463. var participant = this.getParticipantById(id);
  464. if (!participant) {
  465. return;
  466. }
  467. this.room.kick(participant.getJid());
  468. };
  469. /**
  470. * Kick participant from this conference.
  471. * @param {string} id id of the participant to kick
  472. */
  473. JitsiConference.prototype.muteParticipant = function (id) {
  474. var participant = this.getParticipantById(id);
  475. if (!participant) {
  476. return;
  477. }
  478. this.room.muteParticipant(participant.getJid(), true);
  479. };
  480. JitsiConference.prototype.onMemberJoined = function (jid, nick, role) {
  481. var id = Strophe.getResourceFromJid(jid);
  482. if (id === 'focus' || this.myUserId() === id) {
  483. return;
  484. }
  485. var participant = new JitsiParticipant(jid, this, nick);
  486. participant._role = role;
  487. this.participants[id] = participant;
  488. this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
  489. this.xmpp.connection.disco.info(
  490. jid, "node", function(iq) {
  491. participant._supportsDTMF = $(iq).find(
  492. '>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
  493. this.updateDTMFSupport();
  494. }.bind(this)
  495. );
  496. };
  497. JitsiConference.prototype.onMemberLeft = function (jid) {
  498. var id = Strophe.getResourceFromJid(jid);
  499. if (id === 'focus' || this.myUserId() === id) {
  500. return;
  501. }
  502. var participant = this.participants[id];
  503. delete this.participants[id];
  504. this.rtc.removeRemoteStream(id);
  505. this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
  506. };
  507. JitsiConference.prototype.onUserRoleChanged = function (jid, role) {
  508. var id = Strophe.getResourceFromJid(jid);
  509. var participant = this.getParticipantById(id);
  510. if (!participant) {
  511. return;
  512. }
  513. participant._role = role;
  514. this.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, id, role);
  515. };
  516. JitsiConference.prototype.onDisplayNameChanged = function (jid, displayName) {
  517. var id = Strophe.getResourceFromJid(jid);
  518. var participant = this.getParticipantById(id);
  519. if (!participant) {
  520. return;
  521. }
  522. participant._displayName = displayName;
  523. this.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED, id, displayName);
  524. };
  525. JitsiConference.prototype.onTrackAdded = function (track) {
  526. var id = track.getParticipantId();
  527. var participant = this.getParticipantById(id);
  528. if (!participant) {
  529. return;
  530. }
  531. // add track to JitsiParticipant
  532. participant._tracks.push(track);
  533. var emitter = this.eventEmitter;
  534. track.addEventListener(
  535. JitsiTrackEvents.TRACK_MUTE_CHANGED,
  536. function () {
  537. emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  538. }
  539. );
  540. track.addEventListener(
  541. JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  542. function (audioLevel) {
  543. emitter.emit(JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, id, audioLevel);
  544. }
  545. );
  546. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  547. };
  548. JitsiConference.prototype.updateDTMFSupport = function () {
  549. var somebodySupportsDTMF = false;
  550. var participants = this.getParticipants();
  551. // check if at least 1 participant supports DTMF
  552. for (var i = 0; i < participants.length; i += 1) {
  553. if (participants[i].supportsDTMF()) {
  554. somebodySupportsDTMF = true;
  555. break;
  556. }
  557. }
  558. if (somebodySupportsDTMF !== this.somebodySupportsDTMF) {
  559. this.somebodySupportsDTMF = somebodySupportsDTMF;
  560. this.eventEmitter.emit(JitsiConferenceEvents.DTMF_SUPPORT_CHANGED, somebodySupportsDTMF);
  561. }
  562. };
  563. /**
  564. * Allows to check if there is at least one user in the conference
  565. * that supports DTMF.
  566. * @returns {boolean} true if somebody supports DTMF, false otherwise
  567. */
  568. JitsiConference.prototype.isDTMFSupported = function () {
  569. return this.somebodySupportsDTMF;
  570. };
  571. /**
  572. * Returns the local user's ID
  573. * @return {string} local user's ID
  574. */
  575. JitsiConference.prototype.myUserId = function () {
  576. return (this.room && this.room.myroomjid)? Strophe.getResourceFromJid(this.room.myroomjid) : null;
  577. };
  578. JitsiConference.prototype.sendTones = function (tones, duration, pause) {
  579. if (!this.dtmfManager) {
  580. var connection = this.xmpp.connection.jingle.activecall.peerconnection;
  581. if (!connection) {
  582. logger.warn("cannot sendTones: no conneciton");
  583. return;
  584. }
  585. var tracks = this.getLocalTracks().filter(function (track) {
  586. return track.isAudioTrack();
  587. });
  588. if (!tracks.length) {
  589. logger.warn("cannot sendTones: no local audio stream");
  590. return;
  591. }
  592. this.dtmfManager = new JitsiDTMFManager(tracks[0], connection);
  593. }
  594. this.dtmfManager.sendTones(tones, duration, pause);
  595. };
  596. /**
  597. * Returns true if the recording is supproted and false if not.
  598. */
  599. JitsiConference.prototype.isRecordingSupported = function () {
  600. if(this.room)
  601. return this.room.isRecordingSupported();
  602. return false;
  603. };
  604. /**
  605. * Returns null if the recording is not supported, "on" if the recording started
  606. * and "off" if the recording is not started.
  607. */
  608. JitsiConference.prototype.getRecordingState = function () {
  609. if(this.room)
  610. return this.room.getRecordingState();
  611. return Recording.status.OFF;
  612. }
  613. /**
  614. * Returns the url of the recorded video.
  615. */
  616. JitsiConference.prototype.getRecordingURL = function () {
  617. if(this.room)
  618. return this.room.getRecordingURL();
  619. return null;
  620. }
  621. /**
  622. * Starts/stops the recording
  623. */
  624. JitsiConference.prototype.toggleRecording = function (options) {
  625. if(this.room)
  626. return this.room.toggleRecording(options, function (status, error) {
  627. this.eventEmitter.emit(
  628. JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
  629. }.bind(this));
  630. this.eventEmitter.emit(
  631. JitsiConferenceEvents.RECORDER_STATE_CHANGED, "error",
  632. new Error("The conference is not created yet!"));
  633. }
  634. /**
  635. * Returns true if the SIP calls are supported and false otherwise
  636. */
  637. JitsiConference.prototype.isSIPCallingSupported = function () {
  638. if(this.room)
  639. return this.room.isSIPCallingSupported();
  640. return false;
  641. }
  642. /**
  643. * Dials a number.
  644. * @param number the number
  645. */
  646. JitsiConference.prototype.dial = function (number) {
  647. if(this.room)
  648. return this.room.dial(number);
  649. return new Promise(function(resolve, reject){
  650. reject(new Error("The conference is not created yet!"))});
  651. }
  652. /**
  653. * Hangup an existing call
  654. */
  655. JitsiConference.prototype.hangup = function () {
  656. if(this.room)
  657. return this.room.hangup();
  658. return new Promise(function(resolve, reject){
  659. reject(new Error("The conference is not created yet!"))});
  660. }
  661. /**
  662. * Returns the phone number for joining the conference.
  663. */
  664. JitsiConference.prototype.getPhoneNumber = function () {
  665. if(this.room)
  666. return this.room.getPhoneNumber();
  667. return null;
  668. }
  669. /**
  670. * Returns the pin for joining the conference with phone.
  671. */
  672. JitsiConference.prototype.getPhonePin = function () {
  673. if(this.room)
  674. return this.room.getPhonePin();
  675. return null;
  676. }
  677. /**
  678. * Returns the connection state for the current room. Its ice connection state
  679. * for its session.
  680. */
  681. JitsiConference.prototype.getConnectionState = function () {
  682. if(this.room)
  683. return this.room.getConnectionState();
  684. return null;
  685. }
  686. /**
  687. * Make all new participants mute their audio/video on join.
  688. * @param policy {Object} object with 2 boolean properties for video and audio:
  689. * @param {boolean} audio if audio should be muted.
  690. * @param {boolean} video if video should be muted.
  691. */
  692. JitsiConference.prototype.setStartMutedPolicy = function (policy) {
  693. if (!this.isModerator()) {
  694. return;
  695. }
  696. this.startMutedPolicy = policy;
  697. this.room.removeFromPresence("startmuted");
  698. this.room.addToPresence("startmuted", {
  699. attributes: {
  700. audio: policy.audio,
  701. video: policy.video,
  702. xmlns: 'http://jitsi.org/jitmeet/start-muted'
  703. }
  704. });
  705. this.room.sendPresence();
  706. };
  707. /**
  708. * Returns current start muted policy
  709. * @returns {Object} with 2 proprties - audio and video.
  710. */
  711. JitsiConference.prototype.getStartMutedPolicy = function () {
  712. return this.startMutedPolicy;
  713. };
  714. /**
  715. * Check if audio is muted on join.
  716. */
  717. JitsiConference.prototype.isStartAudioMuted = function () {
  718. return this.startAudioMuted;
  719. };
  720. /**
  721. * Check if video is muted on join.
  722. */
  723. JitsiConference.prototype.isStartVideoMuted = function () {
  724. return this.startVideoMuted;
  725. };
  726. /**
  727. * Get object with internal logs.
  728. */
  729. JitsiConference.prototype.getLogs = function () {
  730. var data = this.xmpp.getJingleLog();
  731. var metadata = {};
  732. metadata.time = new Date();
  733. metadata.url = window.location.href;
  734. metadata.ua = navigator.userAgent;
  735. var log = this.xmpp.getXmppLog();
  736. if (log) {
  737. metadata.xmpp = log;
  738. }
  739. data.metadata = metadata;
  740. return data;
  741. };
  742. /**
  743. * Returns measured performanceTimes.
  744. */
  745. JitsiConference.prototype.getPerformanceTimes = function () {
  746. return this.room.performanceTimes;
  747. };
  748. /**
  749. * Sends the given feedback through CallStats if enabled.
  750. *
  751. * @param overallFeedback an integer between 1 and 5 indicating the
  752. * user feedback
  753. * @param detailedFeedback detailed feedback from the user. Not yet used
  754. */
  755. JitsiConference.prototype.sendFeedback =
  756. function(overallFeedback, detailedFeedback){
  757. this.statistics.sendFeedback(overallFeedback, detailedFeedback);
  758. }
  759. /**
  760. * Returns true if the callstats integration is enabled, otherwise returns
  761. * false.
  762. *
  763. * @returns true if the callstats integration is enabled, otherwise returns
  764. * false.
  765. */
  766. JitsiConference.prototype.isCallstatsEnabled = function () {
  767. return this.statistics.isCallstatsEnabled();
  768. }
  769. /**
  770. * Setups the listeners needed for the conference.
  771. * @param conference the conference
  772. */
  773. function setupListeners(conference) {
  774. conference.xmpp.addListener(
  775. XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer, now) {
  776. if (conference.room.isFocus(jingleSession.peerjid)) {
  777. // Accept incoming call
  778. conference.room.setJingleSession(jingleSession);
  779. conference.room.performanceTimes["session.initiate"] = now;
  780. jingleSession.initialize(false /* initiator */, conference.room);
  781. conference.rtc.onIncommingCall(jingleSession);
  782. jingleSession.acceptOffer(jingleOffer, null,
  783. function (error) {
  784. console.error(
  785. "Failed to accept incoming Jingle session", error);
  786. }
  787. );
  788. conference.statistics.startRemoteStats(
  789. jingleSession.peerconnection);
  790. } else {
  791. // Error cause this should never happen unless something is wrong !
  792. logger.error(
  793. "Rejecting session-initiate from non focus user: "
  794. + jingleSession.peerjid);
  795. }
  796. });
  797. conference.room.addListener(XMPPEvents.REMOTE_STREAM_RECEIVED,
  798. function (data, sid, thessrc) {
  799. var track = conference.rtc.createRemoteStream(data, sid, thessrc);
  800. if (track) {
  801. conference.onTrackAdded(track);
  802. }
  803. }
  804. );
  805. conference.room.addListener(XMPPEvents.REMOTE_STREAM_REMOVED,
  806. function (streamId) {
  807. var participants = conference.getParticipants();
  808. for(var j = 0; j < participants.length; j++) {
  809. var participant = participants[j];
  810. var tracks = participant.getTracks();
  811. for(var i = 0; i < tracks.length; i++) {
  812. if(tracks[i] && tracks[i].stream &&
  813. RTC.getStreamID(tracks[i].stream) == streamId){
  814. var track = participant._tracks.splice(i, 1)[0];
  815. conference.eventEmitter.emit(
  816. JitsiConferenceEvents.TRACK_REMOVED, track);
  817. return;
  818. }
  819. }
  820. }
  821. }
  822. );
  823. conference.rtc.addListener(RTCEvents.FAKE_VIDEO_TRACK_CREATED,
  824. function (track) {
  825. conference.onTrackAdded(track);
  826. }
  827. );
  828. conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
  829. function (value) {
  830. // set isMutedByFocus when setAudioMute Promise ends
  831. conference.rtc.setAudioMute(value).then(
  832. function() {
  833. conference.isMutedByFocus = true;
  834. },
  835. function() {
  836. logger.warn(
  837. "Error while audio muting due to focus request");
  838. });
  839. }
  840. );
  841. conference.room.addListener(XMPPEvents.SUBJECT_CHANGED, function (subject) {
  842. conference.eventEmitter.emit(JitsiConferenceEvents.SUBJECT_CHANGED,
  843. subject);
  844. });
  845. conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
  846. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
  847. });
  848. conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
  849. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  850. JitsiConferenceErrors.CONNECTION_ERROR, pres);
  851. });
  852. conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
  853. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  854. JitsiConferenceErrors.CONNECTION_ERROR, pres);
  855. });
  856. conference.room.addListener(XMPPEvents.ROOM_MAX_USERS_ERROR,
  857. function (pres) {
  858. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  859. JitsiConferenceErrors.CONFERENCE_MAX_USERS, pres);
  860. });
  861. conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
  862. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
  863. });
  864. conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
  865. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
  866. });
  867. conference.room.addListener(XMPPEvents.BRIDGE_DOWN, function () {
  868. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
  869. });
  870. conference.room.addListener(XMPPEvents.RESERVATION_ERROR, function (code, msg) {
  871. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.RESERVATION_ERROR, code, msg);
  872. });
  873. conference.room.addListener(XMPPEvents.GRACEFUL_SHUTDOWN, function () {
  874. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
  875. });
  876. conference.room.addListener(XMPPEvents.JINGLE_FATAL_ERROR, function () {
  877. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.JINGLE_FATAL_ERROR);
  878. });
  879. conference.room.addListener(XMPPEvents.MUC_DESTROYED, function (reason) {
  880. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONFERENCE_DESTROYED, reason);
  881. });
  882. conference.room.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, function (err, msg) {
  883. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_ERROR, JitsiConferenceErrors.CHAT_ERROR, err, msg);
  884. });
  885. conference.room.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focus, retrySec) {
  886. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_DISCONNECTED, focus, retrySec);
  887. });
  888. conference.room.addListener(XMPPEvents.FOCUS_LEFT, function () {
  889. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_LEFT);
  890. });
  891. // FIXME
  892. // conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
  893. // conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
  894. // });
  895. conference.room.addListener(XMPPEvents.KICKED, function () {
  896. conference.eventEmitter.emit(JitsiConferenceEvents.KICKED);
  897. });
  898. conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
  899. conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
  900. conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, conference.onDisplayNameChanged.bind(conference));
  901. conference.room.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
  902. conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, conference.myUserId(), role);
  903. });
  904. conference.room.addListener(XMPPEvents.MUC_ROLE_CHANGED, conference.onUserRoleChanged.bind(conference));
  905. conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
  906. conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
  907. });
  908. conference.room.addListener(XMPPEvents.RECORDER_STATE_CHANGED,
  909. function (state) {
  910. conference.eventEmitter.emit(
  911. JitsiConferenceEvents.RECORDER_STATE_CHANGED, state);
  912. });
  913. conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
  914. conference.eventEmitter.emit(
  915. JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
  916. });
  917. conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
  918. conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
  919. });
  920. conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
  921. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
  922. });
  923. conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
  924. conference.authEnabled = authEnabled;
  925. conference.authIdentity = authIdentity;
  926. conference.eventEmitter.emit(JitsiConferenceEvents.AUTH_STATUS_CHANGED, authEnabled, authIdentity);
  927. });
  928. conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
  929. var id = Strophe.getResourceFromJid(jid);
  930. conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts);
  931. });
  932. conference.room.addListener(XMPPEvents.PRESENCE_STATUS, function (jid, status) {
  933. var id = Strophe.getResourceFromJid(jid);
  934. var participant = conference.getParticipantById(id);
  935. if (!participant || participant._status === status) {
  936. return;
  937. }
  938. participant._status = status;
  939. conference.eventEmitter.emit(JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
  940. });
  941. conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
  942. if(conference.lastDominantSpeaker !== id && conference.room) {
  943. conference.lastDominantSpeaker = id;
  944. conference.eventEmitter.emit(JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
  945. }
  946. });
  947. conference.rtc.addListener(RTCEvents.LASTN_CHANGED, function (oldValue, newValue) {
  948. conference.eventEmitter.emit(JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
  949. });
  950. conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
  951. function (lastNEndpoints, endpointsEnteringLastN) {
  952. conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
  953. lastNEndpoints, endpointsEnteringLastN);
  954. });
  955. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  956. function (audioMuted, videoMuted) {
  957. conference.startAudioMuted = audioMuted;
  958. conference.startVideoMuted = videoMuted;
  959. // mute existing local tracks because this is initial mute from
  960. // Jicofo
  961. conference.getLocalTracks().forEach(function (track) {
  962. if (conference.startAudioMuted && track.isAudioTrack()) {
  963. track.mute();
  964. }
  965. if (conference.startVideoMuted && track.isVideoTrack()) {
  966. track.mute();
  967. }
  968. });
  969. conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
  970. });
  971. conference.room.addPresenceListener("startmuted", function (data, from) {
  972. var isModerator = false;
  973. if (conference.myUserId() === from && conference.isModerator()) {
  974. isModerator = true;
  975. } else {
  976. var participant = conference.getParticipantById(from);
  977. if (participant && participant.isModerator()) {
  978. isModerator = true;
  979. }
  980. }
  981. if (!isModerator) {
  982. return;
  983. }
  984. var startAudioMuted = data.attributes.audio === 'true';
  985. var startVideoMuted = data.attributes.video === 'true';
  986. var updated = false;
  987. if (startAudioMuted !== conference.startMutedPolicy.audio) {
  988. conference.startMutedPolicy.audio = startAudioMuted;
  989. updated = true;
  990. }
  991. if (startVideoMuted !== conference.startMutedPolicy.video) {
  992. conference.startMutedPolicy.video = startVideoMuted;
  993. updated = true;
  994. }
  995. if (updated) {
  996. conference.eventEmitter.emit(
  997. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  998. conference.startMutedPolicy
  999. );
  1000. }
  1001. });
  1002. conference.rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
  1003. conference.room.updateDeviceAvailability(devices);
  1004. });
  1005. conference.room.addPresenceListener("devices", function (data, from) {
  1006. var isAudioAvailable = false;
  1007. var isVideoAvailable = false;
  1008. data.children.forEach(function (config) {
  1009. if (config.tagName === 'audio') {
  1010. isAudioAvailable = config.value === 'true';
  1011. }
  1012. if (config.tagName === 'video') {
  1013. isVideoAvailable = config.value === 'true';
  1014. }
  1015. });
  1016. var availableDevices;
  1017. if (conference.myUserId() === from) {
  1018. availableDevices = conference.availableDevices;
  1019. } else {
  1020. var participant = conference.getParticipantById(from);
  1021. if (!participant) {
  1022. return;
  1023. }
  1024. availableDevices = participant._availableDevices;
  1025. }
  1026. var updated = false;
  1027. if (availableDevices.audio !== isAudioAvailable) {
  1028. updated = true;
  1029. availableDevices.audio = isAudioAvailable;
  1030. }
  1031. if (availableDevices.video !== isVideoAvailable) {
  1032. updated = true;
  1033. availableDevices.video = isVideoAvailable;
  1034. }
  1035. if (updated) {
  1036. conference.eventEmitter.emit(
  1037. JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
  1038. from, availableDevices);
  1039. }
  1040. });
  1041. if(conference.statistics) {
  1042. //FIXME: Maybe remove event should not be associated with the conference.
  1043. conference.statistics.addAudioLevelListener(function (ssrc, level) {
  1044. var userId = null;
  1045. var resource = conference.rtc.getResourceBySSRC(ssrc);
  1046. if (!resource)
  1047. return;
  1048. conference.rtc.setAudioLevel(resource, level);
  1049. });
  1050. conference.statistics.addConnectionStatsListener(function (stats) {
  1051. var ssrc2resolution = stats.resolution;
  1052. var id2resolution = {};
  1053. // preprocess resolutions: group by user id, skip incorrect
  1054. // resolutions etc.
  1055. Object.keys(ssrc2resolution).forEach(function (ssrc) {
  1056. var resolution = ssrc2resolution[ssrc];
  1057. if (!resolution.width || !resolution.height ||
  1058. resolution.width == -1 || resolution.height == -1) {
  1059. return;
  1060. }
  1061. var id = conference.rtc.getResourceBySSRC(ssrc);
  1062. if (!id) {
  1063. return;
  1064. }
  1065. // ssrc to resolution map for user id
  1066. var idResolutions = id2resolution[id] || {};
  1067. idResolutions[ssrc] = resolution;
  1068. id2resolution[id] = idResolutions;
  1069. });
  1070. stats.resolution = id2resolution;
  1071. conference.eventEmitter.emit(
  1072. JitsiConferenceEvents.CONNECTION_STATS, stats);
  1073. });
  1074. conference.xmpp.addListener(XMPPEvents.DISPOSE_CONFERENCE,
  1075. function () {
  1076. conference.statistics.dispose();
  1077. });
  1078. conference.room.addListener(XMPPEvents.PEERCONNECTION_READY,
  1079. function (session) {
  1080. conference.statistics.startCallStats(
  1081. session, conference.settings);
  1082. });
  1083. conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED,
  1084. function () {
  1085. conference.statistics.sendSetupFailedEvent();
  1086. });
  1087. conference.rtc.addListener(RTCEvents.TRACK_ATTACHED,
  1088. function(track, container) {
  1089. var ssrc = track.getSSRC();
  1090. if (!container.id || !ssrc) {
  1091. return;
  1092. }
  1093. conference.statistics.associateStreamWithVideoTag(
  1094. ssrc, track.isLocal(), track.getUsageLabel(), container.id);
  1095. });
  1096. conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  1097. function (track) {
  1098. if(!track.isLocal())
  1099. return;
  1100. var type = (track.getType() === "audio")? "audio" : "video";
  1101. conference.statistics.sendMuteEvent(track.isMuted(), type);
  1102. });
  1103. conference.room.addListener(XMPPEvents.CREATE_OFFER_FAILED, function (e, pc) {
  1104. conference.statistics.sendCreateOfferFailed(e, pc);
  1105. });
  1106. conference.room.addListener(XMPPEvents.CREATE_ANSWER_FAILED, function (e, pc) {
  1107. conference.statistics.sendCreateAnswerFailed(e, pc);
  1108. });
  1109. conference.room.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
  1110. function (e, pc) {
  1111. conference.statistics.sendSetLocalDescFailed(e, pc);
  1112. }
  1113. );
  1114. conference.room.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
  1115. function (e, pc) {
  1116. conference.statistics.sendSetRemoteDescFailed(e, pc);
  1117. }
  1118. );
  1119. conference.room.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  1120. function (e, pc) {
  1121. conference.statistics.sendAddIceCandidateFailed(e, pc);
  1122. }
  1123. );
  1124. }
  1125. }
  1126. module.exports = JitsiConference;