From 2c8ebd5dcf94b2cc475b1c96428c191e5b88a18b Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 12 Feb 2010 15:43:06 +0100 Subject: [PATCH 1/8] add liblinphone jni for java binding --- .cproject | 209 ++++++++++++++++++++++ .project | 78 ++++++++ coreapi/linphonecore_jni.cc | 344 ++++++++++++++++++++++++++++++++++++ mediastreamer2 | 2 +- oRTP | 2 +- 5 files changed, 633 insertions(+), 2 deletions(-) create mode 100644 .cproject create mode 100644 .project create mode 100644 coreapi/linphonecore_jni.cc diff --git a/.cproject b/.cproject new file mode 100644 index 000000000..4dc56ec67 --- /dev/null +++ b/.cproject @@ -0,0 +1,209 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..fb926842f --- /dev/null +++ b/.project @@ -0,0 +1,78 @@ + + + linphone + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc new file mode 100644 index 000000000..21a01824e --- /dev/null +++ b/coreapi/linphonecore_jni.cc @@ -0,0 +1,344 @@ +/* +linphonecore_jni.cc +Copyright (C) 2010 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. + */ +#include +#include "linphonecore.h" +#ifdef ANDROID +#include +#endif /*ANDROID*/ + +extern "C" void ms_andsnd_register_card(JavaVM *jvm) ; +static JavaVM *jvm=0; + +#ifdef ANDROID +static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){ + int prio; + switch(lev){ + case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break; + case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break; + case ORTP_WARNING: prio = ANDROID_LOG_WARN; break; + case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break; + case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break; + default: prio = ANDROID_LOG_DEFAULT; break; + } + __android_log_vprint(prio, LOG_DOMAIN, fmt, args); +} +#endif /*ANDROID*/ + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) +{ + #ifdef ANDROID + linphone_core_enable_logs_with_cb(linphone_android_log_handler); + ms_andsnd_register_card(ajvm); +#endif /*ANDROID*/ + jvm=ajvm; + return JNI_VERSION_1_2; +} + + + +// LinphoneCore + +class LinphoneCoreData { +public: + LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) { + + core = env->NewGlobalRef(lc); + listener = env->NewGlobalRef(alistener); + 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.general_state = generalStateChange; + + listernerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener)); + /*displayStatus(LinphoneCore lc,String message);*/ + displayStatusId = env->GetMethodID(listernerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V"); + /*void generalState(LinphoneCore lc,int state); */ + generalStateId = env->GetMethodID(listernerClass,"generalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GeneralState;)V"); + + generalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GeneralState")); + generalStateFromIntId = env->GetStaticMethodID(generalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GeneralState;"); + } + + ~LinphoneCoreData() { + JNIEnv *env = 0; + jvm->AttachCurrentThread(&env,NULL); + env->DeleteGlobalRef(core); + env->DeleteGlobalRef(listener); + if (userdata) env->DeleteGlobalRef(userdata); + env->DeleteGlobalRef(listernerClass); + env->DeleteGlobalRef(generalStateClass); + } + jobject core; + jobject listener; + jobject userdata; + + jclass listernerClass; + jclass generalStateClass; + jmethodID displayStatusId; + jmethodID generalStateId; + jmethodID generalStateFromIntId; + LinphoneCoreVTable vTable; + + static void showInterfaceCb(LinphoneCore *lc) { + + } + static void inviteReceivedCb(LinphoneCore *lc, const char *from) { + + } + static void byeReceivedCb(LinphoneCore *lc, const char *from) { + + } + static void displayStatusCb(LinphoneCore *lc, const char *message) { + 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->displayStatusId,lcData->core,env->NewStringUTF(message)); + } + static void displayMessageCb(LinphoneCore *lc, const char *message) { + + } + static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) { + + } + static void generalStateChange(LinphoneCore *lc, LinphoneGeneralState *gstate) { + 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->generalStateId + ,lcData->core + ,env->CallStaticObjectMethod(lcData->generalStateClass,lcData->generalStateFromIntId,gstate->new_state)); + } + +}; +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env + ,jobject thiz + ,jobject jlistener + ,jstring juserConfig + ,jstring jfactoryConfig + ,jobject juserdata){ + + const char* userConfig = env->GetStringUTFChars(juserConfig, NULL); + const char* factoryConfig = env->GetStringUTFChars(jfactoryConfig, NULL); + LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata); + jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable + ,userConfig + ,factoryConfig + ,ldata); + //clear auth info list + linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr); + //clear existing proxy config + linphone_core_clear_proxy_config((LinphoneCore*) nativePtr); + + env->ReleaseStringUTFChars(juserConfig, userConfig); + env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); + return nativePtr; +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { + linphone_core_clear_proxy_config((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jlong pc) { + linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env + ,jobject thiz + ,jlong lc) { + LinphoneProxyConfig *config=0; + linphone_core_get_default_proxy((LinphoneCore*)lc,&config); + return (jlong)config; +} + +extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jlong pc) { + return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); +} + +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) { + linphone_core_clear_all_auth_info((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jlong pc) { + linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc); +} +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env + ,jobject thiz + ,jlong lc) { + linphone_core_iterate((LinphoneCore*)lc); +} +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jstring juri) { + const char* uri = env->GetStringUTFChars(juri, NULL); + linphone_core_invite((LinphoneCore*)lc,uri); + env->ReleaseStringUTFChars(juri, uri); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env + ,jobject thiz + ,jlong lc) { + linphone_core_terminate_call((LinphoneCore*)lc,NULL); +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return (jlong)linphone_core_get_remote_uri((LinphoneCore*)lc); +} + + + +//ProxyConfig + +extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) { + return (jlong) linphone_proxy_config_new(); +} + +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) { + linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr); +} +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) { + const char* identity = env->GetStringUTFChars(jidentity, NULL); + linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity); + env->ReleaseStringUTFChars(jidentity, identity); +} +extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { + const char* proxy = env->GetStringUTFChars(jproxy, NULL); + int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); + env->ReleaseStringUTFChars(jproxy, proxy); + return err; +} + +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) { + linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister); +} +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) { + linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg); +} +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) { + linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg); +} +extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) { + const char* number = env->GetStringUTFChars(jnumber, NULL); + int len = env->GetStringLength(jnumber); + char targetBuff[len]; + linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff)); + jstring normalizedNumber = env->NewStringUTF(targetBuff); + env->ReleaseStringUTFChars(jnumber, number); + return normalizedNumber; +} +//Auth Info + +extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env + , jobject thiz + , jstring jusername + , jstring juserid + , jstring jpassword + , jstring jha1 + , jstring jrealm) { + + const char* username = env->GetStringUTFChars(jusername, NULL); + const char* password = env->GetStringUTFChars(jpassword, NULL); + jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL); + + env->ReleaseStringUTFChars(jusername, username); + env->ReleaseStringUTFChars(jpassword, password); + return auth; + +} +extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env + , jobject thiz + , jlong ptr) { + linphone_auth_info_destroy((LinphoneAuthInfo*)ptr); +} + +//LinphoneAddress + +extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env + ,jobject thiz + ,jstring juri + ,jstring jdisplayName) { + const char* uri = env->GetStringUTFChars(juri, NULL); + LinphoneAddress* address = linphone_address_new(uri); + if (jdisplayName) { + const char* displayName = env->GetStringUTFChars(jdisplayName, NULL); + linphone_address_set_display_name(address,displayName); + env->ReleaseStringUTFChars(jdisplayName, displayName); + } + env->ReleaseStringUTFChars(juri, uri); + + return (jlong) address; +} +extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + linphone_address_destroy((LinphoneAddress*)ptr); +} + +extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr); + if (displayName) { + return env->NewStringUTF(displayName); + } else { + return 0; + } +} +extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + const char* userName = linphone_address_get_username((LinphoneAddress*)ptr); + if (userName) { + return env->NewStringUTF(userName); + } else { + return 0; + } +} +extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr); + if (domain) { + return env->NewStringUTF(domain); + } else { + return 0; + } +} diff --git a/mediastreamer2 b/mediastreamer2 index ae7dfdcae..637302226 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit ae7dfdcaea6d5fe6d4f44a6247b4ca506799e379 +Subproject commit 6373022261b4a529400a0c0e1661b4d3e5ebc7c5 diff --git a/oRTP b/oRTP index 36773054c..f17c37857 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 36773054c1e9a47029432a2e8540161dad426293 +Subproject commit f17c378577cb00bced683e3588d115fc41003070 From 9a17310ffd4cf41b8425e12a2bd7e9b4c8a9391c Mon Sep 17 00:00:00 2001 From: jehan monnier Date: Mon, 15 Feb 2010 10:01:35 +0100 Subject: [PATCH 2/8] increase jni support --- coreapi/linphonecore_jni.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 21a01824e..5fd60b1ad 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -264,6 +264,27 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone env->ReleaseStringUTFChars(jnumber, number); return normalizedNumber; } +extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env + ,jobject thiz + ,jlong proxyCfg) { + const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg); + if (domain) { + return env->NewStringUTF(domain); + } else { + return NULL; + } +} + + +void Java_org_linphone_core_LinphoneProxyConfigImpl_setPrefix(JNIEnv* env + ,jobject thiz + ,jlong proxyCfg + ,jstring jprefix) { + const char* prefix = env->GetStringUTFChars(jprefix, NULL); + linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix); + env->ReleaseStringUTFChars(jprefix, prefix); +} + //Auth Info extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env @@ -342,3 +363,12 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* return 0; } } + +extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + char* uri = linphone_address_as_string((LinphoneAddress*)ptr); + jstring juri =env->NewStringUTF(uri); + ms_free(uri); + return juri; +} From 01331f08a99297b9fd76494f3eba8c1476ba0494 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 15 Feb 2010 18:02:19 +0100 Subject: [PATCH 3/8] add traces + more jni implementation --- coreapi/address.c | 1 + coreapi/linphonecore.c | 2 +- coreapi/linphonecore_jni.cc | 28 ++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/coreapi/address.c b/coreapi/address.c index 36f6de903..9c69a2641 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -36,6 +36,7 @@ LinphoneAddress * linphone_address_new(const char *uri){ osip_from_init(&from); if (osip_from_parse(from,uri)!=0){ osip_from_free(from); + ms_error("Cannot create LinphoneAddress, bad uri [%s]",uri); return NULL; } return from; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d54b4907e..d5d7e43f1 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1836,7 +1836,7 @@ int linphone_core_invite(LinphoneCore *lc, const char *url) err=eXosip_call_build_initial_invite(&invite,real_url,from, route,"Phone call"); if (err<0){ - ms_warning("Could not build initial invite"); + ms_warning("Could not build initial invite cause [%i]",err); goto end; } if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){ diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 5fd60b1ad..9380c6196 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -222,9 +222,24 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEn ,jlong lc) { return (jlong)linphone_core_get_remote_uri((LinphoneCore*)lc); } +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return linphone_core_in_call((LinphoneCore*)lc); +} +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return linphone_core_inc_invite_pending((LinphoneCore*)lc); +} +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env + ,jobject thiz + ,jlong lc) { + linphone_core_accept_call((LinphoneCore*)lc,NULL); +} //ProxyConfig extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) { @@ -256,9 +271,12 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env, linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) { + if (jnumber == 0) { + ms_error("cannot normalized null number"); + } const char* number = env->GetStringUTFChars(jnumber, NULL); int len = env->GetStringLength(jnumber); - char targetBuff[len]; + char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff)); jstring normalizedNumber = env->NewStringUTF(targetBuff); env->ReleaseStringUTFChars(jnumber, number); @@ -274,9 +292,11 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIE return NULL; } } +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) { + linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value); +} - -void Java_org_linphone_core_LinphoneProxyConfigImpl_setPrefix(JNIEnv* env +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env ,jobject thiz ,jlong proxyCfg ,jstring jprefix) { @@ -318,7 +338,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressIm ,jstring jdisplayName) { const char* uri = env->GetStringUTFChars(juri, NULL); LinphoneAddress* address = linphone_address_new(uri); - if (jdisplayName) { + if (jdisplayName && address) { const char* displayName = env->GetStringUTFChars(jdisplayName, NULL); linphone_address_set_display_name(address,displayName); env->ReleaseStringUTFChars(jdisplayName, displayName); From 12f68e20f85af88dcf9b6febc5abbbb0eca8c9e3 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 17 Feb 2010 16:53:19 +0100 Subject: [PATCH 4/8] fix misspelt stardard --- coreapi/linphonecore.c | 2 +- gtk-glade/about.glade | 2 +- media_api/media_api.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d5d7e43f1..b76992e2b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3156,7 +3156,7 @@ static bool_t video_size_supported(MSVideoSize vsize){ * * @ingroup media_parameters * This applies only to the stream that is captured and sent to the remote party, - * since we accept all standart video size on the receive path. + * since we accept all standard video size on the receive path. **/ void linphone_core_set_preferred_video_size(LinphoneCore *lc, MSVideoSize vsize){ if (video_size_supported(vsize)){ diff --git a/gtk-glade/about.glade b/gtk-glade/about.glade index 96c6b5f10..8203b4160 100644 --- a/gtk-glade/about.glade +++ b/gtk-glade/about.glade @@ -15,7 +15,7 @@ undef Created by Simon Morlat - An internet video phone using the standart SIP (rfc3261) protocol. + An internet video phone using the standard SIP (rfc3261) protocol. http://www.linphone.org GPL Simon Morlat diff --git a/media_api/media_api.c b/media_api/media_api.c index 28ed3c1a3..8746e9b0c 100644 --- a/media_api/media_api.c +++ b/media_api/media_api.c @@ -20,7 +20,7 @@ #include "media_api.h" -/* non-standart payload types for oRTP */ +/* non-standard payload types for oRTP */ PayloadType lpc1015={ PAYLOAD_AUDIO_PACKETIZED, 8000, From 677d4122e8851b66142187faf3061b5a8dc8f7ea Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 17 Feb 2010 16:54:54 +0100 Subject: [PATCH 5/8] test if number to normilize is empty --- coreapi/linphonecore_jni.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 9380c6196..ea93e0fb4 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -276,6 +276,10 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone } const char* number = env->GetStringUTFChars(jnumber, NULL); int len = env->GetStringLength(jnumber); + if (len == 0) { + ms_warning("cannot normalize empty number"); + return jnumber; + } char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff)); jstring normalizedNumber = env->NewStringUTF(targetBuff); From e27bd0cab8d166f0fc7fb9bb82dc47dea43f2113 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 18 Feb 2010 18:27:43 +0100 Subject: [PATCH 6/8] fix misspelt standard --- share/C/linphonecsh.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/C/linphonecsh.1 b/share/C/linphonecsh.1 index 6c7b77f27..83271c5cb 100644 --- a/share/C/linphonecsh.1 +++ b/share/C/linphonecsh.1 @@ -23,7 +23,7 @@ linphonecsh \fI\--help\fP .SH "DESCRIPTION" .LP Linphonecsh is a small utility to send basic commands to a linphonec (console mode linphone) process. -Unlike linphonec, linphonecsh does not wait commands from standart input: it takes the command from its arguments +Unlike linphonec, linphonecsh does not wait commands from standard input: it takes the command from its arguments and sends it using unix pipe to a linphonec process started in daemon mode. The motivation for this tool is for example to simply execute voip calls from scripts, web-servers, or javascript web pages. .br From 269ee3cb7bfadbac24004180cde3fb783e6ce302 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 18 Feb 2010 18:28:45 +0100 Subject: [PATCH 7/8] ass call logs jnis --- coreapi/linphonecore_jni.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index ea93e0fb4..d4ef6556a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -217,6 +217,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* ,jlong lc) { linphone_core_terminate_call((LinphoneCore*)lc,NULL); } + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env ,jobject thiz ,jlong lc) { @@ -240,6 +241,20 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env linphone_core_accept_call((LinphoneCore*)lc,NULL); } + +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jint position) { + return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position); +} +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); +} + + //ProxyConfig extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) { @@ -396,3 +411,20 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env ms_free(uri); return juri; } + +//CallLog +extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jlong)((LinphoneCallLog*)ptr)->from; +} +extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jlong)((LinphoneCallLog*)ptr)->to; +} +extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE; +} From 013edf6d7d2e9e302e96513f4770a32a87890ea5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 19 Feb 2010 17:04:00 +0100 Subject: [PATCH 8/8] add jni for linphone_core_destroy --- coreapi/linphonecore_jni.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index d4ef6556a..b0ffbbf80 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -163,6 +163,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); return nativePtr; } +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env + ,jobject thiz + ,jlong lc) { + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc); + linphone_core_destroy((LinphoneCore*)lc); + delete lcData; +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { linphone_core_clear_proxy_config((LinphoneCore*)lc); }