您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251
  1. /* global APP */
  2. import Logger from '@jitsi/logger';
  3. import { createApiEvent } from '../../react/features/analytics/AnalyticsEvents';
  4. import { sendAnalytics } from '../../react/features/analytics/functions';
  5. import {
  6. approveParticipantAudio,
  7. approveParticipantVideo,
  8. rejectParticipantAudio,
  9. rejectParticipantVideo,
  10. requestDisableAudioModeration,
  11. requestDisableVideoModeration,
  12. requestEnableAudioModeration,
  13. requestEnableVideoModeration
  14. } from '../../react/features/av-moderation/actions';
  15. import { isEnabledFromState } from '../../react/features/av-moderation/functions';
  16. import { setAudioOnly } from '../../react/features/base/audio-only/actions';
  17. import {
  18. endConference,
  19. sendTones,
  20. setAssumedBandwidthBps,
  21. setFollowMe,
  22. setFollowMeRecorder,
  23. setLocalSubject,
  24. setPassword,
  25. setSubject
  26. } from '../../react/features/base/conference/actions';
  27. import { getCurrentConference, isP2pActive } from '../../react/features/base/conference/functions';
  28. import { overwriteConfig } from '../../react/features/base/config/actions';
  29. import { getWhitelistedJSON } from '../../react/features/base/config/functions.any';
  30. import { toggleDialog } from '../../react/features/base/dialog/actions';
  31. import { isSupportedBrowser } from '../../react/features/base/environment/environment';
  32. import { parseJWTFromURLParams } from '../../react/features/base/jwt/functions';
  33. import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
  34. import { MEDIA_TYPE, VIDEO_TYPE } from '../../react/features/base/media/constants';
  35. import { isVideoMutedByUser } from '../../react/features/base/media/functions';
  36. import {
  37. grantModerator,
  38. kickParticipant,
  39. overwriteParticipantsNames,
  40. pinParticipant,
  41. raiseHand
  42. } from '../../react/features/base/participants/actions';
  43. import { LOCAL_PARTICIPANT_DEFAULT_ID } from '../../react/features/base/participants/constants';
  44. import {
  45. getLocalParticipant,
  46. getNormalizedDisplayName,
  47. getParticipantById,
  48. getScreenshareParticipantIds,
  49. getVirtualScreenshareParticipantByOwnerId,
  50. hasRaisedHand,
  51. isLocalParticipantModerator,
  52. isParticipantModerator
  53. } from '../../react/features/base/participants/functions';
  54. import { updateSettings } from '../../react/features/base/settings/actions';
  55. import { getDisplayName } from '../../react/features/base/settings/functions.web';
  56. import { setCameraFacingMode } from '../../react/features/base/tracks/actions.web';
  57. import { CAMERA_FACING_MODE_MESSAGE } from '../../react/features/base/tracks/constants';
  58. import {
  59. getLocalVideoTrack,
  60. isLocalTrackMuted
  61. } from '../../react/features/base/tracks/functions';
  62. import {
  63. autoAssignToBreakoutRooms,
  64. closeBreakoutRoom,
  65. createBreakoutRoom,
  66. moveToRoom,
  67. removeBreakoutRoom,
  68. sendParticipantToRoom
  69. } from '../../react/features/breakout-rooms/actions';
  70. import { getBreakoutRooms, getRoomsInfo } from '../../react/features/breakout-rooms/functions';
  71. import {
  72. sendMessage,
  73. setPrivateMessageRecipient,
  74. toggleChat
  75. } from '../../react/features/chat/actions';
  76. import { openChat } from '../../react/features/chat/actions.web';
  77. import {
  78. processExternalDeviceRequest
  79. } from '../../react/features/device-selection/functions';
  80. import { appendSuffix } from '../../react/features/display-name/functions';
  81. import { isEnabled as isDropboxEnabled } from '../../react/features/dropbox/functions';
  82. import { setMediaEncryptionKey, toggleE2EE } from '../../react/features/e2ee/actions';
  83. import {
  84. addStageParticipant,
  85. resizeFilmStrip,
  86. setFilmstripVisible,
  87. setVolume,
  88. togglePinStageParticipant
  89. } from '../../react/features/filmstrip/actions.web';
  90. import { getPinnedActiveParticipants, isStageFilmstripAvailable } from '../../react/features/filmstrip/functions.web';
  91. import { invite } from '../../react/features/invite/actions.any';
  92. import {
  93. selectParticipantInLargeVideo
  94. } from '../../react/features/large-video/actions.any';
  95. import {
  96. captureLargeVideoScreenshot,
  97. resizeLargeVideo
  98. } from '../../react/features/large-video/actions.web';
  99. import { answerKnockingParticipant, toggleLobbyMode } from '../../react/features/lobby/actions';
  100. import { setNoiseSuppressionEnabled } from '../../react/features/noise-suppression/actions';
  101. import { hideNotification, showNotification } from '../../react/features/notifications/actions';
  102. import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../../react/features/notifications/constants';
  103. import {
  104. close as closeParticipantsPane,
  105. open as openParticipantsPane
  106. } from '../../react/features/participants-pane/actions';
  107. import { getParticipantsPaneOpen, isForceMuted } from '../../react/features/participants-pane/functions';
  108. import { startLocalVideoRecording, stopLocalVideoRecording } from '../../react/features/recording/actions.any';
  109. import { RECORDING_METADATA_ID, RECORDING_TYPES } from '../../react/features/recording/constants';
  110. import { getActiveSession, supportsLocalRecording } from '../../react/features/recording/functions';
  111. import { startAudioScreenShareFlow, startScreenShareFlow } from '../../react/features/screen-share/actions';
  112. import { isScreenAudioSupported } from '../../react/features/screen-share/functions';
  113. import { toggleScreenshotCaptureSummary } from '../../react/features/screenshot-capture/actions';
  114. import { isScreenshotCaptureEnabled } from '../../react/features/screenshot-capture/functions';
  115. import SettingsDialog from '../../react/features/settings/components/web/SettingsDialog';
  116. import { SETTINGS_TABS } from '../../react/features/settings/constants';
  117. import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
  118. import { extractYoutubeIdOrURL } from '../../react/features/shared-video/functions';
  119. import { setRequestingSubtitles, toggleRequestingSubtitles } from '../../react/features/subtitles/actions';
  120. import { isAudioMuteButtonDisabled } from '../../react/features/toolbox/functions';
  121. import { setTileView, toggleTileView } from '../../react/features/video-layout/actions.any';
  122. import { muteAllParticipants } from '../../react/features/video-menu/actions';
  123. import { setVideoQuality } from '../../react/features/video-quality/actions';
  124. import { toggleBlurredBackgroundEffect } from '../../react/features/virtual-background/actions';
  125. import { toggleWhiteboard } from '../../react/features/whiteboard/actions.web';
  126. import { getJitsiMeetTransport } from '../transport';
  127. import {
  128. API_ID,
  129. ENDPOINT_TEXT_MESSAGE_NAME
  130. } from './constants';
  131. const logger = Logger.getLogger(__filename);
  132. /**
  133. * List of the available commands.
  134. */
  135. let commands = {};
  136. /**
  137. * The transport instance used for communication with external apps.
  138. *
  139. * @type {Transport}
  140. */
  141. const transport = getJitsiMeetTransport();
  142. /**
  143. * The current audio availability.
  144. *
  145. * @type {boolean}
  146. */
  147. let audioAvailable = true;
  148. /**
  149. * The current video availability.
  150. *
  151. * @type {boolean}
  152. */
  153. let videoAvailable = true;
  154. /**
  155. * Initializes supported commands.
  156. *
  157. * @returns {void}
  158. */
  159. function initCommands() {
  160. commands = {
  161. 'add-breakout-room': name => {
  162. if (!isLocalParticipantModerator(APP.store.getState())) {
  163. logger.error('Missing moderator rights to add breakout rooms');
  164. return;
  165. }
  166. APP.store.dispatch(createBreakoutRoom(name));
  167. },
  168. 'answer-knocking-participant': (id, approved) => {
  169. APP.store.dispatch(answerKnockingParticipant(id, approved));
  170. },
  171. 'approve-video': participantId => {
  172. if (!isLocalParticipantModerator(APP.store.getState())) {
  173. return;
  174. }
  175. APP.store.dispatch(approveParticipantVideo(participantId));
  176. },
  177. 'ask-to-unmute': participantId => {
  178. if (!isLocalParticipantModerator(APP.store.getState())) {
  179. return;
  180. }
  181. APP.store.dispatch(approveParticipantAudio(participantId));
  182. },
  183. 'auto-assign-to-breakout-rooms': () => {
  184. if (!isLocalParticipantModerator(APP.store.getState())) {
  185. logger.error('Missing moderator rights to auto-assign participants to breakout rooms');
  186. return;
  187. }
  188. APP.store.dispatch(autoAssignToBreakoutRooms());
  189. },
  190. 'grant-moderator': participantId => {
  191. if (!isLocalParticipantModerator(APP.store.getState())) {
  192. logger.error('Missing moderator rights to grant moderator right to another participant');
  193. return;
  194. }
  195. APP.store.dispatch(grantModerator(participantId));
  196. },
  197. 'display-name': displayName => {
  198. sendAnalytics(createApiEvent('display.name.changed'));
  199. APP.store.dispatch(updateSettings({ displayName: getNormalizedDisplayName(displayName) }));
  200. },
  201. 'local-subject': localSubject => {
  202. sendAnalytics(createApiEvent('local.subject.changed'));
  203. APP.store.dispatch(setLocalSubject(localSubject));
  204. },
  205. 'mute-everyone': mediaType => {
  206. const muteMediaType = mediaType ? mediaType : MEDIA_TYPE.AUDIO;
  207. sendAnalytics(createApiEvent('muted-everyone'));
  208. const localParticipant = getLocalParticipant(APP.store.getState());
  209. const exclude = [];
  210. if (localParticipant && isParticipantModerator(localParticipant)) {
  211. exclude.push(localParticipant.id);
  212. }
  213. APP.store.dispatch(muteAllParticipants(exclude, muteMediaType));
  214. },
  215. 'toggle-lobby': isLobbyEnabled => {
  216. APP.store.dispatch(toggleLobbyMode(isLobbyEnabled));
  217. },
  218. 'password': password => {
  219. const { conference, passwordRequired }
  220. = APP.store.getState()['features/base/conference'];
  221. if (passwordRequired) {
  222. sendAnalytics(createApiEvent('submit.password'));
  223. APP.store.dispatch(setPassword(
  224. passwordRequired,
  225. passwordRequired.join,
  226. password
  227. ));
  228. } else {
  229. sendAnalytics(createApiEvent('password.changed'));
  230. APP.store.dispatch(setPassword(
  231. conference,
  232. conference.lock,
  233. password
  234. ));
  235. }
  236. },
  237. 'pin-participant': (id, videoType) => {
  238. const state = APP.store.getState();
  239. // if id not provided, unpin everybody.
  240. if (!id) {
  241. if (isStageFilmstripAvailable(state)) {
  242. const pinnedParticipants = getPinnedActiveParticipants(state);
  243. pinnedParticipants?.forEach(p => {
  244. APP.store.dispatch(togglePinStageParticipant(p.participantId));
  245. });
  246. } else {
  247. APP.store.dispatch(pinParticipant());
  248. }
  249. return;
  250. }
  251. const participant = videoType === VIDEO_TYPE.DESKTOP
  252. ? getVirtualScreenshareParticipantByOwnerId(state, id) : getParticipantById(state, id);
  253. if (!participant) {
  254. logger.warn('Trying to pin a non-existing participant with pin-participant command.');
  255. return;
  256. }
  257. sendAnalytics(createApiEvent('participant.pinned'));
  258. const participantId = participant.id;
  259. if (isStageFilmstripAvailable(state)) {
  260. APP.store.dispatch(addStageParticipant(participantId, true));
  261. } else {
  262. APP.store.dispatch(pinParticipant(participantId));
  263. }
  264. },
  265. 'proxy-connection-event': event => {
  266. APP.conference.onProxyConnectionEvent(event);
  267. },
  268. 'reject-participant': (participantId, mediaType) => {
  269. if (!isLocalParticipantModerator(APP.store.getState())) {
  270. return;
  271. }
  272. const reject = mediaType === MEDIA_TYPE.VIDEO ? rejectParticipantVideo : rejectParticipantAudio;
  273. APP.store.dispatch(reject(participantId));
  274. },
  275. 'remove-breakout-room': breakoutRoomJid => {
  276. if (!isLocalParticipantModerator(APP.store.getState())) {
  277. logger.error('Missing moderator rights to remove breakout rooms');
  278. return;
  279. }
  280. APP.store.dispatch(removeBreakoutRoom(breakoutRoomJid));
  281. },
  282. 'resize-large-video': (width, height) => {
  283. sendAnalytics(createApiEvent('largevideo.resized'));
  284. APP.store.dispatch(resizeLargeVideo(width, height));
  285. },
  286. 'send-tones': (options = {}) => {
  287. const { duration, tones, pause } = options;
  288. APP.store.dispatch(sendTones(tones, duration, pause));
  289. },
  290. 'set-assumed-bandwidth-bps': value => {
  291. logger.debug('Set assumed bandwidth bps command received', value);
  292. if (typeof value !== 'number' || isNaN(value)) {
  293. logger.error('Assumed bandwidth bps must be a number.');
  294. return;
  295. }
  296. APP.store.dispatch(setAssumedBandwidthBps(value));
  297. },
  298. 'set-blurred-background': blurType => {
  299. const tracks = APP.store.getState()['features/base/tracks'];
  300. const videoTrack = getLocalVideoTrack(tracks)?.jitsiTrack;
  301. const muted = tracks ? isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO) : isVideoMutedByUser(APP.store);
  302. APP.store.dispatch(toggleBlurredBackgroundEffect(videoTrack, blurType, muted));
  303. },
  304. 'set-follow-me': (value, recorderOnly) => {
  305. if (value) {
  306. sendAnalytics(createApiEvent('follow.me.set', {
  307. recorderOnly
  308. }));
  309. } else {
  310. sendAnalytics(createApiEvent('follow.me.unset', {
  311. recorderOnly
  312. }));
  313. }
  314. APP.store.dispatch(recorderOnly ? setFollowMeRecorder(value) : setFollowMe(value));
  315. },
  316. 'set-large-video-participant': (participantId, videoType) => {
  317. const { getState, dispatch } = APP.store;
  318. if (!participantId) {
  319. sendAnalytics(createApiEvent('largevideo.participant.set'));
  320. dispatch(selectParticipantInLargeVideo());
  321. return;
  322. }
  323. const state = getState();
  324. const participant = videoType === VIDEO_TYPE.DESKTOP
  325. ? getVirtualScreenshareParticipantByOwnerId(state, participantId)
  326. : getParticipantById(state, participantId);
  327. if (!participant) {
  328. logger.warn('Trying to select a non-existing participant with set-large-video-participant command.');
  329. return;
  330. }
  331. dispatch(setTileView(false));
  332. sendAnalytics(createApiEvent('largevideo.participant.set'));
  333. dispatch(selectParticipantInLargeVideo(participant.id));
  334. },
  335. 'set-participant-volume': (participantId, volume) => {
  336. APP.store.dispatch(setVolume(participantId, volume));
  337. },
  338. 'subject': subject => {
  339. sendAnalytics(createApiEvent('subject.changed'));
  340. APP.store.dispatch(setSubject(subject));
  341. },
  342. 'submit-feedback': feedback => {
  343. sendAnalytics(createApiEvent('submit.feedback'));
  344. APP.conference.submitFeedback(feedback.score, feedback.message);
  345. },
  346. 'toggle-audio': () => {
  347. sendAnalytics(createApiEvent('toggle-audio'));
  348. APP.conference.toggleAudioMuted(false /* no UI */);
  349. },
  350. 'toggle-video': () => {
  351. sendAnalytics(createApiEvent('toggle-video'));
  352. APP.conference.toggleVideoMuted(false /* no UI */, true /* ensure track */);
  353. },
  354. 'toggle-film-strip': () => {
  355. sendAnalytics(createApiEvent('film.strip.toggled'));
  356. const { visible } = APP.store.getState()['features/filmstrip'];
  357. APP.store.dispatch(setFilmstripVisible(!visible));
  358. },
  359. /*
  360. * @param {Object} options - Additional details of how to perform
  361. * the action.
  362. * @param {number} options.width - width value for film strip.
  363. */
  364. 'resize-film-strip': (options = {}) => {
  365. sendAnalytics(createApiEvent('film.strip.resize'));
  366. APP.store.dispatch(resizeFilmStrip(options.width));
  367. },
  368. 'toggle-camera': facingMode => {
  369. APP.store.dispatch(setCameraFacingMode(facingMode));
  370. },
  371. 'toggle-camera-mirror': () => {
  372. const state = APP.store.getState();
  373. const { localFlipX: currentFlipX } = state['features/base/settings'];
  374. APP.store.dispatch(updateSettings({ localFlipX: !currentFlipX }));
  375. },
  376. 'toggle-chat': () => {
  377. sendAnalytics(createApiEvent('chat.toggled'));
  378. APP.store.dispatch(toggleChat());
  379. },
  380. 'toggle-moderation': (enabled, mediaType) => {
  381. const state = APP.store.getState();
  382. if (!isLocalParticipantModerator(state)) {
  383. return;
  384. }
  385. const enable = mediaType === MEDIA_TYPE.VIDEO
  386. ? requestEnableVideoModeration : requestEnableAudioModeration;
  387. const disable = mediaType === MEDIA_TYPE.VIDEO
  388. ? requestDisableVideoModeration : requestDisableAudioModeration;
  389. if (enabled) {
  390. APP.store.dispatch(enable());
  391. } else {
  392. APP.store.dispatch(disable());
  393. }
  394. },
  395. 'toggle-participants-pane': enabled => {
  396. const toggleParticipantsPane = enabled
  397. ? openParticipantsPane : closeParticipantsPane;
  398. APP.store.dispatch(toggleParticipantsPane());
  399. },
  400. 'toggle-raise-hand': () => {
  401. const localParticipant = getLocalParticipant(APP.store.getState());
  402. if (!localParticipant) {
  403. return;
  404. }
  405. const raisedHand = hasRaisedHand(localParticipant);
  406. sendAnalytics(createApiEvent('raise-hand.toggled'));
  407. APP.store.dispatch(raiseHand(!raisedHand));
  408. },
  409. 'toggle-share-audio': () => {
  410. sendAnalytics(createApiEvent('audio.screen.sharing.toggled'));
  411. if (isScreenAudioSupported()) {
  412. APP.store.dispatch(startAudioScreenShareFlow());
  413. return;
  414. }
  415. logger.error('Audio screen sharing is not supported by the current platform!');
  416. },
  417. /**
  418. * Callback to invoke when the "toggle-share-screen" command is received.
  419. *
  420. * @param {Object} options - Additional details of how to perform
  421. * the action. Note this parameter is undocumented and experimental.
  422. * @param {boolean} options.enable - Whether trying to enable screen
  423. * sharing or to turn it off.
  424. * @returns {void}
  425. */
  426. 'toggle-share-screen': (options = {}) => {
  427. sendAnalytics(createApiEvent('screen.sharing.toggled'));
  428. toggleScreenSharing(options.enable);
  429. },
  430. 'set-noise-suppression-enabled': (options = {}) => {
  431. APP.store.dispatch(setNoiseSuppressionEnabled(options.enabled));
  432. },
  433. 'toggle-subtitles': () => {
  434. APP.store.dispatch(toggleRequestingSubtitles());
  435. },
  436. 'set-subtitles': (enabled, displaySubtitles, language) => {
  437. APP.store.dispatch(setRequestingSubtitles(enabled, displaySubtitles, language));
  438. },
  439. 'toggle-tile-view': () => {
  440. sendAnalytics(createApiEvent('tile-view.toggled'));
  441. APP.store.dispatch(toggleTileView());
  442. },
  443. 'set-tile-view': enabled => {
  444. APP.store.dispatch(setTileView(enabled));
  445. },
  446. 'video-hangup': (showFeedbackDialog = true) => {
  447. sendAnalytics(createApiEvent('video.hangup'));
  448. APP.conference.hangup(showFeedbackDialog);
  449. },
  450. 'email': email => {
  451. sendAnalytics(createApiEvent('email.changed'));
  452. APP.conference.changeLocalEmail(email);
  453. },
  454. 'avatar-url': avatarUrl => { // @deprecated
  455. console.warn('Using command avatarUrl is deprecated. Use context.user.avatar in the jwt.');
  456. sendAnalytics(createApiEvent('avatar.url.changed'));
  457. APP.conference.changeLocalAvatarUrl(avatarUrl);
  458. },
  459. 'send-chat-message': (message, to, ignorePrivacy = false) => {
  460. if (to) {
  461. const participant = getParticipantById(APP.store.getState(), to);
  462. if (participant) {
  463. APP.store.dispatch(setPrivateMessageRecipient(participant));
  464. } else {
  465. logger.error(`Participant with id ${to} not found!`);
  466. return;
  467. }
  468. } else {
  469. APP.store.dispatch(setPrivateMessageRecipient());
  470. }
  471. APP.store.dispatch(sendMessage(message, ignorePrivacy));
  472. },
  473. 'send-endpoint-text-message': (to, text) => {
  474. try {
  475. APP.conference.sendEndpointMessage(to, {
  476. name: ENDPOINT_TEXT_MESSAGE_NAME,
  477. text
  478. });
  479. } catch (err) {
  480. logger.error('Failed sending endpoint text message', err);
  481. }
  482. },
  483. 'send-camera-facing-mode-message': (to, facingMode) => {
  484. if (!to) {
  485. logger.warn('Participant id not set');
  486. return;
  487. }
  488. APP.conference.sendEndpointMessage(to, {
  489. name: CAMERA_FACING_MODE_MESSAGE,
  490. facingMode
  491. });
  492. },
  493. 'overwrite-names': participantList => {
  494. APP.store.dispatch(overwriteParticipantsNames(participantList));
  495. },
  496. 'toggle-e2ee': enabled => {
  497. APP.store.dispatch(toggleE2EE(enabled));
  498. },
  499. 'set-media-encryption-key': keyInfo => {
  500. APP.store.dispatch(setMediaEncryptionKey(JSON.parse(keyInfo)));
  501. },
  502. 'set-video-quality': frameHeight => {
  503. sendAnalytics(createApiEvent('set.video.quality'));
  504. APP.store.dispatch(setVideoQuality(frameHeight));
  505. },
  506. 'set-audio-only': enable => {
  507. sendAnalytics(createApiEvent('set.audio.only'));
  508. APP.store.dispatch(setAudioOnly(enable));
  509. },
  510. 'start-share-video': url => {
  511. sendAnalytics(createApiEvent('share.video.start'));
  512. const id = extractYoutubeIdOrURL(url);
  513. if (id) {
  514. APP.store.dispatch(playSharedVideo(id));
  515. }
  516. },
  517. 'stop-share-video': () => {
  518. sendAnalytics(createApiEvent('share.video.stop'));
  519. APP.store.dispatch(stopSharedVideo());
  520. },
  521. /**
  522. * Shows a custom in-meeting notification.
  523. *
  524. * @param { string } arg.title - Notification title.
  525. * @param { string } arg.description - Notification description.
  526. * @param { string } arg.uid - Optional unique identifier for the notification.
  527. * @param { string } arg.type - Notification type, either `error`, `info`, `normal`, `success` or `warning`.
  528. * Defaults to "normal" if not provided.
  529. * @param { string } arg.timeout - Timeout type, either `short`, `medium`, `long` or `sticky`.
  530. * Defaults to "short" if not provided.
  531. * @returns {void}
  532. */
  533. 'show-notification': ({
  534. title,
  535. description,
  536. uid,
  537. type = NOTIFICATION_TYPE.NORMAL,
  538. timeout = NOTIFICATION_TIMEOUT_TYPE.SHORT
  539. }) => {
  540. const validTypes = Object.values(NOTIFICATION_TYPE);
  541. const validTimeouts = Object.values(NOTIFICATION_TIMEOUT_TYPE);
  542. if (!validTypes.includes(type)) {
  543. logger.error(`Invalid notification type "${type}". Expecting one of ${validTypes}`);
  544. return;
  545. }
  546. if (!validTimeouts.includes(timeout)) {
  547. logger.error(`Invalid notification timeout "${timeout}". Expecting one of ${validTimeouts}`);
  548. return;
  549. }
  550. APP.store.dispatch(showNotification({
  551. uid,
  552. title,
  553. description,
  554. appearance: type
  555. }, timeout));
  556. },
  557. /**
  558. * Removes a notification given a unique identifier.
  559. *
  560. * @param { string } uid - Unique identifier for the notification to be removed.
  561. * @returns {void}
  562. */
  563. 'hide-notification': uid => {
  564. APP.store.dispatch(hideNotification(uid));
  565. },
  566. /**
  567. * Starts a file recording or streaming session depending on the passed on params.
  568. * For RTMP streams, `rtmpStreamKey` must be passed on. `rtmpBroadcastID` is optional.
  569. * For youtube streams, `youtubeStreamKey` must be passed on. `youtubeBroadcastID` is optional.
  570. * For dropbox recording, recording `mode` should be `file` and a dropbox oauth2 token must be provided.
  571. * For file recording, recording `mode` should be `file` and optionally `shouldShare` could be passed on.
  572. * For local recording, recording `mode` should be `local` and optionally `onlySelf` could be passed on.
  573. * No other params should be passed.
  574. *
  575. * @param { string } arg.mode - Recording mode, either `local`, `file` or `stream`.
  576. * @param { string } arg.dropboxToken - Dropbox oauth2 token.
  577. * @param { boolean } arg.onlySelf - Whether to only record the local streams.
  578. * @param { string } arg.rtmpStreamKey - The RTMP stream key.
  579. * @param { string } arg.rtmpBroadcastID - The RTMP broadcast ID.
  580. * @param { boolean } arg.shouldShare - Whether the recording should be shared with the participants or not.
  581. * Only applies to certain jitsi meet deploys.
  582. * @param { string } arg.youtubeStreamKey - The youtube stream key.
  583. * @param { string } arg.youtubeBroadcastID - The youtube broadcast ID.
  584. * @param { Object } arg.extraMetadata - Any extra metadata params for file recording.
  585. * @param { boolean } arg.transcription - Whether a transcription should be started or not.
  586. * @returns {void}
  587. */
  588. 'start-recording': ({
  589. mode,
  590. dropboxToken,
  591. onlySelf,
  592. shouldShare,
  593. rtmpStreamKey,
  594. rtmpBroadcastID,
  595. youtubeStreamKey,
  596. youtubeBroadcastID,
  597. extraMetadata = {},
  598. transcription
  599. }) => {
  600. const state = APP.store.getState();
  601. const conference = getCurrentConference(state);
  602. if (!conference) {
  603. logger.error('Conference is not defined');
  604. return;
  605. }
  606. if (dropboxToken && !isDropboxEnabled(state)) {
  607. logger.error('Failed starting recording: dropbox is not enabled on this deployment');
  608. return;
  609. }
  610. if (mode === JitsiRecordingConstants.mode.STREAM && !(youtubeStreamKey || rtmpStreamKey)) {
  611. logger.error('Failed starting recording: missing youtube or RTMP stream key');
  612. return;
  613. }
  614. if (mode === 'local') {
  615. const { localRecording } = state['features/base/config'];
  616. if (!localRecording?.disable && supportsLocalRecording()) {
  617. APP.store.dispatch(startLocalVideoRecording(onlySelf));
  618. } else {
  619. logger.error('Failed starting recording: local recording is either disabled or not supported');
  620. }
  621. return;
  622. }
  623. let recordingConfig;
  624. if (mode === JitsiRecordingConstants.mode.FILE) {
  625. const { recordingService } = state['features/base/config'];
  626. if (!recordingService.enabled && !dropboxToken) {
  627. logger.error('Failed starting recording: the recording service is not enabled');
  628. return;
  629. }
  630. if (dropboxToken) {
  631. recordingConfig = {
  632. mode: JitsiRecordingConstants.mode.FILE,
  633. appData: JSON.stringify({
  634. 'file_recording_metadata': {
  635. ...extraMetadata,
  636. 'upload_credentials': {
  637. 'service_name': RECORDING_TYPES.DROPBOX,
  638. 'token': dropboxToken
  639. }
  640. }
  641. })
  642. };
  643. } else {
  644. recordingConfig = {
  645. mode: JitsiRecordingConstants.mode.FILE,
  646. appData: JSON.stringify({
  647. 'file_recording_metadata': {
  648. ...extraMetadata,
  649. 'share': shouldShare
  650. }
  651. })
  652. };
  653. }
  654. } else if (mode === JitsiRecordingConstants.mode.STREAM) {
  655. recordingConfig = {
  656. broadcastId: youtubeBroadcastID || rtmpBroadcastID,
  657. mode: JitsiRecordingConstants.mode.STREAM,
  658. streamId: youtubeStreamKey || rtmpStreamKey
  659. };
  660. }
  661. if (isScreenshotCaptureEnabled(state, true, false)) {
  662. APP.store.dispatch(toggleScreenshotCaptureSummary(true));
  663. }
  664. // Start audio / video recording, if requested.
  665. if (typeof recordingConfig !== 'undefined') {
  666. conference.startRecording(recordingConfig);
  667. }
  668. if (transcription) {
  669. APP.store.dispatch(setRequestingSubtitles(true, false, null));
  670. conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
  671. isTranscribingEnabled: true
  672. });
  673. }
  674. },
  675. /**
  676. * Stops a recording or streaming in progress.
  677. *
  678. * @param {string} mode - `local`, `file` or `stream`.
  679. * @param {boolean} transcription - Whether the transcription needs to be stopped.
  680. * @returns {void}
  681. */
  682. 'stop-recording': (mode, transcription) => {
  683. const state = APP.store.getState();
  684. const conference = getCurrentConference(state);
  685. if (!conference) {
  686. logger.error('Conference is not defined');
  687. return;
  688. }
  689. if (transcription) {
  690. APP.store.dispatch(setRequestingSubtitles(false, false, null));
  691. conference.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
  692. isTranscribingEnabled: false
  693. });
  694. }
  695. if (mode === 'local') {
  696. APP.store.dispatch(stopLocalVideoRecording());
  697. return;
  698. }
  699. if (![ JitsiRecordingConstants.mode.FILE, JitsiRecordingConstants.mode.STREAM ].includes(mode)) {
  700. logger.error('Invalid recording mode provided!');
  701. return;
  702. }
  703. const activeSession = getActiveSession(state, mode);
  704. if (activeSession && activeSession.id) {
  705. APP.store.dispatch(toggleScreenshotCaptureSummary(false));
  706. conference.stopRecording(activeSession.id);
  707. } else {
  708. logger.error('No recording or streaming session found');
  709. }
  710. },
  711. 'initiate-private-chat': participantId => {
  712. const state = APP.store.getState();
  713. const participant = getParticipantById(state, participantId);
  714. if (participant) {
  715. const { isOpen: isChatOpen } = state['features/chat'];
  716. if (!isChatOpen) {
  717. APP.store.dispatch(toggleChat());
  718. }
  719. APP.store.dispatch(openChat(participant));
  720. } else {
  721. logger.error('No participant found for the given participantId');
  722. }
  723. },
  724. 'cancel-private-chat': () => {
  725. APP.store.dispatch(setPrivateMessageRecipient());
  726. },
  727. 'close-breakout-room': roomId => {
  728. if (!isLocalParticipantModerator(APP.store.getState())) {
  729. logger.error('Missing moderator rights to close breakout rooms');
  730. return;
  731. }
  732. APP.store.dispatch(closeBreakoutRoom(roomId));
  733. },
  734. 'join-breakout-room': roomId => {
  735. APP.store.dispatch(moveToRoom(roomId));
  736. },
  737. 'send-participant-to-room': (participantId, roomId) => {
  738. if (!isLocalParticipantModerator(APP.store.getState())) {
  739. logger.error('Missing moderator rights to send participants to rooms');
  740. return;
  741. }
  742. APP.store.dispatch(sendParticipantToRoom(participantId, roomId));
  743. },
  744. 'kick-participant': participantId => {
  745. APP.store.dispatch(kickParticipant(participantId));
  746. },
  747. 'overwrite-config': config => {
  748. const whitelistedConfig = getWhitelistedJSON('config', config);
  749. APP.store.dispatch(overwriteConfig(whitelistedConfig));
  750. },
  751. 'toggle-virtual-background': () => {
  752. APP.store.dispatch(toggleDialog(SettingsDialog, {
  753. defaultTab: SETTINGS_TABS.VIRTUAL_BACKGROUND }));
  754. },
  755. 'end-conference': () => {
  756. APP.store.dispatch(endConference());
  757. const state = APP.store.getState();
  758. const conference = getCurrentConference(state);
  759. if (!conference) {
  760. logger.error('Conference not yet available');
  761. } else if (conference.isEndConferenceSupported()) {
  762. APP.store.dispatch(endConference());
  763. } else {
  764. logger.error(' End Conference not supported');
  765. }
  766. },
  767. 'toggle-whiteboard': () => {
  768. APP.store.dispatch(toggleWhiteboard());
  769. }
  770. };
  771. transport.on('event', ({ data, name }) => {
  772. if (name && commands[name]) {
  773. logger.info(`API command received: ${name}`);
  774. commands[name](...data);
  775. return true;
  776. }
  777. return false;
  778. });
  779. transport.on('request', (request, callback) => {
  780. const { dispatch, getState } = APP.store;
  781. if (processExternalDeviceRequest(dispatch, getState, request, callback)) {
  782. return true;
  783. }
  784. const { name } = request;
  785. switch (name) {
  786. case 'capture-largevideo-screenshot' :
  787. APP.store.dispatch(captureLargeVideoScreenshot())
  788. .then(dataURL => {
  789. let error;
  790. if (!dataURL) {
  791. error = new Error('No large video found!');
  792. }
  793. callback({
  794. error,
  795. dataURL
  796. });
  797. });
  798. break;
  799. case 'deployment-info':
  800. callback(APP.store.getState()['features/base/config'].deploymentInfo);
  801. break;
  802. case 'invite': {
  803. const { invitees } = request;
  804. if (!Array.isArray(invitees) || invitees.length === 0) {
  805. callback({
  806. error: new Error('Unexpected format of invitees')
  807. });
  808. break;
  809. }
  810. // The store should be already available because API.init is called
  811. // on appWillMount action.
  812. APP.store.dispatch(
  813. invite(invitees, true))
  814. .then(failedInvitees => {
  815. let error;
  816. let result;
  817. if (failedInvitees.length) {
  818. error = new Error('One or more invites failed!');
  819. } else {
  820. result = true;
  821. }
  822. callback({
  823. error,
  824. result
  825. });
  826. });
  827. break;
  828. }
  829. case 'is-audio-muted':
  830. callback(APP.conference.isLocalAudioMuted());
  831. break;
  832. case 'is-audio-disabled':
  833. callback(isAudioMuteButtonDisabled(APP.store.getState()));
  834. break;
  835. case 'is-moderation-on': {
  836. const { mediaType } = request;
  837. const type = mediaType || MEDIA_TYPE.AUDIO;
  838. callback(isEnabledFromState(type, APP.store.getState()));
  839. break;
  840. }
  841. case 'is-participant-force-muted': {
  842. const state = APP.store.getState();
  843. const { participantId, mediaType } = request;
  844. const type = mediaType || MEDIA_TYPE.AUDIO;
  845. const participant = getParticipantById(state, participantId);
  846. callback(isForceMuted(participant, type, state));
  847. break;
  848. }
  849. case 'is-participants-pane-open': {
  850. callback(getParticipantsPaneOpen(APP.store.getState()));
  851. break;
  852. }
  853. case 'is-video-muted':
  854. callback(APP.conference.isLocalVideoMuted());
  855. break;
  856. case 'is-audio-available':
  857. callback(audioAvailable);
  858. break;
  859. case 'is-video-available':
  860. callback(videoAvailable);
  861. break;
  862. case 'is-sharing-screen':
  863. callback(Boolean(APP.conference.isSharingScreen));
  864. break;
  865. case 'is-start-silent':
  866. callback(Boolean(APP.store.getState()['features/base/config'].startSilent));
  867. break;
  868. case 'get-content-sharing-participants': {
  869. const sharingParticipantIds = getScreenshareParticipantIds(APP.store.getState());
  870. callback({
  871. sharingParticipantIds
  872. });
  873. break;
  874. }
  875. case 'get-livestream-url': {
  876. const state = APP.store.getState();
  877. const conference = getCurrentConference(state);
  878. let livestreamUrl;
  879. if (conference) {
  880. const activeSession = getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
  881. livestreamUrl = activeSession?.liveStreamViewURL;
  882. } else {
  883. logger.error('Conference is not defined');
  884. }
  885. callback({
  886. livestreamUrl
  887. });
  888. break;
  889. }
  890. case 'get-custom-avatar-backgrounds' : {
  891. callback({
  892. avatarBackgrounds: APP.store.getState()['features/dynamic-branding'].avatarBackgrounds
  893. });
  894. break;
  895. }
  896. case 'list-breakout-rooms': {
  897. callback(getBreakoutRooms(APP.store.getState()));
  898. break;
  899. }
  900. case 'rooms-info': {
  901. callback(getRoomsInfo(APP.store.getState()));
  902. break;
  903. }
  904. case 'get-p2p-status': {
  905. callback(isP2pActive(APP.store.getState()));
  906. break;
  907. }
  908. case 'session-id': {
  909. const { conference } = APP.store.getState()['features/base/conference'];
  910. callback(conference?.getMeetingUniqueId() || '');
  911. break;
  912. }
  913. case '_new_electron_screensharing_supported': {
  914. callback(true);
  915. break;
  916. }
  917. default:
  918. callback({ error: new Error('UnknownRequestError') });
  919. return false;
  920. }
  921. return true;
  922. });
  923. }
  924. /**
  925. * Check whether the API should be enabled or not.
  926. *
  927. * @returns {boolean}
  928. */
  929. function shouldBeEnabled() {
  930. return (
  931. typeof API_ID === 'number'
  932. // XXX Enable the API when a JSON Web Token (JWT) is specified in
  933. // the location/URL because then it is very likely that the Jitsi
  934. // Meet (Web) app is being used by an external/wrapping (Web) app
  935. // and, consequently, the latter will need to communicate with the
  936. // former. (The described logic is merely a heuristic though.)
  937. || parseJWTFromURLParams());
  938. }
  939. /**
  940. * Executes on toggle-share-screen command.
  941. *
  942. * @param {boolean} [enable] - Whether this toggle is to explicitly enable or
  943. * disable screensharing. If not defined, the application will automatically
  944. * attempt to toggle between enabled and disabled. This boolean is useful for
  945. * explicitly setting desired screensharing state.
  946. * @returns {void}
  947. */
  948. function toggleScreenSharing(enable) {
  949. if (JitsiMeetJS.isDesktopSharingEnabled()) {
  950. APP.store.dispatch(startScreenShareFlow(enable));
  951. }
  952. }
  953. /**
  954. * Removes sensitive data from a mouse event.
  955. *
  956. * @param {MouseEvent} event - The mouse event to sanitize.
  957. * @returns {Object}
  958. */
  959. function sanitizeMouseEvent(event) {
  960. const {
  961. clientX,
  962. clientY,
  963. movementX,
  964. movementY,
  965. offsetX,
  966. offsetY,
  967. pageX,
  968. pageY,
  969. x,
  970. y,
  971. screenX,
  972. screenY
  973. } = event;
  974. return {
  975. clientX,
  976. clientY,
  977. movementX,
  978. movementY,
  979. offsetX,
  980. offsetY,
  981. pageX,
  982. pageY,
  983. x,
  984. y,
  985. screenX,
  986. screenY
  987. };
  988. }
  989. /**
  990. * Implements API class that communicates with external API class and provides
  991. * interface to access Jitsi Meet features by external applications that embed
  992. * Jitsi Meet.
  993. */
  994. class API {
  995. _enabled;
  996. /**
  997. * Initializes the API. Setups message event listeners that will receive
  998. * information from external applications that embed Jitsi Meet. It also
  999. * sends a message to the external application that API is initialized.
  1000. *
  1001. * @param {Object} options - Optional parameters.
  1002. * @returns {void}
  1003. */
  1004. init() {
  1005. if (!shouldBeEnabled()) {
  1006. return;
  1007. }
  1008. /**
  1009. * Current status (enabled/disabled) of API.
  1010. *
  1011. * @private
  1012. * @type {boolean}
  1013. */
  1014. this._enabled = true;
  1015. initCommands();
  1016. this.notifyBrowserSupport(isSupportedBrowser());
  1017. // Let the embedder know we are ready.
  1018. this._sendEvent({ name: 'ready' });
  1019. }
  1020. /**
  1021. * Notify external application (if API is enabled) that the large video
  1022. * visibility changed.
  1023. *
  1024. * @param {boolean} isHidden - True if the large video is hidden and false
  1025. * otherwise.
  1026. * @returns {void}
  1027. */
  1028. notifyLargeVideoVisibilityChanged(isHidden) {
  1029. this._sendEvent({
  1030. name: 'large-video-visibility-changed',
  1031. isVisible: !isHidden
  1032. });
  1033. }
  1034. /**
  1035. * Notifies the external application (spot) that the local jitsi-participant
  1036. * has a status update.
  1037. *
  1038. * @param {Object} event - The message to pass onto spot.
  1039. * @returns {void}
  1040. */
  1041. sendProxyConnectionEvent(event) {
  1042. this._sendEvent({
  1043. name: 'proxy-connection-event',
  1044. ...event
  1045. });
  1046. }
  1047. /**
  1048. * Sends event to the external application.
  1049. *
  1050. * @param {Object} event - The event to be sent.
  1051. * @returns {void}
  1052. */
  1053. _sendEvent(event = {}) {
  1054. if (this._enabled) {
  1055. try {
  1056. transport.sendEvent(event);
  1057. } catch (error) {
  1058. logger.error('Failed to send and IFrame API event', error);
  1059. }
  1060. }
  1061. }
  1062. /**
  1063. * Notify external application (if API is enabled) that the chat state has been updated.
  1064. *
  1065. * @param {number} unreadCount - The unread messages counter.
  1066. * @param {boolean} isOpen - True if the chat panel is open.
  1067. * @returns {void}
  1068. */
  1069. notifyChatUpdated(unreadCount, isOpen) {
  1070. this._sendEvent({
  1071. name: 'chat-updated',
  1072. unreadCount,
  1073. isOpen
  1074. });
  1075. }
  1076. /**
  1077. * Notify external application (if API is enabled) that message was sent.
  1078. *
  1079. * @param {string} message - Message body.
  1080. * @param {boolean} privateMessage - True if the message was a private message.
  1081. * @returns {void}
  1082. */
  1083. notifySendingChatMessage(message, privateMessage) {
  1084. this._sendEvent({
  1085. name: 'outgoing-message',
  1086. message,
  1087. privateMessage
  1088. });
  1089. }
  1090. /**
  1091. * Notify external application (if API is enabled) that the mouse has entered inside the iframe.
  1092. *
  1093. * @param {MouseEvent} event - The mousemove event.
  1094. * @returns {void}
  1095. */
  1096. notifyMouseEnter(event) {
  1097. this._sendEvent({
  1098. name: 'mouse-enter',
  1099. event: sanitizeMouseEvent(event)
  1100. });
  1101. }
  1102. /**
  1103. * Notify external application (if API is enabled) that the mouse has entered inside the iframe.
  1104. *
  1105. * @param {MouseEvent} event - The mousemove event.
  1106. * @returns {void}
  1107. */
  1108. notifyMouseLeave(event) {
  1109. this._sendEvent({
  1110. name: 'mouse-leave',
  1111. event: sanitizeMouseEvent(event)
  1112. });
  1113. }
  1114. /**
  1115. * Notify external application (if API is enabled) that the mouse has moved inside the iframe.
  1116. *
  1117. * @param {MouseEvent} event - The mousemove event.
  1118. * @returns {void}
  1119. */
  1120. notifyMouseMove(event) {
  1121. this._sendEvent({
  1122. name: 'mouse-move',
  1123. event: sanitizeMouseEvent(event)
  1124. });
  1125. }
  1126. /**
  1127. * Notify the external application that the moderation status has changed.
  1128. *
  1129. * @param {string} mediaType - Media type for which the moderation changed.
  1130. * @param {boolean} enabled - Whether or not the new moderation status is enabled.
  1131. * @returns {void}
  1132. */
  1133. notifyModerationChanged(mediaType, enabled) {
  1134. this._sendEvent({
  1135. name: 'moderation-status-changed',
  1136. mediaType,
  1137. enabled
  1138. });
  1139. }
  1140. /**
  1141. * Notify the external application that a participant was approved on moderation.
  1142. *
  1143. * @param {string} participantId - The ID of the participant that got approved.
  1144. * @param {string} mediaType - Media type for which the participant was approved.
  1145. * @returns {void}
  1146. */
  1147. notifyParticipantApproved(participantId, mediaType) {
  1148. this._sendEvent({
  1149. name: 'moderation-participant-approved',
  1150. id: participantId,
  1151. mediaType
  1152. });
  1153. }
  1154. /**
  1155. * Notify the external application that a participant was rejected on moderation.
  1156. *
  1157. * @param {string} participantId - The ID of the participant that got rejected.
  1158. * @param {string} mediaType - Media type for which the participant was rejected.
  1159. * @returns {void}
  1160. */
  1161. notifyParticipantRejected(participantId, mediaType) {
  1162. this._sendEvent({
  1163. name: 'moderation-participant-rejected',
  1164. id: participantId,
  1165. mediaType
  1166. });
  1167. }
  1168. /**
  1169. * Notify the external app that a notification has been triggered.
  1170. *
  1171. * @param {string} title - The notification title.
  1172. * @param {string} description - The notification description.
  1173. *
  1174. * @returns {void}
  1175. */
  1176. notifyNotificationTriggered(title, description) {
  1177. this._sendEvent({
  1178. description,
  1179. name: 'notification-triggered',
  1180. title
  1181. });
  1182. }
  1183. /**
  1184. * Notify request desktop sources.
  1185. *
  1186. * @param {Object} options - Object with the options for desktop sources.
  1187. * @returns {void}
  1188. */
  1189. requestDesktopSources(options) {
  1190. return transport.sendRequest({
  1191. name: '_request-desktop-sources',
  1192. options
  1193. });
  1194. }
  1195. /**
  1196. * Notify external application that the video quality setting has changed.
  1197. *
  1198. * @param {number} videoQuality - The video quality. The number represents the maximum height of the video streams.
  1199. * @returns {void}
  1200. */
  1201. notifyVideoQualityChanged(videoQuality) {
  1202. this._sendEvent({
  1203. name: 'video-quality-changed',
  1204. videoQuality
  1205. });
  1206. }
  1207. /**
  1208. * Notify external application (if API is enabled) that message was
  1209. * received.
  1210. *
  1211. * @param {Object} options - Object with the message properties.
  1212. * @returns {void}
  1213. */
  1214. notifyReceivedChatMessage(
  1215. { body, from, nick, privateMessage, ts } = {}) {
  1216. if (APP.conference.isLocalId(from)) {
  1217. return;
  1218. }
  1219. this._sendEvent({
  1220. name: 'incoming-message',
  1221. from,
  1222. message: body,
  1223. nick,
  1224. privateMessage,
  1225. stamp: ts
  1226. });
  1227. }
  1228. /**
  1229. * Notify external application (if API is enabled) that user joined the
  1230. * conference.
  1231. *
  1232. * @param {string} id - User id.
  1233. * @param {Object} props - The display name of the user.
  1234. * @returns {void}
  1235. */
  1236. notifyUserJoined(id, props) {
  1237. this._sendEvent({
  1238. name: 'participant-joined',
  1239. id,
  1240. ...props
  1241. });
  1242. }
  1243. /**
  1244. * Notify external application (if API is enabled) that user left the
  1245. * conference.
  1246. *
  1247. * @param {string} id - User id.
  1248. * @returns {void}
  1249. */
  1250. notifyUserLeft(id) {
  1251. this._sendEvent({
  1252. name: 'participant-left',
  1253. id
  1254. });
  1255. }
  1256. /**
  1257. * Notify external application (if API is enabled) that the user role
  1258. * has changed.
  1259. *
  1260. * @param {string} id - User id.
  1261. * @param {string} role - The new user role.
  1262. * @returns {void}
  1263. */
  1264. notifyUserRoleChanged(id, role) {
  1265. this._sendEvent({
  1266. name: 'participant-role-changed',
  1267. id,
  1268. role
  1269. });
  1270. }
  1271. /**
  1272. * Notify external application (if API is enabled) that user changed their
  1273. * avatar.
  1274. *
  1275. * @param {string} id - User id.
  1276. * @param {string} avatarURL - The new avatar URL of the participant.
  1277. * @returns {void}
  1278. */
  1279. notifyAvatarChanged(id, avatarURL) {
  1280. this._sendEvent({
  1281. name: 'avatar-changed',
  1282. avatarURL,
  1283. id
  1284. });
  1285. }
  1286. /**
  1287. * Notify external application (if API is enabled) that user received
  1288. * a text message through datachannels.
  1289. *
  1290. * @param {Object} data - The event data.
  1291. * @returns {void}
  1292. */
  1293. notifyEndpointTextMessageReceived(data) {
  1294. this._sendEvent({
  1295. name: 'endpoint-text-message-received',
  1296. data
  1297. });
  1298. }
  1299. /**
  1300. * Notify external application (if API is enabled) that some face landmark data is available.
  1301. *
  1302. * @param {Object | undefined} faceBox - Detected face(s) bounding box (left, right, width).
  1303. * @param {string} faceExpression - Detected face expression.
  1304. * @returns {void}
  1305. */
  1306. notifyFaceLandmarkDetected(faceBox, faceExpression) {
  1307. this._sendEvent({
  1308. name: 'face-landmark-detected',
  1309. faceBox,
  1310. faceExpression
  1311. });
  1312. }
  1313. /**
  1314. * Notify external application (if API is enabled) that the list of sharing participants changed.
  1315. *
  1316. * @param {Object} data - The event data.
  1317. * @returns {void}
  1318. */
  1319. notifySharingParticipantsChanged(data) {
  1320. this._sendEvent({
  1321. name: 'content-sharing-participants-changed',
  1322. data
  1323. });
  1324. }
  1325. /**
  1326. * Notify external application (if API is enabled) that the device list has
  1327. * changed.
  1328. *
  1329. * @param {Object} devices - The new device list.
  1330. * @returns {void}
  1331. */
  1332. notifyDeviceListChanged(devices) {
  1333. this._sendEvent({
  1334. name: 'device-list-changed',
  1335. devices
  1336. });
  1337. }
  1338. /**
  1339. * Notify external application (if API is enabled) that user changed their
  1340. * nickname.
  1341. *
  1342. * @param {string} id - User id.
  1343. * @param {string} displayname - User nickname.
  1344. * @param {string} formattedDisplayName - The display name shown in Jitsi
  1345. * meet's UI for the user.
  1346. * @returns {void}
  1347. */
  1348. notifyDisplayNameChanged(
  1349. id,
  1350. { displayName, formattedDisplayName }) {
  1351. this._sendEvent({
  1352. name: 'display-name-change',
  1353. displayname: displayName,
  1354. formattedDisplayName,
  1355. id
  1356. });
  1357. }
  1358. /**
  1359. * Notify external application (if API is enabled) that user changed their
  1360. * email.
  1361. *
  1362. * @param {string} id - User id.
  1363. * @param {string} email - The new email of the participant.
  1364. * @returns {void}
  1365. */
  1366. notifyEmailChanged(
  1367. id,
  1368. { email }) {
  1369. this._sendEvent({
  1370. name: 'email-change',
  1371. email,
  1372. id
  1373. });
  1374. }
  1375. /**
  1376. * Notify external application (if API is enabled) that the an error has been logged.
  1377. *
  1378. * @param {string} logLevel - The message log level.
  1379. * @param {Array<string>} args - Array of strings composing the log message.
  1380. * @returns {void}
  1381. */
  1382. notifyLog(logLevel, args = []) {
  1383. if (!Array.isArray(args)) {
  1384. logger.error('notifyLog received wrong argument types!');
  1385. return;
  1386. }
  1387. // Trying to convert arguments to strings. Otherwise in order to send the event the arguments will be formatted
  1388. // with JSON.stringify which can throw an error because of circular objects and we will lose the whole log.
  1389. const formattedArguments = [];
  1390. args.forEach(arg => {
  1391. let formattedArgument = '';
  1392. if (arg instanceof Error) {
  1393. formattedArgument += `${arg.toString()}: ${arg.stack}`;
  1394. } else if (typeof arg === 'object') {
  1395. // NOTE: The non-enumerable properties of the objects wouldn't be included in the string after
  1396. // JSON.strigify. For example Map instance will be translated to '{}'. So I think we have to eventually
  1397. // do something better for parsing the arguments. But since this option for strigify is part of the
  1398. // public interface and I think it could be useful in some cases I will it for now.
  1399. try {
  1400. formattedArgument += JSON.stringify(arg);
  1401. } catch (error) {
  1402. formattedArgument += arg;
  1403. }
  1404. } else {
  1405. formattedArgument += arg;
  1406. }
  1407. formattedArguments.push(formattedArgument);
  1408. });
  1409. this._sendEvent({
  1410. name: 'log',
  1411. logLevel,
  1412. args: formattedArguments
  1413. });
  1414. }
  1415. /**
  1416. * Notify external application (if API is enabled) that the conference has
  1417. * been joined.
  1418. *
  1419. * @param {string} roomName - The room name.
  1420. * @param {string} id - The id of the local user.
  1421. * @param {Object} props - The display name, the avatar URL of the local
  1422. * user and the type of the room.
  1423. * @returns {void}
  1424. */
  1425. notifyConferenceJoined(roomName, id, props) {
  1426. this._sendEvent({
  1427. name: 'video-conference-joined',
  1428. roomName,
  1429. id,
  1430. ...props
  1431. });
  1432. }
  1433. /**
  1434. * Notify external application (if API is enabled) that local user has left the conference.
  1435. *
  1436. * @param {string} roomName - User id.
  1437. * @returns {void}
  1438. */
  1439. notifyConferenceLeft(roomName) {
  1440. this._sendEvent({
  1441. name: 'video-conference-left',
  1442. roomName
  1443. });
  1444. }
  1445. /**
  1446. * Notify external application that the data channel has been closed.
  1447. *
  1448. * @param {number} code - The close code.
  1449. * @param {string} reason - The close reason.
  1450. *
  1451. * @returns {void}
  1452. */
  1453. notifyDataChannelClosed(code, reason) {
  1454. this._sendEvent({
  1455. name: 'data-channel-closed',
  1456. code,
  1457. reason
  1458. });
  1459. }
  1460. /**
  1461. * Notify external application that the data channel has been opened.
  1462. *
  1463. * @returns {void}
  1464. */
  1465. notifyDataChannelOpened() {
  1466. this._sendEvent({ name: 'data-channel-opened' });
  1467. }
  1468. /**
  1469. * Notify external application (if API is enabled) that we are ready to be
  1470. * closed.
  1471. *
  1472. * @returns {void}
  1473. */
  1474. notifyReadyToClose() {
  1475. this._sendEvent({ name: 'video-ready-to-close' });
  1476. }
  1477. /**
  1478. * Notify external application (if API is enabled) that a suspend event in host computer.
  1479. *
  1480. * @returns {void}
  1481. */
  1482. notifySuspendDetected() {
  1483. this._sendEvent({ name: 'suspend-detected' });
  1484. }
  1485. /**
  1486. * Notify external application (if API is enabled) for audio muted status
  1487. * changed.
  1488. *
  1489. * @param {boolean} muted - The new muted status.
  1490. * @returns {void}
  1491. */
  1492. notifyAudioMutedStatusChanged(muted) {
  1493. this._sendEvent({
  1494. name: 'audio-mute-status-changed',
  1495. muted
  1496. });
  1497. }
  1498. /**
  1499. * Notify external application (if API is enabled) for video muted status
  1500. * changed.
  1501. *
  1502. * @param {boolean} muted - The new muted status.
  1503. * @returns {void}
  1504. */
  1505. notifyVideoMutedStatusChanged(muted) {
  1506. this._sendEvent({
  1507. name: 'video-mute-status-changed',
  1508. muted
  1509. });
  1510. }
  1511. /**
  1512. * Notify external application (if API is enabled) for audio availability
  1513. * changed.
  1514. *
  1515. * @param {boolean} available - True if available and false otherwise.
  1516. * @returns {void}
  1517. */
  1518. notifyAudioAvailabilityChanged(available) {
  1519. audioAvailable = available;
  1520. this._sendEvent({
  1521. name: 'audio-availability-changed',
  1522. available
  1523. });
  1524. }
  1525. /**
  1526. * Notify external application (if API is enabled) for video available
  1527. * status changed.
  1528. *
  1529. * @param {boolean} available - True if available and false otherwise.
  1530. * @returns {void}
  1531. */
  1532. notifyVideoAvailabilityChanged(available) {
  1533. videoAvailable = available;
  1534. this._sendEvent({
  1535. name: 'video-availability-changed',
  1536. available
  1537. });
  1538. }
  1539. /**
  1540. * Notify external application (if API is enabled) that the on stage
  1541. * participant has changed.
  1542. *
  1543. * @param {string} id - User id of the new on stage participant.
  1544. * @returns {void}
  1545. */
  1546. notifyOnStageParticipantChanged(id) {
  1547. this._sendEvent({
  1548. name: 'on-stage-participant-changed',
  1549. id
  1550. });
  1551. }
  1552. /**
  1553. * Notify external application (if API is enabled) that the prejoin video
  1554. * visibility had changed.
  1555. *
  1556. * @param {boolean} isVisible - Whether the prejoin video is visible.
  1557. * @returns {void}
  1558. */
  1559. notifyPrejoinVideoVisibilityChanged(isVisible) {
  1560. this._sendEvent({
  1561. name: 'on-prejoin-video-changed',
  1562. isVisible
  1563. });
  1564. }
  1565. /**
  1566. * Notify external application (if API is enabled) that the prejoin
  1567. * screen was loaded.
  1568. *
  1569. * @returns {void}
  1570. */
  1571. notifyPrejoinLoaded() {
  1572. const state = APP.store.getState();
  1573. const { defaultLocalDisplayName } = state['features/base/config'];
  1574. const displayName = getDisplayName(state);
  1575. this._sendEvent({
  1576. name: 'prejoin-screen-loaded',
  1577. id: LOCAL_PARTICIPANT_DEFAULT_ID,
  1578. displayName,
  1579. formattedDisplayName: appendSuffix(displayName, defaultLocalDisplayName)
  1580. });
  1581. }
  1582. /**
  1583. * Notify external application of an unexpected camera-related error having
  1584. * occurred.
  1585. *
  1586. * @param {string} type - The type of the camera error.
  1587. * @param {string} message - Additional information about the error.
  1588. * @returns {void}
  1589. */
  1590. notifyOnCameraError(type, message) {
  1591. this._sendEvent({
  1592. name: 'camera-error',
  1593. type,
  1594. message
  1595. });
  1596. }
  1597. /**
  1598. * Notify external application of an unexpected mic-related error having
  1599. * occurred.
  1600. *
  1601. * @param {string} type - The type of the mic error.
  1602. * @param {string} message - Additional information about the error.
  1603. * @returns {void}
  1604. */
  1605. notifyOnMicError(type, message) {
  1606. this._sendEvent({
  1607. name: 'mic-error',
  1608. type,
  1609. message
  1610. });
  1611. }
  1612. /**
  1613. * Notify external application (if API is enabled) that conference feedback
  1614. * has been submitted. Intended to be used in conjunction with the
  1615. * submit-feedback command to get notified if feedback was submitted.
  1616. *
  1617. * @param {string} error - A failure message, if any.
  1618. * @returns {void}
  1619. */
  1620. notifyFeedbackSubmitted(error) {
  1621. this._sendEvent({
  1622. name: 'feedback-submitted',
  1623. error
  1624. });
  1625. }
  1626. /**
  1627. * Notify external application (if API is enabled) that the feedback prompt
  1628. * has been displayed.
  1629. *
  1630. * @returns {void}
  1631. */
  1632. notifyFeedbackPromptDisplayed() {
  1633. this._sendEvent({ name: 'feedback-prompt-displayed' });
  1634. }
  1635. /**
  1636. * Notify external application (if API is enabled) that the display
  1637. * configuration of the filmstrip has been changed.
  1638. *
  1639. * @param {boolean} visible - Whether or not the filmstrip has been set to
  1640. * be displayed or hidden.
  1641. * @returns {void}
  1642. */
  1643. notifyFilmstripDisplayChanged(visible) {
  1644. this._sendEvent({
  1645. name: 'filmstrip-display-changed',
  1646. visible
  1647. });
  1648. }
  1649. /**
  1650. * Notify external application of a participant, remote or local, being
  1651. * removed from the conference by another participant.
  1652. *
  1653. * @param {Object} kicked - The participant removed from the
  1654. * conference.
  1655. * @param {Object} kicker - The participant that removed the
  1656. * other participant.
  1657. * @returns {void}
  1658. */
  1659. notifyKickedOut(kicked, kicker) {
  1660. this._sendEvent({
  1661. name: 'participant-kicked-out',
  1662. kicked,
  1663. kicker
  1664. });
  1665. }
  1666. /**
  1667. * Notify external application of the current meeting requiring a password
  1668. * to join.
  1669. *
  1670. * @returns {void}
  1671. */
  1672. notifyOnPasswordRequired() {
  1673. this._sendEvent({ name: 'password-required' });
  1674. }
  1675. /**
  1676. * Notify external application (if API is enabled) that the screen sharing
  1677. * has been turned on/off.
  1678. *
  1679. * @param {boolean} on - True if screen sharing is enabled.
  1680. * @param {Object} details - Additional information about the screen
  1681. * sharing.
  1682. * @param {string} details.sourceType - Type of device or window the screen
  1683. * share is capturing.
  1684. * @returns {void}
  1685. */
  1686. notifyScreenSharingStatusChanged(on, details) {
  1687. this._sendEvent({
  1688. name: 'screen-sharing-status-changed',
  1689. on,
  1690. details
  1691. });
  1692. }
  1693. /**
  1694. * Notify external application (if API is enabled) that the dominant speaker
  1695. * has been turned on/off.
  1696. *
  1697. * @param {string} id - Id of the dominant participant.
  1698. * @returns {void}
  1699. */
  1700. notifyDominantSpeakerChanged(id) {
  1701. this._sendEvent({
  1702. name: 'dominant-speaker-changed',
  1703. id
  1704. });
  1705. }
  1706. /**
  1707. * Notify external application (if API is enabled) that the conference
  1708. * changed their subject.
  1709. *
  1710. * @param {string} subject - Conference subject.
  1711. * @returns {void}
  1712. */
  1713. notifySubjectChanged(subject) {
  1714. this._sendEvent({
  1715. name: 'subject-change',
  1716. subject
  1717. });
  1718. }
  1719. /**
  1720. * Notify external application (if API is enabled) that tile view has been
  1721. * entered or exited.
  1722. *
  1723. * @param {string} enabled - True if tile view is currently displayed, false
  1724. * otherwise.
  1725. * @returns {void}
  1726. */
  1727. notifyTileViewChanged(enabled) {
  1728. this._sendEvent({
  1729. name: 'tile-view-changed',
  1730. enabled
  1731. });
  1732. }
  1733. /**
  1734. * Notify external application (if API is enabled) that the localStorage has changed.
  1735. *
  1736. * @param {string} localStorageContent - The new localStorageContent.
  1737. * @returns {void}
  1738. */
  1739. notifyLocalStorageChanged(localStorageContent) {
  1740. this._sendEvent({
  1741. name: 'local-storage-changed',
  1742. localStorageContent
  1743. });
  1744. }
  1745. /**
  1746. * Notify external application (if API is enabled) that user updated their hand raised.
  1747. *
  1748. * @param {string} id - User id.
  1749. * @param {boolean} handRaised - Whether user has raised hand.
  1750. * @returns {void}
  1751. */
  1752. notifyRaiseHandUpdated(id, handRaised) {
  1753. this._sendEvent({
  1754. name: 'raise-hand-updated',
  1755. handRaised,
  1756. id
  1757. });
  1758. }
  1759. /**
  1760. * Notify external application (if API is enabled) that recording has started or stopped.
  1761. *
  1762. * @param {boolean} on - True if recording is on, false otherwise.
  1763. * @param {string} mode - Stream or file or local.
  1764. * @param {string} error - Error type or null if success.
  1765. * @param {boolean} transcription - True if a transcription is being recorded, false otherwise.
  1766. * @returns {void}
  1767. */
  1768. notifyRecordingStatusChanged(on, mode, error, transcription) {
  1769. this._sendEvent({
  1770. name: 'recording-status-changed',
  1771. on,
  1772. mode,
  1773. error,
  1774. transcription
  1775. });
  1776. }
  1777. /**
  1778. * Notify external application (if API is enabled) that the current recording link is
  1779. * available.
  1780. *
  1781. * @param {string} link - The recording download link.
  1782. * @param {number} ttl - The recording download link time to live.
  1783. * @returns {void}
  1784. */
  1785. notifyRecordingLinkAvailable(link, ttl) {
  1786. this._sendEvent({
  1787. name: 'recording-link-available',
  1788. link,
  1789. ttl
  1790. });
  1791. }
  1792. /**
  1793. * Notify external application (if API is enabled) that a participant is knocking in the lobby.
  1794. *
  1795. * @param {Object} participant - Participant data such as id and name.
  1796. * @returns {void}
  1797. */
  1798. notifyKnockingParticipant(participant) {
  1799. this._sendEvent({
  1800. name: 'knocking-participant',
  1801. participant
  1802. });
  1803. }
  1804. /**
  1805. * Notify external application (if API is enabled) that an error occurred.
  1806. *
  1807. * @param {Object} error - The error.
  1808. * @returns {void}
  1809. */
  1810. notifyError(error) {
  1811. this._sendEvent({
  1812. name: 'error-occurred',
  1813. error
  1814. });
  1815. }
  1816. /**
  1817. * Notify external application ( if API is enabled) that a toolbar button was clicked.
  1818. *
  1819. * @param {string} key - The key of the toolbar button.
  1820. * @param {boolean} preventExecution - Whether execution of the button click was prevented or not.
  1821. * @returns {void}
  1822. */
  1823. notifyToolbarButtonClicked(key, preventExecution) {
  1824. this._sendEvent({
  1825. name: 'toolbar-button-clicked',
  1826. key,
  1827. preventExecution
  1828. });
  1829. }
  1830. /**
  1831. * Notify external application (if API is enabled) that transcribing has started or stopped.
  1832. *
  1833. * @param {boolean} on - True if transcribing is on, false otherwise.
  1834. * @returns {void}
  1835. */
  1836. notifyTranscribingStatusChanged(on) {
  1837. this._sendEvent({
  1838. name: 'transcribing-status-changed',
  1839. on
  1840. });
  1841. }
  1842. /**
  1843. * Notify external application (if API is enabled) that the user received
  1844. * a transcription chunk.
  1845. *
  1846. * @param {Object} data - The event data.
  1847. * @returns {void}
  1848. */
  1849. notifyTranscriptionChunkReceived(data) {
  1850. this._sendEvent({
  1851. name: 'transcription-chunk-received',
  1852. data
  1853. });
  1854. }
  1855. /**
  1856. * Notify external application (if API is enabled) whether the used browser is supported or not.
  1857. *
  1858. * @param {boolean} supported - If browser is supported or not.
  1859. * @returns {void}
  1860. */
  1861. notifyBrowserSupport(supported) {
  1862. this._sendEvent({
  1863. name: 'browser-support',
  1864. supported
  1865. });
  1866. }
  1867. /**
  1868. * Notify external application that the breakout rooms changed.
  1869. *
  1870. * @param {Array} rooms - Array containing the breakout rooms and main room.
  1871. * @returns {void}
  1872. */
  1873. notifyBreakoutRoomsUpdated(rooms) {
  1874. this._sendEvent({
  1875. name: 'breakout-rooms-updated',
  1876. rooms
  1877. });
  1878. }
  1879. /**
  1880. * Notify the external application that the state of the participants pane changed.
  1881. *
  1882. * @param {boolean} open - Whether the panel is open or not.
  1883. * @returns {void}
  1884. */
  1885. notifyParticipantsPaneToggled(open) {
  1886. this._sendEvent({
  1887. name: 'participants-pane-toggled',
  1888. open
  1889. });
  1890. }
  1891. /**
  1892. * Notify the external application that the audio or video is being shared by a participant.
  1893. *
  1894. * @param {string} mediaType - Whether the content which is being shared is audio or video.
  1895. * @param {string} value - Whether the sharing is playing, pause or stop (on audio there is only playing and stop).
  1896. * @param {string} participantId - Participant id of the participant which started or ended
  1897. * the video or audio sharing.
  1898. * @returns {void}
  1899. */
  1900. notifyAudioOrVideoSharingToggled(mediaType, value, participantId) {
  1901. this._sendEvent({
  1902. name: 'audio-or-video-sharing-toggled',
  1903. mediaType,
  1904. value,
  1905. participantId
  1906. });
  1907. }
  1908. /**
  1909. * Notify the external application that a PeerConnection lost connectivity. This event is fired only if
  1910. * a PC `failed` but connectivity to the rtcstats server is still maintained signaling that there is a
  1911. * problem establishing a link between the app and the JVB server or the remote peer in case of P2P.
  1912. * Will only fire if rtcstats is enabled.
  1913. *
  1914. * @param {boolean} isP2P - Type of PC.
  1915. * @param {boolean} wasConnected - Was this connection previously connected. If it was it could mean
  1916. * that connectivity was disrupted, if not it most likely means that the app could not reach
  1917. * the JVB server, or the other peer in case of P2P.
  1918. *
  1919. * @returns {void}
  1920. */
  1921. notifyPeerConnectionFailure(isP2P, wasConnected) {
  1922. this._sendEvent({
  1923. name: 'peer-connection-failure',
  1924. isP2P,
  1925. wasConnected
  1926. });
  1927. }
  1928. /**
  1929. * Notify external application ( if API is enabled) that a participant menu button was clicked.
  1930. *
  1931. * @param {string} key - The key of the participant menu button.
  1932. * @param {string} participantId - The ID of the participant for whom the participant menu button was clicked.
  1933. * @param {boolean} preventExecution - Whether execution of the button click was prevented or not.
  1934. * @returns {void}
  1935. */
  1936. notifyParticipantMenuButtonClicked(key, participantId, preventExecution) {
  1937. this._sendEvent({
  1938. name: 'participant-menu-button-clicked',
  1939. key,
  1940. participantId,
  1941. preventExecution
  1942. });
  1943. }
  1944. /**
  1945. * Notify external application (if API is enabled) if whiteboard state is
  1946. * changed.
  1947. *
  1948. * @param {WhiteboardStatus} status - The new whiteboard status.
  1949. * @returns {void}
  1950. */
  1951. notifyWhiteboardStatusChanged(status) {
  1952. this._sendEvent({
  1953. name: 'whiteboard-status-changed',
  1954. status
  1955. });
  1956. }
  1957. /**
  1958. * Notify external application (if API is enabled) if non participant message
  1959. * is received.
  1960. *
  1961. * @param {string} id - The resource id of the sender.
  1962. * @param {Object} json - The json carried by the message.
  1963. * @returns {void}
  1964. */
  1965. notifyNonParticipantMessageReceived(id, json) {
  1966. this._sendEvent({
  1967. name: 'non-participant-message-received',
  1968. id,
  1969. message: json
  1970. });
  1971. }
  1972. /**
  1973. * Notify external application (if API is enabled) the conference
  1974. * start time.
  1975. *
  1976. * @param {number} timestamp - Timestamp conference was created.
  1977. * @returns {void}
  1978. */
  1979. notifyConferenceCreatedTimestamp(timestamp) {
  1980. this._sendEvent({
  1981. name: 'conference-created-timestamp',
  1982. timestamp
  1983. });
  1984. }
  1985. /**
  1986. * Notify the external application (if API is enabled) if the connection type changed.
  1987. *
  1988. * @param {boolean} isP2p - Whether the new connection is P2P.
  1989. * @returns {void}
  1990. */
  1991. notifyP2pStatusChanged(isP2p) {
  1992. this._sendEvent({
  1993. name: 'p2p-status-changed',
  1994. isP2p
  1995. });
  1996. }
  1997. /**
  1998. * Notify the external application (if API is enabled) when the compute pressure changed.
  1999. *
  2000. * @param {Array} records - The new pressure records.
  2001. * @returns {void}
  2002. */
  2003. notifyComputePressureChanged(records) {
  2004. this._sendEvent({
  2005. name: 'compute-pressure-changed',
  2006. records
  2007. });
  2008. }
  2009. /**
  2010. * Notify the external application (if API is enabled) when the audio only enabled status changed.
  2011. *
  2012. * @param {boolean} enabled - Whether the audio only is enabled or not.
  2013. * @returns {void}
  2014. */
  2015. notifyAudioOnlyChanged(enabled) {
  2016. this._sendEvent({
  2017. name: 'audio-only-changed',
  2018. enabled
  2019. });
  2020. }
  2021. /**
  2022. * Disposes the allocated resources.
  2023. *
  2024. * @returns {void}
  2025. */
  2026. dispose() {
  2027. if (this._enabled) {
  2028. this._enabled = false;
  2029. }
  2030. }
  2031. }
  2032. export default new API();