Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiConference.js 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262
  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 "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.RECORDING_STATE_CHANGED, status, error);
  629. }.bind(this));
  630. this.eventEmitter.emit(
  631. JitsiConferenceEvents.RECORDING_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. * Sends the given feedback through CallStats if enabled.
  744. *
  745. * @param overallFeedback an integer between 1 and 5 indicating the
  746. * user feedback
  747. * @param detailedFeedback detailed feedback from the user. Not yet used
  748. */
  749. JitsiConference.prototype.sendFeedback =
  750. function(overallFeedback, detailedFeedback){
  751. this.statistics.sendFeedback(overallFeedback, detailedFeedback);
  752. }
  753. /**
  754. * Returns true if the callstats integration is enabled, otherwise returns
  755. * false.
  756. *
  757. * @returns true if the callstats integration is enabled, otherwise returns
  758. * false.
  759. */
  760. JitsiConference.prototype.isCallstatsEnabled = function () {
  761. return this.statistics.isCallstatsEnabled();
  762. }
  763. /**
  764. * Setups the listeners needed for the conference.
  765. * @param conference the conference
  766. */
  767. function setupListeners(conference) {
  768. conference.xmpp.addListener(
  769. XMPPEvents.CALL_INCOMING, function (jingleSession, jingleOffer) {
  770. if (conference.room.isFocus(jingleSession.peerjid)) {
  771. // Accept incoming call
  772. conference.room.setJingleSession(jingleSession);
  773. conference.rtc.onIncommingCall(jingleSession);
  774. jingleSession.acceptOffer(jingleOffer, null,
  775. function (error) {
  776. console.error(
  777. "Failed to accept incoming Jingle session", error);
  778. }
  779. );
  780. conference.statistics.startRemoteStats(
  781. jingleSession.peerconnection);
  782. } else {
  783. // Error cause this should never happen unless something is wrong !
  784. logger.error(
  785. "Rejecting session-initiate from non focus user: "
  786. + jingleSession.peerjid);
  787. }
  788. });
  789. conference.room.addListener(XMPPEvents.REMOTE_STREAM_RECEIVED,
  790. function (data, sid, thessrc) {
  791. var track = conference.rtc.createRemoteStream(data, sid, thessrc);
  792. if (track) {
  793. conference.onTrackAdded(track);
  794. }
  795. }
  796. );
  797. conference.room.addListener(XMPPEvents.REMOTE_STREAM_REMOVED,
  798. function (streamId) {
  799. var participants = conference.getParticipants();
  800. for(var j = 0; j < participants.length; j++) {
  801. var participant = participants[j];
  802. var tracks = participant.getTracks();
  803. for(var i = 0; i < tracks.length; i++) {
  804. if(tracks[i] && tracks[i].stream &&
  805. RTC.getStreamID(tracks[i].stream) == streamId){
  806. var track = participant._tracks.splice(i, 1)[0];
  807. conference.eventEmitter.emit(
  808. JitsiConferenceEvents.TRACK_REMOVED, track);
  809. return;
  810. }
  811. }
  812. }
  813. }
  814. );
  815. conference.rtc.addListener(RTCEvents.FAKE_VIDEO_TRACK_CREATED,
  816. function (track) {
  817. conference.onTrackAdded(track);
  818. }
  819. );
  820. conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
  821. function (value) {
  822. // set isMutedByFocus when setAudioMute Promise ends
  823. conference.rtc.setAudioMute(value).then(
  824. function() {
  825. conference.isMutedByFocus = true;
  826. },
  827. function() {
  828. logger.warn(
  829. "Error while audio muting due to focus request");
  830. });
  831. }
  832. );
  833. conference.room.addListener(XMPPEvents.SUBJECT_CHANGED, function (subject) {
  834. conference.eventEmitter.emit(JitsiConferenceEvents.SUBJECT_CHANGED,
  835. subject);
  836. });
  837. conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
  838. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
  839. });
  840. conference.room.addListener(XMPPEvents.ROOM_JOIN_ERROR, function (pres) {
  841. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  842. JitsiConferenceErrors.CONNECTION_ERROR, pres);
  843. });
  844. conference.room.addListener(XMPPEvents.ROOM_CONNECT_ERROR, function (pres) {
  845. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  846. JitsiConferenceErrors.CONNECTION_ERROR, pres);
  847. });
  848. conference.room.addListener(XMPPEvents.ROOM_MAX_USERS_ERROR,
  849. function (pres) {
  850. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  851. JitsiConferenceErrors.CONFERENCE_MAX_USERS, pres);
  852. });
  853. conference.room.addListener(XMPPEvents.PASSWORD_REQUIRED, function (pres) {
  854. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.PASSWORD_REQUIRED, pres);
  855. });
  856. conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
  857. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
  858. });
  859. conference.room.addListener(XMPPEvents.BRIDGE_DOWN, function () {
  860. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
  861. });
  862. conference.room.addListener(XMPPEvents.RESERVATION_ERROR, function (code, msg) {
  863. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.RESERVATION_ERROR, code, msg);
  864. });
  865. conference.room.addListener(XMPPEvents.GRACEFUL_SHUTDOWN, function () {
  866. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
  867. });
  868. conference.room.addListener(XMPPEvents.JINGLE_FATAL_ERROR, function () {
  869. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.JINGLE_FATAL_ERROR);
  870. });
  871. conference.room.addListener(XMPPEvents.MUC_DESTROYED, function (reason) {
  872. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.CONFERENCE_DESTROYED, reason);
  873. });
  874. conference.room.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, function (err, msg) {
  875. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_ERROR, JitsiConferenceErrors.CHAT_ERROR, err, msg);
  876. });
  877. conference.room.addListener(XMPPEvents.FOCUS_DISCONNECTED, function (focus, retrySec) {
  878. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_DISCONNECTED, focus, retrySec);
  879. });
  880. conference.room.addListener(XMPPEvents.FOCUS_LEFT, function () {
  881. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_LEFT);
  882. });
  883. // FIXME
  884. // conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
  885. // conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
  886. // });
  887. conference.room.addListener(XMPPEvents.KICKED, function () {
  888. conference.eventEmitter.emit(JitsiConferenceEvents.KICKED);
  889. });
  890. conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
  891. conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
  892. conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, conference.onDisplayNameChanged.bind(conference));
  893. conference.room.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function (role) {
  894. conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, conference.myUserId(), role);
  895. });
  896. conference.room.addListener(XMPPEvents.MUC_ROLE_CHANGED, conference.onUserRoleChanged.bind(conference));
  897. conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
  898. conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
  899. });
  900. conference.room.addListener(XMPPEvents.RECORDING_STATE_CHANGED,
  901. function () {
  902. conference.eventEmitter.emit(
  903. JitsiConferenceEvents.RECORDING_STATE_CHANGED);
  904. });
  905. conference.room.addListener(XMPPEvents.PHONE_NUMBER_CHANGED, function () {
  906. conference.eventEmitter.emit(
  907. JitsiConferenceEvents.PHONE_NUMBER_CHANGED);
  908. });
  909. conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
  910. conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
  911. });
  912. conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
  913. conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.SETUP_FAILED);
  914. });
  915. conference.room.addListener(AuthenticationEvents.IDENTITY_UPDATED, function (authEnabled, authIdentity) {
  916. conference.authEnabled = authEnabled;
  917. conference.authIdentity = authIdentity;
  918. conference.eventEmitter.emit(JitsiConferenceEvents.AUTH_STATUS_CHANGED, authEnabled, authIdentity);
  919. });
  920. conference.room.addListener(XMPPEvents.MESSAGE_RECEIVED, function (jid, displayName, txt, myJid, ts) {
  921. var id = Strophe.getResourceFromJid(jid);
  922. conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED, id, txt, ts);
  923. });
  924. conference.room.addListener(XMPPEvents.PRESENCE_STATUS, function (jid, status) {
  925. var id = Strophe.getResourceFromJid(jid);
  926. var participant = conference.getParticipantById(id);
  927. if (!participant || participant._status === status) {
  928. return;
  929. }
  930. participant._status = status;
  931. conference.eventEmitter.emit(JitsiConferenceEvents.USER_STATUS_CHANGED, id, status);
  932. });
  933. conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
  934. if(conference.lastDominantSpeaker !== id && conference.room) {
  935. conference.lastDominantSpeaker = id;
  936. conference.eventEmitter.emit(JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED, id);
  937. }
  938. });
  939. conference.rtc.addListener(RTCEvents.LASTN_CHANGED, function (oldValue, newValue) {
  940. conference.eventEmitter.emit(JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
  941. });
  942. conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
  943. function (lastNEndpoints, endpointsEnteringLastN) {
  944. conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
  945. lastNEndpoints, endpointsEnteringLastN);
  946. });
  947. conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
  948. function (audioMuted, videoMuted) {
  949. conference.startAudioMuted = audioMuted;
  950. conference.startVideoMuted = videoMuted;
  951. // mute existing local tracks because this is initial mute from
  952. // Jicofo
  953. conference.getLocalTracks().forEach(function (track) {
  954. if (conference.startAudioMuted && track.isAudioTrack()) {
  955. track.mute();
  956. }
  957. if (conference.startVideoMuted && track.isVideoTrack()) {
  958. track.mute();
  959. }
  960. });
  961. conference.eventEmitter.emit(JitsiConferenceEvents.STARTED_MUTED);
  962. });
  963. conference.room.addPresenceListener("startmuted", function (data, from) {
  964. var isModerator = false;
  965. if (conference.myUserId() === from && conference.isModerator()) {
  966. isModerator = true;
  967. } else {
  968. var participant = conference.getParticipantById(from);
  969. if (participant && participant.isModerator()) {
  970. isModerator = true;
  971. }
  972. }
  973. if (!isModerator) {
  974. return;
  975. }
  976. var startAudioMuted = data.attributes.audio === 'true';
  977. var startVideoMuted = data.attributes.video === 'true';
  978. var updated = false;
  979. if (startAudioMuted !== conference.startMutedPolicy.audio) {
  980. conference.startMutedPolicy.audio = startAudioMuted;
  981. updated = true;
  982. }
  983. if (startVideoMuted !== conference.startMutedPolicy.video) {
  984. conference.startMutedPolicy.video = startVideoMuted;
  985. updated = true;
  986. }
  987. if (updated) {
  988. conference.eventEmitter.emit(
  989. JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
  990. conference.startMutedPolicy
  991. );
  992. }
  993. });
  994. conference.rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
  995. conference.room.updateDeviceAvailability(devices);
  996. });
  997. conference.room.addPresenceListener("devices", function (data, from) {
  998. var isAudioAvailable = false;
  999. var isVideoAvailable = false;
  1000. data.children.forEach(function (config) {
  1001. if (config.tagName === 'audio') {
  1002. isAudioAvailable = config.value === 'true';
  1003. }
  1004. if (config.tagName === 'video') {
  1005. isVideoAvailable = config.value === 'true';
  1006. }
  1007. });
  1008. var availableDevices;
  1009. if (conference.myUserId() === from) {
  1010. availableDevices = conference.availableDevices;
  1011. } else {
  1012. var participant = conference.getParticipantById(from);
  1013. if (!participant) {
  1014. return;
  1015. }
  1016. availableDevices = participant._availableDevices;
  1017. }
  1018. var updated = false;
  1019. if (availableDevices.audio !== isAudioAvailable) {
  1020. updated = true;
  1021. availableDevices.audio = isAudioAvailable;
  1022. }
  1023. if (availableDevices.video !== isVideoAvailable) {
  1024. updated = true;
  1025. availableDevices.video = isVideoAvailable;
  1026. }
  1027. if (updated) {
  1028. conference.eventEmitter.emit(
  1029. JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED,
  1030. from, availableDevices);
  1031. }
  1032. });
  1033. if(conference.statistics) {
  1034. //FIXME: Maybe remove event should not be associated with the conference.
  1035. conference.statistics.addAudioLevelListener(function (ssrc, level) {
  1036. var userId = null;
  1037. var resource = conference.rtc.getResourceBySSRC(ssrc);
  1038. if (!resource)
  1039. return;
  1040. conference.rtc.setAudioLevel(resource, level);
  1041. });
  1042. conference.statistics.addConnectionStatsListener(function (stats) {
  1043. var ssrc2resolution = stats.resolution;
  1044. var id2resolution = {};
  1045. // preprocess resolutions: group by user id, skip incorrect
  1046. // resolutions etc.
  1047. Object.keys(ssrc2resolution).forEach(function (ssrc) {
  1048. var resolution = ssrc2resolution[ssrc];
  1049. if (!resolution.width || !resolution.height ||
  1050. resolution.width == -1 || resolution.height == -1) {
  1051. return;
  1052. }
  1053. var id = conference.rtc.getResourceBySSRC(ssrc);
  1054. if (!id) {
  1055. return;
  1056. }
  1057. // ssrc to resolution map for user id
  1058. var idResolutions = id2resolution[id] || {};
  1059. idResolutions[ssrc] = resolution;
  1060. id2resolution[id] = idResolutions;
  1061. });
  1062. stats.resolution = id2resolution;
  1063. conference.eventEmitter.emit(
  1064. JitsiConferenceEvents.CONNECTION_STATS, stats);
  1065. });
  1066. conference.xmpp.addListener(XMPPEvents.DISPOSE_CONFERENCE,
  1067. function () {
  1068. conference.statistics.dispose();
  1069. });
  1070. conference.room.addListener(XMPPEvents.PEERCONNECTION_READY,
  1071. function (session) {
  1072. conference.statistics.startCallStats(
  1073. session, conference.settings);
  1074. });
  1075. conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED,
  1076. function () {
  1077. conference.statistics.sendSetupFailedEvent();
  1078. });
  1079. conference.rtc.addListener(RTCEvents.TRACK_ATTACHED,
  1080. function(track, container) {
  1081. var ssrc = track.getSSRC();
  1082. if (!container.id || !ssrc) {
  1083. return;
  1084. }
  1085. conference.statistics.associateStreamWithVideoTag(
  1086. ssrc, track.isLocal(), track.getUsageLabel(), container.id);
  1087. });
  1088. conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  1089. function (track) {
  1090. if(!track.isLocal())
  1091. return;
  1092. var type = (track.getType() === "audio")? "audio" : "video";
  1093. conference.statistics.sendMuteEvent(track.isMuted(), type);
  1094. });
  1095. conference.room.addListener(XMPPEvents.CREATE_OFFER_FAILED, function (e, pc) {
  1096. conference.statistics.sendCreateOfferFailed(e, pc);
  1097. });
  1098. conference.room.addListener(XMPPEvents.CREATE_ANSWER_FAILED, function (e, pc) {
  1099. conference.statistics.sendCreateAnswerFailed(e, pc);
  1100. });
  1101. conference.room.addListener(XMPPEvents.SET_LOCAL_DESCRIPTION_FAILED,
  1102. function (e, pc) {
  1103. conference.statistics.sendSetLocalDescFailed(e, pc);
  1104. }
  1105. );
  1106. conference.room.addListener(XMPPEvents.SET_REMOTE_DESCRIPTION_FAILED,
  1107. function (e, pc) {
  1108. conference.statistics.sendSetRemoteDescFailed(e, pc);
  1109. }
  1110. );
  1111. conference.room.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
  1112. function (e, pc) {
  1113. conference.statistics.sendAddIceCandidateFailed(e, pc);
  1114. }
  1115. );
  1116. }
  1117. }
  1118. module.exports = JitsiConference;