Skip to content

Conversation

ByeongUkChoi
Copy link

Summary

This PR adds support for server-side dynamic client configuration in LiveKit Server, enabling administrators to configure client behavior based on client characteristics (browser, OS, device model, etc.) without requiring client-side code changes.

Background

Previously, LiveKit Server only supported static client configurations that were hardcoded in the StaticConfigurations variable. This made it difficult to:

  • Respond to new device issues - Required server code changes and releases
  • Test configurations - No way to A/B test different configurations
  • Environment-specific configs - Same configurations across all environments
  • Runtime adjustments - Required server restarts for any changes

Changes

New Features

  • YAML Configuration Support: Configure client rules in config.yaml
  • Runtime Updates: Update configurations without server restart
  • Rule-based Matching: Use JavaScript-like expressions to match clients
  • Merge Strategy: Choose to merge with or override static configurations
  • Backward Compatible: Existing static configurations continue to work

Files Added

  • pkg/clientconfiguration/dynamicconfiguration.go - Dynamic configuration manager
  • pkg/clientconfiguration/dynamicconfiguration_test.go - Unit tests
  • pkg/service/clientconfigurationservice.go - API service for future use
  • examples/dynamic_config_example.go - Example usage

Files Modified

  • pkg/config/config.go - Added ClientConfigurationConfig and ClientConfigurationItem structs
  • pkg/service/roommanager.go - Integration with DynamicClientConfigurationManager
  • config-sample.yaml - Added configuration examples

Configuration Example

client_configuration:
  configurations:
    # Disable AV1 for older Safari versions
    - match: 'c.browser == "safari" && c.browser_version < "17.0"'
      configuration: '{"disabled_codecs": {"codecs": [{"mime": "video/AV1"}]}}'
      merge: true
    
    # Enable hardware encoder for Android
    - match: 'c.os == "android"'
      configuration: '{"video": {"hardware_encoder": 1}}'
      merge: true

Match Rule Expressions

Support JavaScript-like expressions with client fields:

  • c.browser - Browser name (safari, chrome, firefox)
  • c.browser_version - Browser version string
  • c.os - Operating system (android, ios, windows, etc.)
  • c.device_model - Device model string
  • c.sdk - SDK name
  • c.protocol - Protocol version

Implementation Details

Architecture

  1. DynamicClientConfigurationManager extends the existing ClientConfigurationManager interface
  2. Fallback Strategy - Falls back to static configuration if dynamic initialization fails
  3. Configuration Merging - Dynamic configs can be merged with static ones using protobuf merge
  4. Thread-Safe - Uses RWMutex for concurrent access during updates

Backward Compatibility

  • Zero breaking changes
  • Existing static configurations work unchanged
  • Servers without dynamic configuration behave exactly as before
  • Dynamic configurations supplement static ones by default

- Add DynamicClientConfigurationManager for server-side client config
- Support YAML-based configuration with JavaScript-like match rules
- Enable runtime configuration updates without server restart
- Maintain full backward compatibility with static configurations
- Add comprehensive tests and examples

This allows server administrators to configure client behavior based on
browser, OS, device model, and other client characteristics without
requiring client-side code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant