diff --git a/app.js b/app.js index 523e55781..1f84d4b3c 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,24 @@ import API from './modules/API/API'; import UIEvents from './service/UI/UIEvents'; +/** + * Tries to push history state with the following parameters: + * 'VideoChat', `Room: ${roomName}`, URL. If fail, prints the error and returns + * it. + */ +function pushHistoryState(roomName, URL) { + try { + window.history.pushState( + 'VideoChat', `Room: ${roomName}`, URL + ); + } catch (e) { + console.warn("Push history state failed with parameters:", + 'VideoChat', `Room: ${roomName}`, URL, e); + return e; + } + return null; +} + /** * Builds and returns the room name. */ @@ -33,9 +51,9 @@ function buildRoomName () { if(!roomName) { let word = RoomnameGenerator.generateRoomWithoutSeparator(); roomName = word.toLowerCase(); - window.history.pushState( - 'VideoChat', `Room: ${word}`, window.location.pathname + word - ); + let historyURL = window.location.href + word; + //Trying to push state with current URL + roomName + pushHistoryState(word, historyURL); } return roomName; diff --git a/conference.js b/conference.js index 46045ae47..1c7d1b93d 100644 --- a/conference.js +++ b/conference.js @@ -356,7 +356,6 @@ export default { if(JitsiMeetJS.getGlobalOnErrorHandler){ var oldOnErrorHandler = window.onerror; window.onerror = function (message, source, lineno, colno, error) { - JitsiMeetJS.getGlobalOnErrorHandler( message, source, lineno, colno, error); @@ -375,17 +374,39 @@ export default { }; } + let audioAndVideoError, audioOnlyError; + return JitsiMeetJS.init(config).then(() => { return Promise.all([ // try to retrieve audio and video createLocalTracks(['audio', 'video']) // if failed then try to retrieve only audio - .catch(() => createLocalTracks(['audio'])) + .catch(err => { + audioAndVideoError = err; + return createLocalTracks(['audio']); + }) // if audio also failed then just return empty array - .catch(() => []), + .catch(err => { + audioOnlyError = err; + return []; + }), connect(options.roomName) ]); }).then(([tracks, con]) => { + if (audioAndVideoError) { + if (audioOnlyError) { + // If both requests for 'audio' + 'video' and 'audio' only + // failed, we assume that there is some problems with user's + // microphone and show corresponding dialog. + APP.UI.showDeviceErrorDialog(audioOnlyError, null); + } else { + // If request for 'audio' + 'video' failed, but request for + // 'audio' only was OK, we assume that we had problems with + // camera and show corresponding dialog. + APP.UI.showDeviceErrorDialog(null, audioAndVideoError); + } + } + console.log('initialized with %s local tracks', tracks.length); APP.connection = connection = con; this._createRoom(tracks); @@ -541,39 +562,78 @@ export default { } function createNewTracks(type, cameraDeviceId, micDeviceId) { - return createLocalTracks(type, cameraDeviceId, micDeviceId) - .then(onTracksCreated) - .catch(() => { - // if we tried to create both audio and video tracks - // at once and failed, let's try again only with - // audio. Such situation may happen in case if we - // granted access only to microphone, but not to - // camera. - if (type.indexOf('audio') !== -1 - && type.indexOf('video') !== -1) { - return createLocalTracks(['audio'], null, - micDeviceId); - } + let audioTrackCreationError; + let videoTrackCreationError; + let audioRequested = type.indexOf('audio') !== -1; + let videoRequested = type.indexOf('video') !== -1; + let promise; - }) - .then(onTracksCreated) - .catch(() => { - // if we tried to create both audio and video tracks - // at once and failed, let's try again only with - // video. Such situation may happen in case if we - // granted access only to camera, but not to - // microphone. - if (type.indexOf('audio') !== -1 - && type.indexOf('video') !== -1) { - return createLocalTracks(['video'], - cameraDeviceId, - null); - } - }) - .then(onTracksCreated) - .catch(() => { - // can't do anything in this case, so just ignore; - }); + if (audioRequested && micDeviceId !== null) { + if (videoRequested && cameraDeviceId !== null) { + promise = createLocalTracks( + type, cameraDeviceId, micDeviceId) + .catch(() => { + return Promise.all([ + createAudioTrack(false), + createVideoTrack(false)]); + }) + .then((audioTracks, videoTracks) => { + if (audioTrackCreationError) { + if (videoTrackCreationError) { + APP.UI.showDeviceErrorDialog( + audioTrackCreationError, + videoTrackCreationError); + } else { + APP.UI.showDeviceErrorDialog( + audioTrackCreationError, + null); + } + } else if (videoTrackCreationError) { + APP.UI.showDeviceErrorDialog( + null, + videoTrackCreationError); + } + + return audioTracks.concat(videoTracks); + }); + } else { + promise = createAudioTrack(); + } + } else if (videoRequested && cameraDeviceId !== null) { + promise = createVideoTrack(); + } else { + promise = Promise.resolve([]); + } + + return promise + .then(onTracksCreated); + + function createAudioTrack(showError) { + return createLocalTracks(['audio'], null, micDeviceId) + .catch(err => { + audioTrackCreationError = err; + + if (showError) { + APP.UI.showDeviceErrorDialog(err, null); + } + + return []; + }); + } + + function createVideoTrack(showError) { + return createLocalTracks( + ['video'], cameraDeviceId, null) + .catch(err => { + videoTrackCreationError = err; + + if (showError) { + APP.UI.showDeviceErrorDialog(null, err); + } + + return []; + }); + } } function onTracksCreated(tracks) { @@ -896,13 +956,13 @@ export default { this.isSharingScreen = stream.videoType === 'desktop'; APP.UI.addLocalStream(stream); + + stream.videoType === 'camera' && APP.UI.enableCameraButton(); } else { this.videoMuted = false; this.isSharingScreen = false; } - stream.videoType === 'camera' && APP.UI.enableCameraButton(); - APP.UI.setVideoMuted(this.localId, this.videoMuted); APP.UI.updateDesktopSharingButtons(); @@ -977,12 +1037,13 @@ export default { this.videoSwitchInProgress = false; this.toggleScreenSharing(false); - if(err === TrackErrors.CHROME_EXTENSION_USER_CANCELED) + if (err.name === TrackErrors.CHROME_EXTENSION_USER_CANCELED) { return; + } console.error('failed to share local desktop', err); - if (err === TrackErrors.FIREFOX_EXTENSION_NEEDED) { + if (err.name === TrackErrors.FIREFOX_EXTENSION_NEEDED) { APP.UI.showExtensionRequiredDialog( config.desktopSharingFirefoxExtensionURL ); @@ -990,18 +1051,26 @@ export default { } // Handling: + // TrackErrors.PERMISSION_DENIED // TrackErrors.CHROME_EXTENSION_INSTALLATION_ERROR // TrackErrors.GENERAL // and any other - let dialogTxt = APP.translation - .generateTranslationHTML("dialog.failtoinstall"); - let dialogTitle = APP.translation - .generateTranslationHTML("dialog.error"); - APP.UI.messageHandler.openDialog( - dialogTitle, - dialogTxt, - false - ); + let dialogTxt; + let dialogTitle; + + if (err.name === TrackErrors.PERMISSION_DENIED) { + dialogTxt = APP.translation.generateTranslationHTML( + "dialog.screenSharingPermissionDeniedError"); + dialogTitle = APP.translation.generateTranslationHTML( + "dialog.error"); + } else { + dialogTxt = APP.translation.generateTranslationHTML( + "dialog.failtoinstall"); + dialogTitle = APP.translation.generateTranslationHTML( + "dialog.permissionDenied"); + } + + APP.UI.messageHandler.openDialog(dialogTitle, dialogTxt, false); }); } else { createLocalTracks(['video']).then( @@ -1354,22 +1423,32 @@ export default { APP.UI.addListener( UIEvents.VIDEO_DEVICE_CHANGED, (cameraDeviceId) => { - APP.settings.setCameraDeviceId(cameraDeviceId); - createLocalTracks(['video']).then(([stream]) => { - this.useVideoStream(stream); - console.log('switched local video device'); - }); + createLocalTracks(['video']) + .then(([stream]) => { + this.useVideoStream(stream); + console.log('switched local video device'); + APP.settings.setCameraDeviceId(cameraDeviceId); + }) + .catch((err) => { + APP.UI.showDeviceErrorDialog(null, err); + APP.UI.setSelectedCameraFromSettings(); + }); } ); APP.UI.addListener( UIEvents.AUDIO_DEVICE_CHANGED, (micDeviceId) => { - APP.settings.setMicDeviceId(micDeviceId); - createLocalTracks(['audio']).then(([stream]) => { - this.useAudioStream(stream); - console.log('switched local audio device'); - }); + createLocalTracks(['audio']) + .then(([stream]) => { + this.useAudioStream(stream); + console.log('switched local audio device'); + APP.settings.setMicDeviceId(micDeviceId); + }) + .catch((err) => { + APP.UI.showDeviceErrorDialog(err, null); + APP.UI.setSelectedMicFromSettings(); + }); } ); @@ -1382,6 +1461,7 @@ export default { console.warn('Failed to change audio output device. ' + 'Default or previously set audio output device ' + 'will be used instead.', err); + APP.UI.setSelectedAudioOutputFromSettings(); }); } ); diff --git a/debian/jitsi-meet.postinst b/debian/jitsi-meet.postinst index fdf38cccc..9e8844185 100644 --- a/debian/jitsi-meet.postinst +++ b/debian/jitsi-meet.postinst @@ -90,6 +90,7 @@ case "$1" in echo "org.jitsi.videobridge.rest.jetty.ResourceHandler.alias./config.js=/etc/jitsi/meet/$JVB_HOSTNAME-config.js" >> $JVB_CONFIG echo "org.jitsi.videobridge.rest.jetty.RewriteHandler.regex=^/([a-zA-Z0-9]+)$" >> $JVB_CONFIG echo "org.jitsi.videobridge.rest.jetty.RewriteHandler.replacement=/" >> $JVB_CONFIG + echo "org.jitsi.videobridge.rest.jetty.SSIResourceHandler.paths=/" >> $JVB_CONFIG echo "org.jitsi.videobridge.rest.jetty.tls.port=443" >> $JVB_CONFIG echo "org.jitsi.videobridge.TCP_HARVESTER_PORT=443" >> $JVB_CONFIG echo "org.jitsi.videobridge.rest.jetty.sslContextFactory.keyStorePath=/etc/jitsi/videobridge/$JVB_HOSTNAME.jks" >> $JVB_CONFIG diff --git a/lang/main.json b/lang/main.json index 62539cad0..f29084d0e 100644 --- a/lang/main.json +++ b/lang/main.json @@ -222,7 +222,21 @@ "stopStreamingWarning": "Are you sure you would like to stop the live streaming?", "stopRecordingWarning": "Are you sure you would like to stop the recording?", "stopLiveStreaming": "Stop live streaming", - "stopRecording": "Stop recording" + "stopRecording": "Stop recording", + "doNotShowWarningAgain": "Don't show this warning again", + "permissionDenied": "Permission Denied", + "screenSharingPermissionDeniedError": "You have not granted permission to share your screen.", + "micErrorPresent": "There was an error connecting to your microphone.", + "cameraErrorPresent": "There was an error connecting to your camera.", + "cameraUnsupportedResolutionError": "Your camera does not support required video resolution.", + "cameraUnknownError": "Cannot use camera for a unknown reason.", + "cameraPermissionDeniedError": "You have not granted permission to use your camera.", + "cameraNotFoundError": "Requested camera was not found.", + "cameraConstraintFailedError": "Yor camera does not satisfy some of required constraints.", + "micUnknownError": "Cannot use microphone for a unknown reason.", + "micPermissionDeniedError": "You have not granted permission to use your microphone.", + "micNotFoundError": "Requested microphone was not found.", + "micConstraintFailedError": "Yor microphone does not satisfy some of required constraints." }, "email": { @@ -275,7 +289,8 @@ "off": "Recording stopped", "failedToStart": "Recording failed to start", "buttonTooltip": "Start / stop recording", - "error": "Recording failed. Please try again." + "error": "Recording failed. Please try again.", + "unavailable": "The recording service is currently unavailable. Please try again later." }, "liveStreaming": { @@ -286,6 +301,7 @@ "failedToStart": "Live streaming failed to start", "buttonTooltip": "Start / stop live stream", "streamIdRequired": "Please fill in the stream id in order to launch the live streaming.", - "error": "Live streaming failed. Please try again" + "error": "Live streaming failed. Please try again.", + "busy": "All recorders are currently busy. Please try again later." } } diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 612f407c8..8b50f3041 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1,4 +1,4 @@ -/* global APP, $, config, interfaceConfig, toastr */ +/* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */ /* jshint -W101 */ var UI = {}; @@ -38,6 +38,32 @@ let sharedVideoManager; let followMeHandler; +const TrackErrors = JitsiMeetJS.errors.track; + +const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = { + microphone: {}, + camera: {} +}; + +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION] + = "dialog.cameraUnsupportedResolutionError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL] + = "dialog.cameraUnknownError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED] + = "dialog.cameraPermissionDeniedError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND] + = "dialog.cameraNotFoundError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED] + = "dialog.cameraConstraintFailedError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL] + = "dialog.micUnknownError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED] + = "dialog.micPermissionDeniedError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND] + = "dialog.micNotFoundError"; +JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED] + = "dialog.micConstraintFailedError"; + /** * Prompt user for nickname. */ @@ -1078,6 +1104,28 @@ UI.onAvailableDevicesChanged = function (devices) { SettingsMenu.changeDevicesList(devices); }; +/** + * Sets microphone's element to select camera ID from settings. + */ +UI.setSelectedCameraFromSettings = function () { + SettingsMenu.setSelectedCameraFromSettings(); +}; + +/** + * Sets audio outputs's + + ` + : ``; + let message = ''; + + if (micError) { + message = ` + ${message} +

+

+ ${additionalMicErrorMsg}`; + } + + if (cameraError) { + message = ` + ${message} +

+

+ ${additionalCameraErrorMsg}`; + } + + message = `${message}${doNotShowWarningAgainSection}`; + + messageHandler.openDialog( + titleMsg, + message, + false, + {Ok: true}, + function () { + let form = $.prompt.getPrompt(); + + if (form) { + let input = form.find("#doNotShowWarningAgain"); + + if (input.length) { + window.localStorage[localStoragePropName] = + input.prop("checked"); + } + } + } + ); + + APP.translation.translateElement($(".jqibox")); + + function getTitleKey() { + let title = "dialog.error"; + + if (micError && micError.name === TrackErrors.PERMISSION_DENIED) { + if (cameraError && cameraError.name === TrackErrors.PERMISSION_DENIED) { + title = "dialog.permissionDenied"; + } else if (!cameraError) { + title = "dialog.permissionDenied"; + } + } else if (cameraError && + cameraError.name === TrackErrors.PERMISSION_DENIED) { + title = "dialog.permissionDenied"; + } + + return title; + } +}; + UI.updateDevicesAvailability = function (id, devices) { VideoLayout.setDeviceAvailabilityIcons(id, devices); }; diff --git a/modules/UI/recording/Recording.js b/modules/UI/recording/Recording.js index 051aeda1a..8929d1be7 100644 --- a/modules/UI/recording/Recording.js +++ b/modules/UI/recording/Recording.js @@ -206,7 +206,9 @@ var Status = { AVAILABLE: "available", UNAVAILABLE: "unavailable", PENDING: "pending", - ERROR: "error" + ERROR: "error", + FAILED: "failed", + BUSY: "busy" }; /** @@ -245,21 +247,27 @@ var Recording = { if (recordingType === 'jibri') { this.baseClass = "fa fa-play-circle"; + this.recordingTitle = "dialog.liveStreaming"; this.recordingOnKey = "liveStreaming.on"; this.recordingOffKey = "liveStreaming.off"; this.recordingPendingKey = "liveStreaming.pending"; this.failedToStartKey = "liveStreaming.failedToStart"; this.recordingErrorKey = "liveStreaming.error"; this.recordingButtonTooltip = "liveStreaming.buttonTooltip"; + this.recordingUnavailable = "liveStreaming.unavailable"; + this.recordingBusy = "liveStreaming.busy"; } else { this.baseClass = "icon-recEnable"; + this.recordingTitle = "dialog.recording"; this.recordingOnKey = "recording.on"; this.recordingOffKey = "recording.off"; this.recordingPendingKey = "recording.pending"; this.failedToStartKey = "recording.failedToStart"; this.recordingErrorKey = "recording.error"; this.recordingButtonTooltip = "recording.buttonTooltip"; + this.recordingUnavailable = "recording.unavailable"; + this.recordingBusy = "liveStreaming.busy"; } selector.addClass(this.baseClass); @@ -307,10 +315,17 @@ var Recording = { } break; } + case Status.BUSY: { + APP.UI.messageHandler.openMessageDialog( + self.recordingTitle, + self.recordingBusy + ); + break; + } default: { APP.UI.messageHandler.openMessageDialog( - "dialog.liveStreaming", - "liveStreaming.unavailable" + self.recordingTitle, + self.recordingUnavailable ); } } @@ -352,6 +367,9 @@ var Recording = { updateRecordingUI (recordingState) { let buttonSelector = $('#toolbar_button_record'); + let oldState = this.currentState; + this.currentState = recordingState; + // TODO: handle recording state=available if (recordingState === Status.ON) { @@ -361,19 +379,21 @@ var Recording = { this._updateStatusLabel(this.recordingOnKey, false); } else if (recordingState === Status.OFF - || recordingState === Status.UNAVAILABLE) { + || recordingState === Status.UNAVAILABLE + || recordingState === Status.BUSY + || recordingState === Status.FAILED) { // We don't want to do any changes if this is // an availability change. - if (this.currentState !== Status.ON - && this.currentState !== Status.PENDING) + if (oldState !== Status.ON + && oldState !== Status.PENDING) return; buttonSelector.removeClass(this.baseClass + " active"); buttonSelector.addClass(this.baseClass); let messageKey; - if (this.currentState === Status.PENDING) + if (oldState === Status.PENDING) messageKey = this.failedToStartKey; else messageKey = this.recordingOffKey; @@ -391,15 +411,14 @@ var Recording = { this._updateStatusLabel(this.recordingPendingKey, true); } - else if (recordingState === Status.ERROR) { + else if (recordingState === Status.ERROR + || recordingState === Status.FAILED) { buttonSelector.removeClass(this.baseClass + " active"); buttonSelector.addClass(this.baseClass); this._updateStatusLabel(this.recordingErrorKey, true); } - this.currentState = recordingState; - let labelSelector = $('#recordingLabel'); // We don't show the label for available state. diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.js index bee62594f..58c78b3e3 100644 --- a/modules/UI/side_pannels/settings/SettingsMenu.js +++ b/modules/UI/side_pannels/settings/SettingsMenu.js @@ -203,6 +203,28 @@ export default { $('#avatar').attr('src', avatarUrl); }, + /** + * Sets microphone's element to select camera ID from settings. + */ + setSelectedCameraFromSettings () { + $('#selectCamera').val(Settings.getCameraDeviceId()); + }, + + /** + * Sets audio outputs's