From dfa388b30485965a8e10f9013551c6e63e6c3bb2 Mon Sep 17 00:00:00 2001 From: Jehan Monnier <jehan.monnier@linphone.org> Date: Mon, 13 Sep 2010 23:39:54 +0200 Subject: [PATCH] migrate java binding to multical api --- build/android/Android.mk | 4 +- coreapi/linphonecore_jni.cc | 55 +++++++++++++------ .../org/linphone/core/LinphoneCall.java | 1 + .../org/linphone/core/LinphoneCore.java | 15 ++++- .../linphone/core/LinphoneCoreListener.java | 3 - mediastreamer2 | 2 +- oRTP | 2 +- 7 files changed, 56 insertions(+), 26 deletions(-) diff --git a/build/android/Android.mk b/build/android/Android.mk index 0997d9639d..9ffa431923 100755 --- a/build/android/Android.mk +++ b/build/android/Android.mk @@ -30,7 +30,6 @@ LOCAL_SRC_FILES = \ linphonecore.c \ misc.c \ enum.c \ - enum.h \ presence.c \ proxy.c \ friend.c \ @@ -46,7 +45,8 @@ LOCAL_SRC_FILES = \ sal_eXosip2_presence.c \ sal_eXosip2_sdp.c \ offeranswer.c \ - callbacks.c + callbacks.c \ + linphonecall.c LOCAL_CFLAGS += \ -D_BYTE_ORDER=_LITTLE_ENDIAN \ diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index c6a7cd6f67..3d12165af6 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -72,14 +72,13 @@ public: userdata = auserdata?env->NewGlobalRef(auserdata):0; memset(&vTable,0,sizeof(vTable)); vTable.show = showInterfaceCb; - vTable.inv_recv = inviteReceivedCb; vTable.auth_info_requested = authInfoRequested; vTable.display_status = displayStatusCb; vTable.display_message = displayMessageCb; vTable.display_warning = displayMessageCb; vTable.global_state_changed = globalStateChange; - vTable.registration_state_changed = registrationState; - vTable.call_state_changed = callState; + vTable.registration_state_changed = registrationStateChange; + vTable.call_state_changed = callStateChange; listernerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener)); /*displayStatus(LinphoneCore lc,String message);*/ @@ -112,7 +111,12 @@ public: env->DeleteGlobalRef(listener); if (userdata) env->DeleteGlobalRef(userdata); env->DeleteGlobalRef(listernerClass); - env->DeleteGlobalRef(generalStateClass); + env->DeleteGlobalRef(globalStateClass); + env->DeleteGlobalRef(registrationStateClass); + env->DeleteGlobalRef(callStateClass); + env->DeleteGlobalRef(proxyClass); + env->DeleteGlobalRef(callClass); + } jobject core; jobject listener; @@ -143,9 +147,6 @@ public: static void showInterfaceCb(LinphoneCore *lc) { - } - static void inviteReceivedCb(LinphoneCore *lc, const char *from) { - } static void byeReceivedCb(LinphoneCore *lc, const char *from) { @@ -177,10 +178,10 @@ public: env->CallVoidMethod(lcData->listener ,lcData->globalStateId ,lcData->core - ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,gstate), + ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate), message ? env->NewStringUTF(message) : NULL); } - static void registerStateChange(LinphoneCore *lc, LinphoneProxyConfig proxy,LinphoneRegistrationState state,const char* message) { + static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -191,11 +192,11 @@ public: env->CallVoidMethod(lcData->listener ,lcData->registrationStateId ,lcData->core - ,env->NewObject(proxyClass,proxyCtrId,proxy) - ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,state), + ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy) + ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state), message ? env->NewStringUTF(message) : NULL); } - static void callStateChange(LinphoneCore *lc, LinphoneCall call,LinphoneCallState *state,const char* message) { + static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); if (result != 0) { @@ -206,8 +207,8 @@ public: env->CallVoidMethod(lcData->listener ,lcData->callStateId ,lcData->core - ,env->NewObject(callClass,callCtrId,call) - ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,state), + ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call) + ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state), message ? env->NewStringUTF(message) : NULL); } @@ -300,11 +301,11 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env ,jlong lc ,jstring juri) { const char* uri = env->GetStringUTFChars(juri, NULL); - LinphoneCall lCall = linphone_core_invite((LinphoneCore*)lc,uri); + LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri); env->ReleaseStringUTFChars(juri, uri); return (jlong)lCall; } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env ,jobject thiz ,jlong lc ,jlong to) { @@ -321,7 +322,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env ,jobject thiz ,jlong lc) { - return (jlong)linphone_core_get_remote_uri((LinphoneCore*)lc); + return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env ,jobject thiz @@ -396,6 +397,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env ,jchar dtmf) { linphone_core_send_dtmf((LinphoneCore*)lc,dtmf); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jchar dtmf + ,jint duration) { + linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration); +} +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env + ,jobject thiz + ,jlong lc) { + linphone_core_stop_dtmf((LinphoneCore*)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env ,jobject thiz ,jlong lc) { @@ -436,6 +450,13 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEn return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc); } +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env + ,jobject thiz + ,jlong lc + ) { + return (jlong)linphone_core_get_current_call((LinphoneCore*)lc); +} + //ProxyConfig diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index c5e7f502c8..03baca9dfc 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -40,6 +40,7 @@ public interface LinphoneCall { public final static State Refered = new State(11,"Refered"); public final static State Error = new State(12,"Error"); public final static State CallEnd = new State(13,"CallEnd"); + public final static State PausedByRemote = new State(14,"PausedByRemote"); private State(int value,String stringValue) { mValue = value; values.addElement(this); diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index d6c7799d9e..c09ff9814d 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -135,10 +135,10 @@ public interface LinphoneCore { * Returns The LinphoneCall the current call if one is in call * **/ - public LinphoneCall getCurrentCall(); + public LinphoneCall getCurrentCall(); /** - * get the remote address in case of in/out call + * get current call remote address in case of in/out call * @return null if no call engaged yet */ public LinphoneAddress getRemoteAddress(); @@ -220,6 +220,17 @@ public interface LinphoneCore { * @param number */ public void sendDtmf(char number); + /** + * Initiate a dtmf signal to the speqker if not in call + * @param number + * @param duration in ms , -1 for unlimited + */ + public void playDtmf(char number,int duration); + /** + * stop current dtmf + */ + public void stopDtmf(); + /** * */ diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index a63acf2814..c37e5d7c74 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -25,9 +25,6 @@ public interface LinphoneCoreListener { /**< Notifies the application that it should show up * @return */ public void show(LinphoneCore lc); - /**< Notifies incoming calls - * @return */ - public void inviteReceived(LinphoneCore lc,String from); /**< Notify calls terminated by far end * @return */ public void byeReceived(LinphoneCore lc,String from); diff --git a/mediastreamer2 b/mediastreamer2 index 46b69fe887..955a7d6b8a 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 46b69fe88700905a362eeb0a57e8218585b76565 +Subproject commit 955a7d6b8aa205e8a97d751dd8d3920de1595455 diff --git a/oRTP b/oRTP index 6bc540160a..461dd13a0a 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 6bc540160a8729f63f6074b958161bc696e78f93 +Subproject commit 461dd13a0aad2a075a075bf618e68443475f7a24 -- GitLab