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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  1. /* global Strophe, $, Promise */
  2. var logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var RTC = require("./modules/RTC/RTC");
  4. var XMPPEvents = require("./service/xmpp/XMPPEvents");
  5. var EventEmitter = require("events");
  6. import * as JitsiConferenceErrors from "./JitsiConferenceErrors";
  7. import * as JitsiConferenceEvents from "./JitsiConferenceEvents";
  8. import JitsiParticipant from "./JitsiParticipant";
  9. var Statistics = require("./modules/statistics/statistics");
  10. var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
  11. import JitsiTrackError from "./JitsiTrackError";
  12. import * as JitsiTrackErrors from "./JitsiTrackErrors";
  13. import * as JitsiTrackEvents from "./JitsiTrackEvents";
  14. var ComponentsVersions = require("./modules/version/ComponentsVersions");
  15. var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
  16. var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
  17. var VideoType = require('./service/RTC/VideoType');
  18. var Transcriber = require("./modules/transcription/transcriber");
  19. import ParticipantConnectionStatus
  20. from "./modules/connectivity/ParticipantConnectionStatus";
  21. import TalkMutedDetection from "./modules/TalkMutedDetection";
  22. import ConnectionQuality from "./modules/connectivity/ConnectionQuality";
  23. /**
  24. * Creates a JitsiConference object with the given name and properties.
  25. * Note: this constructor is not a part of the public API (objects should be
  26. * created using JitsiConnection.createConference).
  27. * @param options.config properties / settings related to the conference that will be created.
  28. * @param options.name the name of the conference
  29. * @param options.connection the JitsiConnection object for this JitsiConference.
  30. * @constructor
  31. */
  32. function JitsiConference(options) {
  33. if(!options.name || options.name.toLowerCase() !== options.name) {
  34. var errmsg
  35. = "Invalid conference name (no conference name passed or it "
  36. + "contains invalid characters like capital letters)!";
  37. logger.error(errmsg);
  38. throw new Error(errmsg);
  39. }
  40. this.eventEmitter = new EventEmitter();
  41. this.options = options;
  42. this.eventManager = new JitsiConferenceEventManager(this);
  43. this._init(options);
  44. this.componentsVersions = new ComponentsVersions(this);
  45. this.participants = {};
  46. this.lastDominantSpeaker = null;
  47. this.dtmfManager = null;
  48. this.somebodySupportsDTMF = false;
  49. this.authEnabled = false;
  50. this.authIdentity;
  51. this.startAudioMuted = false;
  52. this.startVideoMuted = false;
  53. this.startMutedPolicy = {audio: false, video: false};
  54. this.availableDevices = {
  55. audio: undefined,
  56. video: undefined
  57. };
  58. this.isMutedByFocus = false;
  59. // Flag indicates if the 'onCallEnded' method was ever called on this
  60. // instance. Used to log extra analytics event for debugging purpose.
  61. // We need to know if the potential issue happened before or after
  62. // the restart.
  63. this.wasStopped = false;
  64. /**
  65. * The object which monitors local and remote connection statistics (e.g.
  66. * sending bitrate) and calculates a number which represents the connection
  67. * quality.
  68. */
  69. this.connectionQuality
  70. = new ConnectionQuality(this, this.eventEmitter, options);
  71. /**
  72. * Indicates whether the connection is interrupted or not.
  73. */
  74. this.connectionIsInterrupted = false;
  75. }
  76. /**
  77. * Initializes the conference object properties
  78. * @param options {object}
  79. * @param connection {JitsiConnection} overrides this.connection
  80. */
  81. JitsiConference.prototype._init = function (options) {
  82. if(!options)
  83. options = {};
  84. // Override connection and xmpp properties (Usefull if the connection
  85. // reloaded)
  86. if(options.connection) {
  87. this.connection = options.connection;
  88. this.xmpp = this.connection.xmpp;
  89. // Setup XMPP events only if we have new connection object.
  90. this.eventManager.setupXMPPListeners();
  91. }
  92. this.room = this.xmpp.createRoom(this.options.name, this.options.config);
  93. this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
  94. if(!this.rtc) {
  95. this.rtc = new RTC(this, options);
  96. this.eventManager.setupRTCListeners();
  97. }
  98. this.participantConnectionStatus
  99. = new ParticipantConnectionStatus(
  100. this.rtc, this,
  101. options.config.peerDisconnectedThroughRtcTimeout);
  102. this.participantConnectionStatus.init();
  103. if(!this.statistics) {
  104. this.statistics = new Statistics(this.xmpp, {
  105. callStatsID: this.options.config.callStatsID,
  106. callStatsSecret: this.options.config.callStatsSecret,
  107. callStatsConfIDNamespace:
  108. this.options.config.callStatsConfIDNamespace || window.location.hostname,
  109. callStatsCustomScriptUrl:
  110. this.options.config.callStatsCustomScriptUrl,
  111. roomName: this.options.name
  112. });
  113. }
  114. this.eventManager.setupChatRoomListeners();
  115. // Always add listeners because on reload we are executing leave and the
  116. // listeners are removed from statistics module.
  117. this.eventManager.setupStatisticsListeners();
  118. if (this.options.config.enableTalkWhileMuted) {
  119. new TalkMutedDetection(this, () => {
  120. this.eventEmitter.emit(JitsiConferenceEvents.TALK_WHILE_MUTED);
  121. });
  122. }
  123. };
  124. /**
  125. * Joins the conference.
  126. * @param password {string} the password
  127. */
  128. JitsiConference.prototype.join = function (password) {
  129. if(this.room)
  130. this.room.join(password);
  131. };
  132. /**
  133. * Check if joined to the conference.
  134. */
  135. JitsiConference.prototype.isJoined = function () {
  136. return this.room && this.room.joined;
  137. };
  138. /**
  139. * Leaves the conference.
  140. * @returns {Promise}
  141. */
  142. JitsiConference.prototype.leave = function () {
  143. if (this.participantConnectionStatus) {
  144. this.participantConnectionStatus.dispose();
  145. this.participantConnectionStatus = null;
  146. }
  147. this.getLocalTracks().forEach(track => this.onTrackRemoved(track));
  148. this.rtc.closeAllDataChannels();
  149. if(this.statistics)
  150. this.statistics.dispose();
  151. // leave the conference
  152. if (this.room) {
  153. let room = this.room;
  154. this.room = null;
  155. return room.leave().catch(() => {
  156. // remove all participants because currently the conference won't
  157. // be usable anyway. This is done on success automatically by the
  158. // ChatRoom instance.
  159. this.getParticipants().forEach(
  160. participant => this.onMemberLeft(participant.getJid()));
  161. });
  162. }
  163. // If this.room == null we are calling second time leave().
  164. return Promise.reject(
  165. new Error("The conference is has been already left"));
  166. };
  167. /**
  168. * Returns name of this conference.
  169. */
  170. JitsiConference.prototype.getName = function () {
  171. return this.options.name;
  172. };
  173. /**
  174. * Check if authentication is enabled for this conference.
  175. */
  176. JitsiConference.prototype.isAuthEnabled = function () {
  177. return this.authEnabled;
  178. };
  179. /**
  180. * Check if user is logged in.
  181. */
  182. JitsiConference.prototype.isLoggedIn = function () {
  183. return !!this.authIdentity;
  184. };
  185. /**
  186. * Get authorized login.
  187. */
  188. JitsiConference.prototype.getAuthLogin = function () {
  189. return this.authIdentity;
  190. };
  191. /**
  192. * Check if external authentication is enabled for this conference.
  193. */
  194. JitsiConference.prototype.isExternalAuthEnabled = function () {
  195. return this.room && this.room.moderator.isExternalAuthEnabled();
  196. };
  197. /**
  198. * Get url for external authentication.
  199. * @param {boolean} [urlForPopup] if true then return url for login popup,
  200. * else url of login page.
  201. * @returns {Promise}
  202. */
  203. JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
  204. return new Promise(function (resolve, reject) {
  205. if (!this.isExternalAuthEnabled()) {
  206. reject();
  207. return;
  208. }
  209. if (urlForPopup) {
  210. this.room.moderator.getPopupLoginUrl(resolve, reject);
  211. } else {
  212. this.room.moderator.getLoginUrl(resolve, reject);
  213. }
  214. }.bind(this));
  215. };
  216. /**
  217. * Returns the local tracks of the given media type, or all local tracks if no
  218. * specific type is given.
  219. * @param mediaType {MediaType} Optional media type (audio or video).
  220. */
  221. JitsiConference.prototype.getLocalTracks = function (mediaType) {
  222. let tracks = [];
  223. if (this.rtc) {
  224. tracks = this.rtc.localTracks.slice();
  225. }
  226. if (mediaType !== undefined) {
  227. tracks = tracks.filter(
  228. (track) => {
  229. return track && track.getType && track.getType() === mediaType;
  230. });
  231. }
  232. return tracks;
  233. };
  234. /**
  235. * Attaches a handler for events(For example - "participant joined".) in the conference. All possible event are defined
  236. * in JitsiConferenceEvents.
  237. * @param eventId the event ID.
  238. * @param handler handler for the event.
  239. *
  240. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  241. */
  242. JitsiConference.prototype.on = function (eventId, handler) {
  243. if(this.eventEmitter)
  244. this.eventEmitter.on(eventId, handler);
  245. };
  246. /**
  247. * Removes event listener
  248. * @param eventId the event ID.
  249. * @param [handler] optional, the specific handler to unbind
  250. *
  251. * Note: consider adding eventing functionality by extending an EventEmitter impl, instead of rolling ourselves
  252. */
  253. JitsiConference.prototype.off = function (eventId, handler) {
  254. if(this.eventEmitter)
  255. this.eventEmitter.removeListener(eventId, handler);
  256. };
  257. // Common aliases for event emitter
  258. JitsiConference.prototype.addEventListener = JitsiConference.prototype.on;
  259. JitsiConference.prototype.removeEventListener = JitsiConference.prototype.off;
  260. /**
  261. * Receives notifications from other participants about commands / custom events
  262. * (sent by sendCommand or sendCommandOnce methods).
  263. * @param command {String} the name of the command
  264. * @param handler {Function} handler for the command
  265. */
  266. JitsiConference.prototype.addCommandListener = function (command, handler) {
  267. if(this.room)
  268. this.room.addPresenceListener(command, handler);
  269. };
  270. /**
  271. * Removes command listener
  272. * @param command {String} the name of the command
  273. */
  274. JitsiConference.prototype.removeCommandListener = function (command) {
  275. if(this.room)
  276. this.room.removePresenceListener(command);
  277. };
  278. /**
  279. * Sends text message to the other participants in the conference
  280. * @param message the text message.
  281. */
  282. JitsiConference.prototype.sendTextMessage = function (message) {
  283. if(this.room)
  284. this.room.sendMessage(message);
  285. };
  286. /**
  287. * Send presence command.
  288. * @param name {String} the name of the command.
  289. * @param values {Object} with keys and values that will be sent.
  290. **/
  291. JitsiConference.prototype.sendCommand = function (name, values) {
  292. if(this.room) {
  293. this.room.addToPresence(name, values);
  294. this.room.sendPresence();
  295. }
  296. };
  297. /**
  298. * Send presence command one time.
  299. * @param name {String} the name of the command.
  300. * @param values {Object} with keys and values that will be sent.
  301. **/
  302. JitsiConference.prototype.sendCommandOnce = function (name, values) {
  303. this.sendCommand(name, values);
  304. this.removeCommand(name);
  305. };
  306. /**
  307. * Removes presence command.
  308. * @param name {String} the name of the command.
  309. **/
  310. JitsiConference.prototype.removeCommand = function (name) {
  311. if(this.room)
  312. this.room.removeFromPresence(name);
  313. };
  314. /**
  315. * Sets the display name for this conference.
  316. * @param name the display name to set
  317. */
  318. JitsiConference.prototype.setDisplayName = function(name) {
  319. if(this.room){
  320. // remove previously set nickname
  321. this.room.removeFromPresence("nick");
  322. this.room.addToPresence("nick", {attributes: {xmlns: 'http://jabber.org/protocol/nick'}, value: name});
  323. this.room.sendPresence();
  324. }
  325. };
  326. /**
  327. * Set new subject for this conference. (available only for moderator)
  328. * @param {string} subject new subject
  329. */
  330. JitsiConference.prototype.setSubject = function (subject) {
  331. if (this.room && this.isModerator()) {
  332. this.room.setSubject(subject);
  333. }
  334. };
  335. /**
  336. * Get a transcriber object for all current participants in this conference
  337. * @return {Transcriber} the transcriber object
  338. */
  339. JitsiConference.prototype.getTranscriber = function(){
  340. if(this.transcriber === undefined){
  341. this.transcriber = new Transcriber();
  342. //add all existing local audio tracks to the transcriber
  343. this.rtc.localTracks.forEach(function (localTrack) {
  344. if(localTrack.isAudioTrack()){
  345. this.transcriber.addTrack(localTrack);
  346. }
  347. }.bind(this));
  348. //and all remote audio tracks
  349. this.rtc.remoteTracks.forEach(function (remoteTrack){
  350. if(remoteTrack.isAudioTrack()){
  351. this.transcriber.addTrack(remoteTrack);
  352. }
  353. }.bind(this));
  354. }
  355. return this.transcriber;
  356. };
  357. /**
  358. * Adds JitsiLocalTrack object to the conference.
  359. * @param track the JitsiLocalTrack object.
  360. * @returns {Promise<JitsiLocalTrack>}
  361. * @throws {Error} if the specified track is a video track and there is already
  362. * another video track in the conference.
  363. */
  364. JitsiConference.prototype.addTrack = function (track) {
  365. if (track.disposed) {
  366. return Promise.reject(
  367. new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
  368. }
  369. if (track.isVideoTrack()) {
  370. // Ensure there's exactly 1 local video track in the conference.
  371. var localVideoTrack = this.rtc.getLocalVideoTrack();
  372. if (localVideoTrack) {
  373. // Don't be excessively harsh and severe if the API client happens
  374. // to attempt to add the same local video track twice.
  375. if (track === localVideoTrack) {
  376. return Promise.resolve(track);
  377. } else {
  378. return Promise.reject(new Error(
  379. "cannot add second video track to the conference"));
  380. }
  381. }
  382. }
  383. track.ssrcHandler = function (conference, ssrcMap) {
  384. if(ssrcMap[this.getMSID()]){
  385. this._setSSRC(ssrcMap[this.getMSID()]);
  386. conference.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  387. this.ssrcHandler);
  388. }
  389. }.bind(track, this);
  390. this.room.addListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  391. track.ssrcHandler);
  392. if(track.isAudioTrack() || (track.isVideoTrack() &&
  393. track.videoType !== VideoType.DESKTOP)) {
  394. // Report active device to statistics
  395. var devices = RTC.getCurrentlyAvailableMediaDevices();
  396. var device = devices.find(function (d) {
  397. return d.kind === track.getTrack().kind + 'input'
  398. && d.label === track.getTrack().label;
  399. });
  400. if(device)
  401. Statistics.sendActiveDeviceListEvent(
  402. RTC.getEventDataForActiveDevice(device));
  403. }
  404. return new Promise(function (resolve, reject) {
  405. this.room.addStream(track.getOriginalStream(), function () {
  406. if (track.isVideoTrack()) {
  407. this.removeCommand("videoType");
  408. this.sendCommand("videoType", {
  409. value: track.videoType,
  410. attributes: {
  411. xmlns: 'http://jitsi.org/jitmeet/video'
  412. }
  413. });
  414. }
  415. this.rtc.addLocalTrack(track);
  416. if (track.startMuted) {
  417. track.mute();
  418. }
  419. // ensure that we're sharing proper "is muted" state
  420. if (track.isAudioTrack()) {
  421. this.room.setAudioMute(track.isMuted());
  422. } else {
  423. this.room.setVideoMute(track.isMuted());
  424. }
  425. track.muteHandler = this._fireMuteChangeEvent.bind(this, track);
  426. track.audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
  427. track.addEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  428. track.muteHandler);
  429. track.addEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  430. track.audioLevelHandler);
  431. track._setConference(this);
  432. // send event for starting screen sharing
  433. // FIXME: we assume we have only one screen sharing track
  434. // if we change this we need to fix this check
  435. if (track.isVideoTrack() && track.videoType === VideoType.DESKTOP)
  436. this.statistics.sendScreenSharingEvent(true);
  437. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  438. resolve(track);
  439. }.bind(this), function (error) {
  440. reject(error);
  441. });
  442. }.bind(this));
  443. };
  444. /**
  445. * Fires TRACK_AUDIO_LEVEL_CHANGED change conference event.
  446. * @param audioLevel the audio level
  447. */
  448. JitsiConference.prototype._fireAudioLevelChangeEvent = function (audioLevel) {
  449. this.eventEmitter.emit(
  450. JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
  451. this.myUserId(), audioLevel);
  452. };
  453. /**
  454. * Fires TRACK_MUTE_CHANGED change conference event.
  455. * @param track the JitsiTrack object related to the event.
  456. */
  457. JitsiConference.prototype._fireMuteChangeEvent = function (track) {
  458. // check if track was muted by focus and now is unmuted by user
  459. if (this.isMutedByFocus && track.isAudioTrack() && !track.isMuted()) {
  460. this.isMutedByFocus = false;
  461. // unmute local user on server
  462. this.room.muteParticipant(this.room.myroomjid, false);
  463. }
  464. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  465. };
  466. /**
  467. * Clear JitsiLocalTrack properties and listeners.
  468. * @param track the JitsiLocalTrack object.
  469. */
  470. JitsiConference.prototype.onTrackRemoved = function (track) {
  471. track._setSSRC(null);
  472. track._setConference(null);
  473. this.rtc.removeLocalTrack(track);
  474. track.removeEventListener(JitsiTrackEvents.TRACK_MUTE_CHANGED,
  475. track.muteHandler);
  476. track.removeEventListener(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  477. track.audioLevelHandler);
  478. this.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
  479. track.ssrcHandler);
  480. // send event for stopping screen sharing
  481. // FIXME: we assume we have only one screen sharing track
  482. // if we change this we need to fix this check
  483. if (track.isVideoTrack() && track.videoType === VideoType.DESKTOP)
  484. this.statistics.sendScreenSharingEvent(false);
  485. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  486. };
  487. /**
  488. * Removes JitsiLocalTrack object to the conference.
  489. * @param track the JitsiLocalTrack object.
  490. * @returns {Promise}
  491. */
  492. JitsiConference.prototype.removeTrack = function (track) {
  493. if (track.disposed) {
  494. return Promise.reject(
  495. new JitsiTrackError(JitsiTrackErrors.TRACK_IS_DISPOSED));
  496. }
  497. if(!this.room){
  498. if(this.rtc) {
  499. this.onTrackRemoved(track);
  500. }
  501. return Promise.resolve();
  502. }
  503. return new Promise(function (resolve, reject) {
  504. this.room.removeStream(track.getOriginalStream(), function(){
  505. this.onTrackRemoved(track);
  506. resolve();
  507. }.bind(this), function (error) {
  508. reject(error);
  509. }, {
  510. mtype: track.getType(),
  511. type: "remove",
  512. ssrc: track.ssrc});
  513. }.bind(this));
  514. };
  515. /**
  516. * Get role of the local user.
  517. * @returns {string} user role: 'moderator' or 'none'
  518. */
  519. JitsiConference.prototype.getRole = function () {
  520. return this.room.role;
  521. };
  522. /**
  523. * Check if local user is moderator.
  524. * @returns {boolean|null} true if local user is moderator, false otherwise. If
  525. * we're no longer in the conference room then <tt>null</tt> is returned.
  526. */
  527. JitsiConference.prototype.isModerator = function () {
  528. return this.room ? this.room.isModerator() : null;
  529. };
  530. /**
  531. * Set password for the room.
  532. * @param {string} password new password for the room.
  533. * @returns {Promise}
  534. */
  535. JitsiConference.prototype.lock = function (password) {
  536. if (!this.isModerator()) {
  537. return Promise.reject();
  538. }
  539. var conference = this;
  540. return new Promise(function (resolve, reject) {
  541. conference.room.lockRoom(password || "", function () {
  542. resolve();
  543. }, function (err) {
  544. reject(err);
  545. }, function () {
  546. reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
  547. });
  548. });
  549. };
  550. /**
  551. * Remove password from the room.
  552. * @returns {Promise}
  553. */
  554. JitsiConference.prototype.unlock = function () {
  555. return this.lock();
  556. };
  557. /**
  558. * Elects the participant with the given id to be the selected participant in
  559. * order to receive higher video quality (if simulcast is enabled).
  560. * Or cache it if channel is not created and send it once channel is available.
  561. * @param participantId the identifier of the participant
  562. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  563. */
  564. JitsiConference.prototype.selectParticipant = function(participantId) {
  565. this.rtc.selectEndpoint(participantId);
  566. };
  567. /**
  568. * Elects the participant with the given id to be the pinned participant in
  569. * order to always receive video for this participant (even when last n is
  570. * enabled).
  571. * @param participantId the identifier of the participant
  572. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  573. */
  574. JitsiConference.prototype.pinParticipant = function(participantId) {
  575. this.rtc.pinEndpoint(participantId);
  576. };
  577. /**
  578. * @return Array<JitsiParticipant> an array of all participants in this
  579. * conference.
  580. */
  581. JitsiConference.prototype.getParticipants = function() {
  582. return Object.keys(this.participants).map(function (key) {
  583. return this.participants[key];
  584. }, this);
  585. };
  586. /**
  587. * Returns the number of participants in the conference, including the local
  588. * participant.
  589. * @param countHidden {boolean} Whether or not to include hidden participants
  590. * in the count. Default: false.
  591. **/
  592. JitsiConference.prototype.getParticipantCount
  593. = function(countHidden = false) {
  594. let participants = this.getParticipants();
  595. if (!countHidden) {
  596. participants = participants.filter(p => !p.isHidden());
  597. }
  598. // Add one for the local participant.
  599. return participants.length + 1;
  600. };
  601. /**
  602. * @returns {JitsiParticipant} the participant in this conference with the
  603. * specified id (or undefined if there isn't one).
  604. * @param id the id of the participant.
  605. */
  606. JitsiConference.prototype.getParticipantById = function(id) {
  607. return this.participants[id];
  608. };
  609. /**
  610. * Kick participant from this conference.
  611. * @param {string} id id of the participant to kick
  612. */
  613. JitsiConference.prototype.kickParticipant = function (id) {
  614. var participant = this.getParticipantById(id);
  615. if (!participant) {
  616. return;
  617. }
  618. this.room.kick(participant.getJid());
  619. };
  620. /**
  621. * Mutes a participant.
  622. * @param {string} id The id of the participant to mute.
  623. */
  624. JitsiConference.prototype.muteParticipant = function (id) {
  625. var participant = this.getParticipantById(id);
  626. if (!participant) {
  627. return;
  628. }
  629. this.room.muteParticipant(participant.getJid(), true);
  630. };
  631. /**
  632. * Notifies this JitsiConference that a new member has joined its chat room.
  633. *
  634. * FIXME This should NOT be exposed!
  635. *
  636. * @param jid the jid of the participant in the MUC
  637. * @param nick the display name of the participant
  638. * @param role the role of the participant in the MUC
  639. * @param isHidden indicates if this is a hidden participant (system
  640. * participant for example a recorder).
  641. */
  642. JitsiConference.prototype.onMemberJoined
  643. = function (jid, nick, role, isHidden) {
  644. var id = Strophe.getResourceFromJid(jid);
  645. if (id === 'focus' || this.myUserId() === id) {
  646. return;
  647. }
  648. var participant = new JitsiParticipant(jid, this, nick, isHidden);
  649. participant._role = role;
  650. this.participants[id] = participant;
  651. this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
  652. // XXX Since disco is checked in multiple places (e.g.
  653. // modules/xmpp/strophe.jingle.js, modules/xmpp/strophe.rayo.js), check it
  654. // here as well.
  655. var disco = this.xmpp.connection.disco;
  656. if (disco) {
  657. disco.info(
  658. jid, "node", function(iq) {
  659. participant._supportsDTMF = $(iq).find(
  660. '>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
  661. this.updateDTMFSupport();
  662. }.bind(this)
  663. );
  664. } else {
  665. // FIXME Should participant._supportsDTMF be assigned false here (and
  666. // this.updateDTMFSupport invoked)?
  667. }
  668. };
  669. JitsiConference.prototype.onMemberLeft = function (jid) {
  670. var id = Strophe.getResourceFromJid(jid);
  671. if (id === 'focus' || this.myUserId() === id) {
  672. return;
  673. }
  674. var participant = this.participants[id];
  675. delete this.participants[id];
  676. var removedTracks = this.rtc.removeRemoteTracks(id);
  677. removedTracks.forEach(function (track) {
  678. this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
  679. }.bind(this));
  680. // there can be no participant in case the member that left is focus
  681. if (participant)
  682. this.eventEmitter.emit(
  683. JitsiConferenceEvents.USER_LEFT, id, participant);
  684. };
  685. JitsiConference.prototype.onUserRoleChanged = function (jid, role) {
  686. var id = Strophe.getResourceFromJid(jid);
  687. var participant = this.getParticipantById(id);
  688. if (!participant) {
  689. return;
  690. }
  691. participant._role = role;
  692. this.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED, id, role);
  693. };
  694. JitsiConference.prototype.onDisplayNameChanged = function (jid, displayName) {
  695. var id = Strophe.getResourceFromJid(jid);
  696. var participant = this.getParticipantById(id);
  697. if (!participant) {
  698. return;
  699. }
  700. if (participant._displayName === displayName)
  701. return;
  702. participant._displayName = displayName;
  703. this.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED, id, displayName);
  704. };
  705. /**
  706. * Notifies this JitsiConference that a JitsiRemoteTrack was added (into the
  707. * ChatRoom of this JitsiConference).
  708. *
  709. * @param {JitsiRemoteTrack} track the JitsiRemoteTrack which was added to this
  710. * JitsiConference
  711. */
  712. JitsiConference.prototype.onTrackAdded = function (track) {
  713. var id = track.getParticipantId();
  714. var participant = this.getParticipantById(id);
  715. if (!participant) {
  716. return;
  717. }
  718. // Add track to JitsiParticipant.
  719. participant._tracks.push(track);
  720. if(this.transcriber){
  721. this.transcriber.addTrack(track);
  722. }
  723. var emitter = this.eventEmitter;
  724. track.addEventListener(
  725. JitsiTrackEvents.TRACK_MUTE_CHANGED,
  726. function () {
  727. emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
  728. }
  729. );
  730. track.addEventListener(
  731. JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
  732. function (audioLevel) {
  733. emitter.emit(
  734. JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
  735. id,
  736. audioLevel);
  737. }
  738. );
  739. emitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
  740. };
  741. /**
  742. * Handles incoming call event.
  743. */
  744. JitsiConference.prototype.onIncomingCall =
  745. function (jingleSession, jingleOffer, now) {
  746. if (!this.room.isFocus(jingleSession.peerjid)) {
  747. // Error cause this should never happen unless something is wrong!
  748. var errmsg = "Rejecting session-initiate from non-focus user: "
  749. + jingleSession.peerjid;
  750. GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
  751. logger.error(errmsg);
  752. // Terminate the jingle session with a reason
  753. jingleSession.terminate(
  754. 'security-error', 'Only focus can start new sessions',
  755. null /* success callback => we don't care */,
  756. function (error) {
  757. logger.warn(
  758. "An error occurred while trying to terminate"
  759. + " invalid Jingle session", error);
  760. });
  761. return;
  762. }
  763. // Accept incoming call
  764. this.room.setJingleSession(jingleSession);
  765. this.room.connectionTimes["session.initiate"] = now;
  766. // Log "session.restart"
  767. if (this.wasStopped) {
  768. Statistics.sendEventToAll("session.restart");
  769. }
  770. // add info whether call is cross-region
  771. var crossRegion = null;
  772. if (window.jitsiRegionInfo) {
  773. crossRegion = window.jitsiRegionInfo["CrossRegion"];
  774. }
  775. Statistics.analytics.sendEvent(
  776. "session.initiate", {
  777. value: now - this.room.connectionTimes["muc.joined"],
  778. label: crossRegion
  779. });
  780. try {
  781. jingleSession.initialize(false /* initiator */,this.room);
  782. } catch (error) {
  783. GlobalOnErrorHandler.callErrorHandler(error);
  784. }
  785. this.rtc.onIncommingCall(jingleSession);
  786. // Add local Tracks to the ChatRoom
  787. this.rtc.localTracks.forEach(function(localTrack) {
  788. var ssrcInfo = null;
  789. if(localTrack.isVideoTrack() && localTrack.isMuted()) {
  790. /**
  791. * Handles issues when the stream is added before the peerconnection
  792. * is created. The peerconnection is created when second participant
  793. * enters the call. In that use case the track doesn't have
  794. * information about it's ssrcs and no jingle packets are sent. That
  795. * can cause inconsistent behavior later.
  796. *
  797. * For example:
  798. * If we mute the stream and than second participant enter it's
  799. * remote SDP won't include that track. On unmute we are not sending
  800. * any jingle packets which will brake the unmute.
  801. *
  802. * In order to solve issues like the above one here we have to
  803. * generate the ssrc information for the track .
  804. */
  805. localTrack._setSSRC(
  806. this.room.generateNewStreamSSRCInfo());
  807. ssrcInfo = {
  808. mtype: localTrack.getType(),
  809. type: "addMuted",
  810. ssrc: localTrack.ssrc,
  811. msid: localTrack.initialMSID
  812. };
  813. }
  814. try {
  815. this.room.addStream(
  816. localTrack.getOriginalStream(), function () {}, function () {},
  817. ssrcInfo, true);
  818. } catch(e) {
  819. GlobalOnErrorHandler.callErrorHandler(e);
  820. logger.error(e);
  821. }
  822. }.bind(this));
  823. jingleSession.acceptOffer(jingleOffer, null,
  824. function (error) {
  825. GlobalOnErrorHandler.callErrorHandler(error);
  826. logger.error(
  827. "Failed to accept incoming Jingle session", error);
  828. }
  829. );
  830. // Start callstats as soon as peerconnection is initialized,
  831. // do not wait for XMPPEvents.PEERCONNECTION_READY, as it may never
  832. // happen in case if user doesn't have or denied permission to
  833. // both camera and microphone.
  834. this.statistics.startCallStats(jingleSession);
  835. this.statistics.startRemoteStats(jingleSession.peerconnection);
  836. };
  837. /**
  838. * Handles the call ended event.
  839. * @param {JingleSessionPC} JingleSession the jingle session which has been
  840. * terminated.
  841. * @param {String} reasonCondition the Jingle reason condition.
  842. * @param {String|null} reasonText human readable reason text which may provide
  843. * more details about why the call has been terminated.
  844. */
  845. JitsiConference.prototype.onCallEnded
  846. = function (JingleSession, reasonCondition, reasonText) {
  847. logger.info("Call ended: " + reasonCondition + " - " + reasonText);
  848. this.wasStopped = true;
  849. // Send session.terminate event
  850. Statistics.sendEventToAll("session.terminate");
  851. // Stop the stats
  852. if (this.statistics) {
  853. this.statistics.stopRemoteStats();
  854. this.statistics.stopCallStats();
  855. }
  856. // Current JingleSession is invalid so set it to null on the room
  857. this.room.setJingleSession(null);
  858. // Let the RTC service do any cleanups
  859. this.rtc.onCallEnded();
  860. // PeerConnection has been closed which means that SSRCs stored in
  861. // JitsiLocalTrack will not match those assigned by the old PeerConnection
  862. // and SSRC replacement logic will not work as expected.
  863. // We want to re-register 'ssrcHandler' of our local tracks, so that they
  864. // will learn what their SSRC from the new PeerConnection which will be
  865. // created on incoming call event.
  866. var self = this;
  867. this.rtc.localTracks.forEach(function(localTrack) {
  868. // Reset SSRC as it will no longer be valid
  869. localTrack._setSSRC(null);
  870. // Bind the handler to fetch new SSRC, it will un register itself once
  871. // it reads the values
  872. self.room.addListener(
  873. XMPPEvents.SENDRECV_STREAMS_CHANGED, localTrack.ssrcHandler);
  874. });
  875. };
  876. /**
  877. * Handles the suspend detected event. Leaves the room and fires suspended.
  878. */
  879. JitsiConference.prototype.onSuspendDetected = function () {
  880. this.leave();
  881. this.eventEmitter.emit(JitsiConferenceEvents.SUSPEND_DETECTED);
  882. };
  883. JitsiConference.prototype.updateDTMFSupport = function () {
  884. var somebodySupportsDTMF = false;
  885. var participants = this.getParticipants();
  886. // check if at least 1 participant supports DTMF
  887. for (var i = 0; i < participants.length; i += 1) {
  888. if (participants[i].supportsDTMF()) {
  889. somebodySupportsDTMF = true;
  890. break;
  891. }
  892. }
  893. if (somebodySupportsDTMF !== this.somebodySupportsDTMF) {
  894. this.somebodySupportsDTMF = somebodySupportsDTMF;
  895. this.eventEmitter.emit(JitsiConferenceEvents.DTMF_SUPPORT_CHANGED, somebodySupportsDTMF);
  896. }
  897. };
  898. /**
  899. * Allows to check if there is at least one user in the conference
  900. * that supports DTMF.
  901. * @returns {boolean} true if somebody supports DTMF, false otherwise
  902. */
  903. JitsiConference.prototype.isDTMFSupported = function () {
  904. return this.somebodySupportsDTMF;
  905. };
  906. /**
  907. * Returns the local user's ID
  908. * @return {string} local user's ID
  909. */
  910. JitsiConference.prototype.myUserId = function () {
  911. return (this.room && this.room.myroomjid)? Strophe.getResourceFromJid(this.room.myroomjid) : null;
  912. };
  913. JitsiConference.prototype.sendTones = function (tones, duration, pause) {
  914. if (!this.dtmfManager) {
  915. var connection = this.xmpp.connection.jingle.activecall.peerconnection;
  916. if (!connection) {
  917. logger.warn("cannot sendTones: no conneciton");
  918. return;
  919. }
  920. var tracks = this.getLocalTracks().filter(function (track) {
  921. return track.isAudioTrack();
  922. });
  923. if (!tracks.length) {
  924. logger.warn("cannot sendTones: no local audio stream");
  925. return;
  926. }
  927. this.dtmfManager = new JitsiDTMFManager(tracks[0], connection);
  928. }
  929. this.dtmfManager.sendTones(tones, duration, pause);
  930. };
  931. /**
  932. * Returns true if recording is supported and false if not.
  933. */
  934. JitsiConference.prototype.isRecordingSupported = function () {
  935. if(this.room)
  936. return this.room.isRecordingSupported();
  937. return false;
  938. };
  939. /**
  940. * Returns null if the recording is not supported, "on" if the recording started
  941. * and "off" if the recording is not started.
  942. */
  943. JitsiConference.prototype.getRecordingState = function () {
  944. return (this.room) ? this.room.getRecordingState() : undefined;
  945. };
  946. /**
  947. * Returns the url of the recorded video.
  948. */
  949. JitsiConference.prototype.getRecordingURL = function () {
  950. return (this.room) ? this.room.getRecordingURL() : null;
  951. };
  952. /**
  953. * Starts/stops the recording
  954. */
  955. JitsiConference.prototype.toggleRecording = function (options) {
  956. if(this.room)
  957. return this.room.toggleRecording(options, function (status, error) {
  958. this.eventEmitter.emit(
  959. JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
  960. }.bind(this));
  961. this.eventEmitter.emit(
  962. JitsiConferenceEvents.RECORDER_STATE_CHANGED, "error",
  963. new Error("The conference is not created yet!"));
  964. };
  965. /**
  966. * Returns true if the SIP calls are supported and false otherwise
  967. */
  968. JitsiConference.prototype.isSIPCallingSupported = function () {
  969. if(this.room)
  970. return this.room.isSIPCallingSupported();
  971. return false;
  972. };
  973. /**
  974. * Dials a number.
  975. * @param number the number
  976. */
  977. JitsiConference.prototype.dial = function (number) {
  978. if(this.room)
  979. return this.room.dial(number);
  980. return new Promise(function(resolve, reject){
  981. reject(new Error("The conference is not created yet!"));});
  982. };
  983. /**
  984. * Hangup an existing call
  985. */
  986. JitsiConference.prototype.hangup = function () {
  987. if(this.room)
  988. return this.room.hangup();
  989. return new Promise(function(resolve, reject){
  990. reject(new Error("The conference is not created yet!"));});
  991. };
  992. /**
  993. * Returns the phone number for joining the conference.
  994. */
  995. JitsiConference.prototype.getPhoneNumber = function () {
  996. if(this.room)
  997. return this.room.getPhoneNumber();
  998. return null;
  999. };
  1000. /**
  1001. * Returns the pin for joining the conference with phone.
  1002. */
  1003. JitsiConference.prototype.getPhonePin = function () {
  1004. if(this.room)
  1005. return this.room.getPhonePin();
  1006. return null;
  1007. };
  1008. /**
  1009. * Returns the connection state for the current room. Its ice connection state
  1010. * for its session.
  1011. */
  1012. JitsiConference.prototype.getConnectionState = function () {
  1013. if(this.room)
  1014. return this.room.getConnectionState();
  1015. return null;
  1016. };
  1017. /**
  1018. * Make all new participants mute their audio/video on join.
  1019. * @param policy {Object} object with 2 boolean properties for video and audio:
  1020. * @param {boolean} audio if audio should be muted.
  1021. * @param {boolean} video if video should be muted.
  1022. */
  1023. JitsiConference.prototype.setStartMutedPolicy = function (policy) {
  1024. if (!this.isModerator()) {
  1025. return;
  1026. }
  1027. this.startMutedPolicy = policy;
  1028. this.room.removeFromPresence("startmuted");
  1029. this.room.addToPresence("startmuted", {
  1030. attributes: {
  1031. audio: policy.audio,
  1032. video: policy.video,
  1033. xmlns: 'http://jitsi.org/jitmeet/start-muted'
  1034. }
  1035. });
  1036. this.room.sendPresence();
  1037. };
  1038. /**
  1039. * Returns current start muted policy
  1040. * @returns {Object} with 2 properties - audio and video.
  1041. */
  1042. JitsiConference.prototype.getStartMutedPolicy = function () {
  1043. return this.startMutedPolicy;
  1044. };
  1045. /**
  1046. * Check if audio is muted on join.
  1047. */
  1048. JitsiConference.prototype.isStartAudioMuted = function () {
  1049. return this.startAudioMuted;
  1050. };
  1051. /**
  1052. * Check if video is muted on join.
  1053. */
  1054. JitsiConference.prototype.isStartVideoMuted = function () {
  1055. return this.startVideoMuted;
  1056. };
  1057. /**
  1058. * Get object with internal logs.
  1059. */
  1060. JitsiConference.prototype.getLogs = function () {
  1061. var data = this.xmpp.getJingleLog();
  1062. var metadata = {};
  1063. metadata.time = new Date();
  1064. metadata.url = window.location.href;
  1065. metadata.ua = navigator.userAgent;
  1066. var log = this.xmpp.getXmppLog();
  1067. if (log) {
  1068. metadata.xmpp = log;
  1069. }
  1070. data.metadata = metadata;
  1071. return data;
  1072. };
  1073. /**
  1074. * Returns measured connectionTimes.
  1075. */
  1076. JitsiConference.prototype.getConnectionTimes = function () {
  1077. return this.room.connectionTimes;
  1078. };
  1079. /**
  1080. * Sets a property for the local participant.
  1081. */
  1082. JitsiConference.prototype.setLocalParticipantProperty = function(name, value) {
  1083. this.sendCommand("jitsi_participant_" + name, {value: value});
  1084. };
  1085. /**
  1086. * Sends the given feedback through CallStats if enabled.
  1087. *
  1088. * @param overallFeedback an integer between 1 and 5 indicating the
  1089. * user feedback
  1090. * @param detailedFeedback detailed feedback from the user. Not yet used
  1091. */
  1092. JitsiConference.prototype.sendFeedback =
  1093. function(overallFeedback, detailedFeedback){
  1094. this.statistics.sendFeedback(overallFeedback, detailedFeedback);
  1095. };
  1096. /**
  1097. * Returns true if the callstats integration is enabled, otherwise returns
  1098. * false.
  1099. *
  1100. * @returns true if the callstats integration is enabled, otherwise returns
  1101. * false.
  1102. */
  1103. JitsiConference.prototype.isCallstatsEnabled = function () {
  1104. return this.statistics.isCallstatsEnabled();
  1105. };
  1106. /**
  1107. * Handles track attached to container (Calls associateStreamWithVideoTag method
  1108. * from statistics module)
  1109. * @param track the track
  1110. * @param container the container
  1111. */
  1112. JitsiConference.prototype._onTrackAttach = function(track, container) {
  1113. var ssrc = track.getSSRC();
  1114. if (!container.id || !ssrc) {
  1115. return;
  1116. }
  1117. this.statistics.associateStreamWithVideoTag(
  1118. ssrc, track.isLocal(), track.getUsageLabel(), container.id);
  1119. };
  1120. /**
  1121. * Logs an "application log" message.
  1122. * @param message {string} The message to log. Note that while this can be a
  1123. * generic string, the convention used by lib-jitsi-meet and jitsi-meet is to
  1124. * log valid JSON strings, with an "id" field used for distinguishing between
  1125. * message types. E.g.: {id: "recorder_status", status: "off"}
  1126. */
  1127. JitsiConference.prototype.sendApplicationLog = function(message) {
  1128. Statistics.sendLog(message);
  1129. };
  1130. /**
  1131. * Checks if the user identified by given <tt>mucJid</tt> is the conference
  1132. * focus.
  1133. * @param mucJid the full MUC address of the user to be checked.
  1134. * @returns {boolean|null} <tt>true</tt> if MUC user is the conference focus,
  1135. * <tt>false</tt> when is not. <tt>null</tt> if we're not in the MUC anymore and
  1136. * are unable to figure out the status or if given <tt>mucJid</tt> is invalid.
  1137. */
  1138. JitsiConference.prototype._isFocus = function (mucJid) {
  1139. return this.room ? this.room.isFocus(mucJid) : null;
  1140. };
  1141. /**
  1142. * Fires CONFERENCE_FAILED event with INCOMPATIBLE_SERVER_VERSIONS parameter
  1143. */
  1144. JitsiConference.prototype._fireIncompatibleVersionsEvent = function () {
  1145. this.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED,
  1146. JitsiConferenceErrors.INCOMPATIBLE_SERVER_VERSIONS);
  1147. };
  1148. /**
  1149. * Sends a message via the data channel.
  1150. * @param to {string} the id of the endpoint that should receive the message.
  1151. * If "" the message will be sent to all participants.
  1152. * @param payload {object} the payload of the message.
  1153. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  1154. */
  1155. JitsiConference.prototype.sendEndpointMessage = function (to, payload) {
  1156. this.rtc.sendDataChannelMessage(to, payload);
  1157. };
  1158. /**
  1159. * Sends a broadcast message via the data channel.
  1160. * @param payload {object} the payload of the message.
  1161. * @throws NetworkError or InvalidStateError or Error if the operation fails.
  1162. */
  1163. JitsiConference.prototype.broadcastEndpointMessage = function (payload) {
  1164. this.sendEndpointMessage("", payload);
  1165. };
  1166. JitsiConference.prototype.isConnectionInterrupted = function () {
  1167. return this.connectionIsInterrupted;
  1168. };
  1169. module.exports = JitsiConference;