How alvr-org/alvr works
Main components
• Server (PC) Side:
• Server Core (alvr/server_core): Handles streaming logic, video encoding/decoding, connection handling, logging, and statistics.
• Server IO (alvr/server_io): Manages firewall rules, OpenVR integration, and parts of the network interface.
• Server OpenVR (alvr/server_openvr): Contains C++ code for OpenVR integration and low-level interfacing with VR hardware (includes platform-specific code for Windows, Linux, macOS).
• Dashboard (alvr/dashboard): Provides a graphical user interface for installation, debugging, log viewing, and server configuration.
• Filesystem, Events, and Packets (alvr/filesystem, alvr/events, alvr/packets): Handle supportive tasks such as file management, input events, and data representations.
• Network Sockets (alvr/sockets): Implements the communication protocols (TCP/UDP) used to send/receive streaming data between the PC and the headset.
• Client (Headset) Side:
• Client Core (alvr/client_core): Acts as the core for client-side operations (e.g., handling decoded audio/video streams, managing connection state, logging, etc.).
• Client OpenXR (alvr/client_openxr): Manages integration with OpenXR – ensuring compatibility with various VR headsets.
• Audio and Graphics (alvr/audio, alvr/graphics): Provide platform-specific implementations for processing audio and rendering video streams.
• VR Compositor Wrapper (alvr/vrcompositor_wrapper): Wraps VR compositors to inject or manage streaming contexts.
• Cross-Cutting/Common Modules:
• Common (alvr/common): Shared libraries for logging, versioning, and general-purpose utilities.
• ADB (alvr/adb): Likely handles communication for Android-based headsets.
• Vulkan Layer (alvr/vulkan_layer): Implements a Vulkan intercept layer for capturing or modifying graphics calls, with associated cross-platform support.
• XTask (alvr/xtask): Contains helper scripts and tasks for building, packaging, and deployment.
• Other utility modules like session management (alvr/session) and system info (alvr/system_info).
Relationships and Interactions
• The Server Core modules communicate with the Client Core via the networking layer (sockets), sending encoded video, decoded audio, and control signals.
• The Dashboard (server side) interfaces with the Server Core to provide real-time insights, configuration options, and logging outputs.
• Platform-specific implementations (such as those found in server_openvr, client_openxr, audio, and graphics modules) connect with respective OS-level or VR runtime APIs.
• The Vulkan Layer intercepts Vulkan API calls on supported platforms, acting as an integration point between the system’s graphical output and VR headset rendering.
• Common utilities and shared protocols (alvr/common, alvr/packets) ensure consistent data structures and error/log management across different modules.
• The ADB and other xtask scripts ensure that deployment and build automation work seamlessly across the diverse components of the project.
Architectural Patterns and Principles
• Modularity and Separation of Concerns: Each directory addresses a distinct area (networking, audio, video, VR API integration) ensuring that each module is isolated and testable.
• Cross-Platform Abstractions: Many modules have platform-specific implementations (Windows, Linux, Android) as seen in folders like alvr/audio (linux.rs, windows.rs) and server_openvr (multiple platform directories).
• Client-Server Architecture: There is a clear division between the streaming server on the PC and the client on the VR headset, with an explicit network communication layer.
• Use of Both Rust and C++: Most business logic is implemented in Rust (as seen by extensive use of Cargo.toml files), but low-level VR interfacing and performance-critical components (like in server_openvr) are implemented in C++.
Relevant Technologies and Frameworks
• Rust for core modules, ensuring safety and concurrency.
• C++ for performance-critical and platform-specific VR interfacing.
• Use of Vulkan and OpenXR/OpenVR APIs for graphics and VR interactions.
• Networking libraries and protocols (part of the sockets modules) for real-time streaming.
• Annotations for architectural patterns (e.g., “modular”, “layered”, “platform adaptations”) and note any bridging modules like common utilities shared across server and client.
• Detail specific interactions, such as “Dashboard configures Server Core” or “Client Core communicates video/audio streams over sockets”.