From 59349e73b6ef56ef48821f27d4757ef44ab267e7 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Mon, 7 Oct 2024 19:39:02 +0200 Subject: [PATCH 1/9] feat(call): add option to enable blur background by default for all conversations Signed-off-by: DorraJaouad --- .../MediaSettings/MediaSettings.vue | 27 +++++++++++------ .../SettingsDialog/MediaDevicesPreview.vue | 30 +++++++++++++++++++ src/composables/useDevices.js | 11 +++++++ src/stores/settings.js | 22 +++++++++++++- 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index eb2fd8af0f9..fb1cb0f3fe0 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -352,6 +352,10 @@ export default { return this.settingsStore.getShowMediaSettings(this.token) }, + blurBackgroundEnabled() { + return this.settingsStore.getBlurBackgroundEnabled + }, + showVideo() { return this.videoPreviewAvailable && this.videoOn }, @@ -431,16 +435,21 @@ export default { this.audioOn = !BrowserStorage.getItem('audioDisabled_' + this.token) this.videoOn = !BrowserStorage.getItem('videoDisabled_' + this.token) this.silentCall = !!BrowserStorage.getItem('silentCall_' + this.token) - - // Set virtual background depending on BrowserStorage's settings - if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { - if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { - this.blurVirtualBackground() - } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { - this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) - } + // Check main blur background setting + if (this.blurBackgroundEnabled) { + this.blurVirtualBackground() + this.blurBackground() } else { - this.clearVirtualBackground() + // Set virtual background depending on BrowserStorage's settings + if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { + if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { + this.blurVirtualBackground() + } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { + this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) + } + } else { + this.clearVirtualBackground() + } } this.initializeDevices() diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index d672aa1b14b..9c3c74a68ff 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -63,6 +63,11 @@ disablePictureInPicture="true" tabindex="-1" /> + + {{ t('spreed', 'Enable blur background by default for all conversations.') }} + @@ -75,10 +80,14 @@ import VideoOff from 'vue-material-design-icons/VideoOff.vue' import { t } from '@nextcloud/l10n' +import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' + import MediaDevicesSelector from '../MediaSettings/MediaDevicesSelector.vue' import VolumeIndicator from '../UIShared/VolumeIndicator.vue' import { useDevices } from '../../composables/useDevices.js' +import { VIRTUAL_BACKGROUND } from '../../constants.js' +import { useSettingsStore } from '../../stores/settings.js' export default { @@ -88,6 +97,7 @@ export default { AlertCircle, MediaDevicesSelector, MicrophoneOff, + NcCheckboxRadioSwitch, VideoOff, VolumeIndicator, }, @@ -108,6 +118,7 @@ export default { audioStreamError, videoStream, videoStreamError, + virtualBackground, } = useDevices(video, true) return { @@ -125,6 +136,8 @@ export default { audioStreamError, videoStream, videoStreamError, + virtualBackground, + settingsStore: useSettingsStore(), } }, @@ -180,6 +193,10 @@ export default { return t('spreed', 'Error while accessing camera') }, + + blurBackgroundEnabled() { + return this.settingsStore.getBlurBackgroundEnabled + }, }, methods: { @@ -194,6 +211,19 @@ export default { this.videoInputId = videoInputId this.updatePreferences('videoinput') }, + + setBlurBackgroundEnabled(value) { + this.settingsStore.setBlurBackgroundEnabled(value) + if (value) { + this.virtualBackground.setEnabled(true) + this.virtualBackground.setVirtualBackground({ + backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, + blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, + }) + } else { + this.virtualBackground.setEnabled(false) + } + }, }, } diff --git a/src/composables/useDevices.js b/src/composables/useDevices.js index aa0b2714a6b..1dd7c1d8ac8 100644 --- a/src/composables/useDevices.js +++ b/src/composables/useDevices.js @@ -6,6 +6,8 @@ import createHark from 'hark' import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue' +import { VIRTUAL_BACKGROUND } from '../constants.js' +import BrowserStorage from '../services/BrowserStorage.js' import attachMediaStream from '../utils/attachmediastream.js' import TrackToStream from '../utils/media/pipeline/TrackToStream.js' import VirtualBackground from '../utils/media/pipeline/VirtualBackground.js' @@ -106,6 +108,15 @@ export function useDevices(video, initializeOnMounted) { virtualBackground.value.connectTrackSink('default', videoTrackToStream.value, 'video') + const blurBackgroundEnabled = BrowserStorage.getItem('blurBackgroundEnabled') + if (blurBackgroundEnabled === 'true') { + virtualBackground.value.setEnabled(true) + virtualBackground.value.setVirtualBackground({ + backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, + blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, + }) + } + if (initializeOnMounted) { initializeDevices() } diff --git a/src/stores/settings.js b/src/stores/settings.js index 5eb93f533ef..e0a5e613ee8 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -39,7 +39,8 @@ export const useSettingsStore = defineStore('settings', { readStatusPrivacy: loadState('spreed', 'read_status_privacy', PRIVACY.PRIVATE), typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE), showMediaSettings: {}, - startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'), + startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'),, + blurBackgroundEnabled: undefined, }), getters: { @@ -71,6 +72,16 @@ export const useSettingsStore = defineStore('settings', { } } }, + + getBlurBackgroundEnabled: (state) => { + if (state.blurBackgroundEnabled !== undefined) { + return state.blurBackgroundEnabled + } + + const storedValue = BrowserStorage.getItem('blurBackgroundEnabled') + state.blurBackgroundEnabled = storedValue === 'true' + return state.blurBackgroundEnabled + } }, actions: { @@ -103,6 +114,15 @@ export const useSettingsStore = defineStore('settings', { Vue.set(this.showMediaSettings, token, value) }, + setBlurBackgroundEnabled(value) { + if (value) { + BrowserStorage.setItem('blurBackgroundEnabled', 'true') + } else { + BrowserStorage.removeItem('blurBackgroundEnabled') + } + this.blurBackgroundEnabled = value + }, + async setStartWithoutMedia(value) { await setStartWithoutMedia(value) this.startWithoutMedia = value From b6cb2d9d5d713bf337b1c45e01215bedbc6d234f Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 30 Oct 2024 13:04:47 +0100 Subject: [PATCH 2/9] Feat: add blur background config Signed-off-by: DorraJaouad --- docs/capabilities.md | 1 + docs/settings.md | 1 + lib/Capabilities.php | 3 +++ lib/Config.php | 14 ++++++++++++++ lib/Controller/RoomController.php | 3 +++ lib/Federation/Proxy/TalkV1/ProxyRequest.php | 3 +++ lib/ResponseDefinitions.php | 1 + lib/Settings/BeforePreferenceSetEventListener.php | 3 ++- lib/Settings/UserPreference.php | 1 + src/__mocks__/capabilities.ts | 2 ++ src/services/settingsService.js | 4 ++++ tests/php/CapabilitiesTest.php | 2 ++ 12 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/capabilities.md b/docs/capabilities.md index f8bebf371cd..729936cc8c7 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -162,3 +162,4 @@ * `download-call-participants` - Whether the endpoints for moderators to download the call participants is available * `config => call => start-without-media` (local) - Boolean, whether media should be disabled when starting or joining a conversation * `config => call => max-duration` - Integer, maximum call duration in seconds. Please note that this should only be used with system cron and with a reasonable high value, due to the expended duration until the background job ran. +* `config => call => blur-background` (local) - Boolean, whether blur background is set by default when joining a conversation diff --git a/docs/settings.md b/docs/settings.md index 6093c41af7e..9a37ab2375a 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -31,6 +31,7 @@ Instead, the server API `POST /ocs/v2.php/apps/provisioning_api/api/v1/config/us | `typing_privacy` | `config => chat => typing-privacy` | `0` | One of the typing privacy constants from the [constants list](constants.md#participant-typing-privacy) | | `play_sounds` | | `'yes'` | `'yes'` and `'no'` | | `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` | +| `blur_background` | `config => call => blur-background` | `'no'` | `'yes'` and `'no'` | ## Set SIP settings diff --git a/lib/Capabilities.php b/lib/Capabilities.php index cb30c4bb443..fcfbd34ffae 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -130,6 +130,7 @@ class Capabilities implements IPublicCapability { 'predefined-backgrounds', 'can-upload-background', 'start-without-media', + 'blur-background', ], 'chat' => [ 'read-privacy', @@ -201,6 +202,7 @@ public function getCapabilities(): array { 'can-enable-sip' => false, 'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()), 'max-duration' => $this->appConfig->getAppValueInt('max_call_duration'), + 'blur-background' => $this->talkConfig->getBlurBackground($user?->getUID()), ], 'chat' => [ 'max-length' => ChatManager::MAX_CHAT_LENGTH, @@ -250,6 +252,7 @@ public function getCapabilities(): array { $capabilities['config']['attachments']['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID()); $capabilities['config']['chat']['read-privacy'] = $this->talkConfig->getUserReadPrivacy($user->getUID()); $capabilities['config']['chat']['typing-privacy'] = $this->talkConfig->getUserTypingPrivacy($user->getUID()); + $capabilities['config']['call']['blur-background'] = $this->talkConfig->getBlurBackground($user->getUID()); } $pubKey = $this->talkConfig->getSignalingTokenPublicKey(); diff --git a/lib/Config.php b/lib/Config.php index 2019731d976..aebb084a206 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -680,4 +680,18 @@ public function getCallsStartWithoutMedia(?string $userId): bool { return $this->appConfig->getAppValueBool('calls_start_without_media'); } + + /** + * User setting for blur background + * + * @param ?string $userId + * @return bool + */ + public function getBlurBackground(?string $userId): bool { + if ($userId !== null) { + $userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_BACKGROUND); + return $userSetting === 'yes'; + } + return false; + } } diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 17821e88409..5bf57809e0b 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -2458,6 +2458,9 @@ public function getCapabilities(): DataResponse { if (isset($data['config']['call']['start-without-media'])) { $data['config']['call']['start-without-media'] = $this->talkConfig->getCallsStartWithoutMedia($this->userId); } + if (isset($data['config']['call']['blur-background'])) { + $data['config']['call']['blur-background'] = $this->talkConfig->getBlurBackground($this->userId); + } if ($response->getHeaders()['X-Nextcloud-Talk-Hash']) { $headers['X-Nextcloud-Talk-Proxy-Hash'] = $response->getHeaders()['X-Nextcloud-Talk-Hash']; diff --git a/lib/Federation/Proxy/TalkV1/ProxyRequest.php b/lib/Federation/Proxy/TalkV1/ProxyRequest.php index 04305ca24d1..03f975fc48e 100644 --- a/lib/Federation/Proxy/TalkV1/ProxyRequest.php +++ b/lib/Federation/Proxy/TalkV1/ProxyRequest.php @@ -42,6 +42,9 @@ public function overwrittenRemoteTalkHash(string $hash): string { 'read-privacy', 'typing-privacy', ], + 'call' => [ + 'blur-background', + ] ], ] ])); diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 9722340e49d..86915555a78 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -348,6 +348,7 @@ * can-enable-sip: bool, * start-without-media: bool, * max-duration: int, + * blur-background: bool, * }, * chat: array{ * max-length: int, diff --git a/lib/Settings/BeforePreferenceSetEventListener.php b/lib/Settings/BeforePreferenceSetEventListener.php index 00f41f19f6a..f6173531cd4 100644 --- a/lib/Settings/BeforePreferenceSetEventListener.php +++ b/lib/Settings/BeforePreferenceSetEventListener.php @@ -60,7 +60,8 @@ public function validatePreference(string $userId, string $key, string|int|null // "boolean" yes/no if ($key === UserPreference::CALLS_START_WITHOUT_MEDIA - || $key === UserPreference::PLAY_SOUNDS) { + || $key === UserPreference::PLAY_SOUNDS + || $key === UserPreference::BLUR_BACKGROUND) { return $value === 'yes' || $value === 'no'; } diff --git a/lib/Settings/UserPreference.php b/lib/Settings/UserPreference.php index f360172f20e..f3e7829a681 100644 --- a/lib/Settings/UserPreference.php +++ b/lib/Settings/UserPreference.php @@ -9,6 +9,7 @@ namespace OCA\Talk\Settings; class UserPreference { + public const BLUR_BACKGROUND = 'blur_background'; public const CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media'; public const PLAY_SOUNDS = 'play_sounds'; public const TYPING_PRIVACY = 'typing_privacy'; diff --git a/src/__mocks__/capabilities.ts b/src/__mocks__/capabilities.ts index fe67a337f02..c1c565af8ce 100644 --- a/src/__mocks__/capabilities.ts +++ b/src/__mocks__/capabilities.ts @@ -117,6 +117,7 @@ export const mockedCapabilities: Capabilities = { 'can-enable-sip': true, 'start-without-media': false, 'max-duration': 0, + 'blur-background': false, }, chat: { 'max-length': 32000, @@ -149,6 +150,7 @@ export const mockedCapabilities: Capabilities = { 'predefined-backgrounds', 'can-upload-background', 'start-without-media', + 'blur-background', ], chat: [ 'read-privacy', diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 684e8a8babe..4127575e669 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -78,6 +78,10 @@ const setStartWithoutMedia = async function(value) { await setUserConfig('spreed', 'calls_start_without_media', value ? 'yes' : 'no') } +const setBlurBackground = async function(value) { + await setUserConfig('spreed', 'blur_background', value ? 'yes' : 'no') +} + /** * Set user config using provisioning API * diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index f18ab3d3c55..6d3ed7cda54 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -121,6 +121,7 @@ public function testGetCapabilitiesGuest(): void { 'can-enable-sip' => false, 'start-without-media' => false, 'max-duration' => 0, + 'blur-background' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', @@ -256,6 +257,7 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea 'can-enable-sip' => false, 'start-without-media' => false, 'max-duration' => 0, + 'blur-background' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', From d2022b813bec81bfa5d511dd9068a719a9f4e56d Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 30 Oct 2024 14:09:39 +0100 Subject: [PATCH 3/9] fix: migrate from browser storage to stored value config Signed-off-by: DorraJaouad --- .../MediaSettings/MediaSettings.vue | 29 ++++++++--- .../MediaSettings/VideoBackgroundEditor.vue | 7 +++ .../SettingsDialog/MediaDevicesPreview.vue | 50 +++++++++++++------ src/composables/useDevices.js | 11 ---- src/services/settingsService.js | 1 + src/stores/settings.js | 25 +++------- src/utils/webrtc/models/LocalMediaModel.js | 10 ++-- 7 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index fb1cb0f3fe0..b2e59f64e72 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -321,6 +321,7 @@ export default { isRecordingFromStart: false, isPublicShareAuthSidebar: false, isMirrored: false, + skipBlurBackgroundEnabled: false, } }, @@ -353,7 +354,7 @@ export default { }, blurBackgroundEnabled() { - return this.settingsStore.getBlurBackgroundEnabled + return this.settingsStore.blurBackgroundEnabled }, showVideo() { @@ -438,7 +439,6 @@ export default { // Check main blur background setting if (this.blurBackgroundEnabled) { this.blurVirtualBackground() - this.blurBackground() } else { // Set virtual background depending on BrowserStorage's settings if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { @@ -473,6 +473,15 @@ export default { isRecordingFromStart(value) { this.setRecordingConsentGiven(value) }, + + isInCall(value) { + if (value) { + // Apply global blur background setting + if (this.blurBackgroundEnabled && !this.skipBlurBackgroundEnabled) { + this.blurBackground(true) + } + } + }, }, beforeMount() { @@ -563,10 +572,15 @@ export default { }, handleUpdateBackground(background) { + // Default global blur background setting was changed by user + if (this.blurBackgroundEnabled && background !== 'blur') { + this.skipBlurBackgroundEnabled = true + } + // Apply the new background if (background === 'none') { this.clearBackground() } else if (background === 'blur') { - this.blurBackground() + this.blurBackground(this.blurBackgroundEnabled) } else { this.setBackgroundImage(background) } @@ -614,12 +628,15 @@ export default { /** * Blurs the background of the participants in current or future call + * + * @param {boolean} globalBlurBackground - Whether the global blur background setting is enabled (in Talk settings) */ - blurBackground() { + blurBackground(globalBlurBackground = false) { if (this.isInCall) { localMediaModel.enableVirtualBackground() - localMediaModel.setVirtualBackgroundBlur(VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT) - } else { + localMediaModel.setVirtualBackgroundBlur(VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, globalBlurBackground) + } else if (!globalBlurBackground) { + this.skipBlurBackgroundEnabled = true BrowserStorage.setItem('virtualBackgroundEnabled_' + this.token, 'true') BrowserStorage.setItem('virtualBackgroundType_' + this.token, VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.token, VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT) diff --git a/src/components/MediaSettings/VideoBackgroundEditor.vue b/src/components/MediaSettings/VideoBackgroundEditor.vue index ec3db3e9f35..b9842b325b4 100644 --- a/src/components/MediaSettings/VideoBackgroundEditor.vue +++ b/src/components/MediaSettings/VideoBackgroundEditor.vue @@ -87,6 +87,7 @@ import { VIRTUAL_BACKGROUND } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { getDavClient } from '../../services/DavClient.js' +import { useSettingsStore } from '../../stores/settings.js' import { findUniquePath } from '../../utils/fileUpload.js' const predefinedBackgroundLabels = { @@ -125,6 +126,7 @@ export default { return { canUploadBackgrounds: getTalkConfig('local', 'call', 'can-upload-background'), predefinedBackgrounds: getTalkConfig('local', 'call', 'predefined-backgrounds'), + settingsStore: useSettingsStore(), } }, @@ -254,6 +256,11 @@ export default { }, loadBackground() { + // Set virtual background depending on main blur setting (in Talk settings) + if (this.settingsStore.blurBackgroundEnabled) { + this.selectedBackground = 'blur' + return + } // Set virtual background depending on browser storage's settings if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index 9c3c74a68ff..9588a606ea4 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -63,10 +63,11 @@ disablePictureInPicture="true" tabindex="-1" /> - - {{ t('spreed', 'Enable blur background by default for all conversations.') }} + {{ t('spreed', 'Enable blur background by default for all conversation') }} @@ -87,8 +88,11 @@ import VolumeIndicator from '../UIShared/VolumeIndicator.vue' import { useDevices } from '../../composables/useDevices.js' import { VIRTUAL_BACKGROUND } from '../../constants.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useSettingsStore } from '../../stores/settings.js' +const supportDefaultBlurBackground = getTalkConfig('local', 'call', 'blur-background') !== undefined + export default { name: 'MediaDevicesPreview', @@ -136,8 +140,9 @@ export default { audioStreamError, videoStream, videoStreamError, - virtualBackground, settingsStore: useSettingsStore(), + virtualBackground, + supportDefaultBlurBackground, } }, @@ -195,10 +200,23 @@ export default { }, blurBackgroundEnabled() { - return this.settingsStore.getBlurBackgroundEnabled + return this.settingsStore.blurBackgroundEnabled }, }, + mounted() { + if (this.blurBackgroundEnabled) { + // wait for the virtual background to be ready + this.$nextTick(() => { + this.virtualBackground.setEnabled(true) + this.virtualBackground.setVirtualBackground({ + backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, + blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, + }) + }) + } + }, + methods: { t, @@ -212,16 +230,20 @@ export default { this.updatePreferences('videoinput') }, - setBlurBackgroundEnabled(value) { - this.settingsStore.setBlurBackgroundEnabled(value) - if (value) { - this.virtualBackground.setEnabled(true) - this.virtualBackground.setVirtualBackground({ - backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, - blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, - }) - } else { - this.virtualBackground.setEnabled(false) + async setBlurBackgroundEnabled(value) { + try { + await this.settingsStore.setBlurBackgroundEnabled(value) + if (value) { + this.virtualBackground.setEnabled(true) + this.virtualBackground.setVirtualBackground({ + backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, + blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, + }) + } else { + this.virtualBackground.setEnabled(false) + } + } catch (error) { + console.error('Failed to set blur background enabled:', error) } }, }, diff --git a/src/composables/useDevices.js b/src/composables/useDevices.js index 1dd7c1d8ac8..aa0b2714a6b 100644 --- a/src/composables/useDevices.js +++ b/src/composables/useDevices.js @@ -6,8 +6,6 @@ import createHark from 'hark' import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue' -import { VIRTUAL_BACKGROUND } from '../constants.js' -import BrowserStorage from '../services/BrowserStorage.js' import attachMediaStream from '../utils/attachmediastream.js' import TrackToStream from '../utils/media/pipeline/TrackToStream.js' import VirtualBackground from '../utils/media/pipeline/VirtualBackground.js' @@ -108,15 +106,6 @@ export function useDevices(video, initializeOnMounted) { virtualBackground.value.connectTrackSink('default', videoTrackToStream.value, 'video') - const blurBackgroundEnabled = BrowserStorage.getItem('blurBackgroundEnabled') - if (blurBackgroundEnabled === 'true') { - virtualBackground.value.setEnabled(true) - virtualBackground.value.setVirtualBackground({ - backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, - blurValue: VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, - }) - } - if (initializeOnMounted) { initializeDevices() } diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 4127575e669..f0f476126d0 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -97,6 +97,7 @@ const setUserConfig = async function(appId, configKey, configValue) { export { setAttachmentFolder, + setBlurBackground, setReadStatusPrivacy, setTypingStatusPrivacy, setSIPSettings, diff --git a/src/stores/settings.js b/src/stores/settings.js index e0a5e613ee8..a80cb684789 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -14,7 +14,8 @@ import { getTalkConfig } from '../services/CapabilitiesManager.ts' import { setReadStatusPrivacy, setTypingStatusPrivacy, - setStartWithoutMedia + setStartWithoutMedia, + setBlurBackground, } from '../services/settingsService.js' /** @@ -39,8 +40,8 @@ export const useSettingsStore = defineStore('settings', { readStatusPrivacy: loadState('spreed', 'read_status_privacy', PRIVACY.PRIVATE), typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE), showMediaSettings: {}, - startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'),, - blurBackgroundEnabled: undefined, + startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'), + blurBackgroundEnabled: getTalkConfig('local', 'call', 'blur-background'), }), getters: { @@ -72,16 +73,6 @@ export const useSettingsStore = defineStore('settings', { } } }, - - getBlurBackgroundEnabled: (state) => { - if (state.blurBackgroundEnabled !== undefined) { - return state.blurBackgroundEnabled - } - - const storedValue = BrowserStorage.getItem('blurBackgroundEnabled') - state.blurBackgroundEnabled = storedValue === 'true' - return state.blurBackgroundEnabled - } }, actions: { @@ -114,12 +105,8 @@ export const useSettingsStore = defineStore('settings', { Vue.set(this.showMediaSettings, token, value) }, - setBlurBackgroundEnabled(value) { - if (value) { - BrowserStorage.setItem('blurBackgroundEnabled', 'true') - } else { - BrowserStorage.removeItem('blurBackgroundEnabled') - } + async setBlurBackgroundEnabled(value) { + await setBlurBackground(value) this.blurBackgroundEnabled = value }, diff --git a/src/utils/webrtc/models/LocalMediaModel.js b/src/utils/webrtc/models/LocalMediaModel.js index c8121182164..8ab62df0f9d 100644 --- a/src/utils/webrtc/models/LocalMediaModel.js +++ b/src/utils/webrtc/models/LocalMediaModel.js @@ -387,7 +387,7 @@ LocalMediaModel.prototype = { this._webRtc.enableVirtualBackground() }, - setVirtualBackgroundBlur(blurStrength) { + setVirtualBackgroundBlur(blurStrength, globalBlurBackground = false) { if (!this._webRtc) { throw new Error('WebRtc not initialized yet') } @@ -396,9 +396,11 @@ LocalMediaModel.prototype = { blurStrength = VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT } - BrowserStorage.setItem('virtualBackgroundType_' + this.get('token'), VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) - BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.get('token'), blurStrength) - BrowserStorage.removeItem('virtualBackgroundUrl_' + this.get('token')) + if (!globalBlurBackground) { + BrowserStorage.setItem('virtualBackgroundType_' + this.get('token'), VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) + BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.get('token'), blurStrength) + BrowserStorage.removeItem('virtualBackgroundUrl_' + this.get('token')) + } this._webRtc.setVirtualBackground({ backgroundType: VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR, From a4564240b947a894e97a2c1144868367436e27e5 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 31 Oct 2024 20:10:34 +0100 Subject: [PATCH 4/9] fix: openapi Signed-off-by: DorraJaouad --- openapi-administration.json | 6 +++++- openapi-backend-recording.json | 6 +++++- openapi-backend-signaling.json | 6 +++++- openapi-backend-sipbridge.json | 6 +++++- openapi-bots.json | 6 +++++- openapi-federation.json | 6 +++++- openapi-full.json | 9 +++++++-- openapi.json | 9 +++++++-- src/types/openapi/openapi-administration.ts | 1 + src/types/openapi/openapi-backend-recording.ts | 1 + src/types/openapi/openapi-backend-signaling.ts | 1 + src/types/openapi/openapi-backend-sipbridge.ts | 1 + src/types/openapi/openapi-bots.ts | 1 + src/types/openapi/openapi-federation.ts | 1 + src/types/openapi/openapi-full.ts | 3 ++- src/types/openapi/openapi.ts | 3 ++- 16 files changed, 54 insertions(+), 12 deletions(-) diff --git a/openapi-administration.json b/openapi-administration.json index fa4e80bed78..b02dca1cfa7 100644 --- a/openapi-administration.json +++ b/openapi-administration.json @@ -149,7 +149,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -195,6 +196,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-backend-recording.json b/openapi-backend-recording.json index f6b1d452627..1db0bfc4f00 100644 --- a/openapi-backend-recording.json +++ b/openapi-backend-recording.json @@ -82,7 +82,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -128,6 +129,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-backend-signaling.json b/openapi-backend-signaling.json index ad42624f290..c65fe7e8ec6 100644 --- a/openapi-backend-signaling.json +++ b/openapi-backend-signaling.json @@ -82,7 +82,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -128,6 +129,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-backend-sipbridge.json b/openapi-backend-sipbridge.json index 5df0b9eeb46..9d4709d271d 100644 --- a/openapi-backend-sipbridge.json +++ b/openapi-backend-sipbridge.json @@ -125,7 +125,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -171,6 +172,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-bots.json b/openapi-bots.json index 8f24560fe4b..3c6d837a031 100644 --- a/openapi-bots.json +++ b/openapi-bots.json @@ -82,7 +82,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -128,6 +129,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-federation.json b/openapi-federation.json index 1b2274d22c7..62faf73b846 100644 --- a/openapi-federation.json +++ b/openapi-federation.json @@ -125,7 +125,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -171,6 +172,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, diff --git a/openapi-full.json b/openapi-full.json index b6f65dfcd2c..c3b0a0cff3c 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -301,7 +301,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -347,6 +348,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, @@ -16368,7 +16372,8 @@ "attachment_folder", "read_status_privacy", "typing_privacy", - "play_sounds" + "play_sounds", + "blur_background" ], "description": "Key to update" }, diff --git a/openapi.json b/openapi.json index 5c125efe00e..0429cd75985 100644 --- a/openapi.json +++ b/openapi.json @@ -242,7 +242,8 @@ "sip-dialout-enabled", "can-enable-sip", "start-without-media", - "max-duration" + "max-duration", + "blur-background" ], "properties": { "enabled": { @@ -288,6 +289,9 @@ "max-duration": { "type": "integer", "format": "int64" + }, + "blur-background": { + "type": "boolean" } } }, @@ -16502,7 +16506,8 @@ "attachment_folder", "read_status_privacy", "typing_privacy", - "play_sounds" + "play_sounds", + "blur_background" ], "description": "Key to update" }, diff --git a/src/types/openapi/openapi-administration.ts b/src/types/openapi/openapi-administration.ts index e960be1a078..31bccface24 100644 --- a/src/types/openapi/openapi-administration.ts +++ b/src/types/openapi/openapi-administration.ts @@ -231,6 +231,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-recording.ts b/src/types/openapi/openapi-backend-recording.ts index 63f3a3b8602..e3dbe861da5 100644 --- a/src/types/openapi/openapi-backend-recording.ts +++ b/src/types/openapi/openapi-backend-recording.ts @@ -65,6 +65,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-signaling.ts b/src/types/openapi/openapi-backend-signaling.ts index 54bf7d5d98b..ebd108916a1 100644 --- a/src/types/openapi/openapi-backend-signaling.ts +++ b/src/types/openapi/openapi-backend-signaling.ts @@ -51,6 +51,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-sipbridge.ts b/src/types/openapi/openapi-backend-sipbridge.ts index 84e84856e36..e9c6a154628 100644 --- a/src/types/openapi/openapi-backend-sipbridge.ts +++ b/src/types/openapi/openapi-backend-sipbridge.ts @@ -146,6 +146,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-bots.ts b/src/types/openapi/openapi-bots.ts index 5e29b8e7795..4c7d939eca8 100644 --- a/src/types/openapi/openapi-bots.ts +++ b/src/types/openapi/openapi-bots.ts @@ -69,6 +69,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-federation.ts b/src/types/openapi/openapi-federation.ts index b498f99f0f7..212d592a85e 100644 --- a/src/types/openapi/openapi-federation.ts +++ b/src/types/openapi/openapi-federation.ts @@ -177,6 +177,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index d4f3325ea0a..4d0953ca0e1 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -1927,6 +1927,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ @@ -8277,7 +8278,7 @@ export interface operations { * @description Key to update * @enum {string} */ - key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds"; + key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds" | "blur_background"; /** @description New value for the key */ value?: (string | number) | null; }; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 0773d2a108f..a3b06ee054e 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1424,6 +1424,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; + "blur-background": boolean; }; chat: { /** Format: int64 */ @@ -7858,7 +7859,7 @@ export interface operations { * @description Key to update * @enum {string} */ - key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds"; + key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds" | "blur_background"; /** @description New value for the key */ value?: (string | number) | null; }; From 4b473f0b213c4bdbd95606a50c82c968b6c6ae0e Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 31 Oct 2024 21:04:33 +0100 Subject: [PATCH 5/9] fix(jest): update tests Signed-off-by: DorraJaouad --- src/stores/__tests__/settings.spec.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/stores/__tests__/settings.spec.js b/src/stores/__tests__/settings.spec.js index baa9cbb8ba2..f0a2eee7c68 100644 --- a/src/stores/__tests__/settings.spec.js +++ b/src/stores/__tests__/settings.spec.js @@ -71,8 +71,9 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([true, false]) // It's always called at least once : BrowserStorage.getItem('cachedConversations') - // +1 - expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1) + // Whenever capabilitiesManager.ts is imported + // +2 + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(2) }) it('shows correct values received from BrowserStorage', () => { @@ -89,11 +90,11 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([true, true, false]) - // It's always called at least once : BrowserStorage.getItem('cachedConversations') - expect(BrowserStorage.getItem).toHaveBeenCalledTimes(4) // 1 + 3 - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-1') - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-2') - expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(4, 'showMediaSettings_token-3') + // It's always called at least once : BrowserStorage.getItem('cachedConversations') (+2) + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(5) // 2 + 3 + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(3, 'showMediaSettings_token-1') + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(4, 'showMediaSettings_token-2') + expect(BrowserStorage.getItem).toHaveBeenNthCalledWith(5, 'showMediaSettings_token-3') }) it('updates values correctly', async () => { @@ -109,8 +110,8 @@ describe('settingsStore', () => { // Assert expect(results).toEqual([false, true]) - // It's always called at least once : BrowserStorage.getItem('cachedConversations') - expect(BrowserStorage.getItem).toHaveBeenCalledTimes(1) + // It's always called at least once : BrowserStorage.getItem('cachedConversations') (+2) + expect(BrowserStorage.getItem).toHaveBeenCalledTimes(2) expect(BrowserStorage.setItem).toHaveBeenCalledTimes(2) expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(1, 'showMediaSettings_token-1', 'false') expect(BrowserStorage.setItem).toHaveBeenNthCalledWith(2, 'showMediaSettings_token-2', 'true') From ab54a9367dc57ff4f89b675931c14d24a78610bb Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Mon, 11 Nov 2024 23:05:59 +0100 Subject: [PATCH 6/9] fix: rename blur-background to blur-virtual-background Signed-off-by: DorraJaouad --- docs/capabilities.md | 2 +- docs/settings.md | 16 ++++++++-------- lib/Capabilities.php | 6 +++--- lib/Config.php | 2 +- lib/Controller/RoomController.php | 4 ++-- lib/Federation/Proxy/TalkV1/ProxyRequest.php | 2 +- lib/ResponseDefinitions.php | 2 +- .../BeforePreferenceSetEventListener.php | 2 +- lib/Settings/UserPreference.php | 2 +- openapi-administration.json | 4 ++-- openapi-backend-recording.json | 4 ++-- openapi-backend-signaling.json | 4 ++-- openapi-backend-sipbridge.json | 4 ++-- openapi-bots.json | 4 ++-- openapi-federation.json | 4 ++-- openapi-full.json | 7 +++---- openapi.json | 7 +++---- src/__mocks__/capabilities.ts | 4 ++-- .../SettingsDialog/MediaDevicesPreview.vue | 2 +- src/services/settingsService.js | 2 +- src/stores/settings.js | 2 +- src/types/openapi/openapi-administration.ts | 2 +- src/types/openapi/openapi-backend-recording.ts | 2 +- src/types/openapi/openapi-backend-signaling.ts | 2 +- src/types/openapi/openapi-backend-sipbridge.ts | 2 +- src/types/openapi/openapi-bots.ts | 2 +- src/types/openapi/openapi-federation.ts | 2 +- src/types/openapi/openapi-full.ts | 4 ++-- src/types/openapi/openapi.ts | 4 ++-- tests/php/CapabilitiesTest.php | 4 ++-- 30 files changed, 54 insertions(+), 56 deletions(-) diff --git a/docs/capabilities.md b/docs/capabilities.md index 729936cc8c7..a23dbef4c40 100644 --- a/docs/capabilities.md +++ b/docs/capabilities.md @@ -162,4 +162,4 @@ * `download-call-participants` - Whether the endpoints for moderators to download the call participants is available * `config => call => start-without-media` (local) - Boolean, whether media should be disabled when starting or joining a conversation * `config => call => max-duration` - Integer, maximum call duration in seconds. Please note that this should only be used with system cron and with a reasonable high value, due to the expended duration until the background job ran. -* `config => call => blur-background` (local) - Boolean, whether blur background is set by default when joining a conversation +* `config => call => blur-virtual-background` (local) - Boolean, whether blur background is set by default when joining a conversation diff --git a/docs/settings.md b/docs/settings.md index 9a37ab2375a..ad2543d8412 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -24,14 +24,14 @@ **Note:** Settings from `calls_start_without_media` onwards can not be set via above API. Instead, the server API `POST /ocs/v2.php/apps/provisioning_api/api/v1/config/users/{appId}/{configKey}` needs to be used. -| Key | Capability | Default | Valid values | -|-----------------------------|-----------------------------------------|----------------------------------------------------|----------------------------------------------------------------------------------------------------------| -| `attachment_folder` | `config => attachments => folder` | Value of app config `default_attachment_folder` | Path owned by the user to store uploads and received shares. It is created if it does not exist. | -| `read_status_privacy` | `config => chat => read-privacy` | `0` | One of the read-status constants from the [constants list](constants.md#participant-read-status-privacy) | -| `typing_privacy` | `config => chat => typing-privacy` | `0` | One of the typing privacy constants from the [constants list](constants.md#participant-typing-privacy) | -| `play_sounds` | | `'yes'` | `'yes'` and `'no'` | -| `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` | -| `blur_background` | `config => call => blur-background` | `'no'` | `'yes'` and `'no'` | +| Key | Capability | Default | Valid values | +|-----------------------------|---------------------------------------------|----------------------------------------------------|----------------------------------------------------------------------------------------------------------| +| `attachment_folder` | `config => attachments => folder` | Value of app config `default_attachment_folder` | Path owned by the user to store uploads and received shares. It is created if it does not exist. | +| `read_status_privacy` | `config => chat => read-privacy` | `0` | One of the read-status constants from the [constants list](constants.md#participant-read-status-privacy) | +| `typing_privacy` | `config => chat => typing-privacy` | `0` | One of the typing privacy constants from the [constants list](constants.md#participant-typing-privacy) | +| `play_sounds` | | `'yes'` | `'yes'` and `'no'` | +| `calls_start_without_media` | `config => call => start-without-media` | `''` falling back to app config with the same name | `'yes'` and `'no'` | +| `blur_virtual_background` | `config => call => blur-virtual-background` | `'no'` | `'yes'` and `'no'` | ## Set SIP settings diff --git a/lib/Capabilities.php b/lib/Capabilities.php index fcfbd34ffae..a82afab1115 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -130,7 +130,7 @@ class Capabilities implements IPublicCapability { 'predefined-backgrounds', 'can-upload-background', 'start-without-media', - 'blur-background', + 'blur-virtual-background', ], 'chat' => [ 'read-privacy', @@ -202,7 +202,7 @@ public function getCapabilities(): array { 'can-enable-sip' => false, 'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()), 'max-duration' => $this->appConfig->getAppValueInt('max_call_duration'), - 'blur-background' => $this->talkConfig->getBlurBackground($user?->getUID()), + 'blur-virtual-background' => $this->talkConfig->getBlurBackground($user?->getUID()), ], 'chat' => [ 'max-length' => ChatManager::MAX_CHAT_LENGTH, @@ -252,7 +252,7 @@ public function getCapabilities(): array { $capabilities['config']['attachments']['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID()); $capabilities['config']['chat']['read-privacy'] = $this->talkConfig->getUserReadPrivacy($user->getUID()); $capabilities['config']['chat']['typing-privacy'] = $this->talkConfig->getUserTypingPrivacy($user->getUID()); - $capabilities['config']['call']['blur-background'] = $this->talkConfig->getBlurBackground($user->getUID()); + $capabilities['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurBackground($user->getUID()); } $pubKey = $this->talkConfig->getSignalingTokenPublicKey(); diff --git a/lib/Config.php b/lib/Config.php index aebb084a206..015143fbbba 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -689,7 +689,7 @@ public function getCallsStartWithoutMedia(?string $userId): bool { */ public function getBlurBackground(?string $userId): bool { if ($userId !== null) { - $userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_BACKGROUND); + $userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_VIRTUAL_BACKGROUND); return $userSetting === 'yes'; } return false; diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 5bf57809e0b..2826c5d1509 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -2458,8 +2458,8 @@ public function getCapabilities(): DataResponse { if (isset($data['config']['call']['start-without-media'])) { $data['config']['call']['start-without-media'] = $this->talkConfig->getCallsStartWithoutMedia($this->userId); } - if (isset($data['config']['call']['blur-background'])) { - $data['config']['call']['blur-background'] = $this->talkConfig->getBlurBackground($this->userId); + if (isset($data['config']['call']['blur-virtual-background'])) { + $data['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurBackground($this->userId); } if ($response->getHeaders()['X-Nextcloud-Talk-Hash']) { diff --git a/lib/Federation/Proxy/TalkV1/ProxyRequest.php b/lib/Federation/Proxy/TalkV1/ProxyRequest.php index 03f975fc48e..ea5d606bc2f 100644 --- a/lib/Federation/Proxy/TalkV1/ProxyRequest.php +++ b/lib/Federation/Proxy/TalkV1/ProxyRequest.php @@ -43,7 +43,7 @@ public function overwrittenRemoteTalkHash(string $hash): string { 'typing-privacy', ], 'call' => [ - 'blur-background', + 'blur-virtual-background', ] ], ] diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php index 86915555a78..3fef42ab4db 100644 --- a/lib/ResponseDefinitions.php +++ b/lib/ResponseDefinitions.php @@ -348,7 +348,7 @@ * can-enable-sip: bool, * start-without-media: bool, * max-duration: int, - * blur-background: bool, + * blur-virtual-background: bool, * }, * chat: array{ * max-length: int, diff --git a/lib/Settings/BeforePreferenceSetEventListener.php b/lib/Settings/BeforePreferenceSetEventListener.php index f6173531cd4..1fe87fdb1d5 100644 --- a/lib/Settings/BeforePreferenceSetEventListener.php +++ b/lib/Settings/BeforePreferenceSetEventListener.php @@ -61,7 +61,7 @@ public function validatePreference(string $userId, string $key, string|int|null // "boolean" yes/no if ($key === UserPreference::CALLS_START_WITHOUT_MEDIA || $key === UserPreference::PLAY_SOUNDS - || $key === UserPreference::BLUR_BACKGROUND) { + || $key === UserPreference::BLUR_VIRTUAL_BACKGROUND) { return $value === 'yes' || $value === 'no'; } diff --git a/lib/Settings/UserPreference.php b/lib/Settings/UserPreference.php index f3e7829a681..6c729ae0f11 100644 --- a/lib/Settings/UserPreference.php +++ b/lib/Settings/UserPreference.php @@ -9,7 +9,7 @@ namespace OCA\Talk\Settings; class UserPreference { - public const BLUR_BACKGROUND = 'blur_background'; + public const BLUR_VIRTUAL_BACKGROUND = 'blur_virtual_background'; public const CALLS_START_WITHOUT_MEDIA = 'calls_start_without_media'; public const PLAY_SOUNDS = 'play_sounds'; public const TYPING_PRIVACY = 'typing_privacy'; diff --git a/openapi-administration.json b/openapi-administration.json index b02dca1cfa7..84f73eb4e61 100644 --- a/openapi-administration.json +++ b/openapi-administration.json @@ -150,7 +150,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -197,7 +197,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-backend-recording.json b/openapi-backend-recording.json index 1db0bfc4f00..11f4b758125 100644 --- a/openapi-backend-recording.json +++ b/openapi-backend-recording.json @@ -83,7 +83,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -130,7 +130,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-backend-signaling.json b/openapi-backend-signaling.json index c65fe7e8ec6..2d74e247e13 100644 --- a/openapi-backend-signaling.json +++ b/openapi-backend-signaling.json @@ -83,7 +83,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -130,7 +130,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-backend-sipbridge.json b/openapi-backend-sipbridge.json index 9d4709d271d..aecba7b3a81 100644 --- a/openapi-backend-sipbridge.json +++ b/openapi-backend-sipbridge.json @@ -126,7 +126,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -173,7 +173,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-bots.json b/openapi-bots.json index 3c6d837a031..45a49772408 100644 --- a/openapi-bots.json +++ b/openapi-bots.json @@ -83,7 +83,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -130,7 +130,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-federation.json b/openapi-federation.json index 62faf73b846..99cc3664bef 100644 --- a/openapi-federation.json +++ b/openapi-federation.json @@ -126,7 +126,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -173,7 +173,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } diff --git a/openapi-full.json b/openapi-full.json index c3b0a0cff3c..d3295be5f76 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -302,7 +302,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -349,7 +349,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } @@ -16372,8 +16372,7 @@ "attachment_folder", "read_status_privacy", "typing_privacy", - "play_sounds", - "blur_background" + "play_sounds" ], "description": "Key to update" }, diff --git a/openapi.json b/openapi.json index 0429cd75985..76031b3b688 100644 --- a/openapi.json +++ b/openapi.json @@ -243,7 +243,7 @@ "can-enable-sip", "start-without-media", "max-duration", - "blur-background" + "blur-virtual-background" ], "properties": { "enabled": { @@ -290,7 +290,7 @@ "type": "integer", "format": "int64" }, - "blur-background": { + "blur-virtual-background": { "type": "boolean" } } @@ -16506,8 +16506,7 @@ "attachment_folder", "read_status_privacy", "typing_privacy", - "play_sounds", - "blur_background" + "play_sounds" ], "description": "Key to update" }, diff --git a/src/__mocks__/capabilities.ts b/src/__mocks__/capabilities.ts index c1c565af8ce..189409e9639 100644 --- a/src/__mocks__/capabilities.ts +++ b/src/__mocks__/capabilities.ts @@ -117,7 +117,7 @@ export const mockedCapabilities: Capabilities = { 'can-enable-sip': true, 'start-without-media': false, 'max-duration': 0, - 'blur-background': false, + 'blur-virtual-background': false, }, chat: { 'max-length': 32000, @@ -150,7 +150,7 @@ export const mockedCapabilities: Capabilities = { 'predefined-backgrounds', 'can-upload-background', 'start-without-media', - 'blur-background', + 'blur-virtual-background', ], chat: [ 'read-privacy', diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index 9588a606ea4..0d80227fd82 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -91,7 +91,7 @@ import { VIRTUAL_BACKGROUND } from '../../constants.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useSettingsStore } from '../../stores/settings.js' -const supportDefaultBlurBackground = getTalkConfig('local', 'call', 'blur-background') !== undefined +const supportDefaultBlurBackground = getTalkConfig('local', 'call', 'blur-virtual-background') !== undefined export default { diff --git a/src/services/settingsService.js b/src/services/settingsService.js index f0f476126d0..e04f3ad9c83 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -79,7 +79,7 @@ const setStartWithoutMedia = async function(value) { } const setBlurBackground = async function(value) { - await setUserConfig('spreed', 'blur_background', value ? 'yes' : 'no') + await setUserConfig('spreed', 'blur_virtual_background', value ? 'yes' : 'no') } /** diff --git a/src/stores/settings.js b/src/stores/settings.js index a80cb684789..661d1f75e76 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -41,7 +41,7 @@ export const useSettingsStore = defineStore('settings', { typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE), showMediaSettings: {}, startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'), - blurBackgroundEnabled: getTalkConfig('local', 'call', 'blur-background'), + blurBackgroundEnabled: getTalkConfig('local', 'call', 'blur-virtual-background'), }), getters: { diff --git a/src/types/openapi/openapi-administration.ts b/src/types/openapi/openapi-administration.ts index 31bccface24..6a5c7e4be1f 100644 --- a/src/types/openapi/openapi-administration.ts +++ b/src/types/openapi/openapi-administration.ts @@ -231,7 +231,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-recording.ts b/src/types/openapi/openapi-backend-recording.ts index e3dbe861da5..7d5ede90d3f 100644 --- a/src/types/openapi/openapi-backend-recording.ts +++ b/src/types/openapi/openapi-backend-recording.ts @@ -65,7 +65,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-signaling.ts b/src/types/openapi/openapi-backend-signaling.ts index ebd108916a1..e632042a376 100644 --- a/src/types/openapi/openapi-backend-signaling.ts +++ b/src/types/openapi/openapi-backend-signaling.ts @@ -51,7 +51,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-backend-sipbridge.ts b/src/types/openapi/openapi-backend-sipbridge.ts index e9c6a154628..040cd5a9ede 100644 --- a/src/types/openapi/openapi-backend-sipbridge.ts +++ b/src/types/openapi/openapi-backend-sipbridge.ts @@ -146,7 +146,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-bots.ts b/src/types/openapi/openapi-bots.ts index 4c7d939eca8..5698171ec98 100644 --- a/src/types/openapi/openapi-bots.ts +++ b/src/types/openapi/openapi-bots.ts @@ -69,7 +69,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-federation.ts b/src/types/openapi/openapi-federation.ts index 212d592a85e..f03075498c0 100644 --- a/src/types/openapi/openapi-federation.ts +++ b/src/types/openapi/openapi-federation.ts @@ -177,7 +177,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ diff --git a/src/types/openapi/openapi-full.ts b/src/types/openapi/openapi-full.ts index 4d0953ca0e1..d5021edbb7b 100644 --- a/src/types/openapi/openapi-full.ts +++ b/src/types/openapi/openapi-full.ts @@ -1927,7 +1927,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ @@ -8278,7 +8278,7 @@ export interface operations { * @description Key to update * @enum {string} */ - key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds" | "blur_background"; + key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds"; /** @description New value for the key */ value?: (string | number) | null; }; diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index a3b06ee054e..05d49db292c 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -1424,7 +1424,7 @@ export type components = { "start-without-media": boolean; /** Format: int64 */ "max-duration": number; - "blur-background": boolean; + "blur-virtual-background": boolean; }; chat: { /** Format: int64 */ @@ -7859,7 +7859,7 @@ export interface operations { * @description Key to update * @enum {string} */ - key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds" | "blur_background"; + key: "attachment_folder" | "read_status_privacy" | "typing_privacy" | "play_sounds"; /** @description New value for the key */ value?: (string | number) | null; }; diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index 6d3ed7cda54..9569ec7f184 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -121,7 +121,7 @@ public function testGetCapabilitiesGuest(): void { 'can-enable-sip' => false, 'start-without-media' => false, 'max-duration' => 0, - 'blur-background' => false, + 'blur-virtual-background' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', @@ -257,7 +257,7 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea 'can-enable-sip' => false, 'start-without-media' => false, 'max-duration' => 0, - 'blur-background' => false, + 'blur-virtual-background' => false, 'predefined-backgrounds' => [ '1_office.jpg', '2_home.jpg', From 0c8a6ad6b6155a9c759b4f7c6b898413961dc234 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 13 Nov 2024 10:13:34 +0100 Subject: [PATCH 7/9] fix: reduce the global blur implementation against per conversation level virtual background Signed-off-by: DorraJaouad --- .../MediaSettings/MediaSettings.vue | 26 +++++++++---------- .../MediaSettings/VideoBackgroundEditor.vue | 7 ++--- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index b2e59f64e72..1da0a9c8dd6 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -436,20 +436,19 @@ export default { this.audioOn = !BrowserStorage.getItem('audioDisabled_' + this.token) this.videoOn = !BrowserStorage.getItem('videoDisabled_' + this.token) this.silentCall = !!BrowserStorage.getItem('silentCall_' + this.token) - // Check main blur background setting - if (this.blurBackgroundEnabled) { + + // Set virtual background depending on BrowserStorage's settings + if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { + if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { + this.blurVirtualBackground() + } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { + this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) + } + } else if (this.blurBackgroundEnabled) { + // Fall back to global blur background setting this.blurVirtualBackground() } else { - // Set virtual background depending on BrowserStorage's settings - if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { - if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { - this.blurVirtualBackground() - } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { - this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) - } - } else { - this.clearVirtualBackground() - } + this.clearVirtualBackground() } this.initializeDevices() @@ -476,8 +475,9 @@ export default { isInCall(value) { if (value) { + const virtualBackgroundEnabled = BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true' // Apply global blur background setting - if (this.blurBackgroundEnabled && !this.skipBlurBackgroundEnabled) { + if (this.blurBackgroundEnabled && !this.skipBlurBackgroundEnabled && !virtualBackgroundEnabled) { this.blurBackground(true) } } diff --git a/src/components/MediaSettings/VideoBackgroundEditor.vue b/src/components/MediaSettings/VideoBackgroundEditor.vue index b9842b325b4..a24bc38d46e 100644 --- a/src/components/MediaSettings/VideoBackgroundEditor.vue +++ b/src/components/MediaSettings/VideoBackgroundEditor.vue @@ -256,11 +256,6 @@ export default { }, loadBackground() { - // Set virtual background depending on main blur setting (in Talk settings) - if (this.settingsStore.blurBackgroundEnabled) { - this.selectedBackground = 'blur' - return - } // Set virtual background depending on browser storage's settings if (BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true') { if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) { @@ -270,6 +265,8 @@ export default { } else { this.selectedBackground = 'none' } + } else if (this.settingsStore.blurBackgroundEnabled) { + this.selectedBackground = 'blur' } else { this.selectedBackground = 'none' } From 3d7cbd8d836a6599829ed2aed4ebe016874e4dde Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 14 Nov 2024 17:29:29 +0100 Subject: [PATCH 8/9] fix: total renaming from blurBackground to blurVirtualBackground Signed-off-by: DorraJaouad --- lib/Capabilities.php | 4 +-- lib/Config.php | 2 +- lib/Controller/RoomController.php | 2 +- .../MediaSettings/MediaSettings.vue | 26 +++++++++---------- .../MediaSettings/VideoBackgroundEditor.vue | 2 +- .../SettingsDialog/MediaDevicesPreview.vue | 20 +++++++------- src/services/settingsService.js | 4 +-- src/stores/settings.js | 10 +++---- src/utils/webrtc/models/LocalMediaModel.js | 4 +-- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/Capabilities.php b/lib/Capabilities.php index a82afab1115..4d777717ef0 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -202,7 +202,7 @@ public function getCapabilities(): array { 'can-enable-sip' => false, 'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()), 'max-duration' => $this->appConfig->getAppValueInt('max_call_duration'), - 'blur-virtual-background' => $this->talkConfig->getBlurBackground($user?->getUID()), + 'blur-virtual-background' => $this->talkConfig->getBlurVirtualBackground($user?->getUID()), ], 'chat' => [ 'max-length' => ChatManager::MAX_CHAT_LENGTH, @@ -252,7 +252,7 @@ public function getCapabilities(): array { $capabilities['config']['attachments']['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID()); $capabilities['config']['chat']['read-privacy'] = $this->talkConfig->getUserReadPrivacy($user->getUID()); $capabilities['config']['chat']['typing-privacy'] = $this->talkConfig->getUserTypingPrivacy($user->getUID()); - $capabilities['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurBackground($user->getUID()); + $capabilities['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurVirtualBackground($user->getUID()); } $pubKey = $this->talkConfig->getSignalingTokenPublicKey(); diff --git a/lib/Config.php b/lib/Config.php index 015143fbbba..87f26c52cd5 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -687,7 +687,7 @@ public function getCallsStartWithoutMedia(?string $userId): bool { * @param ?string $userId * @return bool */ - public function getBlurBackground(?string $userId): bool { + public function getBlurVirtualBackground(?string $userId): bool { if ($userId !== null) { $userSetting = $this->config->getUserValue($userId, 'spreed', UserPreference::BLUR_VIRTUAL_BACKGROUND); return $userSetting === 'yes'; diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 2826c5d1509..4efb1c853ff 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -2459,7 +2459,7 @@ public function getCapabilities(): DataResponse { $data['config']['call']['start-without-media'] = $this->talkConfig->getCallsStartWithoutMedia($this->userId); } if (isset($data['config']['call']['blur-virtual-background'])) { - $data['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurBackground($this->userId); + $data['config']['call']['blur-virtual-background'] = $this->talkConfig->getBlurVirtualBackground($this->userId); } if ($response->getHeaders()['X-Nextcloud-Talk-Hash']) { diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 1da0a9c8dd6..716e2073321 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -321,7 +321,7 @@ export default { isRecordingFromStart: false, isPublicShareAuthSidebar: false, isMirrored: false, - skipBlurBackgroundEnabled: false, + skipBlurVirtualBackgroundEnabled: false, } }, @@ -353,8 +353,8 @@ export default { return this.settingsStore.getShowMediaSettings(this.token) }, - blurBackgroundEnabled() { - return this.settingsStore.blurBackgroundEnabled + blurVirtualBackgroundEnabled() { + return this.settingsStore.blurVirtualBackgroundEnabled }, showVideo() { @@ -444,7 +444,7 @@ export default { } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) } - } else if (this.blurBackgroundEnabled) { + } else if (this.blurVirtualBackgroundEnabled) { // Fall back to global blur background setting this.blurVirtualBackground() } else { @@ -477,7 +477,7 @@ export default { if (value) { const virtualBackgroundEnabled = BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true' // Apply global blur background setting - if (this.blurBackgroundEnabled && !this.skipBlurBackgroundEnabled && !virtualBackgroundEnabled) { + if (this.blurVirtualBackgroundEnabled && !this.skipBlurVirtualBackgroundEnabled && !virtualBackgroundEnabled) { this.blurBackground(true) } } @@ -573,14 +573,14 @@ export default { handleUpdateBackground(background) { // Default global blur background setting was changed by user - if (this.blurBackgroundEnabled && background !== 'blur') { - this.skipBlurBackgroundEnabled = true + if (this.blurVirtualBackgroundEnabled && background !== 'blur') { + this.skipBlurVirtualBackgroundEnabled = true } // Apply the new background if (background === 'none') { this.clearBackground() } else if (background === 'blur') { - this.blurBackground(this.blurBackgroundEnabled) + this.blurBackground(this.blurVirtualBackgroundEnabled) } else { this.setBackgroundImage(background) } @@ -629,14 +629,14 @@ export default { /** * Blurs the background of the participants in current or future call * - * @param {boolean} globalBlurBackground - Whether the global blur background setting is enabled (in Talk settings) + * @param {boolean} globalBlurVirtualBackground - Whether the global blur background setting is enabled (in Talk settings) */ - blurBackground(globalBlurBackground = false) { + blurBackground(globalBlurVirtualBackground = false) { if (this.isInCall) { localMediaModel.enableVirtualBackground() - localMediaModel.setVirtualBackgroundBlur(VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, globalBlurBackground) - } else if (!globalBlurBackground) { - this.skipBlurBackgroundEnabled = true + localMediaModel.setVirtualBackgroundBlur(VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, globalBlurVirtualBackground) + } else if (!globalBlurVirtualBackground) { + this.skipBlurVirtualBackgroundEnabled = true BrowserStorage.setItem('virtualBackgroundEnabled_' + this.token, 'true') BrowserStorage.setItem('virtualBackgroundType_' + this.token, VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.token, VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT) diff --git a/src/components/MediaSettings/VideoBackgroundEditor.vue b/src/components/MediaSettings/VideoBackgroundEditor.vue index a24bc38d46e..0a31f47b954 100644 --- a/src/components/MediaSettings/VideoBackgroundEditor.vue +++ b/src/components/MediaSettings/VideoBackgroundEditor.vue @@ -265,7 +265,7 @@ export default { } else { this.selectedBackground = 'none' } - } else if (this.settingsStore.blurBackgroundEnabled) { + } else if (this.settingsStore.blurVirtualBackgroundEnabled) { this.selectedBackground = 'blur' } else { this.selectedBackground = 'none' diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index 0d80227fd82..f694253e3a9 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -63,10 +63,10 @@ disablePictureInPicture="true" tabindex="-1" /> - + :checked="blurVirtualBackgroundEnabled" + @update:checked="setBlurVirtualBackgroundEnabled"> {{ t('spreed', 'Enable blur background by default for all conversation') }} @@ -91,7 +91,7 @@ import { VIRTUAL_BACKGROUND } from '../../constants.js' import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useSettingsStore } from '../../stores/settings.js' -const supportDefaultBlurBackground = getTalkConfig('local', 'call', 'blur-virtual-background') !== undefined +const supportDefaultBlurVirtualBackground = getTalkConfig('local', 'call', 'blur-virtual-background') !== undefined export default { @@ -142,7 +142,7 @@ export default { videoStreamError, settingsStore: useSettingsStore(), virtualBackground, - supportDefaultBlurBackground, + supportDefaultBlurVirtualBackground, } }, @@ -199,13 +199,13 @@ export default { return t('spreed', 'Error while accessing camera') }, - blurBackgroundEnabled() { - return this.settingsStore.blurBackgroundEnabled + blurVirtualBackgroundEnabled() { + return this.settingsStore.blurVirtualBackgroundEnabled }, }, mounted() { - if (this.blurBackgroundEnabled) { + if (this.blurVirtualBackgroundEnabled) { // wait for the virtual background to be ready this.$nextTick(() => { this.virtualBackground.setEnabled(true) @@ -230,9 +230,9 @@ export default { this.updatePreferences('videoinput') }, - async setBlurBackgroundEnabled(value) { + async setBlurVirtualBackgroundEnabled(value) { try { - await this.settingsStore.setBlurBackgroundEnabled(value) + await this.settingsStore.setBlurVirtualBackgroundEnabled(value) if (value) { this.virtualBackground.setEnabled(true) this.virtualBackground.setVirtualBackground({ diff --git a/src/services/settingsService.js b/src/services/settingsService.js index e04f3ad9c83..b0f92149f16 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -78,7 +78,7 @@ const setStartWithoutMedia = async function(value) { await setUserConfig('spreed', 'calls_start_without_media', value ? 'yes' : 'no') } -const setBlurBackground = async function(value) { +const setBlurVirtualBackground = async function(value) { await setUserConfig('spreed', 'blur_virtual_background', value ? 'yes' : 'no') } @@ -97,7 +97,7 @@ const setUserConfig = async function(appId, configKey, configValue) { export { setAttachmentFolder, - setBlurBackground, + setBlurVirtualBackground, setReadStatusPrivacy, setTypingStatusPrivacy, setSIPSettings, diff --git a/src/stores/settings.js b/src/stores/settings.js index 661d1f75e76..9c3e37aaf63 100644 --- a/src/stores/settings.js +++ b/src/stores/settings.js @@ -15,7 +15,7 @@ import { setReadStatusPrivacy, setTypingStatusPrivacy, setStartWithoutMedia, - setBlurBackground, + setBlurVirtualBackground, } from '../services/settingsService.js' /** @@ -41,7 +41,7 @@ export const useSettingsStore = defineStore('settings', { typingStatusPrivacy: loadState('spreed', 'typing_privacy', PRIVACY.PRIVATE), showMediaSettings: {}, startWithoutMedia: getTalkConfig('local', 'call', 'start-without-media'), - blurBackgroundEnabled: getTalkConfig('local', 'call', 'blur-virtual-background'), + blurVirtualBackgroundEnabled: getTalkConfig('local', 'call', 'blur-virtual-background'), }), getters: { @@ -105,9 +105,9 @@ export const useSettingsStore = defineStore('settings', { Vue.set(this.showMediaSettings, token, value) }, - async setBlurBackgroundEnabled(value) { - await setBlurBackground(value) - this.blurBackgroundEnabled = value + async setBlurVirtualBackgroundEnabled(value) { + await setBlurVirtualBackground(value) + this.blurVirtualBackgroundEnabled = value }, async setStartWithoutMedia(value) { diff --git a/src/utils/webrtc/models/LocalMediaModel.js b/src/utils/webrtc/models/LocalMediaModel.js index 8ab62df0f9d..00c1a756e99 100644 --- a/src/utils/webrtc/models/LocalMediaModel.js +++ b/src/utils/webrtc/models/LocalMediaModel.js @@ -387,7 +387,7 @@ LocalMediaModel.prototype = { this._webRtc.enableVirtualBackground() }, - setVirtualBackgroundBlur(blurStrength, globalBlurBackground = false) { + setVirtualBackgroundBlur(blurStrength, globalBlurVirtualBackground = false) { if (!this._webRtc) { throw new Error('WebRtc not initialized yet') } @@ -396,7 +396,7 @@ LocalMediaModel.prototype = { blurStrength = VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT } - if (!globalBlurBackground) { + if (!globalBlurVirtualBackground) { BrowserStorage.setItem('virtualBackgroundType_' + this.get('token'), VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.get('token'), blurStrength) BrowserStorage.removeItem('virtualBackgroundUrl_' + this.get('token')) From 9ea1f70545c75f7ce49cca20b251f4ef1bc6804f Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Fri, 15 Nov 2024 10:55:08 +0100 Subject: [PATCH 9/9] Fix: reset and respect flag used for skipping the global config Signed-off-by: DorraJaouad --- .../MediaSettings/MediaSettings.vue | 24 +++++++++++++++---- .../MediaSettings/VideoBackgroundEditor.vue | 7 +++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 716e2073321..f0f981279e0 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -93,6 +93,7 @@ @@ -321,7 +322,7 @@ export default { isRecordingFromStart: false, isPublicShareAuthSidebar: false, isMirrored: false, - skipBlurVirtualBackgroundEnabled: false, + skipBlurVirtualBackground: false, } }, @@ -428,6 +429,10 @@ export default { return this.updatedBackground || this.audioDeviceStateChanged || this.videoDeviceStateChanged }, + + connectionFailed() { + return this.$store.getters.connectionFailed(this.token) + }, }, watch: { @@ -444,7 +449,7 @@ export default { } else if (BrowserStorage.getItem('virtualBackgroundType_' + this.token) === VIRTUAL_BACKGROUND.BACKGROUND_TYPE.IMAGE) { this.setVirtualBackgroundImage(BrowserStorage.getItem('virtualBackgroundUrl_' + this.token)) } - } else if (this.blurVirtualBackgroundEnabled) { + } else if (this.blurVirtualBackgroundEnabled && !this.skipBlurVirtualBackground) { // Fall back to global blur background setting this.blurVirtualBackground() } else { @@ -477,9 +482,18 @@ export default { if (value) { const virtualBackgroundEnabled = BrowserStorage.getItem('virtualBackgroundEnabled_' + this.token) === 'true' // Apply global blur background setting - if (this.blurVirtualBackgroundEnabled && !this.skipBlurVirtualBackgroundEnabled && !virtualBackgroundEnabled) { + if (this.blurVirtualBackgroundEnabled && !this.skipBlurVirtualBackground && !virtualBackgroundEnabled) { this.blurBackground(true) } + } else { + // Reset the flag for the next call + this.skipBlurVirtualBackground = false + } + }, + + connectionFailed(value) { + if (value) { + this.skipBlurVirtualBackground = false } }, }, @@ -574,7 +588,7 @@ export default { handleUpdateBackground(background) { // Default global blur background setting was changed by user if (this.blurVirtualBackgroundEnabled && background !== 'blur') { - this.skipBlurVirtualBackgroundEnabled = true + this.skipBlurVirtualBackground = true } // Apply the new background if (background === 'none') { @@ -636,7 +650,7 @@ export default { localMediaModel.enableVirtualBackground() localMediaModel.setVirtualBackgroundBlur(VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT, globalBlurVirtualBackground) } else if (!globalBlurVirtualBackground) { - this.skipBlurVirtualBackgroundEnabled = true + this.skipBlurVirtualBackground = true BrowserStorage.setItem('virtualBackgroundEnabled_' + this.token, 'true') BrowserStorage.setItem('virtualBackgroundType_' + this.token, VIRTUAL_BACKGROUND.BACKGROUND_TYPE.BLUR) BrowserStorage.setItem('virtualBackgroundBlurStrength_' + this.token, VIRTUAL_BACKGROUND.BLUR_STRENGTH.DEFAULT) diff --git a/src/components/MediaSettings/VideoBackgroundEditor.vue b/src/components/MediaSettings/VideoBackgroundEditor.vue index 0a31f47b954..b6123e2e338 100644 --- a/src/components/MediaSettings/VideoBackgroundEditor.vue +++ b/src/components/MediaSettings/VideoBackgroundEditor.vue @@ -118,6 +118,11 @@ export default { type: String, required: true, }, + + skipBlurVirtualBackground: { + type: Boolean, + default: false, + }, }, emits: ['update-background'], @@ -265,7 +270,7 @@ export default { } else { this.selectedBackground = 'none' } - } else if (this.settingsStore.blurVirtualBackgroundEnabled) { + } else if (this.settingsStore.blurVirtualBackgroundEnabled && !this.skipBlurVirtualBackground) { this.selectedBackground = 'blur' } else { this.selectedBackground = 'none'