Wrap LinphoneConference class into Java

This commit is contained in:
François Grisez 2016-01-06 13:54:22 +01:00
parent d7e761b09e
commit 95c893dcc1
7 changed files with 138 additions and 3 deletions

View file

@ -4135,6 +4135,10 @@ 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" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){
int err=-1;
if (jpath){
@ -4269,6 +4273,10 @@ 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" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
LinphoneCall *call = (LinphoneCall *) ptr;
return (jfloat)linphone_call_get_play_volume(call);
@ -6570,4 +6578,26 @@ 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");
jclass addr_list_class = env->FindClass("[Lorg/linphone/core/LinphoneAddressImpl;");
jmethodID addr_constructor = env->GetMethodID(addr_class, "<init>", "(J)");
jmethodID addr_list_constructor = env->GetMethodID(addr_list_class, "<init>", "(V)");
jmethodID addr_list_append = env->GetMethodID(addr_list_class, "add", "(Lorg/linphone/core/LinphoneAddressImpl;)Z");
jobject jaddr_list = env->NewObject(addr_list_class, addr_list_constructor);
participants = linphone_conference_get_participants((LinphoneConference *)pconference);
for(it = participants; it; it = ms_list_next(it)) {
LinphoneAddress *addr = (LinphoneAddress *)it->data;
jobject jaddr = env->NewObject(addr_class, addr_constructor, addr);
env->CallBooleanMethod(jaddr_list, addr_list_append, jaddr);
}
return jaddr_list;
}
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneConferenteImpl_removeParticipant(JNIEnv *env, jobject thiz, jlong pconference, jobject uri) {
jfieldID native_ptr_attr = env->GetFieldID(env->GetObjectClass(uri), "nativePtr", "J");
LinphoneAddress *addr = (LinphoneAddress *)env->GetLongField(uri, native_ptr_attr);
return linphone_conference_remove_participant((LinphoneConference *)pconference, addr);
}

View file

@ -273,8 +273,17 @@ public interface LinphoneCall {
* @param verified true when displayed SAS is correct
*/
void setAuthenticationTokenVerified(boolean verified);
/**
* Checks wether the call is part of a conferece.
* @return A boolean
*/
boolean isInConference();
/**
* Get the pointer on the C conference instance associated to that call.
* @return A positive value if the call is part of a conference, 0 if not.
*/
long getConference();
/**
* Indicates whether an operation is in progress at the media side.

View file

@ -0,0 +1,39 @@
/*
LinphoneConference.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
import org.linphone.core.LinphoneAddress;
import java.util.List;
/**
* Interface to manipulate a running conference
*/
public interface LinphoneConference {
/**
* Get the URIs of all participants of the conference
*/
public List<LinphoneAddress> getParticipants();
/**
* Remove a participant from the conference
* @param uri The URI of the participant to remove
* @return 0 if succeed, -1 if not.
*/
public int removeParticipant(LinphoneAddress uri);
}

View file

@ -1407,6 +1407,13 @@ public interface LinphoneCore {
* @returns the number of participants to the conference
**/
int getConferenceSize();
/**
* Return the value of the C pointer on the conference instance.
*
* 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();
/**
* Request recording of the conference into a supplied file path.

View file

@ -165,8 +165,11 @@ class LinphoneCallImpl implements LinphoneCall {
}
public boolean isInConference() {
LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr));
return params.localConferenceMode();
return getConference() != 0;
}
private native long getConference(long nativePtr);
public long getConference() {
return getConference(nativePtr);
}
public boolean mediaInProgress() { return mediaInProgress(nativePtr);}

View file

@ -0,0 +1,43 @@
/*
LinphoneConferenceImpl.java
Copyright (C) 2015 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
import org.linphone.core.LinphoneConference;
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<LinphoneAddress> getParticipants(long nativePtr);
public List<LinphoneAddress> getParticipants() {
return getParticipants(nativePtr);
}
private native int removeParticipant(long nativePtr, LinphoneAddress uri);
public int removeParticipant(LinphoneAddress uri) {
return removeParticipant(nativePtr, uri);
}
}

View file

@ -709,6 +709,10 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized int getConferenceSize() {
return getConferenceSize(nativePtr);
}
private native long getConference(long nativePtr);
public synchronized long getConference() {
return getConference(nativePtr);
}
private native int getCallsNb(long nativePtr);
public synchronized int getCallsNb() {
return getCallsNb(nativePtr);