Core

ConfigurationController

Centralized configuration management: reading by section, updating, resetting to defaults, import/export.

Access

typescript
const config = media.configurationController;

Actions

Reading configuration

typescript
// getConfig(): ValmConfiguration
const full = config.getConfig();
// {
//   video: VideoConfiguration,
//   audio: AudioConfiguration,
//   screenShare: ScreenShareConfiguration,
//   recording: RecordingConfiguration,
//   transcription: TranscriptionConfiguration,
// }

// getVideoConfig(): VideoConfiguration
const video = config.getVideoConfig();

// getAudioConfig(): AudioConfiguration
const audio = config.getAudioConfig();

// getScreenShareConfig(): ScreenShareConfiguration
const screenShare = config.getScreenShareConfig();

// getRecordingConfig(): RecordingConfiguration
const recording = config.getRecordingConfig();

// getTranscriptionConfig(): TranscriptionConfiguration
const transcription = config.getTranscriptionConfig();

Updating video

typescript
// updateVideoConfig(updates: Partial<VideoConfiguration>): void
config.updateVideoConfig({
  resolution: { width: 1920, height: 1080 },
  frameRate: 30,
  enabled: true,
})

// setVideoResolution(width: number, height: number): void
config.setVideoResolution(1280, 720)
config.setVideoResolution(1920, 1080)

// setVideoFrameRate(frameRate: number): void
config.setVideoFrameRate(30)
config.setVideoFrameRate(60)

// setVideoDevice(deviceId: string | null): void
config.setVideoDevice('camera-device-id')  // select a specific device
config.setVideoDevice(null)                 // auto-select

// toggleVideoEnabled(): boolean  — returns the new enabled value
const isNowEnabled = config.toggleVideoEnabled()

Updating audio

typescript
// updateAudioConfig(updates: Partial<AudioConfiguration>): void
config.updateAudioConfig({
  echoCancellation: true,
  noiseSuppression: true,
  autoGainControl: false,
  volumeThreshold: 20,    // volume threshold 0-100
})

// setAudioDevice(deviceId: string | null): void
config.setAudioDevice('mic-device-id')
config.setAudioDevice(null)  // auto-select

// setAudioProcessing(options): void
config.setAudioProcessing({
  echoCancellation: true,  // echo cancellation
  noiseSuppression: true,  // noise suppression
  autoGainControl: true,   // automatic gain control
})

// toggleAudioEnabled(): boolean
const isNowEnabled = config.toggleAudioEnabled()

Updating screen share

typescript
// updateScreenShareConfig(updates: Partial<ScreenShareConfiguration>): void
config.updateScreenShareConfig({
  preferDisplaySurface: 'window',   // 'monitor' | 'window' | 'application'
  includeAudio: true,               // capture system audio
  mode: 'video',                    // 'presentation' | 'video' — sets maxFrameRate and contentHint
  maxWidth: 1920,                   // width limit
  maxHeight: 1080,                  // height limit
  maxFrameRate: 15,                 // FPS limit (overrides the value from mode)
  contentHint: 'detail',           // 'motion' | 'detail' | 'text' | '' (overrides the value from mode)
})

// mode sets optimal maxFrameRate and contentHint:
// 'presentation' — 5 FPS, contentHint='text' (slides, documents — light on CPU)
// 'video'        — 30 FPS, contentHint='motion' (movies, games — smooth)
// Explicitly set maxFrameRate/contentHint override the values from mode.

// contentHint hints to the codec about the content type:
// 'motion'  — video, movies (prioritize smoothness)
// 'detail'  — presentations, UI (prioritize sharpness)
// 'text'    — text only (maximum sharpness)

Updating recording

typescript
// updateRecordingConfig(updates: Partial<RecordingConfiguration>): void
config.updateRecordingConfig({
  format: 'webm',            // 'webm' | 'mp4' | 'mkv'
  quality: 'high',           // 'low' | 'medium' | 'high' | 'custom'
  videoBitsPerSecond: 2_500_000,
  audioBitsPerSecond: 128_000,
})

// setRecordingFormat(format: 'webm' | 'mp4' | 'mkv'): void
config.setRecordingFormat('webm')

// setRecordingQuality(quality: 'low' | 'medium' | 'high' | 'custom'): void
config.setRecordingQuality('high')

// setRecordingBitrates(videoBitsPerSecond: number, audioBitsPerSecond: number): void
config.setRecordingBitrates(2_500_000, 128_000)

// setRecordingIncludes(options): void
config.setRecordingIncludes({
  includeVideo: true,        // include the video stream in the recording
  includeAudio: true,        // include the audio stream in the recording
  includeScreenShare: false, // include screen share in the recording
})

// setRecordingLimits(maxDuration: number, maxFileSize: number): void
// maxDuration — in seconds (0 = no limit)
// maxFileSize — in MB (0 = no limit)
config.setRecordingLimits(60, 500)   // 60 s, 500 MB
config.setRecordingLimits(0, 0)      // no limits

// toggleRecordingEnabled(): boolean
const isNowEnabled = config.toggleRecordingEnabled()

Updating transcription

typescript
// updateTranscriptionConfig(updates: Partial<TranscriptionConfiguration>): void
config.updateTranscriptionConfig({
  language: 'ru-RU',       // recognition language
  interimResults: true,    // show interim results
  autoStart: false,        // start automatically on initialization
  saveTranscripts: true,   // save transcript history
  pauseOnMute: true,       // do not listen while the microphone is muted
})

// setTranscriptionLanguage(language: string): void
config.setTranscriptionLanguage('en-US')
config.setTranscriptionLanguage('ru-RU')

// toggleTranscriptionEnabled(): boolean
const isNowEnabled = config.toggleTranscriptionEnabled()

// toggleTranscriptionAutoStart(): boolean
const isAutoStart = config.toggleTranscriptionAutoStart()

Reset

typescript
config.resetVideoConfig()        // reset video to defaults
config.resetAudioConfig()        // reset audio to defaults
config.resetRecordingConfig()    // reset recording to defaults
config.resetTranscriptionConfig() // reset transcription to defaults
config.resetAll()                // reset the entire configuration

Import and export

typescript
// exportConfig(): string  — serializes the configuration to a JSON string
const json = config.exportConfig()
localStorage.setItem('media-config', json)

// importConfig(configJson: string): void  — restores from a JSON string
const saved = localStorage.getItem('media-config')
if (saved) {
  config.importConfig(saved)
}

Getters and state

ValmConfiguration

typescript
interface ValmConfiguration {
  video: VideoConfiguration
  audio: AudioConfiguration
  screenShare: ScreenShareConfiguration
  recording: RecordingConfiguration
  transcription: TranscriptionConfiguration
}

VideoConfiguration

typescript
interface VideoConfiguration {
  enabled: boolean              // whether video is on by default
  deviceId: string | null       // camera ID (null = auto-select)
  resolution: {
    width: number               // width in pixels
    height: number              // height in pixels
  }
  frameRate: number             // frames per second
  facingMode: 'user' | 'environment'  // front or rear camera
  constraints: MediaTrackConstraints  // additional constraints
}

AudioConfiguration

typescript
interface AudioConfiguration {
  enabled: boolean              // whether audio is on by default
  deviceId: string | null       // microphone ID (null = auto-select)
  echoCancellation: boolean     // echo cancellation
  noiseSuppression: boolean     // noise suppression
  autoGainControl: boolean      // automatic gain control
  enableSpeakingDetection: boolean  // speech detection by volume
  volumeThreshold: number       // volume threshold for speech detection (0–100)
  constraints: MediaTrackConstraints
}

ScreenShareConfiguration

typescript
type ScreenShareMode = 'presentation' | 'video'

interface ScreenShareConfiguration {
  preferDisplaySurface: 'monitor' | 'window' | 'application'
  includeAudio: boolean         // capture system audio
  mode?: ScreenShareMode        // broadcast mode — determines frameRate and contentHint
  maxWidth?: number             // width limit (undefined = no limit)
  maxHeight?: number            // height limit
  maxFrameRate?: number         // FPS limit (if unset — from mode)
  contentHint?: 'motion' | 'detail' | 'text' | '' // codec hint (if unset — from mode)
}

RecordingConfiguration

typescript
interface RecordingConfiguration {
  enabled: boolean
  format: 'webm' | 'mp4' | 'mkv'
  quality: 'low' | 'medium' | 'high' | 'custom'
  videoBitsPerSecond: number    // video bitrate
  audioBitsPerSecond: number    // audio bitrate
  includeVideo: boolean
  includeAudio: boolean
  includeScreenShare: boolean
  autoSave: boolean             // automatically save files
  saveDirectory?: string        // folder for auto-saving
  maxDuration: number           // maximum duration in seconds (0 = no limit)
  maxFileSize: number           // maximum file size in MB (0 = no limit)
  chunkInterval: number         // interval for creating chunks in ms
}

TranscriptionConfiguration

typescript
interface TranscriptionConfiguration {
  enabled: boolean
  autoStart: boolean            // start automatically on initialization
  language: string              // BCP-47 language code, e.g. 'en-US', 'ru-RU'
  interimResults: boolean       // show interim (non-final) results
  saveTranscripts: boolean      // save transcript history
  pauseOnMute: boolean          // do not listen while the microphone is muted
}

Subscriptions

All methods return an unsubscribe function.

typescript
// onChange(callback): VoidFunction — any change in any section
const unsub = config.onChange((event: ConfigurationChangeEvent) => {
  // event.section    — 'video' | 'audio' | 'screenShare' | 'recording' | 'transcription'
  // event.property   — name of the changed property, e.g. 'frameRate'
  // event.oldValue   — previous value
  // event.newValue   — new value
  // event.timestamp  — event time in ms (Date.now())
  console.log(`[${event.section}] ${event.property}: ${event.oldValue} → ${event.newValue}`)
})

// Per-section changes — the same ConfigurationChangeEvent, but only for a specific section
config.onVideoChange((event: ConfigurationChangeEvent) => { ... })
config.onAudioChange((event: ConfigurationChangeEvent) => { ... })
config.onScreenShareChange((event: ConfigurationChangeEvent) => { ... })
config.onRecordingChange((event: ConfigurationChangeEvent) => { ... })
config.onTranscriptionChange((event: ConfigurationChangeEvent) => { ... })

// onReset(callback): VoidFunction — called after resetAll() or resetXxxConfig()
config.onReset((data: { oldConfig: ValmConfiguration; newConfig: ValmConfiguration }) => {
  // data.oldConfig — the configuration before the reset
  // data.newConfig — the configuration after the reset (default values)
  console.log('Config reset:', data.newConfig)
})

// onImport(callback): VoidFunction — called after importConfig()
config.onImport((data: { oldConfig: ValmConfiguration; newConfig: ValmConfiguration }) => {
  // data.oldConfig — the configuration before the import
  // data.newConfig — the imported configuration
  console.log('Config imported:', data.newConfig)
})

// onUpdate(callback): VoidFunction — any update (updateXxxConfig)
config.onUpdate((data: { oldConfig: ValmConfiguration; newConfig: ValmConfiguration }) => {
  // data.oldConfig — the configuration before the update
  // data.newConfig — the configuration after the update
})

unsub() // unsubscribe

ConfigurationChangeEvent

typescript
interface ConfigurationChangeEvent<T = any> {
  section: keyof ValmConfiguration  // 'video' | 'audio' | 'screenShare' | 'recording' | 'transcription'
  property: string    // the changed property, e.g. 'frameRate', 'deviceId'
  oldValue: T         // previous value
  newValue: T         // new value
  timestamp: number   // Date.now() at the moment of change
}

Common scenarios

Persisting user settings

typescript
// On any change — save to localStorage
config.onChange(() => {
  localStorage.setItem('media-config', config.exportConfig())
})

// On startup — restore
const saved = localStorage.getItem('media-config')
if (saved) {
  config.importConfig(saved)
}

Video quality presets

typescript
function applyVideoPreset(preset: 'low' | 'medium' | 'high') {
  const presets = {
    low:    { width: 640,  height: 480,  frameRate: 15 },
    medium: { width: 1280, height: 720,  frameRate: 30 },
    high:   { width: 1920, height: 1080, frameRate: 30 },
  }
  const { width, height, frameRate } = presets[preset]
  config.setVideoResolution(width, height)
  config.setVideoFrameRate(frameRate)
}

Logging changes of a specific section

typescript
config.onVideoChange((event) => {
  console.log(`Video config changed: ${event.property} = ${event.newValue}`)
})

config.onAudioChange((event) => {
  if (event.property === 'deviceId') {
    console.log('Microphone switched to:', event.newValue)
  }
})

API

Method / getterReturnsDescription
getConfig()ValmConfigurationFull configuration
getVideoConfig()VideoConfigurationVideo config
getAudioConfig()AudioConfigurationAudio config
getScreenShareConfig()ScreenShareConfigurationScreen share config
getRecordingConfig()RecordingConfigurationRecording config
getTranscriptionConfig()TranscriptionConfigurationTranscription config
updateVideoConfig(updates)voidUpdate the video config
updateAudioConfig(updates)voidUpdate the audio config
updateScreenShareConfig(updates)voidUpdate the screen share config
updateRecordingConfig(updates)voidUpdate the recording config
updateTranscriptionConfig(updates)voidUpdate the transcription config
setVideoResolution(w, h)voidSet the resolution
setVideoFrameRate(fps)voidSet the frame rate
setVideoDevice(deviceId)voidSelect a camera
toggleVideoEnabled()booleanToggle video, return the new value
setAudioDevice(deviceId)voidSelect a microphone
setAudioProcessing(options)voidConfigure audio processing
toggleAudioEnabled()booleanToggle audio, return the new value
setTranscriptionLanguage(lang)voidSet the recognition language
toggleTranscriptionEnabled()booleanToggle transcription
toggleTranscriptionAutoStart()booleanToggle auto-start
setRecordingFormat(format)voidSet the recording format
setRecordingQuality(quality)voidSet the quality
setRecordingBitrates(video, audio)voidSet the bitrates
setRecordingIncludes(options)voidWhat to include in the recording
setRecordingLimits(duration, size)voidRecording limits
toggleRecordingEnabled()booleanToggle recording
resetVideoConfig()voidReset video to defaults
resetAudioConfig()voidReset audio to defaults
resetRecordingConfig()voidReset recording to defaults
resetTranscriptionConfig()voidReset transcription to defaults
resetAll()voidReset the entire configuration
exportConfig()stringExport to a JSON string
importConfig(json)voidImport from a JSON string
onChange(cb)VoidFunctionAny configuration change
onVideoChange(cb)VoidFunctionChanges in the video section
onAudioChange(cb)VoidFunctionChanges in the audio section
onScreenShareChange(cb)VoidFunctionChanges in screen share
onRecordingChange(cb)VoidFunctionChanges in recording
onTranscriptionChange(cb)VoidFunctionChanges in transcription
onReset(cb)VoidFunctionConfiguration reset
onImport(cb)VoidFunctionConfiguration import
onUpdate(cb)VoidFunctionAny update (updateXxx)
destroy()voidRemove all subscriptions