2022-10-17 11:28:01 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2021-10-25 10:04:51 +00:00
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
2020-05-14 12:30:24 +00:00
|
|
|
|
2022-10-17 11:28:01 +00:00
|
|
|
import { IStore } from '../app/types';
|
|
|
|
import { updateConfig } from '../base/config/actions';
|
|
|
|
// @ts-ignore
|
|
|
|
import { getDialOutStatusUrl, getDialOutUrl } from '../base/config/functions';
|
2022-04-08 12:24:58 +00:00
|
|
|
import { browser } from '../base/lib-jitsi-meet';
|
2022-10-17 11:28:01 +00:00
|
|
|
// @ts-ignore
|
2022-04-08 12:24:58 +00:00
|
|
|
import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
|
2022-10-17 11:28:01 +00:00
|
|
|
import { MEDIA_TYPE } from '../base/media/constants';
|
|
|
|
import { isVideoMutedByUser } from '../base/media/functions';
|
|
|
|
import { updateSettings } from '../base/settings/actions';
|
2020-06-19 07:03:26 +00:00
|
|
|
import {
|
2021-09-28 22:50:57 +00:00
|
|
|
createLocalTracksF,
|
2020-06-19 07:03:26 +00:00
|
|
|
getLocalAudioTrack,
|
2021-09-28 22:50:57 +00:00
|
|
|
getLocalTracks,
|
2020-06-19 07:03:26 +00:00
|
|
|
getLocalVideoTrack,
|
2022-09-27 07:10:28 +00:00
|
|
|
replaceLocalTrack,
|
|
|
|
trackAdded
|
2022-10-17 11:28:01 +00:00
|
|
|
// @ts-ignore
|
2020-06-19 07:03:26 +00:00
|
|
|
} from '../base/tracks';
|
2022-10-17 11:28:01 +00:00
|
|
|
// @ts-ignore
|
2020-05-20 10:57:03 +00:00
|
|
|
import { openURLInBrowser } from '../base/util';
|
2022-10-17 11:28:01 +00:00
|
|
|
// @ts-ignore
|
2020-05-20 10:57:03 +00:00
|
|
|
import { executeDialOutRequest, executeDialOutStatusRequest, getDialInfoPageURL } from '../invite/functions';
|
2022-10-17 11:28:01 +00:00
|
|
|
import { showErrorNotification } from '../notifications/actions';
|
|
|
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
|
|
|
import { INotificationProps } from '../notifications/types';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
import {
|
2020-10-26 11:53:44 +00:00
|
|
|
PREJOIN_INITIALIZED,
|
2022-09-27 07:10:28 +00:00
|
|
|
PREJOIN_JOINING_IN_PROGRESS,
|
|
|
|
SET_DEVICE_STATUS,
|
2020-05-14 12:30:24 +00:00
|
|
|
SET_DIALOUT_COUNTRY,
|
|
|
|
SET_DIALOUT_NUMBER,
|
|
|
|
SET_DIALOUT_STATUS,
|
2020-04-16 10:47:10 +00:00
|
|
|
SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
|
2020-07-29 10:27:32 +00:00
|
|
|
SET_PRECALL_TEST_RESULTS,
|
2020-04-16 10:47:10 +00:00
|
|
|
SET_PREJOIN_DEVICE_ERRORS,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_PREJOIN_DISPLAY_NAME_REQUIRED,
|
2021-09-28 22:50:57 +00:00
|
|
|
SET_PREJOIN_PAGE_VISIBILITY,
|
2022-09-27 07:10:28 +00:00
|
|
|
SET_SKIP_PREJOIN_RELOAD
|
2020-04-16 10:47:10 +00:00
|
|
|
} from './actionTypes';
|
2020-05-14 12:30:24 +00:00
|
|
|
import {
|
|
|
|
getDialOutConferenceUrl,
|
|
|
|
getDialOutCountry,
|
2022-09-27 07:10:28 +00:00
|
|
|
getFullDialOutNumber,
|
2020-05-14 12:30:24 +00:00
|
|
|
isJoinByPhoneDialogVisible
|
|
|
|
} from './functions';
|
2020-05-20 10:57:03 +00:00
|
|
|
import logger from './logger';
|
2020-05-14 12:30:24 +00:00
|
|
|
|
|
|
|
const dialOutStatusToKeyMap = {
|
|
|
|
INITIATED: 'presenceStatus.calling',
|
|
|
|
RINGING: 'presenceStatus.ringing'
|
|
|
|
};
|
|
|
|
|
|
|
|
const DIAL_OUT_STATUS = {
|
|
|
|
INITIATED: 'INITIATED',
|
|
|
|
RINGING: 'RINGING',
|
|
|
|
CONNECTED: 'CONNECTED',
|
|
|
|
DISCONNECTED: 'DISCONNECTED',
|
|
|
|
FAILED: 'FAILED'
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The time interval used between requests while polling for dial out status.
|
|
|
|
*/
|
|
|
|
const STATUS_REQ_FREQUENCY = 2000;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The maximum number of retries while polling for dial out status.
|
|
|
|
*/
|
|
|
|
const STATUS_REQ_CAP = 45;
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
/**
|
|
|
|
* Polls for status change after dial out.
|
|
|
|
* Changes dialog message based on response, closes the dialog if there is an error,
|
|
|
|
* joins the meeting when CONNECTED.
|
|
|
|
*
|
|
|
|
* @param {string} reqId - The request id used to correlate the dial out request with this one.
|
|
|
|
* @param {Function} onSuccess - Success handler.
|
|
|
|
* @param {Function} onFail - Fail handler.
|
|
|
|
* @param {number} count - The number of retried calls. When it hits STATUS_REQ_CAP it should no longer make requests.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
function pollForStatus(
|
|
|
|
reqId: string,
|
|
|
|
onSuccess: Function,
|
|
|
|
onFail: Function,
|
|
|
|
count = 0) {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2020-05-14 12:30:24 +00:00
|
|
|
const state = getState();
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (!isJoinByPhoneDialogVisible(state)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const res = await executeDialOutStatusRequest(getDialOutStatusUrl(state), reqId);
|
|
|
|
|
|
|
|
switch (res) {
|
|
|
|
case DIAL_OUT_STATUS.INITIATED:
|
|
|
|
case DIAL_OUT_STATUS.RINGING: {
|
2022-10-17 11:28:01 +00:00
|
|
|
dispatch(setDialOutStatus(dialOutStatusToKeyMap[res as keyof typeof dialOutStatusToKeyMap]));
|
2020-05-14 12:30:24 +00:00
|
|
|
|
|
|
|
if (count < STATUS_REQ_CAP) {
|
|
|
|
return setTimeout(() => {
|
|
|
|
dispatch(pollForStatus(reqId, onSuccess, onFail, count + 1));
|
|
|
|
}, STATUS_REQ_FREQUENCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return onFail();
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIAL_OUT_STATUS.CONNECTED: {
|
|
|
|
return onSuccess();
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIAL_OUT_STATUS.DISCONNECTED: {
|
|
|
|
dispatch(showErrorNotification({
|
|
|
|
titleKey: 'prejoin.errorDialOutDisconnected'
|
2021-11-24 11:05:27 +00:00
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.LONG));
|
2020-05-14 12:30:24 +00:00
|
|
|
|
|
|
|
return onFail();
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIAL_OUT_STATUS.FAILED: {
|
|
|
|
dispatch(showErrorNotification({
|
|
|
|
titleKey: 'prejoin.errorDialOutFailed'
|
2021-11-24 11:05:27 +00:00
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.LONG));
|
2020-05-14 12:30:24 +00:00
|
|
|
|
|
|
|
return onFail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
dispatch(showErrorNotification({
|
|
|
|
titleKey: 'prejoin.errorDialOutStatus'
|
2021-11-24 11:05:27 +00:00
|
|
|
}, NOTIFICATION_TIMEOUT_TYPE.LONG));
|
2020-05-14 12:30:24 +00:00
|
|
|
logger.error('Error getting dial out status', err);
|
|
|
|
onFail();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action used for joining the meeting with phone audio.
|
|
|
|
* A dial out connection is tried and a polling mechanism is used for getting the status.
|
|
|
|
* If the connection succeeds the `onSuccess` callback is executed.
|
|
|
|
* If the phone connection fails or the number is invalid the `onFail` callback is executed.
|
|
|
|
*
|
|
|
|
* @param {Function} onSuccess - Success handler.
|
|
|
|
* @param {Function} onFail - Fail handler.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function dialOut(onSuccess: Function, onFail: Function) {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2020-05-14 12:30:24 +00:00
|
|
|
const state = getState();
|
2021-10-25 10:04:51 +00:00
|
|
|
const reqId = uuidv4();
|
2020-05-14 12:30:24 +00:00
|
|
|
const url = getDialOutUrl(state);
|
|
|
|
const conferenceUrl = getDialOutConferenceUrl(state);
|
|
|
|
const phoneNumber = getFullDialOutNumber(state);
|
|
|
|
const countryCode = getDialOutCountry(state).code.toUpperCase();
|
|
|
|
|
|
|
|
const body = {
|
|
|
|
conferenceUrl,
|
|
|
|
countryCode,
|
|
|
|
name: phoneNumber,
|
|
|
|
phoneNumber
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
await executeDialOutRequest(url, body, reqId);
|
|
|
|
|
|
|
|
dispatch(pollForStatus(reqId, onSuccess, onFail));
|
2022-10-17 11:28:01 +00:00
|
|
|
} catch (err: any) {
|
|
|
|
const notification: INotificationProps = {
|
2020-05-14 12:30:24 +00:00
|
|
|
titleKey: 'prejoin.errorDialOut',
|
|
|
|
titleArguments: undefined
|
|
|
|
};
|
|
|
|
|
|
|
|
if (err.status) {
|
|
|
|
if (err.messageKey === 'validation.failed') {
|
|
|
|
notification.titleKey = 'prejoin.errorValidation';
|
|
|
|
} else {
|
|
|
|
notification.titleKey = 'prejoin.errorStatusCode';
|
|
|
|
notification.titleArguments = { status: err.status };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-24 11:05:27 +00:00
|
|
|
dispatch(showErrorNotification(notification, NOTIFICATION_TIMEOUT_TYPE.LONG));
|
2020-05-14 12:30:24 +00:00
|
|
|
logger.error('Error dialing out', err);
|
|
|
|
onFail();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Adds all the newly created tracks to store on init.
|
|
|
|
*
|
|
|
|
* @param {Object[]} tracks - The newly created tracks.
|
|
|
|
* @param {Object} errors - The errors from creating the tracks.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function initPrejoin(tracks: Object[], errors: Object) {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async function(dispatch: IStore['dispatch']) {
|
2020-04-16 10:47:10 +00:00
|
|
|
dispatch(setPrejoinDeviceErrors(errors));
|
2020-10-26 11:53:44 +00:00
|
|
|
dispatch(prejoinInitialized());
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2020-06-19 07:03:26 +00:00
|
|
|
tracks.forEach(track => dispatch(trackAdded(track)));
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-08 09:59:46 +00:00
|
|
|
* Action used to start the conference.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2020-08-14 07:45:15 +00:00
|
|
|
* @param {Object} options - The config options that override the default ones (if any).
|
2021-09-28 22:50:57 +00:00
|
|
|
* @param {boolean} ignoreJoiningInProgress - If true we won't check the joiningInProgress flag.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {Function}
|
|
|
|
*/
|
2022-10-17 11:28:01 +00:00
|
|
|
export function joinConference(options?: Object, ignoreJoiningInProgress = false) {
|
|
|
|
return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2021-09-28 22:50:57 +00:00
|
|
|
if (!ignoreJoiningInProgress) {
|
|
|
|
const state = getState();
|
|
|
|
const { joiningInProgress } = state['features/prejoin'];
|
|
|
|
|
|
|
|
if (joiningInProgress) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(setJoiningInProgress(true));
|
|
|
|
}
|
|
|
|
|
|
|
|
const state = getState();
|
|
|
|
let localTracks = getLocalTracks(state['features/base/tracks']);
|
|
|
|
|
|
|
|
options && dispatch(updateConfig(options));
|
|
|
|
|
|
|
|
// Do not signal audio/video tracks if the user joins muted.
|
|
|
|
for (const track of localTracks) {
|
2021-11-10 18:05:24 +00:00
|
|
|
// Always add the audio track on Safari because of a known issue where audio playout doesn't happen
|
2021-09-28 22:50:57 +00:00
|
|
|
// if the user joins audio and video muted.
|
|
|
|
if (track.muted
|
2021-11-10 18:05:24 +00:00
|
|
|
&& !(browser.isWebKitBased() && track.jitsiTrack && track.jitsiTrack.getType() === MEDIA_TYPE.AUDIO)) {
|
2021-09-28 22:50:57 +00:00
|
|
|
try {
|
|
|
|
await dispatch(replaceLocalTrack(track.jitsiTrack, null));
|
|
|
|
} catch (error) {
|
|
|
|
logger.error(`Failed to replace local track (${track.jitsiTrack}) with null: ${error}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-fetch the local tracks after muted tracks have been removed above.
|
|
|
|
// This is needed, because the tracks are effectively disposed by the replaceLocalTrack and should not be used
|
|
|
|
// anymore.
|
|
|
|
localTracks = getLocalTracks(getState()['features/base/tracks']);
|
|
|
|
|
2022-10-17 11:28:01 +00:00
|
|
|
const jitsiTracks = localTracks.map((t: any) => t.jitsiTrack);
|
2021-09-28 22:50:57 +00:00
|
|
|
|
|
|
|
APP.conference.prejoinStart(jitsiTracks);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action used to set the flag for joining operation in progress.
|
|
|
|
*
|
|
|
|
* @param {boolean} value - The config options that override the default ones (if any).
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function setJoiningInProgress(value: boolean) {
|
2020-07-08 09:59:46 +00:00
|
|
|
return {
|
2021-09-28 22:50:57 +00:00
|
|
|
type: PREJOIN_JOINING_IN_PROGRESS,
|
|
|
|
value
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-28 22:50:57 +00:00
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Joins the conference without audio.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function joinConferenceWithoutAudio() {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2021-09-28 22:50:57 +00:00
|
|
|
const state = getState();
|
|
|
|
const { joiningInProgress } = state['features/prejoin'];
|
|
|
|
|
|
|
|
if (joiningInProgress) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch(setJoiningInProgress(true));
|
|
|
|
const tracks = state['features/base/tracks'];
|
2020-06-19 07:03:26 +00:00
|
|
|
const audioTrack = getLocalAudioTrack(tracks)?.jitsiTrack;
|
2020-04-16 10:47:10 +00:00
|
|
|
|
|
|
|
if (audioTrack) {
|
2021-09-28 22:50:57 +00:00
|
|
|
try {
|
|
|
|
await dispatch(replaceLocalTrack(audioTrack, null));
|
|
|
|
} catch (error) {
|
|
|
|
logger.error(`Failed to replace local audio with null: ${error}`);
|
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
}
|
2020-08-14 07:45:15 +00:00
|
|
|
|
|
|
|
dispatch(joinConference({
|
|
|
|
startSilent: true
|
2021-09-28 22:50:57 +00:00
|
|
|
}, true));
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-29 10:27:32 +00:00
|
|
|
/**
|
|
|
|
* Initializes the 'precallTest' and executes one test, storing the results.
|
|
|
|
*
|
|
|
|
* @param {Object} conferenceOptions - The conference options.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function makePrecallTest(conferenceOptions: Object) {
|
|
|
|
return async function(dispatch: Function) {
|
2020-10-08 19:04:15 +00:00
|
|
|
try {
|
|
|
|
await JitsiMeetJS.precallTest.init(conferenceOptions);
|
|
|
|
const results = await JitsiMeetJS.precallTest.execute();
|
2020-07-29 10:27:32 +00:00
|
|
|
|
2020-10-08 19:04:15 +00:00
|
|
|
dispatch(setPrecallTestResults(results));
|
|
|
|
} catch (error) {
|
|
|
|
logger.debug('Failed to execute pre call test - ', error);
|
|
|
|
}
|
2020-07-29 10:27:32 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
/**
|
|
|
|
* Opens an external page with all the dial in numbers.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function openDialInPage() {
|
2022-10-17 11:28:01 +00:00
|
|
|
return function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2021-02-24 09:37:14 +00:00
|
|
|
const dialInPage = getDialInfoPageURL(getState());
|
2020-05-14 12:30:24 +00:00
|
|
|
|
|
|
|
openURLInBrowser(dialInPage, true);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-26 11:53:44 +00:00
|
|
|
/**
|
|
|
|
* Action used to signal that the prejoin page has been initialized.
|
|
|
|
*
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function prejoinInitialized() {
|
|
|
|
return {
|
|
|
|
type: PREJOIN_INITIALIZED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* Creates a new audio track based on a device id and replaces the current one.
|
|
|
|
*
|
|
|
|
* @param {string} deviceId - The deviceId of the microphone.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function replaceAudioTrackById(deviceId: string) {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2020-04-16 10:47:10 +00:00
|
|
|
try {
|
2020-06-19 07:03:26 +00:00
|
|
|
const tracks = getState()['features/base/tracks'];
|
|
|
|
const newTrack = await createLocalTrack('audio', deviceId);
|
|
|
|
const oldTrack = getLocalAudioTrack(tracks)?.jitsiTrack;
|
2022-08-18 20:45:33 +00:00
|
|
|
const micDeviceId = newTrack.getDeviceId();
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2022-08-18 20:45:33 +00:00
|
|
|
logger.info(`Switching audio input device to ${micDeviceId}`);
|
2022-05-24 20:27:15 +00:00
|
|
|
dispatch(replaceLocalTrack(oldTrack, newTrack)).then(() => {
|
|
|
|
dispatch(updateSettings({
|
2022-08-18 20:45:33 +00:00
|
|
|
micDeviceId
|
2022-05-24 20:27:15 +00:00
|
|
|
}));
|
|
|
|
});
|
2020-04-16 10:47:10 +00:00
|
|
|
} catch (err) {
|
|
|
|
dispatch(setDeviceStatusWarning('prejoin.audioTrackError'));
|
|
|
|
logger.log('Error replacing audio track', err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new video track based on a device id and replaces the current one.
|
|
|
|
*
|
|
|
|
* @param {string} deviceId - The deviceId of the camera.
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function replaceVideoTrackById(deviceId: Object) {
|
2022-10-17 11:28:01 +00:00
|
|
|
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
2020-04-16 10:47:10 +00:00
|
|
|
try {
|
2020-06-19 07:03:26 +00:00
|
|
|
const tracks = getState()['features/base/tracks'];
|
2021-05-06 06:54:23 +00:00
|
|
|
const wasVideoMuted = isVideoMutedByUser(getState());
|
|
|
|
const [ newTrack ] = await createLocalTracksF(
|
|
|
|
{ cameraDeviceId: deviceId,
|
|
|
|
devices: [ 'video' ] },
|
|
|
|
{ dispatch,
|
|
|
|
getState }
|
|
|
|
);
|
2020-06-19 07:03:26 +00:00
|
|
|
const oldTrack = getLocalVideoTrack(tracks)?.jitsiTrack;
|
2022-08-18 20:45:33 +00:00
|
|
|
const cameraDeviceId = newTrack.getDeviceId();
|
2020-04-16 10:47:10 +00:00
|
|
|
|
2022-08-18 20:45:33 +00:00
|
|
|
logger.info(`Switching camera to ${cameraDeviceId}`);
|
2022-05-24 20:27:15 +00:00
|
|
|
dispatch(replaceLocalTrack(oldTrack, newTrack)).then(() => {
|
|
|
|
dispatch(updateSettings({
|
2022-08-18 20:45:33 +00:00
|
|
|
cameraDeviceId
|
2022-05-24 20:27:15 +00:00
|
|
|
}));
|
|
|
|
});
|
2021-05-06 06:54:23 +00:00
|
|
|
wasVideoMuted && newTrack.mute();
|
2020-04-16 10:47:10 +00:00
|
|
|
} catch (err) {
|
|
|
|
dispatch(setDeviceStatusWarning('prejoin.videoTrackError'));
|
|
|
|
logger.log('Error replacing video track', err);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the device status as OK with the corresponding text.
|
|
|
|
*
|
|
|
|
* @param {string} deviceStatusText - The text to be set.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setDeviceStatusOk(deviceStatusText: string) {
|
|
|
|
return {
|
|
|
|
type: SET_DEVICE_STATUS,
|
|
|
|
value: {
|
|
|
|
deviceStatusText,
|
|
|
|
deviceStatusType: 'ok'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the device status as 'warning' with the corresponding text.
|
|
|
|
*
|
|
|
|
* @param {string} deviceStatusText - The text to be set.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setDeviceStatusWarning(deviceStatusText: string) {
|
|
|
|
return {
|
|
|
|
type: SET_DEVICE_STATUS,
|
|
|
|
value: {
|
|
|
|
deviceStatusText,
|
|
|
|
deviceStatusType: 'warning'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
/**
|
|
|
|
* Action used to set the dial out status.
|
|
|
|
*
|
|
|
|
* @param {string} value - The status.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function setDialOutStatus(value: string) {
|
|
|
|
return {
|
|
|
|
type: SET_DIALOUT_STATUS,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action used to set the dial out country.
|
|
|
|
*
|
|
|
|
* @param {{ name: string, dialCode: string, code: string }} value - The country.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setDialOutCountry(value: Object) {
|
|
|
|
return {
|
|
|
|
type: SET_DIALOUT_COUNTRY,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-02 09:18:38 +00:00
|
|
|
/**
|
|
|
|
* Action used to set the stance of the display name.
|
|
|
|
*
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setPrejoinDisplayNameRequired() {
|
|
|
|
return {
|
|
|
|
type: SET_PREJOIN_DISPLAY_NAME_REQUIRED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-14 12:30:24 +00:00
|
|
|
/**
|
|
|
|
* Action used to set the dial out number.
|
|
|
|
*
|
|
|
|
* @param {string} value - The dial out number.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setDialOutNumber(value: string) {
|
|
|
|
return {
|
|
|
|
type: SET_DIALOUT_NUMBER,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-02-04 17:33:18 +00:00
|
|
|
/**
|
|
|
|
* Sets the visibility of the prejoin page when a client reload
|
|
|
|
* is triggered as a result of call migration initiated by Jicofo.
|
|
|
|
*
|
|
|
|
* @param {boolean} value - The visibility value.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setSkipPrejoinOnReload(value: boolean) {
|
|
|
|
return {
|
|
|
|
type: SET_SKIP_PREJOIN_RELOAD,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
2020-05-07 07:42:55 +00:00
|
|
|
* Action used to set the visiblitiy of the 'JoinByPhoneDialog'.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2020-05-07 07:42:55 +00:00
|
|
|
* @param {boolean} value - The value.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2020-05-07 07:42:55 +00:00
|
|
|
export function setJoinByPhoneDialogVisiblity(value: boolean) {
|
2020-04-16 10:47:10 +00:00
|
|
|
return {
|
2020-05-07 07:42:55 +00:00
|
|
|
type: SET_JOIN_BY_PHONE_DIALOG_VISIBLITY,
|
2020-04-16 10:47:10 +00:00
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-07-29 10:27:32 +00:00
|
|
|
/**
|
|
|
|
* Action used to set data from precall test.
|
|
|
|
*
|
|
|
|
* @param {Object} value - The precall test results.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
export function setPrecallTestResults(value: Object) {
|
|
|
|
return {
|
|
|
|
type: SET_PRECALL_TEST_RESULTS,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
2020-05-07 07:42:55 +00:00
|
|
|
* Action used to set the initial errors after creating the tracks.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2020-05-07 07:42:55 +00:00
|
|
|
* @param {Object} value - The track errors.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2020-05-07 07:42:55 +00:00
|
|
|
export function setPrejoinDeviceErrors(value: Object) {
|
2020-04-16 10:47:10 +00:00
|
|
|
return {
|
2020-05-07 07:42:55 +00:00
|
|
|
type: SET_PREJOIN_DEVICE_ERRORS,
|
2020-04-16 10:47:10 +00:00
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-03-16 15:59:33 +00:00
|
|
|
* Action used to set the visibility of the prejoin page.
|
2020-04-16 10:47:10 +00:00
|
|
|
*
|
2021-10-14 17:00:14 +00:00
|
|
|
* @param {boolean} value - The value.
|
2020-04-16 10:47:10 +00:00
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2021-10-14 17:00:14 +00:00
|
|
|
export function setPrejoinPageVisibility(value: boolean) {
|
2020-04-16 10:47:10 +00:00
|
|
|
return {
|
|
|
|
type: SET_PREJOIN_PAGE_VISIBILITY,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|