# Native codecs (libvpx, Opus, Speex)

The app loads `libandroidcast_codecs.so` for availability probes and future software encode/decode paths.

## Current status

| Component | Java | Native | Notes |
|-----------|------|--------|-------|
| FEC 3/4 + RS | Yes | — | v2 **per-shard** on wire (`FecShardWire`); v1 monolithic decode still accepted |
| NACK + retransmit cache | Yes | — | UDP `MSG_NACK`, combined with FEC when enabled |
| libvpx VP8/VP9 | Native | Encode + decode | Screen cast via ImageReader; receiver libvpx (decoder uses `VPX_CODEC_USE_ERROR_CONCEALMENT` when supported) or MediaCodec fallback |
| Opus / Speex | Stub | Probe only | Submodules under `third-party/` |

## Enable libvpx (developer)

1. `git submodule update --init third-party/libvpx`
2. Build `libvpx.a` per ABI (NDK is auto-detected; see `scripts/android-ndk.sh`):

   `./scripts/build-native-codecs.sh arm64-v8a`

   (If the repo path has **spaces**, the script uses `/tmp/androidcast-libvpx-$USER` automatically.)
3. Build **each ABI** you ship (Gradle links `build/native/<abi>/libvpx.a` automatically):

```bash
./scripts/build-native-codecs.sh arm64-v8a
./scripts/build-native-codecs.sh armeabi-v7a   # if armeabi-v7a is in your APK
./gradlew assembleDebug
```

Optional override: `ANDROIDCAST_LIBVPX_LIB` only applies when its path contains the current ABI name (e.g. `.../arm64-v8a/libvpx.a`).

ABIs without a matching `libvpx.a` still build; software VPx is disabled on those architectures.

## Stream protection defaults

- Default: **None** (no FEC/NACK)
- Enable in **Global settings → Stream protection (UDP)**
- After handshake, sender and receiver negotiate the effective mode (no protocol version bump)
- Until negotiation completes, UDP protection stays **off**; peers without FEC support **ignore** protected frames

Full checklist: [docs/ROADMAP.md](../docs/ROADMAP.md)
