2018-11-07 07:10:56 +08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React, { Component } from 'react';
|
2019-03-29 05:53:42 +08:00
|
|
|
import {
|
2020-05-26 04:00:13 +08:00
|
|
|
defineMessages, injectIntl, FormattedMessage,
|
2019-03-29 05:53:42 +08:00
|
|
|
} from 'react-intl';
|
2022-02-15 04:20:50 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2021-07-20 04:19:06 +08:00
|
|
|
import VirtualBgSelector from '/imports/ui/components/video-preview/virtual-background/component'
|
2018-11-17 01:59:15 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2021-04-01 19:14:24 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
2021-04-03 11:06:39 +08:00
|
|
|
import PreviewService from './service';
|
2024-06-17 19:54:03 +08:00
|
|
|
import VideoService from '/imports/ui/components/video-provider/service';
|
2021-10-28 21:16:36 +08:00
|
|
|
import Styled from './styles';
|
2021-04-03 11:06:39 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
|
|
|
import MediaStreamUtils from '/imports/utils/media-stream-utils';
|
2021-07-02 22:05:09 +08:00
|
|
|
import { notify } from '/imports/ui/services/notification';
|
2021-07-20 04:19:06 +08:00
|
|
|
import {
|
|
|
|
EFFECT_TYPES,
|
|
|
|
setSessionVirtualBackgroundInfo,
|
|
|
|
getSessionVirtualBackgroundInfo,
|
2024-07-19 04:24:10 +08:00
|
|
|
removeSessionVirtualBackgroundInfo,
|
2022-09-01 20:29:08 +08:00
|
|
|
isVirtualBackgroundSupported,
|
2024-08-23 20:04:56 +08:00
|
|
|
getSessionVirtualBackgroundInfoWithDefault,
|
2022-03-23 03:01:27 +08:00
|
|
|
} from '/imports/ui/services/virtual-background/service';
|
2024-05-29 21:26:11 +08:00
|
|
|
import { getSettingsSingletonInstance } from '/imports/ui/services/settings';
|
2022-08-26 22:50:46 +08:00
|
|
|
import Checkbox from '/imports/ui/components/common/checkbox/component'
|
2023-10-05 02:00:24 +08:00
|
|
|
import AppService from '/imports/ui/components/app/service';
|
2024-07-19 04:24:10 +08:00
|
|
|
import { CustomVirtualBackgroundsContext } from '/imports/ui/components/video-preview/virtual-background/context';
|
|
|
|
import VBGSelectorService from '/imports/ui/components/video-preview/virtual-background/service';
|
2018-11-15 05:12:02 +08:00
|
|
|
|
2019-09-27 02:28:37 +08:00
|
|
|
const VIEW_STATES = {
|
|
|
|
finding: 'finding',
|
|
|
|
found: 'found',
|
|
|
|
error: 'error',
|
|
|
|
};
|
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
const propTypes = {
|
2020-05-26 04:00:13 +08:00
|
|
|
intl: PropTypes.object.isRequired,
|
2018-11-07 07:10:56 +08:00
|
|
|
closeModal: PropTypes.func.isRequired,
|
|
|
|
startSharing: PropTypes.func.isRequired,
|
2019-12-19 01:50:16 +08:00
|
|
|
stopSharing: PropTypes.func.isRequired,
|
2019-07-24 06:24:31 +08:00
|
|
|
resolve: PropTypes.func,
|
2022-02-22 21:33:26 +08:00
|
|
|
camCapReached: PropTypes.bool,
|
2020-03-12 03:42:53 +08:00
|
|
|
hasVideoStream: PropTypes.bool.isRequired,
|
2019-07-27 00:48:51 +08:00
|
|
|
webcamDeviceId: PropTypes.string,
|
2019-11-29 04:28:41 +08:00
|
|
|
sharedDevices: PropTypes.arrayOf(PropTypes.string),
|
2018-11-07 07:10:56 +08:00
|
|
|
};
|
|
|
|
|
2019-07-24 06:24:31 +08:00
|
|
|
const defaultProps = {
|
|
|
|
resolve: null,
|
2022-02-22 21:33:26 +08:00
|
|
|
camCapReached: true,
|
2019-07-27 00:48:51 +08:00
|
|
|
webcamDeviceId: null,
|
2019-12-19 01:50:16 +08:00
|
|
|
sharedDevices: [],
|
2019-07-24 06:24:31 +08:00
|
|
|
};
|
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
const intlMessages = defineMessages({
|
2023-10-05 02:00:24 +08:00
|
|
|
webcamVirtualBackgroundTitle: {
|
|
|
|
id: 'app.videoPreview.webcamVirtualBackgroundLabel',
|
|
|
|
description: 'Title for the virtual background modal',
|
2022-04-12 01:09:13 +08:00
|
|
|
},
|
2018-11-07 07:10:56 +08:00
|
|
|
webcamSettingsTitle: {
|
|
|
|
id: 'app.videoPreview.webcamSettingsTitle',
|
|
|
|
description: 'Title for the video preview modal',
|
|
|
|
},
|
|
|
|
closeLabel: {
|
|
|
|
id: 'app.videoPreview.closeLabel',
|
|
|
|
description: 'Close button label',
|
|
|
|
},
|
2024-06-14 00:46:45 +08:00
|
|
|
cancelLabel: {
|
2024-05-22 01:36:03 +08:00
|
|
|
id: 'app.mobileAppModal.dismissLabel',
|
2024-06-14 00:46:45 +08:00
|
|
|
description: 'Close button label',
|
|
|
|
},
|
2018-11-07 07:10:56 +08:00
|
|
|
webcamPreviewLabel: {
|
|
|
|
id: 'app.videoPreview.webcamPreviewLabel',
|
|
|
|
description: 'Webcam preview label',
|
|
|
|
},
|
|
|
|
cameraLabel: {
|
|
|
|
id: 'app.videoPreview.cameraLabel',
|
|
|
|
description: 'Camera dropdown label',
|
|
|
|
},
|
2019-05-01 06:29:30 +08:00
|
|
|
qualityLabel: {
|
|
|
|
id: 'app.videoPreview.profileLabel',
|
|
|
|
description: 'Quality dropdown label',
|
|
|
|
},
|
2020-08-18 00:19:45 +08:00
|
|
|
low: {
|
|
|
|
id: 'app.videoPreview.quality.low',
|
|
|
|
description: 'Low quality option label',
|
|
|
|
},
|
|
|
|
medium: {
|
|
|
|
id: 'app.videoPreview.quality.medium',
|
|
|
|
description: 'Medium quality option label',
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
id: 'app.videoPreview.quality.high',
|
|
|
|
description: 'High quality option label',
|
|
|
|
},
|
|
|
|
hd: {
|
|
|
|
id: 'app.videoPreview.quality.hd',
|
|
|
|
description: 'High definition option label',
|
|
|
|
},
|
2018-11-07 07:10:56 +08:00
|
|
|
startSharingLabel: {
|
|
|
|
id: 'app.videoPreview.startSharingLabel',
|
2019-12-19 01:44:56 +08:00
|
|
|
description: 'Start sharing button label',
|
|
|
|
},
|
|
|
|
stopSharingLabel: {
|
|
|
|
id: 'app.videoPreview.stopSharingLabel',
|
|
|
|
description: 'Stop sharing button label',
|
|
|
|
},
|
2020-03-12 03:42:53 +08:00
|
|
|
stopSharingAllLabel: {
|
|
|
|
id: 'app.videoPreview.stopSharingAllLabel',
|
|
|
|
description: 'Stop sharing all button label',
|
|
|
|
},
|
2019-12-19 01:44:56 +08:00
|
|
|
sharedCameraLabel: {
|
|
|
|
id: 'app.videoPreview.sharedCameraLabel',
|
|
|
|
description: 'Already Shared camera label',
|
2018-11-07 07:10:56 +08:00
|
|
|
},
|
2019-09-27 02:28:37 +08:00
|
|
|
findingWebcamsLabel: {
|
|
|
|
id: 'app.videoPreview.findingWebcamsLabel',
|
|
|
|
description: 'Finding webcams label',
|
|
|
|
},
|
2018-11-07 07:10:56 +08:00
|
|
|
webcamOptionLabel: {
|
|
|
|
id: 'app.videoPreview.webcamOptionLabel',
|
|
|
|
description: 'Default webcam option label',
|
|
|
|
},
|
|
|
|
webcamNotFoundLabel: {
|
|
|
|
id: 'app.videoPreview.webcamNotFoundLabel',
|
|
|
|
description: 'Webcam not found label',
|
|
|
|
},
|
2019-05-01 06:29:30 +08:00
|
|
|
profileNotFoundLabel: {
|
|
|
|
id: 'app.videoPreview.profileNotFoundLabel',
|
|
|
|
description: 'Profile not found label',
|
|
|
|
},
|
2018-12-18 01:45:57 +08:00
|
|
|
permissionError: {
|
|
|
|
id: 'app.video.permissionError',
|
|
|
|
description: 'Error message for webcam permission',
|
|
|
|
},
|
2020-10-28 22:14:47 +08:00
|
|
|
AbortError: {
|
|
|
|
id: 'app.video.abortError',
|
|
|
|
description: 'Some problem occurred which prevented the device from being used',
|
|
|
|
},
|
|
|
|
OverconstrainedError: {
|
|
|
|
id: 'app.video.overconstrainedError',
|
|
|
|
description: 'No candidate devices which met the criteria requested',
|
|
|
|
},
|
|
|
|
SecurityError: {
|
|
|
|
id: 'app.video.securityError',
|
|
|
|
description: 'Media support is disabled on the Document',
|
|
|
|
},
|
|
|
|
TypeError: {
|
|
|
|
id: 'app.video.typeError',
|
|
|
|
description: 'List of constraints specified is empty, or has all constraints set to false',
|
|
|
|
},
|
2018-12-18 01:45:57 +08:00
|
|
|
NotFoundError: {
|
|
|
|
id: 'app.video.notFoundError',
|
|
|
|
description: 'error message when can not get webcam video',
|
|
|
|
},
|
|
|
|
NotAllowedError: {
|
|
|
|
id: 'app.video.notAllowed',
|
|
|
|
description: 'error message when webcam had permission denied',
|
|
|
|
},
|
|
|
|
NotSupportedError: {
|
|
|
|
id: 'app.video.notSupportedError',
|
|
|
|
description: 'error message when origin do not have ssl valid',
|
|
|
|
},
|
|
|
|
NotReadableError: {
|
|
|
|
id: 'app.video.notReadableError',
|
|
|
|
description: 'error message When the webcam is being used by other software',
|
2018-11-16 04:00:11 +08:00
|
|
|
},
|
2020-12-22 03:47:00 +08:00
|
|
|
TimeoutError: {
|
|
|
|
id: 'app.video.timeoutError',
|
|
|
|
description: 'error message when promise did not return',
|
|
|
|
},
|
2019-06-28 00:02:42 +08:00
|
|
|
iOSError: {
|
|
|
|
id: 'app.audioModal.iOSBrowser',
|
|
|
|
description: 'Audio/Video Not supported warning',
|
|
|
|
},
|
|
|
|
iOSErrorDescription: {
|
|
|
|
id: 'app.audioModal.iOSErrorDescription',
|
|
|
|
description: 'Audio/Video not supported description',
|
|
|
|
},
|
|
|
|
iOSErrorRecommendation: {
|
|
|
|
id: 'app.audioModal.iOSErrorRecommendation',
|
|
|
|
description: 'Audio/Video recommended action',
|
|
|
|
},
|
2020-06-04 06:25:21 +08:00
|
|
|
genericError: {
|
|
|
|
id: 'app.video.genericError',
|
|
|
|
description: 'error message for when the webcam sharing fails with unknown error',
|
|
|
|
},
|
2022-02-22 21:33:26 +08:00
|
|
|
camCapReached: {
|
|
|
|
id: 'app.video.camCapReached',
|
|
|
|
description: 'message for when the camera cap has been reached',
|
|
|
|
},
|
2021-07-20 04:19:06 +08:00
|
|
|
virtualBgGenericError: {
|
|
|
|
id: 'app.video.virtualBackground.genericError',
|
|
|
|
description: 'Failed to apply camera effect',
|
2021-07-20 21:41:14 +08:00
|
|
|
},
|
2022-07-13 05:44:20 +08:00
|
|
|
inactiveError: {
|
|
|
|
id: 'app.video.inactiveError',
|
|
|
|
description: 'Camera stopped unexpectedly',
|
|
|
|
},
|
2022-08-26 22:50:46 +08:00
|
|
|
brightness: {
|
|
|
|
id: 'app.videoPreview.brightness',
|
|
|
|
description: 'Brightness label',
|
|
|
|
},
|
|
|
|
wholeImageBrightnessLabel: {
|
|
|
|
id: 'app.videoPreview.wholeImageBrightnessLabel',
|
|
|
|
description: 'Whole image brightness label',
|
|
|
|
},
|
2022-09-30 10:06:18 +08:00
|
|
|
wholeImageBrightnessDesc: {
|
|
|
|
id: 'app.videoPreview.wholeImageBrightnessDesc',
|
|
|
|
description: 'Whole image brightness aria description',
|
|
|
|
},
|
2023-04-27 00:09:02 +08:00
|
|
|
cameraAsContentSettingsTitle: {
|
|
|
|
id: 'app.videoPreview.cameraAsContentSettingsTitle',
|
|
|
|
description: 'Title for the video preview modal when sharing camera as content',
|
|
|
|
},
|
2022-09-30 10:06:18 +08:00
|
|
|
sliderDesc: {
|
|
|
|
id: 'app.videoPreview.sliderDesc',
|
|
|
|
description: 'Brightness slider aria description',
|
|
|
|
},
|
2018-11-07 07:10:56 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
class VideoPreview extends Component {
|
2024-07-19 04:24:10 +08:00
|
|
|
static contextType = CustomVirtualBackgroundsContext;
|
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
const {
|
2018-11-17 02:56:39 +08:00
|
|
|
webcamDeviceId,
|
2018-11-07 07:10:56 +08:00
|
|
|
} = props;
|
|
|
|
|
2018-11-16 03:38:04 +08:00
|
|
|
this.handleProceed = this.handleProceed.bind(this);
|
|
|
|
this.handleStartSharing = this.handleStartSharing.bind(this);
|
2019-11-29 04:28:41 +08:00
|
|
|
this.handleStopSharing = this.handleStopSharing.bind(this);
|
2020-03-12 03:42:53 +08:00
|
|
|
this.handleStopSharingAll = this.handleStopSharingAll.bind(this);
|
2019-09-27 02:28:37 +08:00
|
|
|
this.handleSelectWebcam = this.handleSelectWebcam.bind(this);
|
|
|
|
this.handleSelectProfile = this.handleSelectProfile.bind(this);
|
2021-07-20 04:19:06 +08:00
|
|
|
this.handleVirtualBgSelected = this.handleVirtualBgSelected.bind(this);
|
2022-07-13 05:44:20 +08:00
|
|
|
this.handleLocalStreamInactive = this.handleLocalStreamInactive.bind(this);
|
2022-08-26 22:50:46 +08:00
|
|
|
this.handleBrightnessAreaChange = this.handleBrightnessAreaChange.bind(this);
|
2024-06-14 00:46:45 +08:00
|
|
|
this.handleSelectTab = this.handleSelectTab.bind(this);
|
2018-11-08 05:16:36 +08:00
|
|
|
|
2019-04-09 06:07:26 +08:00
|
|
|
this._isMounted = false;
|
|
|
|
|
2018-11-17 02:56:39 +08:00
|
|
|
this.state = {
|
2019-01-18 00:33:43 +08:00
|
|
|
webcamDeviceId,
|
2024-06-14 00:46:45 +08:00
|
|
|
selectedTab: 0,
|
2018-11-17 02:56:39 +08:00
|
|
|
availableWebcams: null,
|
2019-04-09 06:07:26 +08:00
|
|
|
selectedProfile: null,
|
|
|
|
isStartSharingDisabled: true,
|
2019-09-27 02:28:37 +08:00
|
|
|
viewState: VIEW_STATES.finding,
|
2019-11-21 01:17:42 +08:00
|
|
|
deviceError: null,
|
|
|
|
previewError: null,
|
2022-08-26 22:50:46 +08:00
|
|
|
brightness: 100,
|
|
|
|
wholeImageBrightness: false,
|
2024-07-19 04:24:10 +08:00
|
|
|
skipPreviewFailed: false,
|
2018-11-17 02:56:39 +08:00
|
|
|
};
|
2018-11-08 05:16:36 +08:00
|
|
|
}
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
set currentVideoStream (bbbVideoStream) {
|
2022-07-13 05:44:20 +08:00
|
|
|
// Stream is being unset - remove gUM revocation handler to avoid false negatives
|
|
|
|
if (this._currentVideoStream) {
|
|
|
|
this._currentVideoStream.removeListener('inactive', this.handleLocalStreamInactive);
|
|
|
|
}
|
|
|
|
// Set up inactivation handler for the new stream (to, eg, detect gUM revocation)
|
|
|
|
if (bbbVideoStream) {
|
|
|
|
bbbVideoStream.once('inactive', this.handleLocalStreamInactive);
|
|
|
|
}
|
2021-07-20 04:19:06 +08:00
|
|
|
this._currentVideoStream = bbbVideoStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
get currentVideoStream () {
|
|
|
|
return this._currentVideoStream;
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
shouldSkipVideoPreview() {
|
|
|
|
const { skipPreviewFailed } = this.state;
|
|
|
|
const { forceOpen } = this.props;
|
|
|
|
|
|
|
|
return PreviewService.getSkipVideoPreview() && !forceOpen && !skipPreviewFailed;
|
|
|
|
}
|
|
|
|
|
2019-06-28 00:02:42 +08:00
|
|
|
componentDidMount() {
|
2019-11-21 02:35:16 +08:00
|
|
|
const {
|
|
|
|
webcamDeviceId,
|
2022-01-13 03:25:35 +08:00
|
|
|
forceOpen,
|
2019-11-21 02:35:16 +08:00
|
|
|
} = this.props;
|
2019-06-28 00:02:42 +08:00
|
|
|
|
|
|
|
this._isMounted = true;
|
|
|
|
|
2021-04-03 11:06:39 +08:00
|
|
|
if (deviceInfo.hasMediaDevices) {
|
2024-07-19 04:24:10 +08:00
|
|
|
navigator.mediaDevices.enumerateDevices().then(async (devices) => {
|
2021-07-02 22:05:09 +08:00
|
|
|
VideoService.updateNumberOfDevices(devices);
|
2024-07-19 04:24:10 +08:00
|
|
|
// Tries to skip video preview - this can happen if:
|
|
|
|
// 1. skipVideoPreview, skipVideoPreviewOnFirstJoin, or
|
|
|
|
// skipVideoPreviewIfPreviousDevice flags are enabled and meet their
|
|
|
|
// own conditions
|
|
|
|
// 2. forceOpen flag was not specified to this component
|
|
|
|
//
|
|
|
|
// This will fail if no skip conditions are met, or if an unexpected
|
|
|
|
// failure occurs during the process. In that case, the error will be
|
|
|
|
// handled and the component will display the default video preview UI
|
|
|
|
if (this.shouldSkipVideoPreview()) {
|
|
|
|
try {
|
|
|
|
await this.skipVideoPreview()
|
|
|
|
return;
|
|
|
|
} catch (error) {
|
|
|
|
logger.warn({
|
|
|
|
logCode: 'video_preview_skip_failure',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, 'Skipping video preview failed');
|
|
|
|
}
|
|
|
|
}
|
2021-07-02 22:05:09 +08:00
|
|
|
// Late enumerateDevices resolution, stop.
|
|
|
|
if (!this._isMounted) return;
|
|
|
|
|
|
|
|
let {
|
|
|
|
webcams,
|
|
|
|
areLabelled,
|
|
|
|
areIdentified
|
|
|
|
} = PreviewService.digestVideoDevices(devices, webcamDeviceId);
|
|
|
|
|
|
|
|
logger.debug({
|
|
|
|
logCode: 'video_preview_enumerate_devices',
|
|
|
|
extraInfo: {
|
|
|
|
devices,
|
2021-04-03 11:06:39 +08:00
|
|
|
webcams,
|
2021-07-02 22:05:09 +08:00
|
|
|
},
|
|
|
|
}, `Enumerate devices came back. There are ${devices.length} devices and ${webcams.length} are video inputs`);
|
|
|
|
|
|
|
|
if (webcams.length > 0) {
|
2024-07-19 04:24:10 +08:00
|
|
|
await this.getInitialCameraStream(webcams[0].deviceId);
|
|
|
|
// Late gUM resolve, stop.
|
|
|
|
if (!this._isMounted) return;
|
|
|
|
|
|
|
|
if (!areLabelled || !areIdentified) {
|
|
|
|
// If they aren't labelled or have nullish deviceIds, run
|
|
|
|
// enumeration again and get their full versions
|
|
|
|
// Why: fingerprinting countermeasures obfuscate those when
|
|
|
|
// no permission was granted via gUM
|
|
|
|
try {
|
|
|
|
const newDevices = await navigator.mediaDevices.enumerateDevices();
|
|
|
|
webcams = PreviewService.digestVideoDevices(newDevices, webcamDeviceId).webcams;
|
|
|
|
} catch (error) {
|
|
|
|
// Not a critical error beucase it should only affect UI; log it
|
|
|
|
// and go ahead
|
|
|
|
logger.error({
|
|
|
|
logCode: 'video_preview_enumerate_relabel_failure',
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name, errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, 'enumerateDevices for relabelling failed');
|
|
|
|
}
|
|
|
|
}
|
2019-07-05 02:37:40 +08:00
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
this.setState({
|
|
|
|
availableWebcams: webcams,
|
|
|
|
viewState: VIEW_STATES.found,
|
|
|
|
});
|
|
|
|
this.displayPreview();
|
2021-07-02 22:05:09 +08:00
|
|
|
} else {
|
|
|
|
// There were no webcams coming from enumerateDevices. Throw an error.
|
|
|
|
const noWebcamsError = new Error('NotFoundError');
|
|
|
|
this.handleDeviceError('enumerate', noWebcamsError, ': no webcams found');
|
|
|
|
}
|
|
|
|
}).catch((error) => {
|
|
|
|
// enumerateDevices failed
|
|
|
|
this.handleDeviceError('enumerate', error, 'enumerating devices');
|
|
|
|
});
|
2019-09-27 02:28:37 +08:00
|
|
|
} else {
|
2021-04-03 11:06:39 +08:00
|
|
|
// Top-level navigator.mediaDevices is not supported.
|
|
|
|
// The session went through the version checking, but somehow ended here.
|
|
|
|
// Nothing we can do.
|
|
|
|
const error = new Error('NotSupportedError');
|
|
|
|
this.handleDeviceError('mount', error, ': navigator.mediaDevices unavailable');
|
2019-06-28 00:02:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 22:50:46 +08:00
|
|
|
componentDidUpdate() {
|
|
|
|
if (this.brightnessMarker) {
|
|
|
|
const markerStyle = window.getComputedStyle(this.brightnessMarker);
|
|
|
|
const left = parseFloat(markerStyle.left);
|
|
|
|
const right = parseFloat(markerStyle.right);
|
|
|
|
|
|
|
|
if (left < 0) {
|
|
|
|
this.brightnessMarker.style.left = '0px';
|
|
|
|
this.brightnessMarker.style.right = 'auto';
|
|
|
|
} else if (right < 0) {
|
|
|
|
this.brightnessMarker.style.right = '0px';
|
|
|
|
this.brightnessMarker.style.left = 'auto';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-28 00:02:42 +08:00
|
|
|
componentWillUnmount() {
|
2021-07-20 04:19:06 +08:00
|
|
|
const { webcamDeviceId } = this.state;
|
2022-07-13 05:44:20 +08:00
|
|
|
this.terminateCameraStream(this.currentVideoStream, webcamDeviceId);
|
2021-07-02 22:05:09 +08:00
|
|
|
this.cleanupStreamAndVideo();
|
2019-06-28 00:02:42 +08:00
|
|
|
this._isMounted = false;
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
async startCameraBrightness() {
|
2024-05-29 21:26:11 +08:00
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
|
|
|
const CAMERA_BRIGHTNESS_AVAILABLE = ENABLE_CAMERA_BRIGHTNESS && isVirtualBackgroundSupported();
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
if (CAMERA_BRIGHTNESS_AVAILABLE && this.currentVideoStream) {
|
2022-10-14 03:26:25 +08:00
|
|
|
const setBrightnessInfo = () => {
|
|
|
|
const stream = this.currentVideoStream || {};
|
|
|
|
const service = stream.virtualBgService || {};
|
|
|
|
const { brightness = 100, wholeImageBrightness = false } = service;
|
|
|
|
this.setState({ brightness, wholeImageBrightness });
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!this.currentVideoStream.virtualBgService) {
|
2024-07-19 04:24:10 +08:00
|
|
|
const switched = await this.startVirtualBackground(
|
2022-10-14 03:26:25 +08:00
|
|
|
this.currentVideoStream,
|
|
|
|
EFFECT_TYPES.NONE_TYPE,
|
2024-07-19 04:24:10 +08:00
|
|
|
);
|
|
|
|
if (switched) setBrightnessInfo();
|
2022-10-14 03:26:25 +08:00
|
|
|
} else {
|
|
|
|
setBrightnessInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
async setCameraBrightness(brightness) {
|
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
|
|
|
const CAMERA_BRIGHTNESS_AVAILABLE = ENABLE_CAMERA_BRIGHTNESS && isVirtualBackgroundSupported();
|
|
|
|
|
|
|
|
if (CAMERA_BRIGHTNESS_AVAILABLE && this.currentVideoStream) {
|
|
|
|
if (this.currentVideoStream?.virtualBgService == null) {
|
|
|
|
await this.startCameraBrightness();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentVideoStream.changeCameraBrightness(brightness);
|
|
|
|
this.setState({ brightness });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
handleSelectWebcam(event) {
|
|
|
|
const webcamValue = event.target.value;
|
2019-04-09 06:07:26 +08:00
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
this.getInitialCameraStream(webcamValue).then(() => {
|
2021-04-03 11:06:39 +08:00
|
|
|
this.displayPreview();
|
|
|
|
});
|
2019-04-09 06:07:26 +08:00
|
|
|
}
|
|
|
|
|
2022-09-06 03:06:22 +08:00
|
|
|
handleLocalStreamInactive({ id }) {
|
|
|
|
// id === MediaStream.id
|
|
|
|
if (this.currentVideoStream
|
|
|
|
&& typeof id === 'string'
|
|
|
|
&& this.currentVideoStream?.mediaStream?.id === id) {
|
|
|
|
this.setState({
|
|
|
|
isStartSharingDisabled: true,
|
|
|
|
});
|
|
|
|
this.handlePreviewError(
|
|
|
|
'stream_inactive',
|
|
|
|
new Error('inactiveError'),
|
|
|
|
'- preview camera stream inactive',
|
|
|
|
);
|
|
|
|
}
|
2022-07-13 05:44:20 +08:00
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
updateVirtualBackgroundInfo () {
|
2022-06-14 20:40:13 +08:00
|
|
|
const { webcamDeviceId } = this.state;
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
if (this.currentVideoStream) {
|
|
|
|
setSessionVirtualBackgroundInfo(
|
|
|
|
webcamDeviceId,
|
|
|
|
this.currentVideoStream.virtualBgType,
|
|
|
|
this.currentVideoStream.virtualBgName,
|
|
|
|
this.currentVideoStream.virtualBgUniqueId,
|
|
|
|
);
|
|
|
|
}
|
2022-06-14 20:40:13 +08:00
|
|
|
};
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
// Resolves into true if the background switch is successful, false otherwise
|
2022-04-12 01:09:13 +08:00
|
|
|
handleVirtualBgSelected(type, name, customParams) {
|
2022-06-14 20:40:13 +08:00
|
|
|
const { sharedDevices } = this.props;
|
2024-07-19 04:24:10 +08:00
|
|
|
const { webcamDeviceId, brightness } = this.state;
|
2023-03-28 05:46:42 +08:00
|
|
|
const shared = this.isAlreadyShared(webcamDeviceId);
|
2022-06-14 20:40:13 +08:00
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
|
|
|
const CAMERA_BRIGHTNESS_AVAILABLE = ENABLE_CAMERA_BRIGHTNESS && isVirtualBackgroundSupported();
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
if (type !== EFFECT_TYPES.NONE_TYPE || CAMERA_BRIGHTNESS_AVAILABLE && brightness !== 100) {
|
2022-08-25 19:30:36 +08:00
|
|
|
return this.startVirtualBackground(this.currentVideoStream, type, name, customParams).then((switched) => {
|
2024-08-23 20:04:56 +08:00
|
|
|
if (switched) this.updateVirtualBackgroundInfo();
|
2022-06-14 20:40:13 +08:00
|
|
|
return switched;
|
|
|
|
});
|
2021-07-20 21:41:14 +08:00
|
|
|
} else {
|
2021-07-20 04:19:06 +08:00
|
|
|
this.stopVirtualBackground(this.currentVideoStream);
|
2022-06-14 20:40:13 +08:00
|
|
|
if (shared) this.updateVirtualBackgroundInfo();
|
2021-07-20 04:19:06 +08:00
|
|
|
return Promise.resolve(true);
|
2021-07-20 21:41:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
stopVirtualBackground(bbbVideoStream) {
|
|
|
|
if (bbbVideoStream) {
|
|
|
|
bbbVideoStream.stopVirtualBackground();
|
|
|
|
this.displayPreview();
|
2021-07-20 21:41:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-12 01:09:13 +08:00
|
|
|
startVirtualBackground(bbbVideoStream, type, name, customParams) {
|
2021-07-20 04:19:06 +08:00
|
|
|
this.setState({ isStartSharingDisabled: true });
|
2021-07-20 21:41:14 +08:00
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
if (bbbVideoStream == null) return Promise.resolve(false);
|
2021-07-20 21:41:14 +08:00
|
|
|
|
2022-04-12 01:09:13 +08:00
|
|
|
return bbbVideoStream.startVirtualBackground(type, name, customParams).then(() => {
|
2021-07-20 04:19:06 +08:00
|
|
|
this.displayPreview();
|
|
|
|
return true;
|
|
|
|
}).catch(error => {
|
|
|
|
this.handleVirtualBgError(error, type, name);
|
|
|
|
return false;
|
|
|
|
}).finally(() => {
|
|
|
|
this.setState({ isStartSharingDisabled: false });
|
|
|
|
});
|
2021-07-20 21:41:14 +08:00
|
|
|
}
|
|
|
|
|
2019-04-09 06:07:26 +08:00
|
|
|
handleSelectProfile(event) {
|
|
|
|
const profileValue = event.target.value;
|
|
|
|
const { webcamDeviceId } = this.state;
|
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
const selectedProfile = PreviewService.getCameraProfile(profileValue);
|
|
|
|
this.getCameraStream(webcamDeviceId, selectedProfile).then(() => {
|
2021-04-03 11:06:39 +08:00
|
|
|
this.displayPreview();
|
|
|
|
});
|
2018-11-07 07:10:56 +08:00
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
async handleStartSharing() {
|
2022-10-03 19:09:03 +08:00
|
|
|
const {
|
|
|
|
resolve,
|
|
|
|
startSharing,
|
2023-04-27 00:09:02 +08:00
|
|
|
cameraAsContent,
|
|
|
|
startSharingCameraAsContent,
|
2022-10-03 19:09:03 +08:00
|
|
|
} = this.props;
|
|
|
|
const {
|
|
|
|
webcamDeviceId,
|
|
|
|
selectedProfile,
|
|
|
|
brightness,
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
// Only streams that will be shared should be stored in the service.
|
|
|
|
// If the store call returns false, we're duplicating stuff. So clean this one
|
2021-04-03 11:06:39 +08:00
|
|
|
// up because it's an impostor.
|
2021-07-20 04:19:06 +08:00
|
|
|
if(!PreviewService.storeStream(webcamDeviceId, this.currentVideoStream)) {
|
|
|
|
this.currentVideoStream.stop();
|
2021-04-03 11:06:39 +08:00
|
|
|
}
|
2021-07-20 04:19:06 +08:00
|
|
|
|
2022-09-01 20:29:08 +08:00
|
|
|
if (
|
|
|
|
this.currentVideoStream.virtualBgService
|
|
|
|
&& brightness === 100
|
|
|
|
&& this.currentVideoStream.virtualBgType === EFFECT_TYPES.NONE_TYPE
|
|
|
|
) {
|
|
|
|
this.stopVirtualBackground(this.currentVideoStream);
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
if (!cameraAsContent) {
|
|
|
|
// Store selected profile, camera ID and virtual background in the storage
|
|
|
|
// for future use
|
|
|
|
PreviewService.changeProfile(selectedProfile);
|
|
|
|
PreviewService.changeWebcam(webcamDeviceId);
|
|
|
|
this.updateVirtualBackgroundInfo();
|
|
|
|
this.cleanupStreamAndVideo();
|
2023-04-27 00:09:02 +08:00
|
|
|
startSharing(webcamDeviceId);
|
2024-07-19 04:24:10 +08:00
|
|
|
} else {
|
|
|
|
this.cleanupStreamAndVideo();
|
|
|
|
startSharingCameraAsContent(webcamDeviceId);
|
2023-04-27 00:09:02 +08:00
|
|
|
}
|
2018-11-16 03:38:04 +08:00
|
|
|
}
|
|
|
|
|
2019-12-19 01:44:56 +08:00
|
|
|
handleStopSharing() {
|
2023-03-28 05:46:42 +08:00
|
|
|
const { resolve, stopSharing, stopSharingCameraAsContent } = this.props;
|
2019-12-19 01:44:56 +08:00
|
|
|
const { webcamDeviceId } = this.state;
|
2023-03-28 05:46:42 +08:00
|
|
|
|
|
|
|
if (this.isCameraAsContentDevice(webcamDeviceId)) {
|
|
|
|
stopSharingCameraAsContent();
|
|
|
|
} else {
|
|
|
|
PreviewService.deleteStream(webcamDeviceId);
|
|
|
|
stopSharing(webcamDeviceId);
|
|
|
|
this.cleanupStreamAndVideo();
|
|
|
|
}
|
2019-11-29 04:28:41 +08:00
|
|
|
if (resolve) resolve();
|
|
|
|
}
|
|
|
|
|
2020-03-12 03:42:53 +08:00
|
|
|
handleStopSharingAll() {
|
|
|
|
const { resolve, stopSharing } = this.props;
|
|
|
|
stopSharing();
|
|
|
|
if (resolve) resolve();
|
|
|
|
}
|
|
|
|
|
2018-11-16 03:38:04 +08:00
|
|
|
handleProceed() {
|
2023-10-05 02:00:24 +08:00
|
|
|
const { resolve, closeModal, sharedDevices } = this.props;
|
2022-09-01 20:29:08 +08:00
|
|
|
const { webcamDeviceId, brightness } = this.state;
|
|
|
|
const shared = sharedDevices.includes(webcamDeviceId);
|
|
|
|
|
|
|
|
if (
|
2023-10-05 02:00:24 +08:00
|
|
|
(shared)
|
2022-09-01 20:29:08 +08:00
|
|
|
&& this.currentVideoStream.virtualBgService
|
|
|
|
&& brightness === 100
|
|
|
|
&& this.currentVideoStream.virtualBgType === EFFECT_TYPES.NONE_TYPE
|
|
|
|
) {
|
|
|
|
this.stopVirtualBackground(this.currentVideoStream);
|
|
|
|
}
|
2021-04-03 11:06:39 +08:00
|
|
|
|
2022-07-13 05:44:20 +08:00
|
|
|
this.terminateCameraStream(this.currentVideoStream, webcamDeviceId);
|
2019-01-18 00:33:43 +08:00
|
|
|
closeModal();
|
2018-11-16 03:38:04 +08:00
|
|
|
if (resolve) resolve();
|
2018-11-08 05:16:36 +08:00
|
|
|
}
|
|
|
|
|
2020-10-28 22:17:20 +08:00
|
|
|
handlePreviewError(logCode, error, description) {
|
|
|
|
logger.warn({
|
|
|
|
logCode: `video_preview_${logCode}_error`,
|
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, `Error ${description}`);
|
|
|
|
this.setState({
|
|
|
|
previewError: this.handleGUMError(error),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-28 21:22:40 +08:00
|
|
|
handleDeviceError(logCode, error, description) {
|
|
|
|
logger.warn({
|
2020-10-28 22:18:34 +08:00
|
|
|
logCode: `video_preview_${logCode}_error`,
|
2020-10-28 21:22:40 +08:00
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
|
|
|
},
|
|
|
|
}, `Error ${description}`);
|
|
|
|
this.setState({
|
|
|
|
viewState: VIEW_STATES.error,
|
|
|
|
deviceError: this.handleGUMError(error),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-06-04 06:25:21 +08:00
|
|
|
handleGUMError(error) {
|
|
|
|
const { intl } = this.props;
|
|
|
|
|
|
|
|
logger.error({
|
|
|
|
logCode: 'video_preview_gum_failure',
|
|
|
|
extraInfo: {
|
2020-06-09 01:13:36 +08:00
|
|
|
errorName: error.name, errorMessage: error.message,
|
2020-06-04 06:25:21 +08:00
|
|
|
},
|
2020-06-09 01:13:36 +08:00
|
|
|
}, 'getUserMedia failed in video-preview');
|
|
|
|
|
2021-04-03 11:06:39 +08:00
|
|
|
const intlError = intlMessages[error.name] || intlMessages[error.message];
|
|
|
|
if (intlError) {
|
|
|
|
return intl.formatMessage(intlError);
|
2020-06-09 01:13:36 +08:00
|
|
|
}
|
2020-06-04 06:25:21 +08:00
|
|
|
|
2020-06-09 01:13:36 +08:00
|
|
|
return intl.formatMessage(intlMessages.genericError,
|
2020-06-09 23:37:08 +08:00
|
|
|
{ 0: `${error.name}: ${error.message}` });
|
2020-06-04 06:25:21 +08:00
|
|
|
}
|
|
|
|
|
2022-07-13 05:44:20 +08:00
|
|
|
terminateCameraStream(stream, deviceId) {
|
|
|
|
if (stream) {
|
|
|
|
// Stream is being destroyed - remove gUM revocation handler to avoid false negatives
|
|
|
|
stream.removeListener('inactive', this.handleLocalStreamInactive);
|
2022-09-06 03:06:22 +08:00
|
|
|
PreviewService.terminateCameraStream(stream, deviceId);
|
2022-07-13 05:44:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
cleanupStreamAndVideo() {
|
2021-07-20 04:19:06 +08:00
|
|
|
this.currentVideoStream = null;
|
2021-07-02 22:05:09 +08:00
|
|
|
if (this.video) this.video.srcObject = null;
|
2021-04-03 11:06:39 +08:00
|
|
|
}
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
handleVirtualBgError(error, type, name) {
|
|
|
|
const { intl } = this.props;
|
|
|
|
logger.error({
|
|
|
|
logCode: `video_preview_virtualbg_error`,
|
2021-07-20 21:41:14 +08:00
|
|
|
extraInfo: {
|
|
|
|
errorName: error.name,
|
|
|
|
errorMessage: error.message,
|
2021-07-20 04:19:06 +08:00
|
|
|
virtualBgType: type,
|
|
|
|
virtualBgName: name,
|
2021-07-20 21:41:14 +08:00
|
|
|
},
|
2021-07-20 04:19:06 +08:00
|
|
|
}, `Failed to toggle virtual background: ${error.message}`);
|
|
|
|
|
|
|
|
notify(intl.formatMessage(intlMessages.virtualBgGenericError), 'error', 'video');
|
2021-07-20 21:41:14 +08:00
|
|
|
}
|
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
updateDeviceId (deviceId) {
|
|
|
|
let actualDeviceId = deviceId;
|
2021-04-03 11:06:39 +08:00
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
if (!actualDeviceId && this.currentVideoStream) {
|
2022-04-05 05:09:35 +08:00
|
|
|
actualDeviceId = MediaStreamUtils.extractDeviceIdFromStream(
|
|
|
|
this.currentVideoStream.mediaStream,
|
|
|
|
'video',
|
|
|
|
);
|
2021-04-03 11:06:39 +08:00
|
|
|
}
|
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
this.setState({ webcamDeviceId: actualDeviceId, });
|
|
|
|
}
|
2019-04-09 06:07:26 +08:00
|
|
|
|
2021-07-02 22:05:09 +08:00
|
|
|
getInitialCameraStream(deviceId) {
|
2023-04-27 00:09:02 +08:00
|
|
|
const { cameraAsContent } = this.props;
|
|
|
|
const defaultProfile = !cameraAsContent ? PreviewService.getDefaultProfile() : PreviewService.getCameraAsContentProfile();
|
2021-04-03 11:06:39 +08:00
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
return this.getCameraStream(deviceId, defaultProfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
applyStoredVirtualBg(deviceId = null) {
|
|
|
|
const webcamDeviceId = deviceId || this.state.webcamDeviceId;
|
|
|
|
|
|
|
|
// Apply the virtual background stored in Local/Session Storage, if any
|
|
|
|
// If it fails, remove the stored background.
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let customParams;
|
|
|
|
const virtualBackground = getSessionVirtualBackgroundInfo(webcamDeviceId);
|
|
|
|
|
|
|
|
if (virtualBackground) {
|
|
|
|
const { type, name, uniqueId } = virtualBackground;
|
|
|
|
const handleFailure = (error) => {
|
|
|
|
this.handleVirtualBgError(error, type, name);
|
|
|
|
removeSessionVirtualBackgroundInfo(webcamDeviceId);
|
|
|
|
reject(error);
|
|
|
|
};
|
|
|
|
const applyCustomVirtualBg = (backgrounds) => {
|
|
|
|
const background = backgrounds[uniqueId]
|
|
|
|
|| Object.values(backgrounds).find(bg => bg.uniqueId === uniqueId);
|
|
|
|
|
|
|
|
if (background && background.data) {
|
|
|
|
customParams = {
|
|
|
|
uniqueId,
|
|
|
|
file: background?.data,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
handleFailure(new Error('Missing virtual background data'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.handleVirtualBgSelected(type, name, customParams).then(resolve, handleFailure);
|
|
|
|
};
|
|
|
|
|
|
|
|
// If uniqueId is defined, this is a custom background. Fetch the custom
|
|
|
|
// params from the context and apply them
|
|
|
|
if (uniqueId) {
|
2024-08-23 20:04:56 +08:00
|
|
|
if (this.context.backgrounds[uniqueId]) {
|
|
|
|
applyCustomVirtualBg(this.context.backgrounds);
|
|
|
|
} else if (!this.context.loaded) {
|
2024-07-19 04:24:10 +08:00
|
|
|
// Virtual BG context might not be loaded yet (in case this is
|
|
|
|
// skipping the video preview). Load it manually.
|
|
|
|
VBGSelectorService.load(handleFailure, applyCustomVirtualBg);
|
|
|
|
} else {
|
2024-08-23 20:04:56 +08:00
|
|
|
handleFailure(new Error('Missing virtual background'));
|
2024-07-19 04:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Built-in background, just apply it.
|
|
|
|
this.handleVirtualBgSelected(type, name, customParams).then(resolve, handleFailure);
|
2024-08-23 20:04:56 +08:00
|
|
|
} else if (this.context.backgrounds.webcamBackgroundURL) {
|
|
|
|
// Apply custom background from JOIN URL parameter automatically
|
|
|
|
// only if there's not any session background yet.
|
|
|
|
const { filename, data, type, uniqueId } = this.context.backgrounds.webcamBackgroundURL;
|
|
|
|
const customParams = {
|
|
|
|
file: data,
|
|
|
|
uniqueId,
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleFailure = (error) => {
|
|
|
|
this.handleVirtualBgError(error, type, filename);
|
|
|
|
removeSessionVirtualBackgroundInfo(webcamDeviceId);
|
|
|
|
reject(error);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.handleVirtualBgSelected(type, filename, customParams).then(resolve, handleFailure);
|
2024-07-19 04:24:10 +08:00
|
|
|
} else {
|
|
|
|
resolve();
|
|
|
|
}
|
2021-07-02 22:05:09 +08:00
|
|
|
});
|
2019-04-09 06:07:26 +08:00
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
async getCameraStream(deviceId, profile) {
|
2021-07-20 04:19:06 +08:00
|
|
|
const { webcamDeviceId } = this.state;
|
2024-07-19 04:24:10 +08:00
|
|
|
const { cameraAsContent, forceOpen } = this.props;
|
2021-07-07 10:54:19 +08:00
|
|
|
|
2019-09-27 02:28:37 +08:00
|
|
|
this.setState({
|
|
|
|
selectedProfile: profile.id,
|
|
|
|
isStartSharingDisabled: true,
|
|
|
|
previewError: undefined,
|
|
|
|
});
|
2021-04-03 11:06:39 +08:00
|
|
|
|
2022-07-13 05:44:20 +08:00
|
|
|
this.terminateCameraStream(this.currentVideoStream, webcamDeviceId);
|
2021-07-02 22:05:09 +08:00
|
|
|
this.cleanupStreamAndVideo();
|
2019-04-09 06:07:26 +08:00
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
try {
|
|
|
|
// The return of doGUM is an instance of BBBVideoStream (a thin wrapper over a MediaStream)
|
|
|
|
const bbbVideoStream = await PreviewService.doGUM(deviceId, profile);
|
2021-07-20 04:19:06 +08:00
|
|
|
this.currentVideoStream = bbbVideoStream;
|
2024-07-19 04:24:10 +08:00
|
|
|
this.updateDeviceId(deviceId);
|
|
|
|
} catch(error) {
|
2021-07-02 22:05:09 +08:00
|
|
|
// When video preview is set to skip, we need some way to bubble errors
|
|
|
|
// up to users; so re-throw the error
|
2024-07-19 04:24:10 +08:00
|
|
|
if (!this.shouldSkipVideoPreview()) {
|
2021-07-02 22:05:09 +08:00
|
|
|
this.handlePreviewError('do_gum_preview', error, 'displaying final selection');
|
|
|
|
} else {
|
|
|
|
throw error;
|
|
|
|
}
|
2024-07-19 04:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Restore virtual background if it was stored in Local/Session Storage
|
|
|
|
try {
|
|
|
|
if (!cameraAsContent) await this.applyStoredVirtualBg(deviceId);
|
|
|
|
} catch (error) {
|
|
|
|
// Only bubble up errors in this case if we're skipping the video preview
|
|
|
|
// This is because virtual background failures are deemed critical when
|
|
|
|
// skipping the video preview, but not otherwise
|
|
|
|
if (this.shouldSkipVideoPreview()) {
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
// Late VBG resolve, clean up tracks, stop.
|
|
|
|
if (!this._isMounted) {
|
|
|
|
this.terminateCameraStream(bbbVideoStream, deviceId);
|
|
|
|
this.cleanupStreamAndVideo();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
isStartSharingDisabled: false,
|
|
|
|
});
|
|
|
|
}
|
2019-04-09 06:07:26 +08:00
|
|
|
}
|
|
|
|
|
2021-04-03 11:06:39 +08:00
|
|
|
displayPreview() {
|
2021-07-20 04:19:06 +08:00
|
|
|
if (this.currentVideoStream && this.video) {
|
|
|
|
this.video.srcObject = this.currentVideoStream.mediaStream;
|
|
|
|
}
|
2021-07-02 22:05:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
skipVideoPreview() {
|
2024-07-19 04:24:10 +08:00
|
|
|
const { webcamDeviceId } = this.state;
|
|
|
|
const { forceOpen } = this.props;
|
|
|
|
|
|
|
|
return this.getInitialCameraStream(webcamDeviceId).then(() => {
|
2021-07-02 22:05:09 +08:00
|
|
|
this.handleStartSharing();
|
|
|
|
}).catch(error => {
|
2024-07-19 04:24:10 +08:00
|
|
|
PreviewService.clearWebcamDeviceId();
|
|
|
|
PreviewService.clearWebcamProfileId();
|
|
|
|
removeSessionVirtualBackgroundInfo(webcamDeviceId);
|
2021-07-02 22:05:09 +08:00
|
|
|
this.cleanupStreamAndVideo();
|
2024-07-19 04:24:10 +08:00
|
|
|
// Mark the skip as failed so that the component will override any option
|
|
|
|
// to skip the video preview and display the default UI
|
|
|
|
if (this._isMounted) this.setState({ skipPreviewFailed: true });
|
|
|
|
throw error;
|
2021-07-02 22:05:09 +08:00
|
|
|
});
|
2021-04-03 11:06:39 +08:00
|
|
|
}
|
|
|
|
|
2019-06-28 00:02:42 +08:00
|
|
|
supportWarning() {
|
|
|
|
const { intl } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.Warning>!</Styled.Warning>
|
|
|
|
<Styled.Main>{intl.formatMessage(intlMessages.iOSError)}</Styled.Main>
|
|
|
|
<Styled.Text>{intl.formatMessage(intlMessages.iOSErrorDescription)}</Styled.Text>
|
|
|
|
<Styled.Text>
|
2019-06-28 00:02:42 +08:00
|
|
|
{intl.formatMessage(intlMessages.iOSErrorRecommendation)}
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.Text>
|
2019-06-28 00:02:42 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-05 21:24:07 +08:00
|
|
|
getFallbackLabel(webcam, index) {
|
|
|
|
const { intl } = this.props;
|
|
|
|
return `${intl.formatMessage(intlMessages.cameraLabel)} ${index}`
|
|
|
|
}
|
|
|
|
|
2023-03-28 05:46:42 +08:00
|
|
|
isAlreadyShared (webcamId) {
|
|
|
|
const { sharedDevices, cameraAsContentDeviceId } = this.props;
|
|
|
|
|
|
|
|
return sharedDevices.includes(webcamId) || webcamId === cameraAsContentDeviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
isCameraAsContentDevice (deviceId) {
|
|
|
|
const { cameraAsContentDeviceId } = this.props;
|
|
|
|
|
|
|
|
return deviceId === cameraAsContentDeviceId;
|
|
|
|
}
|
|
|
|
|
2019-09-27 02:28:37 +08:00
|
|
|
renderDeviceSelectors() {
|
2018-11-07 07:10:56 +08:00
|
|
|
const {
|
|
|
|
intl,
|
2020-05-26 01:32:24 +08:00
|
|
|
sharedDevices,
|
2023-04-27 00:09:02 +08:00
|
|
|
cameraAsContent,
|
2018-11-07 07:10:56 +08:00
|
|
|
} = this.props;
|
|
|
|
|
2019-01-18 00:33:43 +08:00
|
|
|
const {
|
|
|
|
webcamDeviceId,
|
|
|
|
availableWebcams,
|
2023-04-28 00:38:27 +08:00
|
|
|
selectedProfile,
|
2019-09-27 02:28:37 +08:00
|
|
|
} = this.state;
|
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
return (
|
2024-04-10 23:59:12 +08:00
|
|
|
<Styled.InternCol>
|
2024-06-14 00:46:45 +08:00
|
|
|
<Styled.Label htmlFor="setCam">
|
|
|
|
{intl.formatMessage(intlMessages.cameraLabel)}
|
|
|
|
</Styled.Label>
|
|
|
|
{ availableWebcams && availableWebcams.length > 0
|
|
|
|
? (
|
|
|
|
<Styled.Select
|
|
|
|
id="setCam"
|
|
|
|
value={webcamDeviceId || ''}
|
|
|
|
onChange={this.handleSelectWebcam}
|
|
|
|
>
|
|
|
|
{availableWebcams.map((webcam, index) => (
|
|
|
|
<option key={webcam.deviceId} value={webcam.deviceId}>
|
|
|
|
{webcam.label || this.getFallbackLabel(webcam, index)}
|
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</Styled.Select>
|
|
|
|
)
|
|
|
|
: (
|
|
|
|
<span>
|
|
|
|
{intl.formatMessage(intlMessages.webcamNotFoundLabel)}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
{this.renderQualitySelector()}
|
2024-04-10 23:59:12 +08:00
|
|
|
</Styled.InternCol>
|
2024-06-14 00:46:45 +08:00
|
|
|
);
|
|
|
|
}
|
2019-12-19 01:44:56 +08:00
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
renderQualitySelector() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
cameraAsContent,
|
|
|
|
} = this.props
|
2024-05-29 21:26:11 +08:00
|
|
|
|
2024-06-21 04:18:52 +08:00
|
|
|
const {
|
|
|
|
selectedProfile,
|
|
|
|
availableWebcams,
|
|
|
|
webcamDeviceId,
|
|
|
|
} = this.state;
|
2024-06-14 00:46:45 +08:00
|
|
|
|
|
|
|
const shared = this.isAlreadyShared(webcamDeviceId);
|
|
|
|
|
|
|
|
if (shared) {
|
2022-04-12 01:09:13 +08:00
|
|
|
return (
|
2024-06-14 00:46:45 +08:00
|
|
|
<Styled.Label>
|
|
|
|
{intl.formatMessage(intlMessages.sharedCameraLabel)}
|
|
|
|
</Styled.Label>
|
2022-08-26 22:50:46 +08:00
|
|
|
);
|
2022-04-12 01:09:13 +08:00
|
|
|
}
|
2024-06-21 04:18:52 +08:00
|
|
|
|
|
|
|
if (cameraAsContent) return;
|
|
|
|
|
|
|
|
const CAMERA_PROFILES = window.meetingClientSettings.public.kurento.cameraProfiles || [];
|
|
|
|
// Filtered, without hidden profiles
|
|
|
|
const PREVIEW_CAMERA_PROFILES = CAMERA_PROFILES.filter(p => !p.hidden);
|
|
|
|
|
2019-09-27 02:28:37 +08:00
|
|
|
return (
|
2022-08-26 22:50:46 +08:00
|
|
|
<>
|
2024-06-14 00:46:45 +08:00
|
|
|
<Styled.Label htmlFor="setQuality">
|
|
|
|
{intl.formatMessage(intlMessages.qualityLabel)}
|
|
|
|
</Styled.Label>
|
2024-06-21 04:18:52 +08:00
|
|
|
{PREVIEW_CAMERA_PROFILES.length > 0
|
2024-06-14 00:46:45 +08:00
|
|
|
? (
|
|
|
|
<Styled.Select
|
|
|
|
id="setQuality"
|
|
|
|
value={selectedProfile || ''}
|
|
|
|
onChange={this.handleSelectProfile}
|
|
|
|
>
|
2024-06-21 04:18:52 +08:00
|
|
|
{PREVIEW_CAMERA_PROFILES.map((profile) => {
|
2024-06-14 00:46:45 +08:00
|
|
|
const label = intlMessages[`${profile.id}`]
|
|
|
|
? intl.formatMessage(intlMessages[`${profile.id}`])
|
|
|
|
: profile.name;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<option key={profile.id} value={profile.id}>
|
|
|
|
{`${label}`}
|
2023-05-06 03:21:21 +08:00
|
|
|
</option>
|
2024-06-14 00:46:45 +08:00
|
|
|
);
|
|
|
|
})}
|
|
|
|
</Styled.Select>
|
|
|
|
)
|
|
|
|
: (
|
|
|
|
<span>
|
|
|
|
{intl.formatMessage(intlMessages.profileNotFoundLabel)}
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
2022-08-26 22:50:46 +08:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
async handleBrightnessAreaChange() {
|
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
|
|
|
const CAMERA_BRIGHTNESS_AVAILABLE = ENABLE_CAMERA_BRIGHTNESS && isVirtualBackgroundSupported();
|
|
|
|
|
|
|
|
if (CAMERA_BRIGHTNESS_AVAILABLE && this.currentVideoStream) {
|
|
|
|
if (this.currentVideoStream?.virtualBgService == null) {
|
|
|
|
await this.startCameraBrightness();
|
|
|
|
}
|
|
|
|
|
|
|
|
const { wholeImageBrightness } = this.state;
|
|
|
|
this.currentVideoStream.toggleCameraBrightnessArea(!wholeImageBrightness);
|
|
|
|
this.setState({ wholeImageBrightness: !wholeImageBrightness });
|
|
|
|
}
|
2022-08-26 22:50:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renderBrightnessInput() {
|
2023-05-06 03:21:21 +08:00
|
|
|
const {
|
|
|
|
cameraAsContent,
|
2024-06-21 04:18:52 +08:00
|
|
|
cameraAsContentDeviceId,
|
2023-05-06 03:21:21 +08:00
|
|
|
} = this.props;
|
2023-04-28 00:38:27 +08:00
|
|
|
const {
|
|
|
|
webcamDeviceId,
|
|
|
|
} = this.state;
|
2024-05-29 21:26:11 +08:00
|
|
|
|
|
|
|
const ENABLE_CAMERA_BRIGHTNESS = window.meetingClientSettings.public.app.enableCameraBrightness;
|
|
|
|
|
2022-08-26 22:50:46 +08:00
|
|
|
if (!ENABLE_CAMERA_BRIGHTNESS) return null;
|
|
|
|
|
|
|
|
const { intl } = this.props;
|
2022-09-01 20:29:08 +08:00
|
|
|
const { brightness, wholeImageBrightness, isStartSharingDisabled } = this.state;
|
2023-03-28 05:46:42 +08:00
|
|
|
const shared = this.isAlreadyShared(webcamDeviceId);
|
2022-08-26 22:50:46 +08:00
|
|
|
|
|
|
|
const origin = brightness <= 100 ? 'left' : 'right';
|
|
|
|
const offset = origin === 'left'
|
|
|
|
? (brightness * 100) / 200
|
|
|
|
: ((200 - brightness) * 100) / 200;
|
|
|
|
|
2024-06-21 04:18:52 +08:00
|
|
|
if(cameraAsContent || webcamDeviceId === cameraAsContentDeviceId){ return null }
|
2023-05-06 03:21:21 +08:00
|
|
|
|
2022-08-26 22:50:46 +08:00
|
|
|
return (
|
2024-04-10 23:59:12 +08:00
|
|
|
<Styled.InternCol>
|
2022-08-26 22:50:46 +08:00
|
|
|
<Styled.Label htmlFor="brightness">
|
|
|
|
{intl.formatMessage(intlMessages.brightness)}
|
|
|
|
</Styled.Label>
|
2022-09-30 10:06:18 +08:00
|
|
|
<div aria-hidden>
|
2022-08-26 22:50:46 +08:00
|
|
|
<Styled.MarkerDynamicWrapper>
|
|
|
|
<Styled.MarkerDynamic
|
|
|
|
ref={(ref) => this.brightnessMarker = ref}
|
|
|
|
style={{ [origin]: `calc(${offset}% - 1rem)` }}
|
|
|
|
>
|
|
|
|
{brightness - 100}
|
|
|
|
</Styled.MarkerDynamic>
|
|
|
|
</Styled.MarkerDynamicWrapper>
|
|
|
|
</div>
|
|
|
|
<input
|
|
|
|
id="brightness"
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
type="range"
|
|
|
|
min={0}
|
|
|
|
max={200}
|
|
|
|
value={brightness}
|
2023-01-26 03:50:10 +08:00
|
|
|
aria-describedby={'brightness-slider-desc'}
|
2022-08-26 22:50:46 +08:00
|
|
|
onChange={(e) => {
|
|
|
|
const brightness = e.target.valueAsNumber;
|
2024-07-19 04:24:10 +08:00
|
|
|
this.setCameraBrightness(brightness);
|
2022-08-26 22:50:46 +08:00
|
|
|
}}
|
2022-09-01 20:29:08 +08:00
|
|
|
disabled={!isVirtualBackgroundSupported() || isStartSharingDisabled}
|
2022-08-26 22:50:46 +08:00
|
|
|
/>
|
2022-09-30 10:06:18 +08:00
|
|
|
<div style={{ display: 'none' }} id={'brightness-slider-desc'}>
|
|
|
|
{intl.formatMessage(intlMessages.sliderDesc)}
|
|
|
|
</div>
|
|
|
|
<Styled.MarkerWrapper aria-hidden>
|
2022-08-26 22:50:46 +08:00
|
|
|
<Styled.Marker>{'-100'}</Styled.Marker>
|
|
|
|
<Styled.Marker>{'0'}</Styled.Marker>
|
|
|
|
<Styled.Marker>{'100'}</Styled.Marker>
|
|
|
|
</Styled.MarkerWrapper>
|
|
|
|
<div style={{ display: 'flex', marginTop: '.5rem' }}>
|
|
|
|
<Checkbox
|
|
|
|
onChange={this.handleBrightnessAreaChange}
|
|
|
|
checked={wholeImageBrightness}
|
2022-09-30 10:06:18 +08:00
|
|
|
ariaLabel={intl.formatMessage(intlMessages.wholeImageBrightnessLabel)}
|
|
|
|
ariaDescribedBy={'whole-image-desc'}
|
|
|
|
ariaDesc={intl.formatMessage(intlMessages.wholeImageBrightnessDesc)}
|
2022-09-01 20:29:08 +08:00
|
|
|
disabled={!isVirtualBackgroundSupported() || isStartSharingDisabled}
|
2022-12-15 04:03:23 +08:00
|
|
|
label={intl.formatMessage(intlMessages.wholeImageBrightnessLabel)}
|
2022-08-26 22:50:46 +08:00
|
|
|
/>
|
|
|
|
</div>
|
2024-04-10 23:59:12 +08:00
|
|
|
</Styled.InternCol>
|
2019-09-27 02:28:37 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
renderVirtualBgSelector() {
|
2024-06-19 23:00:24 +08:00
|
|
|
const { isCustomVirtualBackgroundsEnabled } = this.props;
|
2021-11-19 19:10:24 +08:00
|
|
|
const { isStartSharingDisabled, webcamDeviceId } = this.state;
|
2021-07-20 04:19:06 +08:00
|
|
|
const initialVirtualBgState = this.currentVideoStream ? {
|
|
|
|
type: this.currentVideoStream.virtualBgType,
|
2024-07-19 04:24:10 +08:00
|
|
|
name: this.currentVideoStream.virtualBgName,
|
|
|
|
uniqueId: this.currentVideoStream.virtualBgUniqueId,
|
2024-08-23 20:04:56 +08:00
|
|
|
} : getSessionVirtualBackgroundInfoWithDefault(webcamDeviceId);
|
2021-07-20 04:19:06 +08:00
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
const {
|
|
|
|
showThumbnails: SHOW_THUMBNAILS = true,
|
|
|
|
} = window.meetingClientSettings.public.virtualBackgrounds;
|
|
|
|
|
2021-07-20 04:19:06 +08:00
|
|
|
return (
|
|
|
|
<VirtualBgSelector
|
|
|
|
handleVirtualBgSelected={this.handleVirtualBgSelected}
|
|
|
|
locked={isStartSharingDisabled}
|
|
|
|
showThumbnails={SHOW_THUMBNAILS}
|
|
|
|
initialVirtualBgState={initialVirtualBgState}
|
2024-06-19 23:00:24 +08:00
|
|
|
isCustomVirtualBackgroundsEnabled={isCustomVirtualBackgroundsEnabled}
|
2021-07-20 04:19:06 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
renderTabsContent(tabNumber) {
|
|
|
|
const {
|
|
|
|
cameraAsContent,
|
2024-06-17 20:35:06 +08:00
|
|
|
isVirtualBackgroundsEnabled,
|
2024-06-14 00:46:45 +08:00
|
|
|
} = this.props;
|
2023-10-05 02:00:24 +08:00
|
|
|
|
2024-06-17 20:35:06 +08:00
|
|
|
const shouldShowVirtualBackgrounds = isVirtualBackgroundsEnabled && !cameraAsContent;
|
2023-10-05 02:00:24 +08:00
|
|
|
|
|
|
|
return (
|
2024-04-10 23:59:12 +08:00
|
|
|
<Styled.ContentCol>
|
2023-10-05 02:00:24 +08:00
|
|
|
{tabNumber === 0 && (
|
2024-06-14 00:46:45 +08:00
|
|
|
<Styled.Col>
|
|
|
|
{this.renderDeviceSelectors()}
|
2024-07-06 03:44:21 +08:00
|
|
|
{isVirtualBackgroundSupported() && this.renderBrightnessInput()}
|
2024-06-14 00:46:45 +08:00
|
|
|
</Styled.Col>
|
2023-10-05 02:00:24 +08:00
|
|
|
)}
|
|
|
|
{tabNumber === 1 && shouldShowVirtualBackgrounds && (
|
2024-05-22 01:36:03 +08:00
|
|
|
<Styled.BgnCol>
|
2023-10-05 02:00:24 +08:00
|
|
|
{this.renderVirtualBgSelector()}
|
2024-05-22 01:36:03 +08:00
|
|
|
</Styled.BgnCol>
|
2023-10-05 02:00:24 +08:00
|
|
|
)}
|
2024-04-10 23:59:12 +08:00
|
|
|
</Styled.ContentCol>
|
2023-10-05 02:00:24 +08:00
|
|
|
);
|
2024-06-14 00:46:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
renderContent(selectedTab) {
|
2019-09-27 02:28:37 +08:00
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
viewState,
|
|
|
|
deviceError,
|
|
|
|
previewError,
|
|
|
|
} = this.state;
|
|
|
|
|
2024-05-29 21:26:11 +08:00
|
|
|
const Settings = getSettingsSingletonInstance();
|
2021-10-28 21:16:36 +08:00
|
|
|
const { animations } = Settings.application;
|
|
|
|
|
2023-10-14 04:30:50 +08:00
|
|
|
const containerStyle = {
|
|
|
|
width: '60%',
|
|
|
|
height: '25vh',
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
};
|
|
|
|
|
2019-09-27 02:28:37 +08:00
|
|
|
switch (viewState) {
|
|
|
|
case VIEW_STATES.finding:
|
|
|
|
return (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.Content>
|
|
|
|
<Styled.VideoCol>
|
2023-10-14 04:30:50 +08:00
|
|
|
<div style={containerStyle}>
|
2019-09-27 02:28:37 +08:00
|
|
|
<span>{intl.formatMessage(intlMessages.findingWebcamsLabel)}</span>
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.FetchingAnimation animations={animations} />
|
2019-09-27 02:28:37 +08:00
|
|
|
</div>
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.VideoCol>
|
|
|
|
</Styled.Content>
|
2019-09-27 02:28:37 +08:00
|
|
|
);
|
|
|
|
case VIEW_STATES.error:
|
2020-05-10 01:19:41 +08:00
|
|
|
return (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.Content>
|
|
|
|
<Styled.VideoCol><div>{deviceError}</div></Styled.VideoCol>
|
|
|
|
</Styled.Content>
|
2020-05-10 01:19:41 +08:00
|
|
|
);
|
2019-09-27 02:28:37 +08:00
|
|
|
case VIEW_STATES.found:
|
|
|
|
default:
|
|
|
|
return (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.Content>
|
|
|
|
<Styled.VideoCol>
|
2019-09-27 02:28:37 +08:00
|
|
|
{
|
2020-10-21 22:48:02 +08:00
|
|
|
previewError
|
|
|
|
? (
|
|
|
|
<div>{previewError}</div>
|
|
|
|
)
|
|
|
|
: (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.VideoPreview
|
|
|
|
mirroredVideo={VideoService.mirrorOwnWebcam()}
|
2020-10-21 22:48:02 +08:00
|
|
|
id="preview"
|
2021-07-02 22:05:09 +08:00
|
|
|
data-test={VideoService.mirrorOwnWebcam() ? 'mirroredVideoPreview' : 'videoPreview'}
|
2020-10-21 22:48:02 +08:00
|
|
|
ref={(ref) => { this.video = ref; }}
|
|
|
|
autoPlay
|
|
|
|
playsInline
|
|
|
|
muted
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.VideoCol>
|
2024-06-14 00:46:45 +08:00
|
|
|
{this.renderTabsContent(selectedTab)}
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.Content>
|
2019-09-27 02:28:37 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-27 00:09:02 +08:00
|
|
|
getModalTitle() {
|
|
|
|
const { intl, cameraAsContent } = this.props;
|
|
|
|
if (cameraAsContent) return intl.formatMessage(intlMessages.cameraAsContentSettingsTitle);
|
|
|
|
return intl.formatMessage(intlMessages.webcamSettingsTitle);
|
|
|
|
}
|
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
renderModalContent(selectedTab) {
|
2019-09-27 02:28:37 +08:00
|
|
|
const {
|
|
|
|
intl,
|
2020-03-12 03:42:53 +08:00
|
|
|
hasVideoStream,
|
2022-01-13 03:25:35 +08:00
|
|
|
forceOpen,
|
2022-02-22 21:33:26 +08:00
|
|
|
camCapReached,
|
2024-06-14 00:46:45 +08:00
|
|
|
closeModal,
|
2019-09-27 02:28:37 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
2019-01-18 00:33:43 +08:00
|
|
|
isStartSharingDisabled,
|
2019-12-19 01:44:56 +08:00
|
|
|
webcamDeviceId,
|
2019-11-21 01:17:42 +08:00
|
|
|
deviceError,
|
|
|
|
previewError,
|
2019-01-18 00:33:43 +08:00
|
|
|
} = this.state;
|
2024-07-19 04:24:10 +08:00
|
|
|
const shouldDisableButtons = this.shouldSkipVideoPreview()
|
|
|
|
&& !(deviceError || previewError);
|
2019-12-19 01:44:56 +08:00
|
|
|
|
2023-03-28 05:46:42 +08:00
|
|
|
const shared = this.isAlreadyShared(webcamDeviceId);
|
2019-12-19 01:44:56 +08:00
|
|
|
|
2023-10-05 02:00:24 +08:00
|
|
|
const showStopAllButton = hasVideoStream && VideoService.isMultipleCamerasEnabled();
|
|
|
|
|
2021-04-03 02:11:46 +08:00
|
|
|
const { isIe } = browserInfo;
|
2021-04-01 19:14:24 +08:00
|
|
|
|
2018-11-07 07:10:56 +08:00
|
|
|
return (
|
2021-11-11 01:52:58 +08:00
|
|
|
<>
|
2021-04-03 02:11:46 +08:00
|
|
|
{isIe ? (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.BrowserWarning>
|
2019-05-07 22:29:47 +08:00
|
|
|
<FormattedMessage
|
|
|
|
id="app.audioModal.unsupportedBrowserLabel"
|
2024-03-18 21:58:53 +08:00
|
|
|
description="Warning when someone joins with a browser that isn't supported"
|
2019-05-07 22:29:47 +08:00
|
|
|
values={{
|
|
|
|
0: <a href="https://www.google.com/chrome/">Chrome</a>,
|
|
|
|
1: <a href="https://getfirefox.com">Firefox</a>,
|
|
|
|
}}
|
|
|
|
/>
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.BrowserWarning>
|
2019-07-24 06:24:31 +08:00
|
|
|
) : null}
|
2019-09-27 02:28:37 +08:00
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
{this.renderContent(selectedTab)}
|
2019-05-07 22:29:47 +08:00
|
|
|
|
2023-10-05 02:00:24 +08:00
|
|
|
<Styled.Footer>
|
|
|
|
<Styled.BottomSeparator />
|
2024-04-10 23:59:12 +08:00
|
|
|
<Styled.FooterContainer>
|
2023-10-05 02:00:24 +08:00
|
|
|
{showStopAllButton ? (
|
2022-04-12 01:09:13 +08:00
|
|
|
<Styled.ExtraActions>
|
2023-10-05 02:00:24 +08:00
|
|
|
<Styled.StopAllButton
|
2022-04-12 01:09:13 +08:00
|
|
|
color="danger"
|
|
|
|
label={intl.formatMessage(intlMessages.stopSharingAllLabel)}
|
|
|
|
onClick={this.handleStopSharingAll}
|
|
|
|
disabled={shouldDisableButtons}
|
|
|
|
/>
|
|
|
|
</Styled.ExtraActions>
|
2023-10-05 02:00:24 +08:00
|
|
|
) : null}
|
|
|
|
{!shared && camCapReached ? (
|
|
|
|
<span>{intl.formatMessage(intlMessages.camCapReached)}</span>
|
|
|
|
) : (
|
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
|
<Styled.CancelButton
|
|
|
|
data-test="cancelSharingWebcam"
|
|
|
|
label={intl.formatMessage(intlMessages.cancelLabel)}
|
|
|
|
onClick={closeModal}
|
|
|
|
/>
|
|
|
|
<Styled.SharingButton
|
|
|
|
data-test="startSharingWebcam"
|
|
|
|
color={shared ? 'danger' : 'primary'}
|
|
|
|
label={intl.formatMessage(shared ? intlMessages.stopSharingLabel : intlMessages.startSharingLabel)}
|
|
|
|
onClick={shared ? this.handleStopSharing : this.handleStartSharing}
|
|
|
|
disabled={isStartSharingDisabled || isStartSharingDisabled === null || shouldDisableButtons}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
2024-04-10 23:59:12 +08:00
|
|
|
|
|
|
|
</Styled.FooterContainer>
|
2023-10-05 02:00:24 +08:00
|
|
|
</Styled.Footer>
|
2021-11-11 01:52:58 +08:00
|
|
|
</>
|
2019-06-28 00:02:42 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-14 00:46:45 +08:00
|
|
|
handleSelectTab(tab) {
|
|
|
|
this.setState({
|
|
|
|
selectedTab: tab,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-28 00:02:42 +08:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
intl,
|
2020-05-10 01:19:41 +08:00
|
|
|
isCamLocked,
|
2022-01-13 03:25:35 +08:00
|
|
|
forceOpen,
|
2023-04-12 23:51:23 +08:00
|
|
|
isOpen,
|
|
|
|
priority,
|
2023-10-14 04:30:50 +08:00
|
|
|
cameraAsContent,
|
2024-06-21 04:18:52 +08:00
|
|
|
cameraAsContentDeviceId,
|
2024-06-19 23:00:24 +08:00
|
|
|
isVirtualBackgroundsEnabled,
|
2019-06-28 00:02:42 +08:00
|
|
|
} = this.props;
|
2020-05-10 01:19:41 +08:00
|
|
|
|
2024-06-21 04:18:52 +08:00
|
|
|
const { selectedTab, webcamDeviceId } = this.state;
|
2024-06-14 00:46:45 +08:00
|
|
|
|
|
|
|
const BASE_NAME = window.meetingClientSettings.public.app.basename;
|
|
|
|
const WebcamSettingsImg = `${BASE_NAME}/resources/images/webcam_settings.svg`;
|
|
|
|
const WebcamBackgroundImg = `${BASE_NAME}/resources/images/webcam_background.svg`;
|
|
|
|
|
2023-10-05 02:00:24 +08:00
|
|
|
const darkThemeState = AppService.isDarkThemeEnabled();
|
|
|
|
|
2020-05-10 01:19:41 +08:00
|
|
|
if (isCamLocked === true) {
|
|
|
|
this.handleProceed();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-07-19 04:24:10 +08:00
|
|
|
if (this.shouldSkipVideoPreview()) {
|
2021-02-06 01:30:58 +08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-11-21 01:17:42 +08:00
|
|
|
const {
|
|
|
|
deviceError,
|
|
|
|
previewError,
|
|
|
|
} = this.state;
|
|
|
|
|
2022-01-13 03:25:35 +08:00
|
|
|
const allowCloseModal = !!(deviceError || previewError)
|
|
|
|
|| !PreviewService.getSkipVideoPreview()
|
|
|
|
|| forceOpen;
|
2019-06-28 00:02:42 +08:00
|
|
|
|
2024-06-21 04:18:52 +08:00
|
|
|
const shouldShowVirtualBackgroundsTab = isVirtualBackgroundsEnabled
|
|
|
|
&& !cameraAsContent
|
|
|
|
&& !(webcamDeviceId === cameraAsContentDeviceId)
|
2024-07-06 03:44:21 +08:00
|
|
|
&& isVirtualBackgroundSupported()
|
2024-06-21 04:18:52 +08:00
|
|
|
|
2019-06-28 00:02:42 +08:00
|
|
|
return (
|
2021-10-28 21:16:36 +08:00
|
|
|
<Styled.VideoPreviewModal
|
2019-06-28 00:02:42 +08:00
|
|
|
onRequestClose={this.handleProceed}
|
|
|
|
contentLabel={intl.formatMessage(intlMessages.webcamSettingsTitle)}
|
2019-11-21 01:17:42 +08:00
|
|
|
shouldShowCloseButton={allowCloseModal}
|
|
|
|
shouldCloseOnOverlayClick={allowCloseModal}
|
2021-12-10 22:55:37 +08:00
|
|
|
isPhone={deviceInfo.isPhone}
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test="webcamSettingsModal"
|
2023-04-12 23:51:23 +08:00
|
|
|
{...{
|
|
|
|
isOpen,
|
|
|
|
priority,
|
|
|
|
}}
|
2019-06-28 00:02:42 +08:00
|
|
|
>
|
2024-06-14 00:46:45 +08:00
|
|
|
<Styled.Container>
|
|
|
|
<Styled.Header>
|
|
|
|
<Styled.WebcamTabs
|
|
|
|
onSelect={this.handleSelectTab}
|
|
|
|
selectedIndex={selectedTab}
|
|
|
|
>
|
|
|
|
<Styled.WebcamTabList>
|
|
|
|
<Styled.WebcamTabSelector selectedClassName="is-selected">
|
|
|
|
<Styled.IconSvg
|
|
|
|
src={WebcamSettingsImg}
|
2023-10-05 02:00:24 +08:00
|
|
|
darkThemeState={darkThemeState}
|
2024-06-14 00:46:45 +08:00
|
|
|
/>
|
|
|
|
<span
|
2024-06-21 04:18:52 +08:00
|
|
|
id="webcam-settings-title">{this.getModalTitle()}
|
2024-06-14 00:46:45 +08:00
|
|
|
</span>
|
|
|
|
</Styled.WebcamTabSelector>
|
2024-06-21 04:18:52 +08:00
|
|
|
{shouldShowVirtualBackgroundsTab && (
|
2023-10-14 04:30:50 +08:00
|
|
|
<>
|
|
|
|
<Styled.HeaderSeparator />
|
|
|
|
<Styled.WebcamTabSelector selectedClassName="is-selected">
|
|
|
|
<Styled.IconSvg
|
|
|
|
src={WebcamBackgroundImg}
|
|
|
|
darkThemeState={darkThemeState}
|
|
|
|
/>
|
2024-06-19 23:00:24 +08:00
|
|
|
<span id="backgrounds-title">{intl.formatMessage(intlMessages.webcamVirtualBackgroundTitle)}</span>
|
2023-10-14 04:30:50 +08:00
|
|
|
</Styled.WebcamTabSelector>
|
|
|
|
</>
|
|
|
|
)}
|
2024-06-14 00:46:45 +08:00
|
|
|
</Styled.WebcamTabList>
|
|
|
|
|
|
|
|
</Styled.WebcamTabs>
|
|
|
|
</Styled.Header>
|
|
|
|
|
|
|
|
{deviceInfo.hasMediaDevices
|
|
|
|
? this.renderModalContent(selectedTab)
|
|
|
|
: this.supportWarning()
|
|
|
|
}
|
|
|
|
|
|
|
|
</Styled.Container>
|
2021-10-28 21:16:36 +08:00
|
|
|
</Styled.VideoPreviewModal>
|
2018-11-07 07:10:56 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoPreview.propTypes = propTypes;
|
2019-07-24 06:24:31 +08:00
|
|
|
VideoPreview.defaultProps = defaultProps;
|
2018-11-07 07:10:56 +08:00
|
|
|
|
|
|
|
export default injectIntl(VideoPreview);
|