Skip to content

Commit

Permalink
add JNI_OnLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Feb 26, 2024
1 parent 8183af1 commit ff199cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
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
13 changes: 13 additions & 0 deletions livekit-ffi/src/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,16 @@ 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 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
}
}

0 comments on commit ff199cd

Please sign in to comment.