Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

API.js 71KB

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