'use strict'; class LocalStorage { constructor() { this.MEDIA_TYPE = { audio: 'audio', video: 'video', audioVideo: 'audioVideo', speaker: 'speaker', }; this.INIT_CONFIG = { audio: true, video: true, audioVideo: true, }; this.SFU_SETTINGS = { share_on_join: true, // popup message on join show_chat_on_msg: true, // show chat on new message transcript_show_on_msg: true, // show transcript on new message speech_in_msg: false, // speech incoming message moderator_video_start_privacy: false, // Everyone starts video in privacy mode moderator_audio_start_muted: false, // Everyone starts muted in the room moderator_video_start_hidden: false, // Everyone starts hidden in the room moderator_audio_cant_unmute: false, // Everyone can't unmute themselves moderator_video_cant_unhide: false, // Everyone can't unhide themselves moderator_screen_cant_share: false, // Everyone can't share screen moderator_chat_cant_privately: false, // Everyone can't chat privately, only Public chat allowed moderator_chat_cant_chatgpt: false, // Everyone can't chat with ChatGPT moderator_chat_cant_deep_seek: false, // Everyone can't chat with DeepSeek moderator_media_cant_sharing: false, // Everyone can't share media moderator_disconnect_all_on_leave: false, // Disconnect all participants on leave room dominant_speaker_focus: false, // Focus on dominant speaker mic_noise_suppression: true, // Noise suppression using RNNoise video_fps: 0, // default 1280x768 30fps aspect_ratio: 0, // default (adaptive) screen_optimization: 1, // default detail (1): For high fidelity (screen sharing with text/graphics) || motion (2): For high frame rate (video playback, game streaming) screen_fps: 3, // default 1920x1080 15fps broadcasting: false, // default false (one to many a/v streaming) lobby: false, // default false pitch_bar: true, // volume indicator sounds: true, // room notify sounds keep_buttons_visible: false, // Keep buttons always visible keyboard_shortcuts: false, // keyboard shortcuts host_only_recording: false, // presenter rec_server: false, // The recording will be stored on the server rather than locally video_obj_fit: 2, // cover video_controls: 0, // off theme: 0, // dark theme_color: '#000000', // custom theme color theme_custom: false, // keep custom theme buttons_bar: 0, // vertical pin_grid: 0, // vertical }; this.DEVICES_COUNT = { audio: 0, speaker: 0, video: 0, }; this.LOCAL_STORAGE_DEVICES = { audio: { count: 0, index: 0, select: null, }, speaker: { count: 0, index: 0, select: null, }, video: { count: 0, index: 0, select: null, }, }; } // #################################################### // SET LOCAL STORAGE // #################################################### setItemLocalStorage(key, value) { localStorage.setItem(key, value); } setObjectLocalStorage(name, object) { localStorage.setItem(name, JSON.stringify(object)); } setSettings(settings) { this.SFU_SETTINGS = settings; this.setObjectLocalStorage('SFU_SETTINGS', this.SFU_SETTINGS); } setInitConfig(type, status) { switch (type) { case this.MEDIA_TYPE.audio: this.INIT_CONFIG.audio = status; break; case this.MEDIA_TYPE.video: this.INIT_CONFIG.video = status; break; case this.MEDIA_TYPE.audioVideo: this.INIT_CONFIG.audioVideo = status; break; default: break; } this.setObjectLocalStorage('INIT_CONFIG', this.INIT_CONFIG); } setLocalStorageDevices(type, index, select) { switch (type) { case this.MEDIA_TYPE.audio: this.LOCAL_STORAGE_DEVICES.audio.count = this.DEVICES_COUNT.audio; this.LOCAL_STORAGE_DEVICES.audio.index = index; this.LOCAL_STORAGE_DEVICES.audio.select = select; break; case this.MEDIA_TYPE.video: this.LOCAL_STORAGE_DEVICES.video.count = this.DEVICES_COUNT.video; this.LOCAL_STORAGE_DEVICES.video.index = index; this.LOCAL_STORAGE_DEVICES.video.select = select; break; case this.MEDIA_TYPE.speaker: this.LOCAL_STORAGE_DEVICES.speaker.count = this.DEVICES_COUNT.speaker; this.LOCAL_STORAGE_DEVICES.speaker.index = index; this.LOCAL_STORAGE_DEVICES.speaker.select = select; break; default: break; } this.setObjectLocalStorage('LOCAL_STORAGE_DEVICES', this.LOCAL_STORAGE_DEVICES); } // #################################################### // GET LOCAL STORAGE // #################################################### getLocalStorageSettings() { return this.getObjectLocalStorage('SFU_SETTINGS'); } getLocalStorageInitConfig() { return this.getObjectLocalStorage('INIT_CONFIG'); } getLocalStorageDevices() { return this.getObjectLocalStorage('LOCAL_STORAGE_DEVICES'); } getItemLocalStorage(key) { localStorage.getItem(key); } getObjectLocalStorage(name) { return JSON.parse(localStorage.getItem(name)); } }