- Moved call_peeruri API function back to Api object, since call object
does not exist when peer URI is needed.
This commit is contained in:
@ -1115,31 +1115,6 @@ Java_com_tutpro_baresip_Api_uag_1current_1set(JNIEnv *env, jobject thiz, jstring
|
||||
uag_current_set(ua);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_tutpro_baresip_Api_call_1peeruri(JNIEnv *env, jobject thiz, jstring javaCall)
|
||||
{
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
struct call *call;
|
||||
call = (struct call *)strtoul(native_call, NULL, 10);
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return (*env)->NewStringUTF(env, call_peeruri(call));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_tutpro_baresip_Api_call_1send_1digit(JNIEnv *env, jobject thiz, jstring javaCall,
|
||||
jchar digit) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
const uint16_t native_digit = digit;
|
||||
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
|
||||
LOGD("sending DTMF digit '%c' to call %s\n", (char)native_digit, native_call);
|
||||
re_thread_enter();
|
||||
int res = call_send_digit(call, (char)native_digit);
|
||||
if (!res) res = call_send_digit(call, KEYCODE_REL);
|
||||
re_thread_leave();
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_tutpro_baresip_Api_ua_1hangup(JNIEnv *env, jobject thiz,
|
||||
jstring javaUA, jstring javaCall, jint code,
|
||||
@ -1340,6 +1315,31 @@ Java_com_tutpro_baresip_Call_call_1unhold(JNIEnv *env, jobject thiz, jstring jav
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_tutpro_baresip_Api_call_1peeruri(JNIEnv *env, jobject thiz, jstring javaCall)
|
||||
{
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
struct call *call;
|
||||
call = (struct call *)strtoul(native_call, NULL, 10);
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return (*env)->NewStringUTF(env, call_peeruri(call));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_tutpro_baresip_Call_call_1send_1digit(JNIEnv *env, jobject thiz, jstring javaCall,
|
||||
jchar digit) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
const uint16_t native_digit = digit;
|
||||
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
|
||||
LOGD("sending DTMF digit '%c' to call %s\n", (char)native_digit, native_call);
|
||||
re_thread_enter();
|
||||
int res = call_send_digit(call, (char)native_digit);
|
||||
if (!res) res = call_send_digit(call, KEYCODE_REL);
|
||||
re_thread_leave();
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_tutpro_baresip_Call_call_1audio_1codecs(JNIEnv *env, jobject thiz, jstring javaCall) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
|
||||
@ -25,6 +25,7 @@ object Api {
|
||||
external fun ua_set_media_af(uap: String, af: Int)
|
||||
external fun account_debug(accp: String)
|
||||
external fun ua_debug(uap: String)
|
||||
external fun call_peeruri(callp: String): String
|
||||
external fun message_send(uap: String, peer_uri: String, message: String, time: String): Int
|
||||
external fun reload_config(): Int
|
||||
external fun cmd_exec(cmd: String): Int
|
||||
|
||||
@ -556,12 +556,7 @@ class BaresipService: Service() {
|
||||
return
|
||||
}
|
||||
"call incoming" -> {
|
||||
val call = Call.find(callp)
|
||||
if (call == null) {
|
||||
Log.w(LOG_TAG, "Incoming call $callp is not found")
|
||||
return
|
||||
}
|
||||
val peerUri = call.peerUri()
|
||||
val peerUri = Api.call_peeruri(callp)
|
||||
if ((Call.calls().size > 0) ||
|
||||
(tm.callState != TelephonyManager.CALL_STATE_IDLE) ||
|
||||
!Utils.checkPermission(applicationContext,
|
||||
|
||||
@ -43,10 +43,6 @@ class Call(val callp: String, val ua: UserAgent, val peerURI: String, val dir: S
|
||||
return call_has_video(callp)
|
||||
}
|
||||
|
||||
fun peerUri(): String {
|
||||
return call_peeruri(callp)
|
||||
}
|
||||
|
||||
fun status(): String {
|
||||
return call_status(callp)
|
||||
}
|
||||
@ -62,7 +58,6 @@ class Call(val callp: String, val ua: UserAgent, val peerURI: String, val dir: S
|
||||
private external fun call_connect(callp: String, peer_uri: String): Int
|
||||
private external fun call_hold(callp: String): Int
|
||||
private external fun call_unhold(callp: String): Int
|
||||
private external fun call_peeruri(callp: String): String
|
||||
private external fun call_send_digit(callp: String, digit: Char): Int
|
||||
private external fun call_notify_sipfrag(callp: String, code: Int, reason: String)
|
||||
private external fun call_start_audio(callp: String)
|
||||
@ -89,5 +84,12 @@ class Call(val callp: String, val ua: UserAgent, val peerURI: String, val dir: S
|
||||
if (c.callp == callp) return c
|
||||
return null
|
||||
}
|
||||
|
||||
fun incomingCall(): Call? {
|
||||
for (c in BaresipService.calls)
|
||||
if (c.status == "incoming") return c
|
||||
return null
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user