Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
340 changes: 340 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"livekit-api",
"livekit-protocol",
"livekit-ffi",
"livekit-uniffi",
"livekit-runtime",
"libwebrtc",
"soxr-sys",
Expand All @@ -25,7 +26,7 @@ members = [
"examples/save_to_disk",
"examples/send_bytes",
"examples/webhooks",
"examples/wgpu_room",
"examples/wgpu_room"
]

[workspace.dependencies]
Expand Down
26 changes: 26 additions & 0 deletions livekit-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "livekit-uniffi"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
description = "Experimental FFI interface using UniFFI"
repository = "https://github.com/livekit/rust-sdks"
readme = "README.md"

[dependencies]
livekit-protocol = { workspace = true }
livekit-api = { workspace = true }
uniffi = { version = "0.30.0", features = ["cli", "scaffolding-ffi-buffer-fns"] }
log = "0.4.28"
tokio = { version = "1.48.0", features = ["sync"] }
once_cell = "1.21.3"

[build-dependencies]
uniffi = { version = "0.30.0", features = ["build", "scaffolding-ffi-buffer-fns"] }

[lib]
crate-type = ["cdylib", "staticlib"]

[[bin]]
name = "uniffi-bindgen"
path = "bindgen.rs"
19 changes: 19 additions & 0 deletions livekit-uniffi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# LiveKit UniFFI

Experimental FFI interface using [UniFFI](https://mozilla.github.io/uniffi-rs/latest/).

At this stage in development, this interface will not attempt to replace the existing FFI interface defined in [_livekit-ffi_](../livekit-ffi/). Instead, it will focus on exposing core business logic that can be cleanly modularized and adopted by client SDKs incrementally.

## Functionality exposed

- [x] Access token generation and verification

## Generating bindings

Use the _bindgen.sh_ script to generate language bindings for Swift, Kotlin, and Python.

Later, this script will integrate community binding generators to support more languages.

## Python test

See the _python_test_ for a simple example of consuming the generated bindings. You will need to manually copy the compiled _livlivekit_uniffi_ to the same directory as the generated Python bindings before running—this will be automated shortly.
19 changes: 19 additions & 0 deletions livekit-uniffi/bindgen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2025 LiveKit, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/// This binary is included to allow invoking the UniFFI bindgen CLI from Cargo:
/// `cargo run --bin uniffi-bindgen generate ...`
fn main() {
uniffi::uniffi_bindgen_main()
}
17 changes: 17 additions & 0 deletions livekit-uniffi/bindgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

cargo build --release

bindgen() {
local lang=$1
# TODO: set the library extension based on platform (i.e., .so, .dylib, .dll)
cargo run --bin uniffi-bindgen generate \
--library ../target/release/liblivekit_uniffi.dylib \
--language "$lang" \
--out-dir "generated/$lang"
}

bindgen swift
bindgen kotlin
bindgen python
Loading