From 88c0123983cbe7e21156daf2fd3ae1b0ce1c8265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 6 Jan 2016 14:47:39 +0100 Subject: [PATCH] Fix JNI of getConference() methods of LinphoneCore and LinphoneCall --- coreapi/linphonecore_jni.cc | 16 ++++++++++++---- java/common/org/linphone/core/LinphoneCore.java | 2 +- .../impl/org/linphone/core/LinphoneCoreImpl.java | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 7c3714d85..6afa06741 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -4135,8 +4135,12 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore); } -extern "C" jlong Jave_org_linphone_core_LinphoneCoreImpl_getConference(JNIEnv *env, jobject thiz, jlong pCore) { - return (jlong)linphone_core_get_conference((LinphoneCore *)pCore); +extern "C" jobject Jave_org_linphone_core_LinphoneCoreImpl_getConference(JNIEnv *env, jobject thiz, jlong pCore) { + jclass conference_class = env->FindClass("org/linphone/core/LinphoneConference"); + jmethodID conference_constructor = env->GetMethodID(conference_class, "", "(J)"); + LinphoneConference *conf = linphone_core_get_conference((LinphoneCore *)pCore); + if(conf) return env->NewObject(conference_class, conference_constructor, conf); + else return NULL; } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){ @@ -4273,8 +4277,12 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVe linphone_call_set_authentication_token_verified(call, verified); } -extern "C" jlong Java_org_linphnoe_core_LinphoneCallImpl_getConference(JNIEnv *env, jobject thiz, jlong ptr) { - return (jlong)linphone_call_get_conference((LinphoneCall *)ptr); +extern "C" jobject Java_org_linphnoe_core_LinphoneCallImpl_getConference(JNIEnv *env, jobject thiz, jlong ptr) { + jclass conference_class = env->FindClass("org/linphone/core/LinphoneConference"); + jmethodID conference_constructor = env->GetMethodID(conference_class, "", "(J)"); + LinphoneConference *conf = linphone_call_get_conference((LinphoneCall *)ptr); + if(conf) return env->NewObject(conference_class, conference_constructor, conf); + return NULL; } extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) { diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 0ff6c25bd..913a7fe11 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1413,7 +1413,7 @@ public interface LinphoneCore { * That function can be used to test whether a conference is running. * @return A positive value if a conference is running, 0 if not. **/ - long getConference(); + LinphoneConference getConference(); /** * Request recording of the conference into a supplied file path. diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index c81100c5c..6b84e310c 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -709,8 +709,8 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized int getConferenceSize() { return getConferenceSize(nativePtr); } - private native long getConference(long nativePtr); - public synchronized long getConference() { + private native LinphoneConference getConference(long nativePtr); + public synchronized LinphoneConference getConference() { return getConference(nativePtr); } private native int getCallsNb(long nativePtr);