1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 03:57:50 +03:00
This commit is contained in:
Anton Afanasyeu
2026-05-18 15:55:02 +02:00
parent f547770288
commit f7e200fa94
121 changed files with 140 additions and 10838 deletions

View File

@@ -4,6 +4,7 @@ project(androidcast_codecs C)
set(CMAKE_C_STANDARD 11)
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/../third-party)
set(NATIVE_LIBS_ROOT ${CMAKE_SOURCE_DIR}/../build/native)
set(NDK_BRIDGE ${CMAKE_SOURCE_DIR})
add_library(androidcast_codecs SHARED
@@ -17,15 +18,31 @@ target_include_directories(androidcast_codecs PRIVATE
${NDK_BRIDGE}/jni
)
if(DEFINED ENV{ANDROIDCAST_LIBVPX_LIB} AND EXISTS "$ENV{ANDROIDCAST_LIBVPX_LIB}")
message(STATUS "Linking libvpx from $ENV{ANDROIDCAST_LIBVPX_LIB}")
# Per-ABI libvpx.a from scripts/build-native-codecs.sh (do not link arm64 into armeabi-v7a).
set(LIBVPX_LIB "")
if(ANDROID_ABI)
set(LIBVPX_PER_ABI "${NATIVE_LIBS_ROOT}/${ANDROID_ABI}/libvpx.a")
if(EXISTS "${LIBVPX_PER_ABI}")
set(LIBVPX_LIB "${LIBVPX_PER_ABI}")
endif()
endif()
if(NOT LIBVPX_LIB AND DEFINED ENV{ANDROIDCAST_LIBVPX_LIB})
string(FIND "$ENV{ANDROIDCAST_LIBVPX_LIB}" "${ANDROID_ABI}" _abi_match)
if(_abi_match GREATER -1 AND EXISTS "$ENV{ANDROIDCAST_LIBVPX_LIB}")
set(LIBVPX_LIB "$ENV{ANDROIDCAST_LIBVPX_LIB}")
endif()
endif()
if(LIBVPX_LIB)
message(STATUS "Linking libvpx for ${ANDROID_ABI}: ${LIBVPX_LIB}")
target_compile_definitions(androidcast_codecs PRIVATE ANDROIDCAST_HAVE_LIBVPX=1)
target_link_libraries(androidcast_codecs "$ENV{ANDROIDCAST_LIBVPX_LIB}")
target_link_libraries(androidcast_codecs "${LIBVPX_LIB}")
if(EXISTS "${THIRD_PARTY_ROOT}/libvpx")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/libvpx")
target_include_directories(androidcast_codecs PRIVATE "${THIRD_PARTY_ROOT}/libvpx/vpx")
endif()
elseif(EXISTS "${THIRD_PARTY_ROOT}/libvpx")
message(STATUS "libvpx submodule present — set ANDROIDCAST_LIBVPX_LIB to link (see ndk/README.md)")
else()
message(STATUS "No libvpx.a for ${ANDROID_ABI} — VPx JNI probe off (build with scripts/build-native-codecs.sh ${ANDROID_ABI})")
endif()
find_library(log-lib log)

View File

@@ -16,14 +16,17 @@ The app loads `libandroidcast_codecs.so` for availability probes and future soft
1. `git submodule update --init third-party/libvpx`
2. Build `libvpx.a` for your ABI: `./scripts/build-native-codecs.sh arm64-v8a`
(If the repo path has **spaces**, the script uses `/tmp/androidcast-libvpx-$USER` automatically.)
3. Rebuild the APK with the static library path:
3. Build **each ABI** you ship (Gradle links `build/native/<abi>/libvpx.a` automatically):
```bash
export ANDROIDCAST_LIBVPX_LIB=/path/to/libvpx.a
./scripts/build-native-codecs.sh arm64-v8a
./scripts/build-native-codecs.sh armeabi-v7a # if armeabi-v7a is in your APK
./gradlew assembleDebug
```
CMake defines `ANDROIDCAST_HAVE_LIBVPX=1` and links the archive when the variable is set.
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

View File

@@ -118,11 +118,8 @@ Java_com_foxx_androidcast_media_codec_jni_NativeCodecBridge_nativeVpxEncoderCrea
(*env)->ReleaseStringUTFChars(env, mime, mime_utf);
return 0L;
}
if (iface == vpx_codec_vp9_cx()) {
vpx_codec_control(&ctx->codec, VP9E_SET_CPUUSED, 8);
} else {
vpx_codec_control(&ctx->codec, VP8E_SET_CPUUSED, 8);
}
/* VP8 and VP9 both use VP8E_SET_CPUUSED (see libvpx tests / vp9_cx_iface.c). */
vpx_codec_control(&ctx->codec, VP8E_SET_CPUUSED, 8);
if (!vpx_img_alloc(&ctx->img, img_fmt(), width, height, 1)) {
vpx_codec_destroy(&ctx->codec);