From 601ce661b1b7696fedbb27707f98bc5804cc5894 Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 18:17:13 +0300 Subject: [PATCH] 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 --- android/app/src/main/AndroidManifest.xml | 3 + .../java/io/github/faumaray/voelin/Bridge.kt | 17 + .../github/faumaray/voelin/CameraCapture.kt | 293 ++++++++++++++++++ .../io/github/faumaray/voelin/MainActivity.kt | 15 + .../java/io/github/faumaray/voelin/Native.kt | 26 ++ crates/voelin-android/src/app.rs | 3 +- crates/voelin-android/src/bridge.rs | 145 +++++++++ crates/voelin-android/src/camera.rs | 174 +++++++++++ crates/voelin-android/src/lib.rs | 4 + crates/voelin-media/src/studio/camera.rs | 263 +++++++++++++++- crates/voelin-ui/src/studio.rs | 36 ++- .../voelin-ui/ui/screens/studio-parts.slint | 8 +- 12 files changed, 972 insertions(+), 15 deletions(-) create mode 100644 android/app/src/main/java/io/github/faumaray/voelin/CameraCapture.kt create mode 100644 crates/voelin-android/src/camera.rs diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0bc2f83..4af7cc3 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,6 +10,9 @@ + + +