73 lines
2.3 KiB
Markdown
73 lines
2.3 KiB
Markdown
# Virtual Camera HAL — KernelSU Module
|
|
|
|
Replaces physical cameras on Pixel 9A (Android 16) with virtual cameras
|
|
backed by v4l2loopback, fed via RTSP stream or MP4 file.
|
|
|
|
## Architecture
|
|
|
|
```
|
|
Boot → post-fs-data.sh → insmod v4l2loopback.ko → /dev/video0
|
|
→ copy binary + AIDL .so files → /data/local/tmp/
|
|
→ start virtual_camera_provider with LD_LIBRARY_PATH
|
|
→ registers ICameraProvider/virtual/0
|
|
→ cameraserver discovers 2 virtual cameras
|
|
```
|
|
|
|
## Files
|
|
|
|
| Path | Purpose |
|
|
|------|---------|
|
|
| `module.prop` | KernelSU metadata |
|
|
| `post-fs-data.sh` | Boot startup (insmod, copy, start) |
|
|
| `service.sh` | Watchdog (30s delay) |
|
|
| `sepolicy.rule` | SELinux permissions |
|
|
| `v4l2loopback.ko` | Kernel module (0x440 struct, ARM64) |
|
|
| `vendor/bin/virtual_camera_provider` | AOSP-built AIDL HAL3 binary |
|
|
| `vendor/lib64/*.so` | AIDL NDK shared libraries (V3) |
|
|
| `system/etc/vintf/manifest/*.xml` | VINTF manifest overlay |
|
|
| `vendor/etc/vintf/manifest/*.xml` | VINTF manifest overlay (vendor) |
|
|
| `control.sh` | WebUI backend |
|
|
| `rtsp_feeder.sh` | RTSP/MP4 → /dev/video0 bridge |
|
|
| `webui/` | KSU WebUI (index.html, style.css, script.js) |
|
|
|
|
## Usage
|
|
|
|
1. Install module via KernelSU app or `ksud module install`
|
|
2. Reboot
|
|
3. Open KernelSU → Modules → Virtual Camera → WebUI
|
|
4. Configure RTSP URL or MP4 file path
|
|
5. Tap "Start" (provides 2 virtual cameras at IDs 10 and 11)
|
|
|
|
## Verification
|
|
|
|
```bash
|
|
# Check provider registered
|
|
adb shell su -c 'service list | grep camera.provider'
|
|
# Expected: ICameraProvider/virtual/0
|
|
|
|
# Check virtual cameras
|
|
adb shell su -c 'dumpsys media.camera | grep "Number of camera"'
|
|
# Expected: Number of camera devices: 4
|
|
|
|
# Check camera characteristics
|
|
adb shell su -c 'dumpsys media.camera | grep -A25 "virtual/10"'
|
|
```
|
|
|
|
## Building
|
|
|
|
```bash
|
|
cd /mnt/opslag/aosp-16-platform
|
|
export TARGET_RELEASE=bp2a
|
|
source build/envsetup.sh
|
|
lunch aosp_arm64-bp2a-userdebug
|
|
cd external/virtualcam && mma -j10
|
|
```
|
|
|
|
## Key Fixes
|
|
|
|
- **-3 registration error**: Overrode `createBinder()` to skip
|
|
`AIBinder_markVintfStability` which caused STATUS_BAD_VALUE
|
|
- **CANNOT LINK**: Bundled AIDL V3 .so files with module
|
|
- **AOSP build memory**: Use `-j10` for 10 cores max, incremental builds
|
|
are fast after initial Soong analysis
|