feat: remove codec from ScreenShareConfig, add transient hwOverdrive

VP9 is now always the default codec, so the persisted codec field is
removed. hwOverdrive is a transient boolean (excluded from partialize)
that drives hardware H.264 on demand without surviving page reload.
Persist version bumped 12→13 with migration to strip stale codec field.
This commit is contained in:
Jannis Braun
2026-03-24 03:45:10 +01:00
parent 0b49300d86
commit 94e955989a
+12 -3
View File
@@ -10,7 +10,6 @@ export interface ScreenShareConfig {
height: number | 'native'; height: number | 'native';
fps: number; fps: number;
mode: 'gaming' | 'text'; mode: 'gaming' | 'text';
codec: 'vp9' | 'h264';
customBitrateKbps: number | null; customBitrateKbps: number | null;
shareAudio: boolean; shareAudio: boolean;
} }
@@ -89,6 +88,8 @@ interface VoiceState {
toggleDeafen: () => void; toggleDeafen: () => void;
setFocusedParticipant: (id: string | null) => void; setFocusedParticipant: (id: string | null) => void;
setScreenShareConfig: (config: Partial<ScreenShareConfig>) => void; setScreenShareConfig: (config: Partial<ScreenShareConfig>) => void;
hwOverdrive: boolean;
setHwOverdrive: (enabled: boolean) => void;
noiseSuppression: boolean; noiseSuppression: boolean;
echoCancellation: boolean; echoCancellation: boolean;
autoGainControl: boolean; autoGainControl: boolean;
@@ -146,7 +147,7 @@ export const useVoiceStore = create<VoiceState>()(
inputDeviceId: 'default', inputDeviceId: 'default',
outputDeviceId: 'default', outputDeviceId: 'default',
focusedParticipantId: null, focusedParticipantId: null,
screenShareConfig: { height: 720, fps: 60, mode: 'gaming', codec: 'vp9', customBitrateKbps: null, shareAudio: !isElectron() }, screenShareConfig: { height: 720, fps: 60, mode: 'gaming', customBitrateKbps: null, shareAudio: !isElectron() },
participantVolumes: new Map(), participantVolumes: new Map(),
setParticipantVolume: (userId, volume) => { setParticipantVolume: (userId, volume) => {
set((state) => { set((state) => {
@@ -329,6 +330,9 @@ export const useVoiceStore = create<VoiceState>()(
setScreenShareConfig: (config) => set((state) => ({ setScreenShareConfig: (config) => set((state) => ({
screenShareConfig: { ...state.screenShareConfig, ...config }, screenShareConfig: { ...state.screenShareConfig, ...config },
})), })),
// Hardware H.264 override — transient (intentionally excluded from partialize for non-persisted behavior)
hwOverdrive: false,
setHwOverdrive: (enabled) => set({ hwOverdrive: enabled }),
noiseSuppression: true, noiseSuppression: true,
echoCancellation: true, echoCancellation: true,
autoGainControl: true, autoGainControl: true,
@@ -545,7 +549,7 @@ export const useVoiceStore = create<VoiceState>()(
}), }),
{ {
name: 'backspace-voice-settings', name: 'backspace-voice-settings',
version: 12, version: 13,
migrate: (persistedState: any, version: number) => { migrate: (persistedState: any, version: number) => {
if (version === 0) { if (version === 0) {
persistedState.streamAttenuationEnabled = false; persistedState.streamAttenuationEnabled = false;
@@ -601,6 +605,11 @@ export const useVoiceStore = create<VoiceState>()(
cfg.height = 1080; cfg.height = 1080;
} }
} }
if (version < 13) {
if (persistedState.screenShareConfig) {
delete persistedState.screenShareConfig.codec;
}
}
return persistedState; return persistedState;
}, },
storage: createJSONStorage(() => localStorage), storage: createJSONStorage(() => localStorage),