Browse Source

Wire incoming call policy and caller continuation through JNI

stream-multiview
evgeny 6 days ago
parent
commit
4cebd0be54
  1. 2
      tools/chatgui-android/app/src/main/java/com/utun/chat/data/CallState.kt
  2. 4
      tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt
  3. 10
      tools/chatgui-android/jni_bridge/android_jni_bridge.c

2
tools/chatgui-android/app/src/main/java/com/utun/chat/data/CallState.kt

@ -3,7 +3,7 @@ package com.utun.chat.data
import com.utun.chat.R
/** Состояние единственной звонковой сессии; не зависит от Activity или ViewModel. */
enum class CallPhase { NONE, OUTGOING, RINGING, INCOMING, ACTIVE, ENDED }
enum class CallPhase { NONE, OUTGOING, RINGING, INCOMING, ACTIVE, ENDED, WAIT_DECISION, PENDING_INCOMING }
/** Значения CONN_TYPE_* общего ядра. */
enum class CallConnectionType(val labelRes: Int) {

4
tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt

@ -271,7 +271,7 @@ object NativeLib {
fun callDecline(callId: Long) { nativeCallDecline(callId) }
fun callHangup(callId: Long) { nativeCallHangup(callId) }
fun callContinue(callId: Long) { nativeCallContinue(callId) }
fun setPhoneState(state: Int) { nativeSetPhoneState(state) }
fun setPhoneState(state: Int, policy: Int) { nativeSetPhoneState(state, policy) }
fun callIsOnline(channelId: String, peerNodeId: Long): Boolean = nativeCallIsOnline(channelId, peerNodeId)
/* action: radio_call_action, результат — CHAT_EVT_RADIO_CALL (65). */
fun radioCall(id: Long, action: Int, group: Long = 0, peer: Long = 0): Boolean = nativeRadioCall(id, group, peer, action)
@ -419,7 +419,7 @@ object NativeLib {
private external fun nativeCallDecline(callId: Long)
private external fun nativeCallHangup(callId: Long)
private external fun nativeCallContinue(callId: Long)
private external fun nativeSetPhoneState(state: Int)
private external fun nativeSetPhoneState(state: Int, policy: Int)
private external fun nativeCallIsOnline(channelId: String, peerNodeId: Long): Boolean
private external fun nativeCallAudioStart(callId: Long): Boolean
private external fun nativeCallAudioFeed(callId: Long, samples: ShortArray, capturePtsUs: Long): Boolean

10
tools/chatgui-android/jni_bridge/android_jni_bridge.c

@ -2824,18 +2824,18 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeCallContinue(
bridge_call_id_action((uint64_t)callId, "continue", call_continue_trampoline);
}
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; };
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; unsigned policy; };
static void phone_state_execute(void* arg) {
struct phone_state_request* req = arg;
call_set_phone_state(req->inst, req->state); u_free(req);
call_set_phone_state(req->inst, req->state, req->policy); u_free(req);
}
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
JNIEnv* env, jobject thiz, jint state) {
JNIEnv* env, jobject thiz, jint state, jint policy) {
(void)env; (void)thiz;
struct UTUN_INSTANCE* inst = instance_lite_get_instance();
struct UASYNC* ua = instance_lite_get_uasync();
if (!inst || !ua || !uasync_is_running(ua) || state < 0 || state > 2) {
if (!inst || !ua || !uasync_is_running(ua) || state < 0 || state > 2 || policy < 0 || policy > 31) {
DEBUG_WARN(DEBUG_CATEGORY_CALL, "phone state JNI unavailable state=%d", state); return;
}
struct phone_state_request* req = u_calloc(1, sizeof(*req));
@ -2843,7 +2843,7 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
if (!req || !task) {
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "phone state JNI allocation failed"); u_free(req); u_free(task); return;
}
req->inst = inst; req->state = state;
req->inst = inst; req->state = state; req->policy = (unsigned)policy;
task->callback = phone_state_execute; task->arg = req; uasync_post_reserved(ua, task);
}

Loading…
Cancel
Save