Files
VoelinClient/crates/voelin-android/src/lib.rs
T
selikhovandClaude Opus 5.5 1eabbb4704 Android: cameras in the Stream Studio through Camera2
The studio listed only the test pattern on Android. voelin-media gains a
camera provider hook (like the external screen capture): the app
registers Camera2, whose cameras the studio's picker lists first (front
ones first, with their YUV sizes and highest frame rate), and a camera
source opens one. CameraCapture.kt asks for the CAMERA permission when a
camera is first opened (the source shows why if it is refused), opens
the camera into an ImageReader (YUV_420_888) at the wished size or the
nearest one (16:9 first, 1280x720 by default) with a fitting frame-rate
range, and hands each frame's planes to Rust as direct buffers valid
during the call, with the clockwise turn that makes it upright for the
screen's current rotation (front cameras turn the other way).

Rust takes the planes as YuvPlanes: an upright planar or NV12 picture
goes to the studio's sink as it is, converted straight from the
camera's memory; NV21 (what most cameras give) and turned pictures are
gathered into I420 in a buffer each camera keeps, so a running camera
allocates nothing per frame. Errors after the start (permission refused,
camera taken by another app) go to the source's feed.

Front and back: a camera's default mirroring now follows the camera (a
back camera is not mirrored, what faces the user is), and the source
menu gains Switch camera, which moves a camera source to the next
camera (and its name with it, if it was named after the camera).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 18:17:13 +03:00

39 lines
1.5 KiB
Rust

//! The Android app's native library (`libvoelin_android.so`).
//!
//! The APK (`android/`) starts a `NativeActivity` subclass that loads this
//! library; `android_main` then runs the shared Slint UI (`voelin_ui`) on
//! Slint's Android backend. The pieces around it:
//!
//! - [`host`]: one engine per process, so voice survives the activity being
//! destroyed and recreated; a new window gets the current state replayed
//! - [`foreground`]: when the voice foreground service must run (Android
//! only lets a service with a notification keep the microphone in the
//! background)
//! - `bridge` (Android): JNI calls into the Kotlin side (`Bridge`) and the
//! native methods it calls back (`Native`)
//! - `capture` (Android): screen and system-audio capture through
//! MediaProjection, registered as `voelin_media` capture providers
//! - `camera` (Android): the Stream Studio's cameras through Camera2,
//! registered as its camera provider
//! - `secrets` (Android): passwords encrypted with an Android Keystore key
//! - `egl` (Android): keeps EGL extension slots for Skia, without which the
//! UI cannot draw on Mesa-based Android (Waydroid)
//!
//! Only [`host`] and [`foreground`] build on other platforms, for tests.
pub mod foreground;
pub mod host;
#[cfg(target_os = "android")]
mod app;
#[cfg(target_os = "android")]
mod bridge;
#[cfg(target_os = "android")]
mod camera;
#[cfg(target_os = "android")]
mod capture;
#[cfg(target_os = "android")]
mod egl;
#[cfg(target_os = "android")]
mod secrets;