From 160d501fbfefe8b7f6f8fa9d46dc7012fb404554 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Mon, 22 Apr 2024 20:35:45 +0200 Subject: fix(MediaSettings): Enfore devices tab when showing modal if preferences are not set yet. Signed-off-by: DorraJaouad --- src/components/MediaSettings/MediaSettings.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 6ee20a477..70937a290 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -473,11 +473,6 @@ export default { mounted() { subscribe('talk:media-settings:show', this.showModal) subscribe('talk:media-settings:hide', this.closeModalAndApplySettings) - - const devicesPreferred = BrowserStorage.getItem('devicesPreferred') - if (!devicesPreferred) { - this.tabContent = 'devices' - } }, beforeDestroy() { @@ -491,6 +486,10 @@ export default { if (page === 'video-verification') { this.isPublicShareAuthSidebar = true } + + if (!BrowserStorage.getItem('devicesPreferred')) { + this.tabContent = 'devices' + } }, closeModal() { -- cgit v1.2.3 From 93a3b6d391a4484d097b247491a5bfee8fd843a0 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Tue, 23 Apr 2024 09:23:58 +0200 Subject: fix(media): move devices preferences list to selection event. do not show apply settings button to devices change Signed-off-by: DorraJaouad --- src/components/MediaSettings/MediaSettings.vue | 27 ++++++++++++++-------- .../SettingsDialog/MediaDevicesPreview.vue | 25 +++++++++++++++++--- 2 files changed, 40 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 70937a290..e0844a584 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -92,12 +92,12 @@ :devices="devices" :device-id="audioInputId" @refresh="updateDevices" - @update:deviceId="audioInputId = $event" /> + @update:deviceId="handleAudioInputIdChange" /> + @update:deviceId="handleVideoInputIdChange" /> @@ -312,7 +312,6 @@ export default { videoOn: undefined, silentCall: false, updatedBackground: undefined, - deviceIdChanged: false, audioDeviceStateChanged: false, videoDeviceStateChanged: false, isRecordingFromStart: false, @@ -422,7 +421,7 @@ export default { }, showUpdateChangesButton() { - return this.updatedBackground || this.deviceIdChanged || this.audioDeviceStateChanged + return this.updatedBackground || this.audioDeviceStateChanged || this.videoDeviceStateChanged }, }, @@ -452,14 +451,12 @@ export default { }, audioInputId(audioInputId) { - this.deviceIdChanged = true if (this.showDeviceSelection && audioInputId && !this.audioOn) { this.toggleAudio() } }, videoInputId(videoInputId) { - this.deviceIdChanged = true if (this.showDeviceSelection && videoInputId && !this.videoOn) { this.toggleVideo() } @@ -495,7 +492,6 @@ export default { closeModal() { this.modal = false this.updatedBackground = undefined - this.deviceIdChanged = false this.audioDeviceStateChanged = false this.videoDeviceStateChanged = false this.isPublicShareAuthSidebar = false @@ -544,7 +540,6 @@ export default { emit('local-video-control-button:toggle-video') } - this.updatePreferences() this.closeModal() }, @@ -655,7 +650,21 @@ export default { setRecordingConsentGiven(value) { this.$emit('update:recording-consent-given', value) - } + }, + + handleAudioInputIdChange(audioInputId) { + this.audioInputId = audioInputId + if (audioInputId !== null) { + this.updatePreferences() + } + }, + + handleVideoInputIdChange(videoInputId) { + this.videoInputId = videoInputId + if (videoInputId !== null) { + this.updatePreferences() + } + }, }, } diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index 1ca524ab9..e4b686f38 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -9,7 +9,7 @@ :devices="devices" :device-id="audioInputId" @refresh="updateDevices" - @update:deviceId="audioInputId = $event" /> + @update:deviceId="handleAudioInputIdChange" />
@@ -38,7 +38,7 @@ :devices="devices" :device-id="videoInputId" @refresh="updateDevices" - @update:deviceId="videoInputId = $event" /> + @update:deviceId="handleVideoInputIdChange" />
@@ -95,6 +95,7 @@ export default { const { devices, updateDevices, + updatePreferences, currentVolume, currentThreshold, audioPreviewAvailable, @@ -111,6 +112,7 @@ export default { video, devices, updateDevices, + updatePreferences, currentVolume, currentThreshold, audioPreviewAvailable, @@ -176,7 +178,24 @@ export default { return t('spreed', 'Error while accessing camera') }, - } + }, + + methods: { + handleAudioInputIdChange(audioInputId) { + this.audioInputId = audioInputId + if (audioInputId !== null) { + this.updatePreferences() + } + }, + + handleVideoInputIdChange(videoInputId) { + this.videoInputId = videoInputId + if (videoInputId !== null) { + this.updatePreferences() + } + }, + + }, } -- cgit v1.2.3 From 9d0c4683f3de7c3159e9d37546eb0fdd0397b820 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Tue, 23 Apr 2024 09:24:56 +0200 Subject: fix: reduce debugging log Signed-off-by: DorraJaouad --- src/utils/webrtc/MediaDevicesManager.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/webrtc/MediaDevicesManager.js b/src/utils/webrtc/MediaDevicesManager.js index b1819952e..7b50d8960 100644 --- a/src/utils/webrtc/MediaDevicesManager.js +++ b/src/utils/webrtc/MediaDevicesManager.js @@ -199,12 +199,17 @@ MediaDevicesManager.prototype = { // according to the spec, a single device of each kind (if at least // one device of that kind is available) with an empty deviceId is // returned, which will not be registered in the preference list. + let deviceIdChanged = false if (this.attributes.audioInputId === undefined || this.attributes.audioInputId === previousFirstAvailableAudioInputId) { this.attributes.audioInputId = getFirstAvailableMediaDevice(devices, this._preferenceAudioInputList) || devices.find(device => device.kind === 'audioinput')?.deviceId - console.debug(listMediaDevices(this.attributes, this._preferenceAudioInputList, this._preferenceVideoInputList)) + deviceIdChanged = true } if (this.attributes.videoInputId === undefined || this.attributes.videoInputId === previousFirstAvailableVideoInputId) { this.attributes.videoInputId = getFirstAvailableMediaDevice(devices, this._preferenceVideoInputList) || devices.find(device => device.kind === 'videoinput')?.deviceId + deviceIdChanged = true + } + + if (deviceIdChanged) { console.debug(listMediaDevices(this.attributes, this._preferenceAudioInputList, this._preferenceVideoInputList)) } @@ -258,8 +263,7 @@ MediaDevicesManager.prototype = { BrowserStorage.setItem('videoInputPreferences', JSON.stringify(newVideoInputList)) } - const devicesPreferred = BrowserStorage.getItem('devicesPreferred') - if (!devicesPreferred) { + if (!BrowserStorage.getItem('devicesPreferred')) { BrowserStorage.setItem('devicesPreferred', true) } -- cgit v1.2.3 From 21a18874d07646249865cb0413864dfc9fd04036 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Tue, 23 Apr 2024 12:56:16 +0200 Subject: fix(Media): split preference update flow for video and audio inputs Signed-off-by: DorraJaouad --- src/components/MediaSettings/MediaSettings.vue | 10 ++---- .../SettingsDialog/MediaDevicesPreview.vue | 8 ++--- src/composables/useDevices.js | 5 +-- .../__tests__/mediaDevicePreferences.spec.js | 41 ++++++++-------------- src/services/mediaDevicePreferences.ts | 20 +---------- src/utils/webrtc/MediaDevicesManager.js | 39 ++++++++++---------- 6 files changed, 44 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index e0844a584..552ad5120 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -484,7 +484,7 @@ export default { this.isPublicShareAuthSidebar = true } - if (!BrowserStorage.getItem('devicesPreferred')) { + if (!BrowserStorage.getItem('audioInputDevicePreferred') || !BrowserStorage.getItem('videoInputDevicePreferred')) { this.tabContent = 'devices' } }, @@ -654,16 +654,12 @@ export default { handleAudioInputIdChange(audioInputId) { this.audioInputId = audioInputId - if (audioInputId !== null) { - this.updatePreferences() - } + this.updatePreferences('audioinput') }, handleVideoInputIdChange(videoInputId) { this.videoInputId = videoInputId - if (videoInputId !== null) { - this.updatePreferences() - } + this.updatePreferences('videoinput') }, }, } diff --git a/src/components/SettingsDialog/MediaDevicesPreview.vue b/src/components/SettingsDialog/MediaDevicesPreview.vue index e4b686f38..1d6433adc 100644 --- a/src/components/SettingsDialog/MediaDevicesPreview.vue +++ b/src/components/SettingsDialog/MediaDevicesPreview.vue @@ -183,16 +183,12 @@ export default { methods: { handleAudioInputIdChange(audioInputId) { this.audioInputId = audioInputId - if (audioInputId !== null) { - this.updatePreferences() - } + this.updatePreferences('audioinput') }, handleVideoInputIdChange(videoInputId) { this.videoInputId = videoInputId - if (videoInputId !== null) { - this.updatePreferences() - } + this.updatePreferences('videoinput') }, }, diff --git a/src/composables/useDevices.js b/src/composables/useDevices.js index 4ad5a90ed..aa0b2714a 100644 --- a/src/composables/useDevices.js +++ b/src/composables/useDevices.js @@ -155,10 +155,11 @@ export function useDevices(video, initializeOnMounted) { /** * Update preference counters for devices (audio and video) + * @param {string} kind the kind of the input stream to update ('audioinput' or 'videoinput') * @public */ - function updatePreferences() { - mediaDevicesManager.updatePreferences() + function updatePreferences(kind) { + mediaDevicesManager.updatePreferences(kind) } /** diff --git a/src/services/__tests__/mediaDevicePreferences.spec.js b/src/services/__tests__/mediaDevicePreferences.spec.js index deaf296b6..9932aea37 100644 --- a/src/services/__tests__/mediaDevicePreferences.spec.js +++ b/src/services/__tests__/mediaDevicePreferences.spec.js @@ -6,7 +6,7 @@ import { getFirstAvailableMediaDevice, listMediaDevices, populateMediaDevicesPreferences, - updateMediaDevicesPreferences, + promoteMediaDevice, } from '../mediaDevicePreferences.ts' describe('mediaDevicePreferences', () => { @@ -122,42 +122,38 @@ describe('mediaDevicePreferences', () => { }) }) - describe('updateMediaDevicesPreferences', () => { + describe('promoteMediaDevice', () => { it('returns null if preference lists were not updated (no id or default id provided)', () => { const ids = [null, undefined, 'default'] const getOutput = (id) => { - const attributes = { devices: allDevices, audioInputId: id, videoInputId: id } - return updateMediaDevicesPreferences(attributes, audioInputPreferenceList, videoInputPreferenceList) + const attributes = { devices: allDevices, audioInputId: id } + return promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) } // Assert ids.forEach(id => { - expect(getOutput(id)).toMatchObject({ newAudioInputList: null, newVideoInputList: null }) + expect(getOutput(id)).toEqual(null) }) }) it('returns updated preference lists (device A id provided)', () => { - const attributes = { devices: allDevices, audioInputId: audioInputDeviceA.deviceId, videoInputId: videoInputDeviceA.deviceId } - const output = updateMediaDevicesPreferences(attributes, audioInputPreferenceList, videoInputPreferenceList) + const attributes = { devices: allDevices, audioInputId: audioInputDeviceA.deviceId } + const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) // Assert: should put device A on top of default device - expect(output).toMatchObject({ - newAudioInputList: [audioInputDeviceA, audioInputDeviceDefault, audioInputDeviceB], - newVideoInputList: [videoInputDeviceA, videoInputDeviceDefault, videoInputDeviceB], - }) + expect(output).toEqual([audioInputDeviceA, audioInputDeviceDefault, audioInputDeviceB]) }) it('returns null if preference lists were not updated (device A id provided but not available)', () => { const attributes = { devices: allDevices.filter(device => !['da1234567890', 'da4567890123'].includes(device.deviceId)), audioInputId: audioInputDeviceA.deviceId, - videoInputId: videoInputDeviceA.deviceId, } - const output = updateMediaDevicesPreferences(attributes, audioInputPreferenceList, videoInputPreferenceList) + const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) // Assert - expect(output).toMatchObject({ newAudioInputList: null, newVideoInputList: null }) + expect(output).toEqual(null) }) it('returns null if preference lists were not updated (all devices are not available)', () => { @@ -166,29 +162,22 @@ describe('mediaDevicePreferences', () => { audioInputId: audioInputDeviceA.deviceId, videoInputId: videoInputDeviceA.deviceId, } - const output = updateMediaDevicesPreferences(attributes, audioInputPreferenceList, videoInputPreferenceList) + const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) // Assert - expect(output).toMatchObject({ newAudioInputList: null, newVideoInputList: null }) + expect(output).toEqual(null) }) it('returns updated preference lists (device B id provided, but not registered, default device and device A not available)', () => { const attributes = { devices: allDevices.filter(device => !['default', 'da1234567890', 'da4567890123'].includes(device.deviceId)), audioInputId: audioInputDeviceB.deviceId, - videoInputId: videoInputDeviceB.deviceId, } - const output = updateMediaDevicesPreferences( - attributes, - [audioInputDeviceDefault, audioInputDeviceA], - [videoInputDeviceDefault, videoInputDeviceA], - ) + + const output = promoteMediaDevice('audioinput', attributes.devices, [audioInputDeviceDefault, audioInputDeviceA], attributes.audioInputId) // Assert: should put device C on top of device B, but not the device A - expect(output).toMatchObject({ - newAudioInputList: [audioInputDeviceDefault, audioInputDeviceA, audioInputDeviceB], - newVideoInputList: [videoInputDeviceDefault, videoInputDeviceA, videoInputDeviceB], - }) + expect(output).toEqual([audioInputDeviceDefault, audioInputDeviceA, audioInputDeviceB]) }) }) }) diff --git a/src/services/mediaDevicePreferences.ts b/src/services/mediaDevicePreferences.ts index 56ef57813..c87ce8540 100644 --- a/src/services/mediaDevicePreferences.ts +++ b/src/services/mediaDevicePreferences.ts @@ -164,27 +164,9 @@ function populateMediaDevicesPreferences(devices: MediaDeviceInfo[], audioInputL } } -/** - * Update devices preferences. Assuming that preferred devices were selected, should be called after applying the selection: - * so either with joining the call or changing device during the call - * - * Returns changed preference lists for audio / video devices (null, if it hasn't been changed) - * - * @param attributes MediaDeviceManager attributes - * @param audioInputList list of registered audio devices in order of preference - * @param videoInputList list of registered video devices in order of preference - * @return {InputLists} object with updated devices lists (null, if they have not been changed) - */ -function updateMediaDevicesPreferences(attributes: Attributes, audioInputList: MediaDeviceInfo[], videoInputList: MediaDeviceInfo[]): InputLists { - return { - newAudioInputList: promoteMediaDevice(DeviceKind.AudioInput, attributes.devices, audioInputList, attributes.audioInputId), - newVideoInputList: promoteMediaDevice(DeviceKind.VideoInput, attributes.devices, videoInputList, attributes.videoInputId), - } -} - export { getFirstAvailableMediaDevice, listMediaDevices, populateMediaDevicesPreferences, - updateMediaDevicesPreferences, + promoteMediaDevice, } diff --git a/src/utils/webrtc/MediaDevicesManager.js b/src/utils/webrtc/MediaDevicesManager.js index 7b50d8960..b37f7f15f 100644 --- a/src/utils/webrtc/MediaDevicesManager.js +++ b/src/utils/webrtc/MediaDevicesManager.js @@ -8,7 +8,7 @@ import { getFirstAvailableMediaDevice, listMediaDevices, populateMediaDevicesPreferences, - updateMediaDevicesPreferences, + promoteMediaDevice, } from '../../services/mediaDevicePreferences.ts' import EmitterMixin from '../EmitterMixin.js' @@ -247,24 +247,25 @@ MediaDevicesManager.prototype = { } }, - updatePreferences() { - const { newAudioInputList, newVideoInputList } = updateMediaDevicesPreferences( - this.attributes, - this._preferenceAudioInputList, - this._preferenceVideoInputList, - ) - - if (newAudioInputList) { - this._preferenceAudioInputList = newAudioInputList - BrowserStorage.setItem('audioInputPreferences', JSON.stringify(newAudioInputList)) - } - if (newVideoInputList) { - this._preferenceVideoInputList = newVideoInputList - BrowserStorage.setItem('videoInputPreferences', JSON.stringify(newVideoInputList)) - } - - if (!BrowserStorage.getItem('devicesPreferred')) { - BrowserStorage.setItem('devicesPreferred', true) + updatePreferences(kind) { + if (kind === 'audioinput') { + const newAudioInputList = promoteMediaDevice('audioinput', this.attributes.devices, this._preferenceAudioInputList, this.attributes.audioInputId) + if (newAudioInputList) { + this._preferenceAudioInputList = newAudioInputList + BrowserStorage.setItem('audioInputPreferences', JSON.stringify(newAudioInputList)) + } + if (!BrowserStorage.getItem('audioInputDevicePreferred')) { + BrowserStorage.setItem('audioInputDevicePreferred', true) + } + } else if (kind === 'videoinput') { + const newVideoInputList = promoteMediaDevice('videoinput', this.attributes.devices, this._preferenceVideoInputList, this.attributes.videoInputId) + if (newVideoInputList) { + this._preferenceVideoInputList = newVideoInputList + BrowserStorage.setItem('videoInputPreferences', JSON.stringify(newVideoInputList)) + } + if (!BrowserStorage.getItem('videoInputDevicePreferred')) { + BrowserStorage.setItem('videoInputDevicePreferred', true) + } } }, -- cgit v1.2.3 From 2651c2ec5ae9714b8e57e2bd019e35bf34dae8f7 Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 24 Apr 2024 12:08:16 +0200 Subject: fix: wrap arguments in an object for better indication of what should be passed. Signed-off-by: DorraJaouad --- src/components/MediaSettings/MediaSettings.vue | 6 +++ .../__tests__/mediaDevicePreferences.spec.js | 45 +++++++++++++--------- src/services/mediaDevicePreferences.ts | 18 ++++++--- src/utils/webrtc/MediaDevicesManager.js | 16 +++++++- 4 files changed, 60 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 552ad5120..4b97dd44d 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -470,6 +470,12 @@ export default { mounted() { subscribe('talk:media-settings:show', this.showModal) subscribe('talk:media-settings:hide', this.closeModalAndApplySettings) + + // FIXME: this is a workaround to remove the old key from the browser storage + // To be removed in the future + if (BrowserStorage.getItem('devicesPreferred')) { + BrowserStorage.removeItem('devicesPreferred') + } }, beforeDestroy() { diff --git a/src/services/__tests__/mediaDevicePreferences.spec.js b/src/services/__tests__/mediaDevicePreferences.spec.js index 9932aea37..8311420d0 100644 --- a/src/services/__tests__/mediaDevicePreferences.spec.js +++ b/src/services/__tests__/mediaDevicePreferences.spec.js @@ -127,8 +127,12 @@ describe('mediaDevicePreferences', () => { const ids = [null, undefined, 'default'] const getOutput = (id) => { - const attributes = { devices: allDevices, audioInputId: id } - return promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) + return promoteMediaDevice({ + kind: 'audioinput', + devices: allDevices, + inputList: audioInputPreferenceList, + inputId: id + }) } // Assert @@ -138,43 +142,48 @@ describe('mediaDevicePreferences', () => { }) it('returns updated preference lists (device A id provided)', () => { - const attributes = { devices: allDevices, audioInputId: audioInputDeviceA.deviceId } - const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) + const output = promoteMediaDevice({ + kind: 'audioinput', + devices: allDevices, + inputList: audioInputPreferenceList, + inputId: audioInputDeviceA.deviceId + }) // Assert: should put device A on top of default device expect(output).toEqual([audioInputDeviceA, audioInputDeviceDefault, audioInputDeviceB]) }) it('returns null if preference lists were not updated (device A id provided but not available)', () => { - const attributes = { + const output = promoteMediaDevice({ + kind: 'audioinput', devices: allDevices.filter(device => !['da1234567890', 'da4567890123'].includes(device.deviceId)), - audioInputId: audioInputDeviceA.deviceId, - } - const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) + inputList: audioInputPreferenceList, + inputId: audioInputDeviceA.deviceId + }) // Assert expect(output).toEqual(null) }) it('returns null if preference lists were not updated (all devices are not available)', () => { - const attributes = { + const output = promoteMediaDevice({ + kind: 'audioinput', devices: allDevices.filter(device => !['audioinput', 'videoinput'].includes(device.kind)), - audioInputId: audioInputDeviceA.deviceId, - videoInputId: videoInputDeviceA.deviceId, - } - const output = promoteMediaDevice('audioinput', attributes.devices, audioInputPreferenceList, attributes.audioInputId) + inputList: audioInputPreferenceList, + inputId: audioInputDeviceA.deviceId + }) // Assert expect(output).toEqual(null) }) it('returns updated preference lists (device B id provided, but not registered, default device and device A not available)', () => { - const attributes = { + const output = promoteMediaDevice({ + kind: 'audioinput', devices: allDevices.filter(device => !['default', 'da1234567890', 'da4567890123'].includes(device.deviceId)), - audioInputId: audioInputDeviceB.deviceId, - } - - const output = promoteMediaDevice('audioinput', attributes.devices, [audioInputDeviceDefault, audioInputDeviceA], attributes.audioInputId) + inputList: [audioInputDeviceDefault, audioInputDeviceA], + inputId: audioInputDeviceB.deviceId + }) // Assert: should put device C on top of device B, but not the device A expect(output).toEqual([audioInputDeviceDefault, audioInputDeviceA, audioInputDeviceB]) diff --git a/src/services/mediaDevicePreferences.ts b/src/services/mediaDevicePreferences.ts index c87ce8540..a1d8eccde 100644 --- a/src/services/mediaDevicePreferences.ts +++ b/src/services/mediaDevicePreferences.ts @@ -21,6 +21,13 @@ enum DeviceKind { AudioOutput = 'audiooutput', } +type PromotePayload = { + kind: DeviceKind, + devices: MediaDeviceInfo[], + inputList: MediaDeviceInfo[], + inputId: InputId +} + /** * List all registered devices in order of their preferences * Show whether device is currently unplugged or selected, if information is available @@ -90,13 +97,14 @@ function registerNewMediaDevice(device: MediaDeviceInfo, devicesList: MediaDevic * * Returns changed preference lists for audio / video devices (null, if it hasn't been changed) * - * @param kind kind of device - * @param devices list of available devices - * @param inputList list of registered audio/video devices in order of preference - * @param inputId id of currently selected input + * @param data the wrapping object + * @param data.kind kind of device + * @param data.devices list of available devices + * @param data.inputList list of registered audio/video devices in order of preference + * @param data.inputId id of currently selected input * @return {InputListUpdated} updated devices list (null, if it has not been changed) */ -function promoteMediaDevice(kind: DeviceKind, devices: MediaDeviceInfo[], inputList: MediaDeviceInfo[], inputId: InputId): InputListUpdated { +function promoteMediaDevice({ kind, devices, inputList, inputId } : PromotePayload) : InputListUpdated { if (!inputId) { return null } diff --git a/src/utils/webrtc/MediaDevicesManager.js b/src/utils/webrtc/MediaDevicesManager.js index b37f7f15f..83bbd36dc 100644 --- a/src/utils/webrtc/MediaDevicesManager.js +++ b/src/utils/webrtc/MediaDevicesManager.js @@ -249,7 +249,13 @@ MediaDevicesManager.prototype = { updatePreferences(kind) { if (kind === 'audioinput') { - const newAudioInputList = promoteMediaDevice('audioinput', this.attributes.devices, this._preferenceAudioInputList, this.attributes.audioInputId) + const newAudioInputList = promoteMediaDevice({ + kind, + devices: this.attributes.devices, + inputList: this._preferenceAudioInputList, + inputId: this.attributes.audioInputId + }) + if (newAudioInputList) { this._preferenceAudioInputList = newAudioInputList BrowserStorage.setItem('audioInputPreferences', JSON.stringify(newAudioInputList)) @@ -258,7 +264,13 @@ MediaDevicesManager.prototype = { BrowserStorage.setItem('audioInputDevicePreferred', true) } } else if (kind === 'videoinput') { - const newVideoInputList = promoteMediaDevice('videoinput', this.attributes.devices, this._preferenceVideoInputList, this.attributes.videoInputId) + const newVideoInputList = promoteMediaDevice({ + kind, + devices: this.attributes.devices, + inputList: this._preferenceVideoInputList, + inputId: this.attributes.videoInputId + }) + if (newVideoInputList) { this._preferenceVideoInputList = newVideoInputList BrowserStorage.setItem('videoInputPreferences', JSON.stringify(newVideoInputList)) -- cgit v1.2.3 From c4e6a9a5f55f73326901c13cf8e7f07e7f20c56a Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Thu, 25 Apr 2024 13:35:42 +0200 Subject: feat(MediaSettings): make apply settings button sticky Signed-off-by: DorraJaouad --- src/components/MediaSettings/MediaSettings.vue | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index 4b97dd44d..cbe92d28c 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -674,6 +674,7 @@ export default {