(frontend) add persistence for video publishing resolution setting

Implement user choice persistence for video publishing resolution
configuration to maintain user preferences across sessions.

Stores selected video resolution in user settings, ensuring consistent
video quality preferences without requiring reconfiguration on each
visit.
This commit is contained in:
lebaudantoine
2025-08-12 19:02:28 +02:00
committed by aleb_the_flash
parent f380d0342d
commit fd90d0b830
3 changed files with 13 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import {
RoomOptions, RoomOptions,
supportsAdaptiveStream, supportsAdaptiveStream,
supportsDynacast, supportsDynacast,
VideoPresets,
} from 'livekit-client' } from 'livekit-client'
import { keys } from '@/api/queryKeys' import { keys } from '@/api/queryKeys'
import { queryClient } from '@/api/queryClient' import { queryClient } from '@/api/queryClient'
@@ -98,6 +99,9 @@ export const Conference = ({
}, },
videoCaptureDefaults: { videoCaptureDefaults: {
deviceId: userConfig.videoDeviceId ?? undefined, deviceId: userConfig.videoDeviceId ?? undefined,
resolution: userConfig.videoPublishResolution
? VideoPresets[userConfig.videoPublishResolution].resolution
: undefined,
}, },
audioCaptureDefaults: { audioCaptureDefaults: {
deviceId: userConfig.audioDeviceId ?? undefined, deviceId: userConfig.audioDeviceId ?? undefined,
@@ -109,6 +113,7 @@ export const Conference = ({
// do not rely on the userConfig object directly as its reference may change on every render // do not rely on the userConfig object directly as its reference may change on every render
}, [ }, [
userConfig.videoDeviceId, userConfig.videoDeviceId,
userConfig.videoPublishResolution,
userConfig.audioDeviceId, userConfig.audioDeviceId,
userConfig.audioOutputDeviceId, userConfig.audioOutputDeviceId,
isAdaptiveStreamSupported, isAdaptiveStreamSupported,

View File

@@ -1,5 +1,6 @@
import { useSnapshot } from 'valtio' import { useSnapshot } from 'valtio'
import { userChoicesStore } from '@/stores/userChoices' import { userChoicesStore } from '@/stores/userChoices'
import type { VideoResolution } from '@/stores/userChoices'
import { ProcessorSerialized } from '@/features/rooms/livekit/components/blur' import { ProcessorSerialized } from '@/features/rooms/livekit/components/blur'
export function usePersistentUserChoices() { export function usePersistentUserChoices() {
@@ -22,6 +23,9 @@ export function usePersistentUserChoices() {
saveVideoInputDeviceId: (deviceId: string) => { saveVideoInputDeviceId: (deviceId: string) => {
userChoicesStore.videoDeviceId = deviceId userChoicesStore.videoDeviceId = deviceId
}, },
saveVideoPublishResolution: (resolution: VideoResolution) => {
userChoicesStore.videoPublishResolution = resolution
},
saveUsername: (username: string) => { saveUsername: (username: string) => {
userChoicesStore.username = username userChoicesStore.username = username
}, },

View File

@@ -6,16 +6,20 @@ import {
LocalUserChoices as LocalUserChoicesLK, LocalUserChoices as LocalUserChoicesLK,
} from '@livekit/components-core' } from '@livekit/components-core'
export type VideoResolution = 'h720' | 'h360' | 'h180'
export type LocalUserChoices = LocalUserChoicesLK & { export type LocalUserChoices = LocalUserChoicesLK & {
processorSerialized?: ProcessorSerialized processorSerialized?: ProcessorSerialized
noiseReductionEnabled?: boolean noiseReductionEnabled?: boolean
audioOutputDeviceId?: string audioOutputDeviceId?: string
videoPublishResolution?: VideoResolution
} }
function getUserChoicesState(): LocalUserChoices { function getUserChoicesState(): LocalUserChoices {
return { return {
noiseReductionEnabled: false, noiseReductionEnabled: false,
audioOutputDeviceId: 'default', // Use 'default' to match LiveKit's standard device selection behavior audioOutputDeviceId: 'default', // Use 'default' to match LiveKit's standard device selection behavior
videoPublishResolution: 'h720',
...loadUserChoices(), ...loadUserChoices(),
} }
} }