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.

API.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. // @flow
  2. import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
  3. import {
  4. createApiEvent,
  5. sendAnalytics
  6. } from '../../react/features/analytics';
  7. import {
  8. sendTones,
  9. setPassword,
  10. setSubject
  11. } from '../../react/features/base/conference';
  12. import { parseJWTFromURLParams } from '../../react/features/base/jwt';
  13. import { setE2EEKey } from '../../react/features/e2ee';
  14. import { invite } from '../../react/features/invite';
  15. import { toggleTileView } from '../../react/features/video-layout';
  16. import { setVideoQuality } from '../../react/features/video-quality';
  17. import { getJitsiMeetTransport } from '../transport';
  18. import { API_ID, ENDPOINT_TEXT_MESSAGE_NAME } from './constants';
  19. import {
  20. processExternalDeviceRequest
  21. } from '../../react/features/device-selection/functions';
  22. const logger = require('jitsi-meet-logger').getLogger(__filename);
  23. declare var APP: Object;
  24. /**
  25. * List of the available commands.
  26. */
  27. let commands = {};
  28. /**
  29. * The state of screen sharing(started/stopped) before the screen sharing is
  30. * enabled and initialized.
  31. * NOTE: This flag help us to cache the state and use it if toggle-share-screen
  32. * was received before the initialization.
  33. */
  34. let initialScreenSharingState = false;
  35. /**
  36. * The transport instance used for communication with external apps.
  37. *
  38. * @type {Transport}
  39. */
  40. const transport = getJitsiMeetTransport();
  41. /**
  42. * The current audio availability.
  43. *
  44. * @type {boolean}
  45. */
  46. let audioAvailable = true;
  47. /**
  48. * The current video availability.
  49. *
  50. * @type {boolean}
  51. */
  52. let videoAvailable = true;
  53. /**
  54. * Initializes supported commands.
  55. *
  56. * @returns {void}
  57. */
  58. function initCommands() {
  59. commands = {
  60. 'display-name': displayName => {
  61. sendAnalytics(createApiEvent('display.name.changed'));
  62. APP.conference.changeLocalDisplayName(displayName);
  63. },
  64. 'password': password => {
  65. const { conference, passwordRequired }
  66. = APP.store.getState()['features/base/conference'];
  67. if (passwordRequired) {
  68. sendAnalytics(createApiEvent('submit.password'));
  69. APP.store.dispatch(setPassword(
  70. passwordRequired,
  71. passwordRequired.join,
  72. password
  73. ));
  74. } else {
  75. sendAnalytics(createApiEvent('password.changed'));
  76. APP.store.dispatch(setPassword(
  77. conference,
  78. conference.lock,
  79. password
  80. ));
  81. }
  82. },
  83. 'proxy-connection-event': event => {
  84. APP.conference.onProxyConnectionEvent(event);
  85. },
  86. 'send-tones': (options = {}) => {
  87. const { duration, tones, pause } = options;
  88. APP.store.dispatch(sendTones(tones, duration, pause));
  89. },
  90. 'subject': subject => {
  91. sendAnalytics(createApiEvent('subject.changed'));
  92. APP.store.dispatch(setSubject(subject));
  93. },
  94. 'submit-feedback': feedback => {
  95. sendAnalytics(createApiEvent('submit.feedback'));
  96. APP.conference.submitFeedback(feedback.score, feedback.message);
  97. },
  98. 'toggle-audio': () => {
  99. sendAnalytics(createApiEvent('toggle-audio'));
  100. logger.log('Audio toggle: API command received');
  101. APP.conference.toggleAudioMuted(false /* no UI */);
  102. },
  103. 'toggle-video': () => {
  104. sendAnalytics(createApiEvent('toggle-video'));
  105. logger.log('Video toggle: API command received');
  106. APP.conference.toggleVideoMuted(false /* no UI */);
  107. },
  108. 'toggle-film-strip': () => {
  109. sendAnalytics(createApiEvent('film.strip.toggled'));
  110. APP.UI.toggleFilmstrip();
  111. },
  112. 'toggle-chat': () => {
  113. sendAnalytics(createApiEvent('chat.toggled'));
  114. APP.UI.toggleChat();
  115. },
  116. /**
  117. * Callback to invoke when the "toggle-share-screen" command is received.
  118. *
  119. * @param {Object} options - Additional details of how to perform
  120. * the action. Note this parameter is undocumented and experimental.
  121. * @param {boolean} options.enable - Whether trying to enable screen
  122. * sharing or to turn it off.
  123. * @returns {void}
  124. */
  125. 'toggle-share-screen': (options = {}) => {
  126. sendAnalytics(createApiEvent('screen.sharing.toggled'));
  127. toggleScreenSharing(options.enable);
  128. },
  129. 'toggle-tile-view': () => {
  130. sendAnalytics(createApiEvent('tile-view.toggled'));
  131. APP.store.dispatch(toggleTileView());
  132. },
  133. 'video-hangup': (showFeedbackDialog = true) => {
  134. sendAnalytics(createApiEvent('video.hangup'));
  135. APP.conference.hangup(showFeedbackDialog);
  136. },
  137. 'email': email => {
  138. sendAnalytics(createApiEvent('email.changed'));
  139. APP.conference.changeLocalEmail(email);
  140. },
  141. 'avatar-url': avatarUrl => {
  142. sendAnalytics(createApiEvent('avatar.url.changed'));
  143. APP.conference.changeLocalAvatarUrl(avatarUrl);
  144. },
  145. 'send-endpoint-text-message': (to, text) => {
  146. logger.debug('Send endpoint message command received');
  147. try {
  148. APP.conference.sendEndpointMessage(to, {
  149. name: ENDPOINT_TEXT_MESSAGE_NAME,
  150. text
  151. });
  152. } catch (err) {
  153. logger.error('Failed sending endpoint text message', err);
  154. }
  155. },
  156. 'e2ee-key': key => {
  157. logger.debug('Set E2EE key command received');
  158. APP.store.dispatch(setE2EEKey(key));
  159. },
  160. 'set-video-quality': frameHeight => {
  161. logger.debug('Set video quality command received');
  162. sendAnalytics(createApiEvent('set.video.quality'));
  163. APP.store.dispatch(setVideoQuality(frameHeight));
  164. }
  165. };
  166. transport.on('event', ({ data, name }) => {
  167. if (name && commands[name]) {
  168. commands[name](...data);
  169. return true;
  170. }
  171. return false;
  172. });
  173. transport.on('request', (request, callback) => {
  174. const { dispatch, getState } = APP.store;
  175. if (processExternalDeviceRequest(dispatch, getState, request, callback)) {
  176. return true;
  177. }
  178. const { name } = request;
  179. switch (name) {
  180. case 'invite': {
  181. const { invitees } = request;
  182. if (!Array.isArray(invitees) || invitees.length === 0) {
  183. callback({
  184. error: new Error('Unexpected format of invitees')
  185. });
  186. break;
  187. }
  188. // The store should be already available because API.init is called
  189. // on appWillMount action.
  190. APP.store.dispatch(
  191. invite(invitees, true))
  192. .then(failedInvitees => {
  193. let error;
  194. let result;
  195. if (failedInvitees.length) {
  196. error = new Error('One or more invites failed!');
  197. } else {
  198. result = true;
  199. }
  200. callback({
  201. error,
  202. result
  203. });
  204. });
  205. break;
  206. }
  207. case 'is-audio-muted':
  208. callback(APP.conference.isLocalAudioMuted());
  209. break;
  210. case 'is-video-muted':
  211. callback(APP.conference.isLocalVideoMuted());
  212. break;
  213. case 'is-audio-available':
  214. callback(audioAvailable);
  215. break;
  216. case 'is-video-available':
  217. callback(videoAvailable);
  218. break;
  219. default:
  220. return false;
  221. }
  222. return true;
  223. });
  224. }
  225. /**
  226. * Listens for desktop/screen sharing enabled events and toggles the screen
  227. * sharing if needed.
  228. *
  229. * @param {boolean} enabled - Current screen sharing enabled status.
  230. * @returns {void}
  231. */
  232. function onDesktopSharingEnabledChanged(enabled = false) {
  233. if (enabled && initialScreenSharingState) {
  234. toggleScreenSharing();
  235. }
  236. }
  237. /**
  238. * Check whether the API should be enabled or not.
  239. *
  240. * @returns {boolean}
  241. */
  242. function shouldBeEnabled() {
  243. return (
  244. typeof API_ID === 'number'
  245. // XXX Enable the API when a JSON Web Token (JWT) is specified in
  246. // the location/URL because then it is very likely that the Jitsi
  247. // Meet (Web) app is being used by an external/wrapping (Web) app
  248. // and, consequently, the latter will need to communicate with the
  249. // former. (The described logic is merely a heuristic though.)
  250. || parseJWTFromURLParams());
  251. }
  252. /**
  253. * Executes on toggle-share-screen command.
  254. *
  255. * @param {boolean} [enable] - Whether this toggle is to explicitly enable or
  256. * disable screensharing. If not defined, the application will automatically
  257. * attempt to toggle between enabled and disabled. This boolean is useful for
  258. * explicitly setting desired screensharing state.
  259. * @returns {void}
  260. */
  261. function toggleScreenSharing(enable) {
  262. if (APP.conference.isDesktopSharingEnabled) {
  263. // eslint-disable-next-line no-empty-function
  264. APP.conference.toggleScreenSharing(enable).catch(() => {});
  265. } else {
  266. initialScreenSharingState = !initialScreenSharingState;
  267. }
  268. }
  269. /**
  270. * Implements API class that communicates with external API class and provides
  271. * interface to access Jitsi Meet features by external applications that embed
  272. * Jitsi Meet.
  273. */
  274. class API {
  275. _enabled: boolean;
  276. /**
  277. * Initializes the API. Setups message event listeners that will receive
  278. * information from external applications that embed Jitsi Meet. It also
  279. * sends a message to the external application that API is initialized.
  280. *
  281. * @param {Object} options - Optional parameters.
  282. * @returns {void}
  283. */
  284. init() {
  285. if (!shouldBeEnabled()) {
  286. return;
  287. }
  288. /**
  289. * Current status (enabled/disabled) of API.
  290. *
  291. * @private
  292. * @type {boolean}
  293. */
  294. this._enabled = true;
  295. APP.conference.addListener(
  296. JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
  297. onDesktopSharingEnabledChanged);
  298. initCommands();
  299. }
  300. /**
  301. * Notify external application (if API is enabled) that the large video
  302. * visibility changed.
  303. *
  304. * @param {boolean} isHidden - True if the large video is hidden and false
  305. * otherwise.
  306. * @returns {void}
  307. */
  308. notifyLargeVideoVisibilityChanged(isHidden: boolean) {
  309. this._sendEvent({
  310. name: 'large-video-visibility-changed',
  311. isVisible: !isHidden
  312. });
  313. }
  314. /**
  315. * Notifies the external application (spot) that the local jitsi-participant
  316. * has a status update.
  317. *
  318. * @param {Object} event - The message to pass onto spot.
  319. * @returns {void}
  320. */
  321. sendProxyConnectionEvent(event: Object) {
  322. this._sendEvent({
  323. name: 'proxy-connection-event',
  324. ...event
  325. });
  326. }
  327. /**
  328. * Sends event to the external application.
  329. *
  330. * @param {Object} event - The event to be sent.
  331. * @returns {void}
  332. */
  333. _sendEvent(event: Object = {}) {
  334. if (this._enabled) {
  335. transport.sendEvent(event);
  336. }
  337. }
  338. /**
  339. * Notify external application (if API is enabled) that message was sent.
  340. *
  341. * @param {string} message - Message body.
  342. * @param {boolean} privateMessage - True if the message was a private message.
  343. * @returns {void}
  344. */
  345. notifySendingChatMessage(message: string, privateMessage: boolean) {
  346. this._sendEvent({
  347. name: 'outgoing-message',
  348. message,
  349. privateMessage
  350. });
  351. }
  352. /**
  353. * Notify external application (if API is enabled) that message was
  354. * received.
  355. *
  356. * @param {Object} options - Object with the message properties.
  357. * @returns {void}
  358. */
  359. notifyReceivedChatMessage(
  360. { body, id, nick, ts }: {
  361. body: *, id: string, nick: string, ts: *
  362. } = {}) {
  363. if (APP.conference.isLocalId(id)) {
  364. return;
  365. }
  366. this._sendEvent({
  367. name: 'incoming-message',
  368. from: id,
  369. message: body,
  370. nick,
  371. stamp: ts
  372. });
  373. }
  374. /**
  375. * Notify external application (if API is enabled) that user joined the
  376. * conference.
  377. *
  378. * @param {string} id - User id.
  379. * @param {Object} props - The display name of the user.
  380. * @returns {void}
  381. */
  382. notifyUserJoined(id: string, props: Object) {
  383. this._sendEvent({
  384. name: 'participant-joined',
  385. id,
  386. ...props
  387. });
  388. }
  389. /**
  390. * Notify external application (if API is enabled) that user left the
  391. * conference.
  392. *
  393. * @param {string} id - User id.
  394. * @returns {void}
  395. */
  396. notifyUserLeft(id: string) {
  397. this._sendEvent({
  398. name: 'participant-left',
  399. id
  400. });
  401. }
  402. /**
  403. * Notify external application (if API is enabled) that the user role
  404. * has changed.
  405. *
  406. * @param {string} id - User id.
  407. * @param {string} role - The new user role.
  408. * @returns {void}
  409. */
  410. notifyUserRoleChanged(id: string, role: string) {
  411. this._sendEvent({
  412. name: 'participant-role-changed',
  413. id,
  414. role
  415. });
  416. }
  417. /**
  418. * Notify external application (if API is enabled) that user changed their
  419. * avatar.
  420. *
  421. * @param {string} id - User id.
  422. * @param {string} avatarURL - The new avatar URL of the participant.
  423. * @returns {void}
  424. */
  425. notifyAvatarChanged(id: string, avatarURL: string) {
  426. this._sendEvent({
  427. name: 'avatar-changed',
  428. avatarURL,
  429. id
  430. });
  431. }
  432. /**
  433. * Notify external application (if API is enabled) that user received
  434. * a text message through datachannels.
  435. *
  436. * @param {Object} data - The event data.
  437. * @returns {void}
  438. */
  439. notifyEndpointTextMessageReceived(data: Object) {
  440. this._sendEvent({
  441. name: 'endpoint-text-message-received',
  442. data
  443. });
  444. }
  445. /**
  446. * Notify external application (if API is enabled) that the device list has
  447. * changed.
  448. *
  449. * @param {Object} devices - The new device list.
  450. * @returns {void}
  451. */
  452. notifyDeviceListChanged(devices: Object) {
  453. this._sendEvent({
  454. name: 'device-list-changed',
  455. devices });
  456. }
  457. /**
  458. * Notify external application (if API is enabled) that user changed their
  459. * nickname.
  460. *
  461. * @param {string} id - User id.
  462. * @param {string} displayname - User nickname.
  463. * @param {string} formattedDisplayName - The display name shown in Jitsi
  464. * meet's UI for the user.
  465. * @returns {void}
  466. */
  467. notifyDisplayNameChanged(
  468. id: string,
  469. { displayName, formattedDisplayName }: Object) {
  470. this._sendEvent({
  471. name: 'display-name-change',
  472. displayname: displayName,
  473. formattedDisplayName,
  474. id
  475. });
  476. }
  477. /**
  478. * Notify external application (if API is enabled) that user changed their
  479. * email.
  480. *
  481. * @param {string} id - User id.
  482. * @param {string} email - The new email of the participant.
  483. * @returns {void}
  484. */
  485. notifyEmailChanged(
  486. id: string,
  487. { email }: Object) {
  488. this._sendEvent({
  489. name: 'email-change',
  490. email,
  491. id
  492. });
  493. }
  494. /**
  495. * Notify external application (if API is enabled) that the conference has
  496. * been joined.
  497. *
  498. * @param {string} roomName - The room name.
  499. * @param {string} id - The id of the local user.
  500. * @param {Object} props - The display name and avatar URL of the local
  501. * user.
  502. * @returns {void}
  503. */
  504. notifyConferenceJoined(roomName: string, id: string, props: Object) {
  505. this._sendEvent({
  506. name: 'video-conference-joined',
  507. roomName,
  508. id,
  509. ...props
  510. });
  511. }
  512. /**
  513. * Notify external application (if API is enabled) that user changed their
  514. * nickname.
  515. *
  516. * @param {string} roomName - User id.
  517. * @returns {void}
  518. */
  519. notifyConferenceLeft(roomName: string) {
  520. this._sendEvent({
  521. name: 'video-conference-left',
  522. roomName
  523. });
  524. }
  525. /**
  526. * Notify external application (if API is enabled) that we are ready to be
  527. * closed.
  528. *
  529. * @returns {void}
  530. */
  531. notifyReadyToClose() {
  532. this._sendEvent({ name: 'video-ready-to-close' });
  533. }
  534. /**
  535. * Notify external application (if API is enabled) that a suspend event in host computer.
  536. *
  537. * @returns {void}
  538. */
  539. notifySuspendDetected() {
  540. this._sendEvent({ name: 'suspend-detected' });
  541. }
  542. /**
  543. * Notify external application (if API is enabled) for audio muted status
  544. * changed.
  545. *
  546. * @param {boolean} muted - The new muted status.
  547. * @returns {void}
  548. */
  549. notifyAudioMutedStatusChanged(muted: boolean) {
  550. this._sendEvent({
  551. name: 'audio-mute-status-changed',
  552. muted
  553. });
  554. }
  555. /**
  556. * Notify external application (if API is enabled) for video muted status
  557. * changed.
  558. *
  559. * @param {boolean} muted - The new muted status.
  560. * @returns {void}
  561. */
  562. notifyVideoMutedStatusChanged(muted: boolean) {
  563. this._sendEvent({
  564. name: 'video-mute-status-changed',
  565. muted
  566. });
  567. }
  568. /**
  569. * Notify external application (if API is enabled) for audio availability
  570. * changed.
  571. *
  572. * @param {boolean} available - True if available and false otherwise.
  573. * @returns {void}
  574. */
  575. notifyAudioAvailabilityChanged(available: boolean) {
  576. audioAvailable = available;
  577. this._sendEvent({
  578. name: 'audio-availability-changed',
  579. available
  580. });
  581. }
  582. /**
  583. * Notify external application (if API is enabled) for video available
  584. * status changed.
  585. *
  586. * @param {boolean} available - True if available and false otherwise.
  587. * @returns {void}
  588. */
  589. notifyVideoAvailabilityChanged(available: boolean) {
  590. videoAvailable = available;
  591. this._sendEvent({
  592. name: 'video-availability-changed',
  593. available
  594. });
  595. }
  596. /**
  597. * Notify external application (if API is enabled) that the on stage
  598. * participant has changed.
  599. *
  600. * @param {string} id - User id of the new on stage participant.
  601. * @returns {void}
  602. */
  603. notifyOnStageParticipantChanged(id: string) {
  604. this._sendEvent({
  605. name: 'on-stage-participant-changed',
  606. id
  607. });
  608. }
  609. /**
  610. * Notify external application of an unexpected camera-related error having
  611. * occurred.
  612. *
  613. * @param {string} type - The type of the camera error.
  614. * @param {string} message - Additional information about the error.
  615. * @returns {void}
  616. */
  617. notifyOnCameraError(type: string, message: string) {
  618. this._sendEvent({
  619. name: 'camera-error',
  620. type,
  621. message
  622. });
  623. }
  624. /**
  625. * Notify external application of an unexpected mic-related error having
  626. * occurred.
  627. *
  628. * @param {string} type - The type of the mic error.
  629. * @param {string} message - Additional information about the error.
  630. * @returns {void}
  631. */
  632. notifyOnMicError(type: string, message: string) {
  633. this._sendEvent({
  634. name: 'mic-error',
  635. type,
  636. message
  637. });
  638. }
  639. /**
  640. * Notify external application (if API is enabled) that conference feedback
  641. * has been submitted. Intended to be used in conjunction with the
  642. * submit-feedback command to get notified if feedback was submitted.
  643. *
  644. * @param {string} error - A failure message, if any.
  645. * @returns {void}
  646. */
  647. notifyFeedbackSubmitted(error: string) {
  648. this._sendEvent({
  649. name: 'feedback-submitted',
  650. error
  651. });
  652. }
  653. /**
  654. * Notify external application (if API is enabled) that the feedback prompt
  655. * has been displayed.
  656. *
  657. * @returns {void}
  658. */
  659. notifyFeedbackPromptDisplayed() {
  660. this._sendEvent({ name: 'feedback-prompt-displayed' });
  661. }
  662. /**
  663. * Notify external application (if API is enabled) that the display
  664. * configuration of the filmstrip has been changed.
  665. *
  666. * @param {boolean} visible - Whether or not the filmstrip has been set to
  667. * be displayed or hidden.
  668. * @returns {void}
  669. */
  670. notifyFilmstripDisplayChanged(visible: boolean) {
  671. this._sendEvent({
  672. name: 'filmstrip-display-changed',
  673. visible
  674. });
  675. }
  676. /**
  677. * Notify external application of a participant, remote or local, being
  678. * removed from the conference by another participant.
  679. *
  680. * @param {string} kicked - The ID of the participant removed from the
  681. * conference.
  682. * @param {string} kicker - The ID of the participant that removed the
  683. * other participant.
  684. * @returns {void}
  685. */
  686. notifyKickedOut(kicked: Object, kicker: Object) {
  687. this._sendEvent({
  688. name: 'participant-kicked-out',
  689. kicked,
  690. kicker
  691. });
  692. }
  693. /**
  694. * Notify external application of the current meeting requiring a password
  695. * to join.
  696. *
  697. * @returns {void}
  698. */
  699. notifyOnPasswordRequired() {
  700. this._sendEvent({ name: 'password-required' });
  701. }
  702. /**
  703. * Notify external application (if API is enabled) that the screen sharing
  704. * has been turned on/off.
  705. *
  706. * @param {boolean} on - True if screen sharing is enabled.
  707. * @param {Object} details - Additional information about the screen
  708. * sharing.
  709. * @param {string} details.sourceType - Type of device or window the screen
  710. * share is capturing.
  711. * @returns {void}
  712. */
  713. notifyScreenSharingStatusChanged(on: boolean, details: Object) {
  714. this._sendEvent({
  715. name: 'screen-sharing-status-changed',
  716. on,
  717. details
  718. });
  719. }
  720. /**
  721. * Notify external application (if API is enabled) that the dominant speaker
  722. * has been turned on/off.
  723. *
  724. * @param {string} id - Id of the dominant participant.
  725. * @returns {void}
  726. */
  727. notifyDominantSpeakerChanged(id: string) {
  728. this._sendEvent({
  729. name: 'dominant-speaker-changed',
  730. id
  731. });
  732. }
  733. /**
  734. * Notify external application (if API is enabled) that the conference
  735. * changed their subject.
  736. *
  737. * @param {string} subject - Conference subject.
  738. * @returns {void}
  739. */
  740. notifySubjectChanged(subject: string) {
  741. this._sendEvent({
  742. name: 'subject-change',
  743. subject
  744. });
  745. }
  746. /**
  747. * Notify external application (if API is enabled) that tile view has been
  748. * entered or exited.
  749. *
  750. * @param {string} enabled - True if tile view is currently displayed, false
  751. * otherwise.
  752. * @returns {void}
  753. */
  754. notifyTileViewChanged(enabled: boolean) {
  755. this._sendEvent({
  756. name: 'tile-view-changed',
  757. enabled
  758. });
  759. }
  760. /**
  761. * Disposes the allocated resources.
  762. *
  763. * @returns {void}
  764. */
  765. dispose() {
  766. if (this._enabled) {
  767. this._enabled = false;
  768. APP.conference.removeListener(
  769. JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
  770. onDesktopSharingEnabledChanged);
  771. }
  772. }
  773. }
  774. export default new API();