Skip to content
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

add JNI_OnLoad on livekit_ffi #313

Merged
merged 2 commits into from
Feb 26, 2024
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions livekit-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ downcast-rs = "1.2"
console-subscriber = { version = "0.1", features = ["parking_lot"], optional = true }
imgproc = "0.3.11"

[target.'cfg(target_os = "android")'.dependencies]
jni = "0.21.1"

[build-dependencies]
webrtc-sys-build = { path = "../webrtc-sys/build", version = "0.3.0" }

Expand Down
17 changes: 17 additions & 0 deletions livekit-ffi/src/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,20 @@ pub unsafe extern "C" fn livekit_ffi_request(
pub extern "C" fn livekit_ffi_drop_handle(handle_id: FfiHandleId) -> bool {
FFI_SERVER.drop_handle(handle_id)
}

#[cfg(target_os = "android")]
pub mod android {
use jni::{
sys::{jint, JNI_VERSION_1_6},
JavaVM,
};
use std::os::raw::c_void;

#[allow(non_snake_case)]
#[no_mangle]
pub extern "C" fn JNI_OnLoad(vm: JavaVM, _: *mut c_void) -> jint {
println!("JNI_OnLoad, initializing LiveKit");
livekit::webrtc::android::initialize_android(&vm);
JNI_VERSION_1_6
}
}
Loading