# libcamera3.so - CamSwapper Native Library

## Status
Pre-compiled binary. **No source code available.**

## Location
`app/src/main/jniLibs/arm64-v8a/libcamera3.so`

## What it does
- Provides JNI functions called from `NativeBridge.kt`
- Decodes video using FFmpeg/libav (VideoDecoder class)
- Manages camera state (CameraState class)
- Overwrites preview buffers with video frames

## What it does NOT do
- Does NOT hook camera HAL directly
- Does NOT provide system-wide camera replacement alone
- Requires Java-level Xposed hooks to feed it surfaces

## Options to modify
1. **Reverse-engineer** the binary (very complex, not recommended)
2. **Reimplement** from scratch (requires C++, FFmpeg, Android NDK knowledge)
3. **Keep as-is** and use Java hooks (recommended - this is what currently works)

## Build (if source existed)
```bash
cd app/src/main/jni
$ANDROID_NDK_HOME/ndk-build
# or
cd app/src/main/jni
cmake . && make
```

## Current Architecture
```
Java Hooks (Camera2Hooker) → NativeBridge.registerSurface() → libcamera3.so
                                    ↓
                              VideoDecoder (decodes video)
                                    ↓
                              overwritePreviewBuffer() (overwrites camera buffers)
```

## Recommendation
Keep the working Java hooking approach. The native library is a utility layer, not a HAL hooking solution.