12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292 |
- // @flow
-
- import Logger from 'jitsi-meet-logger';
-
- import {
- createApiEvent,
- sendAnalytics
- } from '../../react/features/analytics';
- import {
- getCurrentConference,
- sendTones,
- setPassword,
- setSubject
- } from '../../react/features/base/conference';
- import { overwriteConfig, getWhitelistedJSON } from '../../react/features/base/config';
- import { parseJWTFromURLParams } from '../../react/features/base/jwt';
- import JitsiMeetJS, { JitsiRecordingConstants } from '../../react/features/base/lib-jitsi-meet';
- import { MEDIA_TYPE } from '../../react/features/base/media';
- import {
- getLocalParticipant,
- getParticipantById,
- participantUpdated,
- pinParticipant,
- kickParticipant
- } from '../../react/features/base/participants';
- import { updateSettings } from '../../react/features/base/settings';
- import { isToggleCameraEnabled, toggleCamera } from '../../react/features/base/tracks';
- import {
- setPrivateMessageRecipient,
- toggleChat
- } from '../../react/features/chat/actions';
- import { openChat } from '../../react/features/chat/actions.web';
- import {
- processExternalDeviceRequest
- } from '../../react/features/device-selection/functions';
- import { isEnabled as isDropboxEnabled } from '../../react/features/dropbox';
- import { toggleE2EE } from '../../react/features/e2ee/actions';
- import { invite } from '../../react/features/invite';
- import {
- selectParticipantInLargeVideo
- } from '../../react/features/large-video/actions.any';
- import {
- captureLargeVideoScreenshot,
- resizeLargeVideo
- } from '../../react/features/large-video/actions.web';
- import { toggleLobbyMode } from '../../react/features/lobby/actions';
- import { RECORDING_TYPES } from '../../react/features/recording/constants';
- import { getActiveSession } from '../../react/features/recording/functions';
- import { playSharedVideo, stopSharedVideo } from '../../react/features/shared-video/actions.any';
- import { toggleTileView, setTileView } from '../../react/features/video-layout';
- import { muteAllParticipants } from '../../react/features/video-menu/actions';
- import { setVideoQuality } from '../../react/features/video-quality';
- import { getJitsiMeetTransport } from '../transport';
-
- import { API_ID, ENDPOINT_TEXT_MESSAGE_NAME } from './constants';
-
- const logger = Logger.getLogger(__filename);
-
- declare var APP: Object;
-
- /**
- * List of the available commands.
- */
- let commands = {};
-
- /**
- * The transport instance used for communication with external apps.
- *
- * @type {Transport}
- */
- const transport = getJitsiMeetTransport();
-
- /**
- * The current audio availability.
- *
- * @type {boolean}
- */
- let audioAvailable = true;
-
- /**
- * The current video availability.
- *
- * @type {boolean}
- */
- let videoAvailable = true;
-
- /**
- * Initializes supported commands.
- *
- * @returns {void}
- */
- function initCommands() {
- commands = {
- 'display-name': displayName => {
- sendAnalytics(createApiEvent('display.name.changed'));
- APP.conference.changeLocalDisplayName(displayName);
- },
- 'mute-everyone': mediaType => {
- const muteMediaType = mediaType ? mediaType : MEDIA_TYPE.AUDIO;
-
- sendAnalytics(createApiEvent('muted-everyone'));
- const participants = APP.store.getState()['features/base/participants'];
- const localIds = participants
- .filter(participant => participant.local)
- .filter(participant => participant.role === 'moderator')
- .map(participant => participant.id);
-
- APP.store.dispatch(muteAllParticipants(localIds, muteMediaType));
- },
- 'toggle-lobby': isLobbyEnabled => {
- APP.store.dispatch(toggleLobbyMode(isLobbyEnabled));
- },
- 'password': password => {
- const { conference, passwordRequired }
- = APP.store.getState()['features/base/conference'];
-
- if (passwordRequired) {
- sendAnalytics(createApiEvent('submit.password'));
-
- APP.store.dispatch(setPassword(
- passwordRequired,
- passwordRequired.join,
- password
- ));
- } else {
- sendAnalytics(createApiEvent('password.changed'));
-
- APP.store.dispatch(setPassword(
- conference,
- conference.lock,
- password
- ));
- }
- },
- 'pin-participant': id => {
- logger.debug('Pin participant command received');
- sendAnalytics(createApiEvent('participant.pinned'));
- APP.store.dispatch(pinParticipant(id));
- },
- 'proxy-connection-event': event => {
- APP.conference.onProxyConnectionEvent(event);
- },
- 'resize-large-video': (width, height) => {
- logger.debug('Resize large video command received');
- sendAnalytics(createApiEvent('largevideo.resized'));
- APP.store.dispatch(resizeLargeVideo(width, height));
- },
- 'send-tones': (options = {}) => {
- const { duration, tones, pause } = options;
-
- APP.store.dispatch(sendTones(tones, duration, pause));
- },
- 'set-large-video-participant': participantId => {
- logger.debug('Set large video participant command received');
- sendAnalytics(createApiEvent('largevideo.participant.set'));
- APP.store.dispatch(selectParticipantInLargeVideo(participantId));
- },
- 'subject': subject => {
- sendAnalytics(createApiEvent('subject.changed'));
- APP.store.dispatch(setSubject(subject));
- },
- 'submit-feedback': feedback => {
- sendAnalytics(createApiEvent('submit.feedback'));
- APP.conference.submitFeedback(feedback.score, feedback.message);
- },
- 'toggle-audio': () => {
- sendAnalytics(createApiEvent('toggle-audio'));
- logger.log('Audio toggle: API command received');
- APP.conference.toggleAudioMuted(false /* no UI */);
- },
- 'toggle-video': () => {
- sendAnalytics(createApiEvent('toggle-video'));
- logger.log('Video toggle: API command received');
- APP.conference.toggleVideoMuted(false /* no UI */);
- },
- 'toggle-film-strip': () => {
- sendAnalytics(createApiEvent('film.strip.toggled'));
- APP.UI.toggleFilmstrip();
- },
- 'toggle-camera': () => {
- if (!isToggleCameraEnabled(APP.store.getState())) {
- return;
- }
-
- APP.store.dispatch(toggleCamera());
- },
- 'toggle-camera-mirror': () => {
- const state = APP.store.getState();
- const { localFlipX: currentFlipX } = state['features/base/settings'];
-
- APP.store.dispatch(updateSettings({ localFlipX: !currentFlipX }));
- },
- 'toggle-chat': () => {
- sendAnalytics(createApiEvent('chat.toggled'));
- APP.store.dispatch(toggleChat());
- },
- 'toggle-raise-hand': () => {
- const localParticipant = getLocalParticipant(APP.store.getState());
-
- if (!localParticipant) {
- return;
- }
- const { raisedHand } = localParticipant;
-
- sendAnalytics(createApiEvent('raise-hand.toggled'));
- APP.store.dispatch(
- participantUpdated({
- id: APP.conference.getMyUserId(),
- local: true,
- raisedHand: !raisedHand
- })
- );
- },
-
- /**
- * Callback to invoke when the "toggle-share-screen" command is received.
- *
- * @param {Object} options - Additional details of how to perform
- * the action. Note this parameter is undocumented and experimental.
- * @param {boolean} options.enable - Whether trying to enable screen
- * sharing or to turn it off.
- * @returns {void}
- */
- 'toggle-share-screen': (options = {}) => {
- sendAnalytics(createApiEvent('screen.sharing.toggled'));
- toggleScreenSharing(options.enable);
- },
- 'toggle-tile-view': () => {
- sendAnalytics(createApiEvent('tile-view.toggled'));
-
- APP.store.dispatch(toggleTileView());
- },
- 'set-tile-view': enabled => {
- APP.store.dispatch(setTileView(enabled));
- },
- 'video-hangup': (showFeedbackDialog = true) => {
- sendAnalytics(createApiEvent('video.hangup'));
- APP.conference.hangup(showFeedbackDialog);
- },
- 'email': email => {
- sendAnalytics(createApiEvent('email.changed'));
- APP.conference.changeLocalEmail(email);
- },
- 'avatar-url': avatarUrl => {
- sendAnalytics(createApiEvent('avatar.url.changed'));
- APP.conference.changeLocalAvatarUrl(avatarUrl);
- },
- 'send-endpoint-text-message': (to, text) => {
- logger.debug('Send endpoint message command received');
- try {
- APP.conference.sendEndpointMessage(to, {
- name: ENDPOINT_TEXT_MESSAGE_NAME,
- text
- });
- } catch (err) {
- logger.error('Failed sending endpoint text message', err);
- }
- },
- 'toggle-e2ee': enabled => {
- logger.debug('Toggle E2EE key command received');
- APP.store.dispatch(toggleE2EE(enabled));
- },
- 'set-video-quality': frameHeight => {
- logger.debug('Set video quality command received');
- sendAnalytics(createApiEvent('set.video.quality'));
- APP.store.dispatch(setVideoQuality(frameHeight));
- },
-
- 'start-share-video': url => {
- logger.debug('Share video command received');
- sendAnalytics(createApiEvent('share.video.start'));
- APP.store.dispatch(playSharedVideo(url));
- },
-
- 'stop-share-video': () => {
- logger.debug('Share video command received');
- sendAnalytics(createApiEvent('share.video.stop'));
- APP.store.dispatch(stopSharedVideo());
- },
-
- /**
- * Starts a file recording or streaming session depending on the passed on params.
- * For RTMP streams, `rtmpStreamKey` must be passed on. `rtmpBroadcastID` is optional.
- * For youtube streams, `youtubeStreamKey` must be passed on. `youtubeBroadcastID` is optional.
- * For dropbox recording, recording `mode` should be `file` and a dropbox oauth2 token must be provided.
- * For file recording, recording `mode` should be `file` and optionally `shouldShare` could be passed on.
- * No other params should be passed.
- *
- * @param { string } arg.mode - Recording mode, either `file` or `stream`.
- * @param { string } arg.dropboxToken - Dropbox oauth2 token.
- * @param { string } arg.rtmpStreamKey - The RTMP stream key.
- * @param { string } arg.rtmpBroadcastID - The RTMP braodcast ID.
- * @param { boolean } arg.shouldShare - Whether the recording should be shared with the participants or not.
- * Only applies to certain jitsi meet deploys.
- * @param { string } arg.youtubeStreamKey - The youtube stream key.
- * @param { string } arg.youtubeBroadcastID - The youtube broacast ID.
- * @returns {void}
- */
- 'start-recording': ({
- mode,
- dropboxToken,
- shouldShare,
- rtmpStreamKey,
- rtmpBroadcastID,
- youtubeStreamKey,
- youtubeBroadcastID
- }) => {
- const state = APP.store.getState();
- const conference = getCurrentConference(state);
-
- if (!conference) {
- logger.error('Conference is not defined');
-
- return;
- }
-
- if (dropboxToken && !isDropboxEnabled(state)) {
- logger.error('Failed starting recording: dropbox is not enabled on this deployment');
-
- return;
- }
-
- if (mode === JitsiRecordingConstants.mode.STREAM && !(youtubeStreamKey || rtmpStreamKey)) {
- logger.error('Failed starting recording: missing youtube or RTMP stream key');
-
- return;
- }
-
- let recordingConfig;
-
- if (mode === JitsiRecordingConstants.mode.FILE) {
- if (dropboxToken) {
- recordingConfig = {
- mode: JitsiRecordingConstants.mode.FILE,
- appData: JSON.stringify({
- 'file_recording_metadata': {
- 'upload_credentials': {
- 'service_name': RECORDING_TYPES.DROPBOX,
- 'token': dropboxToken
- }
- }
- })
- };
- } else {
- recordingConfig = {
- mode: JitsiRecordingConstants.mode.FILE,
- appData: JSON.stringify({
- 'file_recording_metadata': {
- 'share': shouldShare
- }
- })
- };
- }
- } else if (mode === JitsiRecordingConstants.mode.STREAM) {
- recordingConfig = {
- broadcastId: youtubeBroadcastID || rtmpBroadcastID,
- mode: JitsiRecordingConstants.mode.STREAM,
- streamId: youtubeStreamKey || rtmpStreamKey
- };
- } else {
- logger.error('Invalid recording mode provided');
-
- return;
- }
-
- conference.startRecording(recordingConfig);
- },
-
- /**
- * Stops a recording or streaming in progress.
- *
- * @param {string} mode - `file` or `stream`.
- * @returns {void}
- */
- 'stop-recording': mode => {
- const state = APP.store.getState();
- const conference = getCurrentConference(state);
-
- if (!conference) {
- logger.error('Conference is not defined');
-
- return;
- }
-
- if (![ JitsiRecordingConstants.mode.FILE, JitsiRecordingConstants.mode.STREAM ].includes(mode)) {
- logger.error('Invalid recording mode provided!');
-
- return;
- }
-
- const activeSession = getActiveSession(state, mode);
-
- if (activeSession && activeSession.id) {
- conference.stopRecording(activeSession.id);
- } else {
- logger.error('No recording or streaming session found');
- }
- },
- 'initiate-private-chat': participantId => {
- const state = APP.store.getState();
- const participant = getParticipantById(state, participantId);
-
- if (participant) {
- const { isOpen: isChatOpen } = state['features/chat'];
-
- if (!isChatOpen) {
- APP.store.dispatch(toggleChat());
- }
- APP.store.dispatch(openChat(participant));
- } else {
- logger.error('No participant found for the given participantId');
- }
- },
- 'cancel-private-chat': () => {
- APP.store.dispatch(setPrivateMessageRecipient());
- },
- 'kick-participant': participantId => {
- APP.store.dispatch(kickParticipant(participantId));
- },
- 'overwrite-config': config => {
- const whitelistedConfig = getWhitelistedJSON('config', config);
-
- APP.store.dispatch(overwriteConfig(whitelistedConfig));
- }
- };
- transport.on('event', ({ data, name }) => {
- if (name && commands[name]) {
- commands[name](...data);
-
- return true;
- }
-
- return false;
- });
- transport.on('request', (request, callback) => {
- const { dispatch, getState } = APP.store;
-
- if (processExternalDeviceRequest(dispatch, getState, request, callback)) {
- return true;
- }
-
- const { name } = request;
-
- switch (name) {
- case 'capture-largevideo-screenshot' :
- APP.store.dispatch(captureLargeVideoScreenshot())
- .then(dataURL => {
- let error;
-
- if (!dataURL) {
- error = new Error('No large video found!');
- }
-
- callback({
- error,
- dataURL
- });
- });
- break;
- case 'invite': {
- const { invitees } = request;
-
- if (!Array.isArray(invitees) || invitees.length === 0) {
- callback({
- error: new Error('Unexpected format of invitees')
- });
-
- break;
- }
-
- // The store should be already available because API.init is called
- // on appWillMount action.
- APP.store.dispatch(
- invite(invitees, true))
- .then(failedInvitees => {
- let error;
- let result;
-
- if (failedInvitees.length) {
- error = new Error('One or more invites failed!');
- } else {
- result = true;
- }
-
- callback({
- error,
- result
- });
- });
- break;
- }
- case 'is-audio-muted':
- callback(APP.conference.isLocalAudioMuted());
- break;
- case 'is-video-muted':
- callback(APP.conference.isLocalVideoMuted());
- break;
- case 'is-audio-available':
- callback(audioAvailable);
- break;
- case 'is-video-available':
- callback(videoAvailable);
- break;
- case 'is-sharing-screen':
- callback(Boolean(APP.conference.isSharingScreen));
- break;
- case 'get-content-sharing-participants': {
- const tracks = getState()['features/base/tracks'];
- const sharingParticipantIds = tracks.filter(tr => tr.videoType === 'desktop').map(t => t.participantId);
-
- callback({
- sharingParticipantIds
- });
- break;
- }
- case 'get-livestream-url': {
- const state = APP.store.getState();
- const conference = getCurrentConference(state);
- let livestreamUrl;
-
- if (conference) {
- const activeSession = getActiveSession(state, JitsiRecordingConstants.mode.STREAM);
-
- livestreamUrl = activeSession?.liveStreamViewURL;
- } else {
- logger.error('Conference is not defined');
- }
- callback({
- livestreamUrl
- });
- break;
- }
- default:
- return false;
- }
-
- return true;
- });
- }
-
- /**
- * Check whether the API should be enabled or not.
- *
- * @returns {boolean}
- */
- function shouldBeEnabled() {
- return (
- typeof API_ID === 'number'
-
- // XXX Enable the API when a JSON Web Token (JWT) is specified in
- // the location/URL because then it is very likely that the Jitsi
- // Meet (Web) app is being used by an external/wrapping (Web) app
- // and, consequently, the latter will need to communicate with the
- // former. (The described logic is merely a heuristic though.)
- || parseJWTFromURLParams());
- }
-
- /**
- * Executes on toggle-share-screen command.
- *
- * @param {boolean} [enable] - Whether this toggle is to explicitly enable or
- * disable screensharing. If not defined, the application will automatically
- * attempt to toggle between enabled and disabled. This boolean is useful for
- * explicitly setting desired screensharing state.
- * @returns {void}
- */
- function toggleScreenSharing(enable) {
- if (JitsiMeetJS.isDesktopSharingEnabled()) {
- APP.conference.toggleScreenSharing(enable).catch(() => {
- logger.warn('Failed to toggle screen-sharing');
- });
- }
- }
-
- /**
- * Removes sensitive data from a mouse event.
- *
- * @param {MouseEvent} event - The mouse event to sanitize.
- * @returns {Object}
- */
- function sanitizeMouseEvent(event: MouseEvent) {
- const {
- clientX,
- clientY,
- movementX,
- movementY,
- offsetX,
- offsetY,
- pageX,
- pageY,
- x,
- y,
- screenX,
- screenY
- } = event;
-
- return {
- clientX,
- clientY,
- movementX,
- movementY,
- offsetX,
- offsetY,
- pageX,
- pageY,
- x,
- y,
- screenX,
- screenY
- };
- }
-
- /**
- * Implements API class that communicates with external API class and provides
- * interface to access Jitsi Meet features by external applications that embed
- * Jitsi Meet.
- */
- class API {
- _enabled: boolean;
-
- /**
- * Initializes the API. Setups message event listeners that will receive
- * information from external applications that embed Jitsi Meet. It also
- * sends a message to the external application that API is initialized.
- *
- * @param {Object} options - Optional parameters.
- * @returns {void}
- */
- init() {
- if (!shouldBeEnabled()) {
- return;
- }
-
- /**
- * Current status (enabled/disabled) of API.
- *
- * @private
- * @type {boolean}
- */
- this._enabled = true;
-
- initCommands();
- }
-
- /**
- * Notify external application (if API is enabled) that the large video
- * visibility changed.
- *
- * @param {boolean} isHidden - True if the large video is hidden and false
- * otherwise.
- * @returns {void}
- */
- notifyLargeVideoVisibilityChanged(isHidden: boolean) {
- this._sendEvent({
- name: 'large-video-visibility-changed',
- isVisible: !isHidden
- });
- }
-
- /**
- * Notifies the external application (spot) that the local jitsi-participant
- * has a status update.
- *
- * @param {Object} event - The message to pass onto spot.
- * @returns {void}
- */
- sendProxyConnectionEvent(event: Object) {
- this._sendEvent({
- name: 'proxy-connection-event',
- ...event
- });
- }
-
- /**
- * Sends event to the external application.
- *
- * @param {Object} event - The event to be sent.
- * @returns {void}
- */
- _sendEvent(event: Object = {}) {
- if (this._enabled) {
- transport.sendEvent(event);
- }
- }
-
- /**
- * Notify external application (if API is enabled) that the chat state has been updated.
- *
- * @param {number} unreadCount - The unread messages counter.
- * @param {boolean} isOpen - True if the chat panel is open.
- * @returns {void}
- */
- notifyChatUpdated(unreadCount: number, isOpen: boolean) {
- this._sendEvent({
- name: 'chat-updated',
- unreadCount,
- isOpen
- });
- }
-
- /**
- * Notify external application (if API is enabled) that message was sent.
- *
- * @param {string} message - Message body.
- * @param {boolean} privateMessage - True if the message was a private message.
- * @returns {void}
- */
- notifySendingChatMessage(message: string, privateMessage: boolean) {
- this._sendEvent({
- name: 'outgoing-message',
- message,
- privateMessage
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the mouse has entered inside the iframe.
- *
- * @param {MouseEvent} event - The mousemove event.
- * @returns {void}
- */
- notifyMouseEnter(event: MouseEvent) {
- this._sendEvent({
- name: 'mouse-enter',
- event: sanitizeMouseEvent(event)
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the mouse has entered inside the iframe.
- *
- * @param {MouseEvent} event - The mousemove event.
- * @returns {void}
- */
- notifyMouseLeave(event: MouseEvent) {
- this._sendEvent({
- name: 'mouse-leave',
- event: sanitizeMouseEvent(event)
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the mouse has moved inside the iframe.
- *
- * @param {MouseEvent} event - The mousemove event.
- * @returns {void}
- */
- notifyMouseMove(event: MouseEvent) {
- this._sendEvent({
- name: 'mouse-move',
- event: sanitizeMouseEvent(event)
- });
- }
-
- /**
- * Notify external application that the video quality setting has changed.
- *
- * @param {number} videoQuality - The video quality. The number represents the maximum height of the video streams.
- * @returns {void}
- */
- notifyVideoQualityChanged(videoQuality: number) {
- this._sendEvent({
- name: 'video-quality-changed',
- videoQuality
- });
- }
-
- /**
- * Notify external application (if API is enabled) that message was
- * received.
- *
- * @param {Object} options - Object with the message properties.
- * @returns {void}
- */
- notifyReceivedChatMessage(
- { body, id, nick, privateMessage, ts }: {
- body: *, id: string, nick: string, privateMessage: boolean, ts: *
- } = {}) {
- if (APP.conference.isLocalId(id)) {
- return;
- }
-
- this._sendEvent({
- name: 'incoming-message',
- from: id,
- message: body,
- nick,
- privateMessage,
- stamp: ts
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user joined the
- * conference.
- *
- * @param {string} id - User id.
- * @param {Object} props - The display name of the user.
- * @returns {void}
- */
- notifyUserJoined(id: string, props: Object) {
- this._sendEvent({
- name: 'participant-joined',
- id,
- ...props
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user left the
- * conference.
- *
- * @param {string} id - User id.
- * @returns {void}
- */
- notifyUserLeft(id: string) {
- this._sendEvent({
- name: 'participant-left',
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the user role
- * has changed.
- *
- * @param {string} id - User id.
- * @param {string} role - The new user role.
- * @returns {void}
- */
- notifyUserRoleChanged(id: string, role: string) {
- this._sendEvent({
- name: 'participant-role-changed',
- id,
- role
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user changed their
- * avatar.
- *
- * @param {string} id - User id.
- * @param {string} avatarURL - The new avatar URL of the participant.
- * @returns {void}
- */
- notifyAvatarChanged(id: string, avatarURL: string) {
- this._sendEvent({
- name: 'avatar-changed',
- avatarURL,
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user received
- * a text message through datachannels.
- *
- * @param {Object} data - The event data.
- * @returns {void}
- */
- notifyEndpointTextMessageReceived(data: Object) {
- this._sendEvent({
- name: 'endpoint-text-message-received',
- data
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the list of sharing participants changed.
- *
- * @param {Object} data - The event data.
- * @returns {void}
- */
- notifySharingParticipantsChanged(data: Object) {
- this._sendEvent({
- name: 'content-sharing-participants-changed',
- data
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the device list has
- * changed.
- *
- * @param {Object} devices - The new device list.
- * @returns {void}
- */
- notifyDeviceListChanged(devices: Object) {
- this._sendEvent({
- name: 'device-list-changed',
- devices
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user changed their
- * nickname.
- *
- * @param {string} id - User id.
- * @param {string} displayname - User nickname.
- * @param {string} formattedDisplayName - The display name shown in Jitsi
- * meet's UI for the user.
- * @returns {void}
- */
- notifyDisplayNameChanged(
- id: string,
- { displayName, formattedDisplayName }: Object) {
- this._sendEvent({
- name: 'display-name-change',
- displayname: displayName,
- formattedDisplayName,
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user changed their
- * email.
- *
- * @param {string} id - User id.
- * @param {string} email - The new email of the participant.
- * @returns {void}
- */
- notifyEmailChanged(
- id: string,
- { email }: Object) {
- this._sendEvent({
- name: 'email-change',
- email,
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the an error has been logged.
- *
- * @param {string} logLevel - The message log level.
- * @param {Array} args - Array of strings composing the log message.
- * @returns {void}
- */
- notifyLog(logLevel: string, args: Array<string>) {
- this._sendEvent({
- name: 'log',
- logLevel,
- args
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the conference has
- * been joined.
- *
- * @param {string} roomName - The room name.
- * @param {string} id - The id of the local user.
- * @param {Object} props - The display name and avatar URL of the local
- * user.
- * @returns {void}
- */
- notifyConferenceJoined(roomName: string, id: string, props: Object) {
- this._sendEvent({
- name: 'video-conference-joined',
- roomName,
- id,
- ...props
- });
- }
-
- /**
- * Notify external application (if API is enabled) that local user has left the conference.
- *
- * @param {string} roomName - User id.
- * @returns {void}
- */
- notifyConferenceLeft(roomName: string) {
- this._sendEvent({
- name: 'video-conference-left',
- roomName
- });
- }
-
- /**
- * Notify external application (if API is enabled) that we are ready to be
- * closed.
- *
- * @returns {void}
- */
- notifyReadyToClose() {
- this._sendEvent({ name: 'video-ready-to-close' });
- }
-
- /**
- * Notify external application (if API is enabled) that a suspend event in host computer.
- *
- * @returns {void}
- */
- notifySuspendDetected() {
- this._sendEvent({ name: 'suspend-detected' });
- }
-
- /**
- * Notify external application (if API is enabled) for audio muted status
- * changed.
- *
- * @param {boolean} muted - The new muted status.
- * @returns {void}
- */
- notifyAudioMutedStatusChanged(muted: boolean) {
- this._sendEvent({
- name: 'audio-mute-status-changed',
- muted
- });
- }
-
- /**
- * Notify external application (if API is enabled) for video muted status
- * changed.
- *
- * @param {boolean} muted - The new muted status.
- * @returns {void}
- */
- notifyVideoMutedStatusChanged(muted: boolean) {
- this._sendEvent({
- name: 'video-mute-status-changed',
- muted
- });
- }
-
- /**
- * Notify external application (if API is enabled) for audio availability
- * changed.
- *
- * @param {boolean} available - True if available and false otherwise.
- * @returns {void}
- */
- notifyAudioAvailabilityChanged(available: boolean) {
- audioAvailable = available;
- this._sendEvent({
- name: 'audio-availability-changed',
- available
- });
- }
-
- /**
- * Notify external application (if API is enabled) for video available
- * status changed.
- *
- * @param {boolean} available - True if available and false otherwise.
- * @returns {void}
- */
- notifyVideoAvailabilityChanged(available: boolean) {
- videoAvailable = available;
- this._sendEvent({
- name: 'video-availability-changed',
- available
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the on stage
- * participant has changed.
- *
- * @param {string} id - User id of the new on stage participant.
- * @returns {void}
- */
- notifyOnStageParticipantChanged(id: string) {
- this._sendEvent({
- name: 'on-stage-participant-changed',
- id
- });
- }
-
- /**
- * Notify external application of an unexpected camera-related error having
- * occurred.
- *
- * @param {string} type - The type of the camera error.
- * @param {string} message - Additional information about the error.
- * @returns {void}
- */
- notifyOnCameraError(type: string, message: string) {
- this._sendEvent({
- name: 'camera-error',
- type,
- message
- });
- }
-
- /**
- * Notify external application of an unexpected mic-related error having
- * occurred.
- *
- * @param {string} type - The type of the mic error.
- * @param {string} message - Additional information about the error.
- * @returns {void}
- */
- notifyOnMicError(type: string, message: string) {
- this._sendEvent({
- name: 'mic-error',
- type,
- message
- });
- }
-
- /**
- * Notify external application (if API is enabled) that conference feedback
- * has been submitted. Intended to be used in conjunction with the
- * submit-feedback command to get notified if feedback was submitted.
- *
- * @param {string} error - A failure message, if any.
- * @returns {void}
- */
- notifyFeedbackSubmitted(error: string) {
- this._sendEvent({
- name: 'feedback-submitted',
- error
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the feedback prompt
- * has been displayed.
- *
- * @returns {void}
- */
- notifyFeedbackPromptDisplayed() {
- this._sendEvent({ name: 'feedback-prompt-displayed' });
- }
-
- /**
- * Notify external application (if API is enabled) that the display
- * configuration of the filmstrip has been changed.
- *
- * @param {boolean} visible - Whether or not the filmstrip has been set to
- * be displayed or hidden.
- * @returns {void}
- */
- notifyFilmstripDisplayChanged(visible: boolean) {
- this._sendEvent({
- name: 'filmstrip-display-changed',
- visible
- });
- }
-
- /**
- * Notify external application of a participant, remote or local, being
- * removed from the conference by another participant.
- *
- * @param {string} kicked - The ID of the participant removed from the
- * conference.
- * @param {string} kicker - The ID of the participant that removed the
- * other participant.
- * @returns {void}
- */
- notifyKickedOut(kicked: Object, kicker: Object) {
- this._sendEvent({
- name: 'participant-kicked-out',
- kicked,
- kicker
- });
- }
-
- /**
- * Notify external application of the current meeting requiring a password
- * to join.
- *
- * @returns {void}
- */
- notifyOnPasswordRequired() {
- this._sendEvent({ name: 'password-required' });
- }
-
- /**
- * Notify external application (if API is enabled) that the screen sharing
- * has been turned on/off.
- *
- * @param {boolean} on - True if screen sharing is enabled.
- * @param {Object} details - Additional information about the screen
- * sharing.
- * @param {string} details.sourceType - Type of device or window the screen
- * share is capturing.
- * @returns {void}
- */
- notifyScreenSharingStatusChanged(on: boolean, details: Object) {
- this._sendEvent({
- name: 'screen-sharing-status-changed',
- on,
- details
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the dominant speaker
- * has been turned on/off.
- *
- * @param {string} id - Id of the dominant participant.
- * @returns {void}
- */
- notifyDominantSpeakerChanged(id: string) {
- this._sendEvent({
- name: 'dominant-speaker-changed',
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the conference
- * changed their subject.
- *
- * @param {string} subject - Conference subject.
- * @returns {void}
- */
- notifySubjectChanged(subject: string) {
- this._sendEvent({
- name: 'subject-change',
- subject
- });
- }
-
- /**
- * Notify external application (if API is enabled) that tile view has been
- * entered or exited.
- *
- * @param {string} enabled - True if tile view is currently displayed, false
- * otherwise.
- * @returns {void}
- */
- notifyTileViewChanged(enabled: boolean) {
- this._sendEvent({
- name: 'tile-view-changed',
- enabled
- });
- }
-
- /**
- * Notify external application (if API is enabled) that the localStorage has changed.
- *
- * @param {string} localStorageContent - The new localStorageContent.
- * @returns {void}
- */
- notifyLocalStorageChanged(localStorageContent: string) {
- this._sendEvent({
- name: 'local-storage-changed',
- localStorageContent
- });
- }
-
- /**
- * Notify external application (if API is enabled) that user updated their hand raised.
- *
- * @param {string} id - User id.
- * @param {boolean} handRaised - Whether user has raised hand.
- * @returns {void}
- */
- notifyRaiseHandUpdated(id: string, handRaised: boolean) {
- this._sendEvent({
- name: 'raise-hand-updated',
- handRaised,
- id
- });
- }
-
- /**
- * Notify external application (if API is enabled) that recording has started or stopped.
- *
- * @param {boolean} on - True if recording is on, false otherwise.
- * @param {string} mode - Stream or file.
- * @param {string} error - Error type or null if success.
- * @returns {void}
- */
- notifyRecordingStatusChanged(on: boolean, mode: string, error?: string) {
- this._sendEvent({
- name: 'recording-status-changed',
- on,
- mode,
- error
- });
- }
-
- /**
- * Disposes the allocated resources.
- *
- * @returns {void}
- */
- dispose() {
- if (this._enabled) {
- this._enabled = false;
- }
- }
- }
-
- export default new API();
|