From 8bec813e52a4949f723b94918f4eb37ac5faad86 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 2 Oct 2012 17:06:38 +0200 Subject: [PATCH] JNI DTMF listener --- coreapi/linphonecore_jni.cc | 17 +++++++++++++++++ .../org/linphone/core/LinphoneCoreListener.java | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 3cd7b76c..273d46aa 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -110,6 +110,7 @@ public: vTable.call_encryption_changed = callEncryptionChange; vTable.text_received = text_received; vTable.message_received = message_received; + vTable.dtmf_received = dtmf_received; vTable.new_subscription_request = new_subscription_request; vTable.notify_presence_recv = notify_presence_recv; vTable.call_stats_updated = callStatsUpdated; @@ -157,6 +158,7 @@ public: /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/ textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V"); messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V"); + dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V"); proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl")); proxyCtrId = env->GetMethodID(proxyClass,"", "(J)V"); @@ -211,6 +213,7 @@ public: jmethodID notifyPresenceReceivedId; jmethodID textReceivedId; jmethodID messageReceivedId; + jmethodID dtmfReceivedId; jmethodID callStatsUpdatedId; jclass globalStateClass; @@ -390,6 +393,20 @@ public: ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend) ,url ? env->NewStringUTF(url) : NULL); } + static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM\n"); + return; + } + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); + env->CallVoidMethod(lcData->listener + ,lcData->dtmfReceivedId + ,lcData->core + ,lcData->getCall(env,call) + ,dtmf); + } static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index c81dafec..740bdc29 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -91,6 +91,14 @@ public interface LinphoneCoreListener { */ void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message); + /** + * invoked when a new dtmf is received + * @param lc LinphoneCore + * @param call LinphoneCall involved in the dtmf sending + * @param dtmf value of the dtmf sent + */ + void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf); + /** * Invoked when echo cancalation calibration is completed * @param lc LinphoneCore -- 2.39.2