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.

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