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 23KB

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