From 00e52964dd7b948d132e6b41dd269a30ecc4dc0e Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 9 Dec 2018 05:27:59 +0200 Subject: [PATCH] new api function: audio_codecs --- app/src/main/cpp/baresip.c | 21 +++++++++++++++++++ app/src/main/kotlin/com/tutpro/baresip/Api.kt | 1 + 2 files changed, 22 insertions(+) diff --git a/app/src/main/cpp/baresip.c b/app/src/main/cpp/baresip.c index 29cfab29..571925de 100644 --- a/app/src/main/cpp/baresip.c +++ b/app/src/main/cpp/baresip.c @@ -1146,6 +1146,27 @@ Java_com_tutpro_baresip_Api_call_1unhold(JNIEnv *env, jobject thiz, jstring java return ret; } +JNIEXPORT jstring JNICALL +Java_com_tutpro_baresip_Api_call_1audio_1codecs(JNIEnv *env, jobject thiz, jstring javaCall) { + const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0); + (*env)->ReleaseStringUTFChars(env, javaCall, native_call); + struct call *call = (struct call *) strtoul(native_call, NULL, 10); + const struct aucodec *tx = audio_codec(call_audio(call), true); + const struct aucodec *rx = audio_codec(call_audio(call), false); + char codec_buf[256]; + char *start = &(codec_buf[0]); + unsigned int left = sizeof codec_buf; + int len = -1; + if (tx && rx) + len = re_snprintf(start, left, "%s/%u/%u,%s/%u/%u", tx->name, tx->srate, tx->ch, + rx->name, rx->srate, rx->ch); + if (len == -1) { + LOGE("failed to get call audio codecs\n"); + codec_buf[0] = '\0'; + } + return (*env)->NewStringUTF(env, codec_buf); +} + JNIEXPORT jint JNICALL Java_com_tutpro_baresip_Api_message_1send(JNIEnv *env, jobject thiz, jstring javaUA, jstring javaPeer, jstring javaMsg, jstring javaTime) { diff --git a/app/src/main/kotlin/com/tutpro/baresip/Api.kt b/app/src/main/kotlin/com/tutpro/baresip/Api.kt index aab690f6..12dc931b 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Api.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Api.kt @@ -23,6 +23,7 @@ object Api { external fun call_notify_sipfrag(callp: String, code: Int, reason: String) external fun call_start_audio(callp: String) external fun call_stop_audio(callp: String) + external fun call_audio_codecs(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