mirror of
git://f0xx.org/android_cast
synced 2026-07-29 02:59:00 +03:00
snap
This commit is contained in:
29
ndk/CMakeLists.txt
Normal file
29
ndk/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.22.1)
|
||||
project(androidcast_codecs C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
set(THIRD_PARTY_ROOT ${CMAKE_SOURCE_DIR}/../third-party)
|
||||
set(NDK_BRIDGE ${CMAKE_SOURCE_DIR})
|
||||
|
||||
add_library(androidcast_codecs SHARED
|
||||
${NDK_BRIDGE}/jni/androidcast_codecs.c
|
||||
${NDK_BRIDGE}/jni/libvpx_bridge.c
|
||||
${NDK_BRIDGE}/jni/opus_bridge.c
|
||||
${NDK_BRIDGE}/jni/speex_bridge.c
|
||||
)
|
||||
|
||||
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}")
|
||||
target_compile_definitions(androidcast_codecs PRIVATE ANDROIDCAST_HAVE_LIBVPX=1)
|
||||
target_link_libraries(androidcast_codecs "$ENV{ANDROIDCAST_LIBVPX_LIB}")
|
||||
elseif(EXISTS "${THIRD_PARTY_ROOT}/libvpx")
|
||||
message(STATUS "libvpx submodule present — set ANDROIDCAST_LIBVPX_LIB to link (see ndk/README.md)")
|
||||
endif()
|
||||
|
||||
find_library(log-lib log)
|
||||
target_link_libraries(androidcast_codecs ${log-lib})
|
||||
31
ndk/README.md
Normal file
31
ndk/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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 | — | `ProtectionEnvelope`, handshake-safe scopes |
|
||||
| NACK + retransmit cache | Yes | — | UDP `MSG_NACK`, combined with FEC when enabled |
|
||||
| libvpx VP8/VP9 | Stub | Probe only | HW passthrough until `ANDROIDCAST_LIBVPX_LIB` is linked |
|
||||
| Opus / Speex | Stub | Probe only | Submodules under `third-party/` |
|
||||
|
||||
## Enable libvpx (developer)
|
||||
|
||||
1. `git submodule update --init third-party/libvpx`
|
||||
2. Build `libvpx.a` for your ABI (script stub: `scripts/build-native-codecs.sh`)
|
||||
3. Rebuild the APK with the static library path:
|
||||
|
||||
```bash
|
||||
export ANDROIDCAST_LIBVPX_LIB=/path/to/libvpx.a
|
||||
./gradlew assembleDebug
|
||||
```
|
||||
|
||||
CMake defines `ANDROIDCAST_HAVE_LIBVPX=1` and links the archive when the variable is set.
|
||||
|
||||
## Stream protection defaults
|
||||
|
||||
- Default: **None** (no FEC/NACK)
|
||||
- Enable in **Global settings → Stream protection (UDP)**
|
||||
- After handshake, sender and receiver negotiate the effective mode
|
||||
11
ndk/jni/androidcast_codecs.c
Normal file
11
ndk/jni/androidcast_codecs.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG_TAG "androidcast_codecs"
|
||||
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
(void)vm;
|
||||
(void)reserved;
|
||||
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "androidcast codecs native library loaded");
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
15
ndk/jni/libvpx_bridge.c
Normal file
15
ndk/jni/libvpx_bridge.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <jni.h>
|
||||
#include <string.h>
|
||||
|
||||
/* VP8/VP9 via libvpx — linked when third-party/libvpx is built into this library. */
|
||||
#ifndef ANDROIDCAST_HAVE_LIBVPX
|
||||
#define ANDROIDCAST_HAVE_LIBVPX 0
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_foxx_androidcast_media_codec_jni_NativeCodecBridge_nativeIsLibvpxAvailable(
|
||||
JNIEnv *env, jclass clazz) {
|
||||
(void)env;
|
||||
(void)clazz;
|
||||
return ANDROIDCAST_HAVE_LIBVPX ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
13
ndk/jni/opus_bridge.c
Normal file
13
ndk/jni/opus_bridge.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <jni.h>
|
||||
|
||||
#ifndef ANDROIDCAST_HAVE_OPUS
|
||||
#define ANDROIDCAST_HAVE_OPUS 0
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_foxx_androidcast_media_codec_jni_NativeCodecBridge_nativeIsOpusAvailable(
|
||||
JNIEnv *env, jclass clazz) {
|
||||
(void)env;
|
||||
(void)clazz;
|
||||
return ANDROIDCAST_HAVE_OPUS ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
13
ndk/jni/speex_bridge.c
Normal file
13
ndk/jni/speex_bridge.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <jni.h>
|
||||
|
||||
#ifndef ANDROIDCAST_HAVE_SPEEX
|
||||
#define ANDROIDCAST_HAVE_SPEEX 0
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_foxx_androidcast_media_codec_jni_NativeCodecBridge_nativeIsSpeexAvailable(
|
||||
JNIEnv *env, jclass clazz) {
|
||||
(void)env;
|
||||
(void)clazz;
|
||||
return ANDROIDCAST_HAVE_SPEEX ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
Reference in New Issue
Block a user