1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 03:38:52 +03:00
This commit is contained in:
Anton Afanasyeu
2026-06-08 12:38:57 +02:00
parent bfb41f06d9
commit c1591fa849
86 changed files with 5081 additions and 637 deletions

View File

@@ -46,6 +46,56 @@ else()
message(STATUS "No libvpx.a for ${ANDROID_ABI} — VPx JNI probe off (build with scripts/build-native-codecs.sh ${ANDROID_ABI})")
endif()
# libopus.a — same autodetect pattern (scripts/build-native-codecs.sh).
set(LIBOPUS_LIB "")
if(ANDROID_ABI)
set(LIBOPUS_PER_ABI "${NATIVE_LIBS_ROOT}/${ANDROID_ABI}/libopus.a")
if(EXISTS "${LIBOPUS_PER_ABI}")
set(LIBOPUS_LIB "${LIBOPUS_PER_ABI}")
endif()
endif()
if(NOT LIBOPUS_LIB AND DEFINED ENV{ANDROIDCAST_LIBOPUS_LIB})
string(FIND "$ENV{ANDROIDCAST_LIBOPUS_LIB}" "${ANDROID_ABI}" _opus_abi_match)
if(_opus_abi_match GREATER -1 AND EXISTS "$ENV{ANDROIDCAST_LIBOPUS_LIB}")
set(LIBOPUS_LIB "$ENV{ANDROIDCAST_LIBOPUS_LIB}")
endif()
endif()
if(LIBOPUS_LIB)
message(STATUS "Linking libopus for ${ANDROID_ABI}: ${LIBOPUS_LIB}")
target_compile_definitions(androidcast_codecs PRIVATE ANDROIDCAST_HAVE_OPUS=1)
target_link_libraries(androidcast_codecs "${LIBOPUS_LIB}")
if(EXISTS "${THIRD_PARTY_ROOT}/opus/include")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/opus/include")
endif()
else()
message(STATUS "No libopus.a for ${ANDROID_ABI} — Opus JNI probe off (build with scripts/build-native-codecs.sh ${ANDROID_ABI})")
endif()
# libspeex.a
set(LIBSPEEX_LIB "")
if(ANDROID_ABI)
set(LIBSPEEX_PER_ABI "${NATIVE_LIBS_ROOT}/${ANDROID_ABI}/libspeex.a")
if(EXISTS "${LIBSPEEX_PER_ABI}")
set(LIBSPEEX_LIB "${LIBSPEEX_PER_ABI}")
endif()
endif()
if(NOT LIBSPEEX_LIB AND DEFINED ENV{ANDROIDCAST_LIBSPEEX_LIB})
string(FIND "$ENV{ANDROIDCAST_LIBSPEEX_LIB}" "${ANDROID_ABI}" _speex_abi_match)
if(_speex_abi_match GREATER -1 AND EXISTS "$ENV{ANDROIDCAST_LIBSPEEX_LIB}")
set(LIBSPEEX_LIB "$ENV{ANDROIDCAST_LIBSPEEX_LIB}")
endif()
endif()
if(LIBSPEEX_LIB)
message(STATUS "Linking libspeex for ${ANDROID_ABI}: ${LIBSPEEX_LIB}")
target_compile_definitions(androidcast_codecs PRIVATE ANDROIDCAST_HAVE_SPEEX=1)
target_link_libraries(androidcast_codecs "${LIBSPEEX_LIB}")
if(EXISTS "${THIRD_PARTY_ROOT}/speex/include")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/speex/include")
endif()
else()
message(STATUS "No libspeex.a for ${ANDROID_ABI} — Speex JNI probe off (build with scripts/build-native-codecs.sh ${ANDROID_ABI})")
endif()
find_library(log-lib log)
find_library(android-lib android)
find_library(dl-lib dl)

View File

@@ -9,27 +9,34 @@ The app loads `libandroidcast_codecs.so` for availability probes and future soft
| 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/` |
| Opus / Speex | Probe + static link when `lib*.a` built | Encode/decode JNI sinks | `scripts/build-native-codecs.sh` → CMake autolink |
## Enable libvpx (developer)
## Enable native codecs (developer)
1. `git submodule update --init third-party/libvpx`
2. Build `libvpx.a` per ABI (NDK is auto-detected; see `scripts/android-ndk.sh`):
1. Initialize submodules as needed:
`./scripts/build-native-codecs.sh arm64-v8a`
```bash
git submodule update --init third-party/libvpx
git submodule update --init third-party/opus
git submodule update --init third-party/speex
```
(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):
2. Build static libs per ABI (NDK auto-detected via `scripts/android-ndk.sh`):
```bash
./scripts/build-native-codecs.sh arm64-v8a
./scripts/build-native-codecs.sh armeabi-v7a # if armeabi-v7a is in your APK
./gradlew assembleDebug
```
```bash
./scripts/build-native-codecs.sh arm64-v8a
./scripts/build-native-codecs.sh armeabi-v7a # if shipped in APK
```
If the repo path has **spaces**, the script stages under `/tmp/androidcast-libvpx-$USER`.
3. Gradle / CMake link `build/native/<abi>/lib*.a` when present and set `ANDROIDCAST_HAVE_LIBVPX`, `ANDROIDCAST_HAVE_OPUS`, `ANDROIDCAST_HAVE_SPEEX` accordingly.
4. `./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.
ABIs without matching `.a` files still build; missing codecs are disabled on those architectures.
## Stream protection defaults