-
Notifications
You must be signed in to change notification settings - Fork 56
Sending device model over ffi for client telemetry #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MaxHeimbrock
wants to merge
4
commits into
main
Choose a base branch
from
max/claude/device-model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| LiveKit Unity SDK — a C# wrapper around LiveKit's Rust SDK using FFI (Foreign Function Interface) for real-time audio/video communication. Status: Developer Preview. Unity package name: `io.livekit.livekit-sdk`. | ||
|
|
||
| ## Build & Development Commands | ||
|
|
||
| ### Build FFI locally from Rust source | ||
| ```bash | ||
| # Requires the client-sdk-rust~ submodule and Rust toolchain | ||
| BuildScripts~/build_ffi_locally.sh <platform> [build_type] | ||
| # Platforms: macos, android, ios | ||
| # Build types: debug (default), release | ||
| ``` | ||
| - **macOS**: requires `aarch64-apple-darwin` target | ||
| - **Android**: requires `cargo-ndk` and Android NDK | ||
| - **iOS**: builds static lib (`liblivekit_ffi.a`) | ||
| - After macOS builds, Unity must be restarted to load the new dylib | ||
|
|
||
| ### Run tests | ||
| Tests require a local LiveKit server running: | ||
| ```bash | ||
| # Install and run LiveKit server | ||
| curl -sSL https://get.livekit.io | bash | ||
| livekit-server --dev & | ||
| ``` | ||
| Tests run via Unity Test Framework (game-ci/unity-test-runner in CI). Tested against Unity 6000.0.49f1 and 2023.2.20f1. Tests are in `Tests/EditMode/` and `Tests/PlayMode/`. | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### FFI Bridge Pattern | ||
| The SDK wraps a Rust native library (`liblivekit_ffi`) via P/Invoke. The communication flow: | ||
|
|
||
| 1. **C# public API** (`Runtime/Scripts/*.cs`) — `Room`, `Participant`, `Track`, audio/video sources, data streams, RPC | ||
| 2. **FFI layer** (`Runtime/Scripts/Internal/`) — serializes requests via Protocol Buffers, sends through P/Invoke to Rust | ||
| 3. **Native library** (`Runtime/Plugins/ffi-*/liblivekit_ffi.*`) — Rust implementation per platform/arch | ||
|
|
||
| Key internal files: | ||
| - `FFIClient.cs` — singleton managing request/response lifecycle with Rust via protobuf | ||
| - `FFIBridge.cs` — request factory | ||
| - `NativeMethods.cs` — P/Invoke declarations (`DllImport`) | ||
| - `YieldInstruction.cs` — custom awaitables for async FFI operations (coroutine-based) | ||
|
|
||
| ### Proto/Generated Code | ||
| `Runtime/Scripts/Proto/` contains auto-generated C# from protobuf definitions in the Rust SDK. Do not edit these files manually. | ||
|
|
||
| ### Native Plugins | ||
| 10 platform/arch combinations in `Runtime/Plugins/ffi-{platform}-{arch}/`. These are large binary files tracked with Git LFS. The `.meta` files configure Unity platform targeting. | ||
|
|
||
| ### Samples | ||
| - `Samples~/Basic` — minimal connection example, also used as the CI build target | ||
| - `Samples~/Meet` — more complete multi-participant example | ||
|
|
||
| ### Rust Submodule | ||
| `client-sdk-rust~/` is a git submodule pointing to the shared Rust SDK. The `~` suffix tells Unity to ignore the directory. | ||
|
|
||
| ## Key Conventions | ||
|
|
||
| - Minimum Unity version: 2021.3 | ||
| - Unsafe code is enabled via `csc.rsp` | ||
| - Assembly definitions: `livekit.unity.Runtime.asmdef`, `livekit.unity.Editor.asmdef`, plus test asmdefs | ||
| - Dependencies: `Google.Protobuf.dll` and `System.Runtime.CompilerServices.Unsafe.dll` shipped as managed plugins | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule client-sdk-rust~
updated
from 243ed2 to 5a7a8a
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.