android: fix NDK build — add Opus sources, fix Kotlin composable context, fix bridge db_path param
This commit is contained in:
1 parent
d59ee551b8
commit
b402a6b689
4 files changed
+18
-7
No files matched your search
@@ -10,13 +10,24 @@ set(TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../..)
|
||||
include(${CFG_DIR}/utun_sources.cmake)
|
||||
utun_setup_sources("${LIB_DIR}" "${SRC_DIR}" "${CFG_DIR}" "${TOOLS_DIR}")
|
||||
|
||||
# Exclude opus from Android (no prebuilt for NDK)
|
||||
list(FILTER UTUN_SOURCES EXCLUDE REGEX "opus_codec\\.c$")
|
||||
# Include Opus codec wrapper (was excluded before voice support)
|
||||
# list(FILTER UTUN_SOURCES EXCLUDE REGEX "opus_codec\\.c$")
|
||||
|
||||
# Exclude tun_windows and tun_freebsd (Android is Linux-like)
|
||||
list(FILTER UTUN_SOURCES EXCLUDE REGEX "tun_windows\\.c$")
|
||||
list(FILTER UTUN_SOURCES EXCLUDE REGEX "tun_freebsd\\.c$")
|
||||
|
||||
# Add libopus sources (for voice recording)
|
||||
file(GLOB_RECURSE _OPUS_SRC "${LIB_DIR}/libopus/src/*.c"
|
||||
"${LIB_DIR}/libopus/celt/*.c" "${LIB_DIR}/libopus/silk/*.c"
|
||||
"${LIB_DIR}/libopus/silk/float/*.c")
|
||||
list(FILTER _OPUS_SRC EXCLUDE REGEX "/x86/")
|
||||
list(APPEND UTUN_SOURCES ${_OPUS_SRC})
|
||||
list(APPEND UTUN_INCLUDE_DIRS "${LIB_DIR}/libopus" "${LIB_DIR}/libopus/include"
|
||||
"${LIB_DIR}/libopus/celt" "${LIB_DIR}/libopus/silk" "${LIB_DIR}/libopus/silk/float")
|
||||
# Opus requires these to be defined (or HAVE_CONFIG_H + config.h with VAR_ARRAYS)
|
||||
list(APPEND UTUN_DEFINES OPUS_BUILD VAR_ARRAYS USE_ALLOCA)
|
||||
|
||||
# Prebuilt OpenSSL (cross-compiled for Android)
|
||||
set(OPENSSL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/openssl/${ANDROID_ABI})
|
||||
add_library(openssl_crypto STATIC IMPORTED)
|
||||
|
||||
@@ -34,10 +34,10 @@ fun ChatScreen(
|
||||
var text by remember { mutableStateOf("") }
|
||||
val listState = rememberLazyListState()
|
||||
val isRecording by viewModel.isRecording.collectAsState()
|
||||
val ctx = LocalContext.current
|
||||
|
||||
val filePicker = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
|
||||
uri?.let {
|
||||
val ctx = LocalContext.current
|
||||
val path = it.path ?: return@let
|
||||
viewModel.sendAttachment(path)
|
||||
}
|
||||
|
||||
@@ -467,8 +467,8 @@ int utun_bridge_voice_get_compressor(void) {
|
||||
return voice_recorder_is_compressor_enabled();
|
||||
}
|
||||
|
||||
int utun_bridge_attachment_send(const char* channel_id, const char* file_path) {
|
||||
return attachment_send(channel_id, file_path, g_db_path);
|
||||
int utun_bridge_attachment_send(const char* channel_id, const char* file_path, const char* db_path) {
|
||||
return attachment_send(channel_id, file_path, db_path);
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
@@ -993,7 +993,7 @@ JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeAttachmentSen
|
||||
(void)thiz;
|
||||
const char* ch = (*env)->GetStringUTFChars(env, channelId, NULL);
|
||||
const char* fp = (*env)->GetStringUTFChars(env, filePath, NULL);
|
||||
int rc = utun_bridge_attachment_send(ch, fp);
|
||||
int rc = utun_bridge_attachment_send(ch, fp, g_db_path);
|
||||
if (fp) (*env)->ReleaseStringUTFChars(env, filePath, fp);
|
||||
if (ch) (*env)->ReleaseStringUTFChars(env, channelId, ch);
|
||||
return (rc == 0) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
@@ -88,7 +88,7 @@ int utun_bridge_voice_get_compressor(void);
|
||||
|
||||
/* ── Attachment ── */
|
||||
|
||||
int utun_bridge_attachment_send(const char* channel_id, const char* file_path);
|
||||
int utun_bridge_attachment_send(const char* channel_id, const char* file_path, const char* db_path);
|
||||
|
||||
/* ── Voice playback (Opus decode) ── */
|
||||
|
||||
|
||||
Reference in new issue
Block a user