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

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