From dc62411463b66139f301bf069cb8bfe86eae27b5 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 | 17 +++++++++++++---- java/common/org/linphone/core/LinphoneCore.java | 2 +- .../linphone/core/LinphoneConferenceImpl.java | 7 +++---- .../org/linphone/core/LinphoneCoreImpl.java | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 7c3714d85..7559d2c8f 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) { @@ -6578,6 +6586,7 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getSipTransportTi return linphone_core_get_sip_transport_timeout((LinphoneCore*)pcore); } + JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneConferenceImpl_getParticipants(JNIEnv *env, jobject thiz, jlong pconference) { MSList *participants, *it; jclass addr_class = env->FindClass("org/linphone/core/LinphoneAddressImpl"); 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/LinphoneConferenceImpl.java b/java/impl/org/linphone/core/LinphoneConferenceImpl.java index 4e77a3414..2a3519302 100644 --- a/java/impl/org/linphone/core/LinphoneConferenceImpl.java +++ b/java/impl/org/linphone/core/LinphoneConferenceImpl.java @@ -25,17 +25,16 @@ import java.util.List; public class LinphoneConferenceImpl implements LinphoneConference { private final long nativePtr; + private LinphoneConferenceImpl(long nativePtr) { this.nativePtr = nativePtr; } - private native void finalize(long nativePtr); - protected void finalize() { - finalize(nativePtr); - } + private native List getParticipants(long nativePtr); public List getParticipants() { return getParticipants(nativePtr); } + private native int removeParticipant(long nativePtr, LinphoneAddress uri); public int removeParticipant(LinphoneAddress uri) { return removeParticipant(nativePtr, uri); 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);