X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=coreapi%2Flinphonecore_jni.cc;h=02ac62c7a8498c546a1d49f557b7fe1cca97dabc;hb=e1830ee3077b47d1557a1292e8c8b80cd01fc403;hp=f3ba286857a47a220c7519924c26c511535d904d;hpb=160dc76b0efccc8ef78f006718dd6029f54b10fe;p=linphone diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index f3ba2868..02ac62c7 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -17,12 +17,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#ifdef USE_JAVAH +#include "linphonecore_jni.h" +#endif #include "linphonecore_utils.h" #include -#ifdef TUNNEL_ENABLED -#include "linphone_tunnel.h" -#endif extern "C" { #include "mediastreamer2/mediastream.h" @@ -31,6 +31,8 @@ extern "C" { #include "private.h" #include +#include "lpconfig.h" + #ifdef ANDROID #include extern "C" void libmsilbc_init(); @@ -49,9 +51,30 @@ extern "C" void libmsbcg729_init(); #endif /*ANDROID*/ static JavaVM *jvm=0; +static const char* LogDomain = "Linphone"; #ifdef ANDROID -static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){ +void linphone_android_log_handler(int prio, const char *fmt, va_list args) { + char str[4096]; + char *current; + char *next; + + vsnprintf(str, sizeof(str) - 1, fmt, args); + str[sizeof(str) - 1] = '\0'; + if (strlen(str) < 512) { + __android_log_write(prio, LogDomain, str); + } else { + current = str; + while ((next = strchr(current, '\n')) != NULL) { + *next = '\0'; + __android_log_write(prio, LogDomain, current); + current = next + 1; + } + __android_log_write(prio, LogDomain, current); + } +} + +static void linphone_android_ortp_log_handler(OrtpLogLevel lev, const char *fmt, va_list args) { int prio; switch(lev){ case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break; @@ -61,7 +84,7 @@ static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_l case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break; default: prio = ANDROID_LOG_DEFAULT; break; } - __android_log_vprint(prio, LOG_DOMAIN, fmt, args); + linphone_android_log_handler(prio, fmt, args); } int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() { @@ -82,9 +105,11 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) //LinphoneFactory extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env ,jobject thiz - ,jboolean isDebug) { + ,jboolean isDebug + ,jstring jdebugTag) { if (isDebug) { - linphone_core_enable_logs_with_cb(linphone_android_log_handler); + LogDomain = env->GetStringUTFChars(jdebugTag, NULL); + linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler); } else { linphone_core_disable_logs(); } @@ -109,8 +134,11 @@ public: vTable.call_state_changed = callStateChange; 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; listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener)); @@ -132,6 +160,12 @@ public: callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State")); callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;"); + /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/ + callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V"); + + chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State")); + chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;"); + /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/ callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V"); @@ -148,6 +182,8 @@ 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"); @@ -155,6 +191,9 @@ public: callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl")); callCtrId = env->GetMethodID(callClass,"", "(J)V"); + chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl")); + if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"", "(J)V"); + chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl")); chatRoomCtrId = env->GetMethodID(chatRoomClass,"", "(J)V"); @@ -164,6 +203,10 @@ public: addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl")); addressCtrId =env->GetMethodID(addressClass,"", "(J)V"); + callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl")); + callStatsId = env->GetMethodID(callStatsClass, "", "(JJ)V"); + callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V"); + callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V"); } ~LinphoneCoreData() { @@ -176,8 +219,11 @@ public: env->DeleteGlobalRef(globalStateClass); env->DeleteGlobalRef(registrationStateClass); env->DeleteGlobalRef(callStateClass); + env->DeleteGlobalRef(callStatsClass); + env->DeleteGlobalRef(chatMessageStateClass); env->DeleteGlobalRef(proxyClass); env->DeleteGlobalRef(callClass); + env->DeleteGlobalRef(chatMessageClass); env->DeleteGlobalRef(chatRoomClass); env->DeleteGlobalRef(friendClass); @@ -191,6 +237,9 @@ public: jmethodID newSubscriptionRequestId; jmethodID notifyPresenceReceivedId; jmethodID textReceivedId; + jmethodID messageReceivedId; + jmethodID dtmfReceivedId; + jmethodID callStatsUpdatedId; jclass globalStateClass; jmethodID globalStateId; @@ -204,6 +253,14 @@ public: jmethodID callStateId; jmethodID callStateFromIntId; + jclass callStatsClass; + jmethodID callStatsId; + jmethodID callSetAudioStatsId; + jmethodID callSetVideoStatsId; + + jclass chatMessageStateClass; + jmethodID chatMessageStateFromIntId; + jmethodID callEncryptionChangedId; jclass ecCalibratorStatusClass; @@ -216,6 +273,9 @@ public: jclass callClass; jmethodID callCtrId; + jclass chatMessageClass; + jmethodID chatMessageCtrId; + jclass chatRoomClass; jmethodID chatRoomCtrId; @@ -241,7 +301,7 @@ public: return; } LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); - env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message)); + env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL); } static void displayMessageCb(LinphoneCore *lc, const char *message) { @@ -358,6 +418,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); @@ -373,6 +447,20 @@ public: ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from) ,message ? env->NewStringUTF(message) : NULL); } + static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { + 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->messageReceivedId + ,lcData->core + ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room) + ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg)); + } static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) { JNIEnv *env = 0; jint result = jvm->AttachCurrentThread(&env,NULL); @@ -393,6 +481,24 @@ public: } } + static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) { + JNIEnv *env = 0; + jobject statsobj; + jobject callobj; + 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); + statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats); + callobj = lcData->getCall(env, call); + if (stats->type == LINPHONE_CALL_STATS_AUDIO) + env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj); + else + env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj); + env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj); + } }; @@ -426,16 +532,12 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* ,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); if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig); if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); return nativePtr; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env ,jobject thiz ,jlong lc) { LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc); @@ -443,7 +545,23 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env delete lcData; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) { + const char* displayname = env->GetStringUTFChars(jdisplayname, NULL); + const char* username = env->GetStringUTFChars(jusername, NULL); + + LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc); + if (parsed != NULL) { + linphone_address_set_display_name(parsed, displayname); + linphone_address_set_username(parsed, username); + char *contact = linphone_address_as_string(parsed); + linphone_core_set_primary_contact((LinphoneCore*)lc, contact); + } + + env->ReleaseStringUTFChars(jdisplayname, displayname); + env->ReleaseStringUTFChars(jusername, username); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) { linphone_core_clear_proxy_config((LinphoneCore*)lc); } @@ -477,7 +595,7 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList return jProxies; } -extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env ,jobject thiz ,jobject jproxyCfg ,jlong lc @@ -485,13 +603,17 @@ extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc; linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg)); - return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); + return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc); } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) { +extern "C" void 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_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) { + linphone_core_refresh_registers((LinphoneCore*)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env ,jobject thiz ,jlong lc @@ -528,6 +650,13 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_declineCall( JNIEnv* env + ,jobject thiz + ,jlong lc + ,jlong call, jint reason) { + linphone_core_decline_call((LinphoneCore*)lc,(LinphoneCall*)call,(LinphoneReason)reason); +} + extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env ,jobject thiz ,jlong lc) { @@ -537,13 +666,13 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* e ,jobject thiz ,jlong lc) { - return linphone_core_in_call((LinphoneCore*)lc); + return (jboolean)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); + return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env ,jobject thiz @@ -585,7 +714,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* en 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)); + return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc)); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env ,jobject thiz @@ -594,6 +723,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable); } +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMicrophoneGain(JNIEnv* env + ,jobject thiz + ,jlong lc + ,jfloat gain) { + linphone_core_set_mic_gain_db((LinphoneCore*)lc,gain); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env ,jobject thiz ,jlong lc @@ -601,10 +743,10 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain); } -extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env +extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_get_playback_gain_db((LinphoneCore*)lc); + return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env @@ -642,16 +784,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env linphone_core_stop_dtmf((LinphoneCore*)lc); } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env + ,jobject thiz + ,jlong lc) { + return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env ,jobject thiz ,jlong lc) { - linphone_core_get_missed_calls_count((LinphoneCore*)lc); + linphone_core_reset_missed_calls_count((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env ,jobject thiz ,jlong lc, jlong log) { - linphone_core_remove_call_log((LinphoneCore*)lc, (void*) log); + linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env @@ -662,15 +810,16 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* e extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_is_mic_muted((LinphoneCore*)lc); + return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc); } extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jmime - ,jint rate) { + ,jint rate + ,jint channels) { const char* mime = env->GetStringUTFChars(jmime, NULL); - jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate); + jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels); env->ReleaseStringUTFChars(jmime, mime); return result; } @@ -710,12 +859,12 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTy return jCodecs; } -extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env ,jobject thiz ,jlong lc ,jlong pt ,jboolean enable) { - return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable); + return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env ,jobject thiz @@ -733,14 +882,14 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEn ,jobject thiz ,jlong lc ) { - return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env ,jobject thiz ,jlong lc ) { - return linphone_core_echo_limiter_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env @@ -769,7 +918,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact); } -extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jto) { @@ -777,7 +926,7 @@ extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* const char* to = env->GetStringUTFChars(jto, NULL); LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to); env->ReleaseStringUTFChars(jto, to); - return (long)lResult; + return (jlong)lResult; } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env @@ -791,7 +940,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_video_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env ,jobject thiz @@ -838,59 +987,59 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env ,jobject thiz ,jlong lc) { - return linphone_core_keep_alive_enabled((LinphoneCore*)lc); + return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env ,jobject thiz ,jlong lc ,jobject data) { - return linphone_core_start_echo_calibration((LinphoneCore*)lc + return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc , LinphoneCoreData::ecCalibrationStatus + , NULL + , NULL , data?env->NewGlobalRef(data):NULL); } -extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_needsEchoCalibration(JNIEnv *env, jobject thiz, jlong lc){ + MSSndCard *sndcard; + MSSndCardManager *m=ms_snd_card_manager_get(); + const char *card=linphone_core_get_capture_device((LinphoneCore*)lc); + sndcard=ms_snd_card_manager_get_card(m,card); + if (sndcard == NULL){ + ms_error("Could not get soundcard."); + return TRUE; + } + return (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER) || (ms_snd_card_get_minimal_latency(sndcard)>0); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env ,jobject thiz ,jlong lc ) { - return (int)linphone_core_get_media_encryption((LinphoneCore*)lc); + return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env ,jobject thiz ,jlong lc - ,int menc) { + ,jint menc) { linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); } -extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env - ,jobject thiz - ,jlong cp - ) { - return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp); -} - extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env ,jobject thiz ,jlong lc, jint menc ) { - return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); -} - -extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env - ,jobject thiz - ,jlong cp - ,int jmenc) { - linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc); + return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc); } -extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env ,jobject thiz ,jlong lc ) { - return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc); + return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env @@ -924,9 +1073,9 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JN return NULL; } } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { +extern "C" jint 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); + jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); env->ReleaseStringUTFChars(jproxy, proxy); return err; } @@ -938,14 +1087,19 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEn return NULL; } } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { +extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) { + const char* params = env->GetStringUTFChars(jparams, NULL); + linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params); + env->ReleaseStringUTFChars(jparams, params); +} +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { if (jroute != NULL) { const char* route = env->GetStringUTFChars(jroute, NULL); - int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); + jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); env->ReleaseStringUTFChars(jroute, route); return err; } else { - return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); + return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); } } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -961,10 +1115,10 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JN linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) { linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg); @@ -988,6 +1142,18 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone env->ReleaseStringUTFChars(jnumber, number); return normalizedNumber; } +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) { + const char* iso = env->GetStringUTFChars(jiso, NULL); + int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso); + env->ReleaseStringUTFChars(jiso, iso); + return (jint) prefix; +} +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromE164(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring je164) { + const char* e164 = env->GetStringUTFChars(je164, NULL); + int prefix = linphone_dial_plan_lookup_ccc_from_e164(e164); + env->ReleaseStringUTFChars(je164, e164); + return (jint) prefix; +} extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env ,jobject thiz ,jlong proxyCfg) { @@ -1017,33 +1183,156 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNI linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val); } extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) { - return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg); + return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg); } //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; - + , jobject thiz ) { + return (jlong)linphone_auth_info_new(NULL,NULL,NULL,NULL,NULL); } extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env , jobject thiz , jlong ptr) { linphone_auth_info_destroy((LinphoneAuthInfo*)ptr); } +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: getPassword + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getPassword +(JNIEnv *env , jobject, jlong auth_info) { + const char* passwd = linphone_auth_info_get_passwd((LinphoneAuthInfo*)auth_info); + if (passwd) { + return env->NewStringUTF(passwd); + } else { + return NULL; + } + +} +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: getRealm + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getRealm +(JNIEnv *env , jobject, jlong auth_info) { + const char* realm = linphone_auth_info_get_realm((LinphoneAuthInfo*)auth_info); + if (realm) { + return env->NewStringUTF(realm); + } else { + return NULL; + } + +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: getUsername + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUsername +(JNIEnv *env , jobject, jlong auth_info) { + const char* username = linphone_auth_info_get_username((LinphoneAuthInfo*)auth_info); + if (username) { + return env->NewStringUTF(username); + } else { + return NULL; + } +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: setPassword + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword +(JNIEnv *env, jobject, jlong auth_info, jstring jpassword) { + const char* password = jpassword?env->GetStringUTFChars(jpassword, NULL):NULL; + linphone_auth_info_set_passwd((LinphoneAuthInfo*)auth_info,password); + if (password) env->ReleaseStringUTFChars(jpassword, password); +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: setRealm + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm +(JNIEnv *env, jobject, jlong auth_info, jstring jrealm) { + const char* realm = jrealm?env->GetStringUTFChars(jrealm, NULL):NULL; + linphone_auth_info_set_realm((LinphoneAuthInfo*)auth_info,realm); + if (realm) env->ReleaseStringUTFChars(jrealm, realm); +} +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: setUsername + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername +(JNIEnv *env, jobject, jlong auth_info, jstring jusername) { + const char* username = jusername?env->GetStringUTFChars(jusername, NULL):NULL; + linphone_auth_info_set_username((LinphoneAuthInfo*)auth_info,username); + if (username) env->ReleaseStringUTFChars(jusername, username); +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: setAuthUserId + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUserId +(JNIEnv *env, jobject, jlong auth_info, jstring juserid) { + const char* userid = juserid?env->GetStringUTFChars(juserid, NULL):NULL; + linphone_auth_info_set_userid((LinphoneAuthInfo*)auth_info,userid); + if (userid) env->ReleaseStringUTFChars(juserid, userid); +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: getAuthUserId + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUserId +(JNIEnv *env , jobject, jlong auth_info) { + const char* userid = linphone_auth_info_get_userid((LinphoneAuthInfo*)auth_info); + if (userid) { + return env->NewStringUTF(userid); + } else { + return NULL; + } +} + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: setHa1 + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setHa1 +(JNIEnv *env, jobject, jlong auth_info, jstring jha1) { + const char* ha1 = jha1?env->GetStringUTFChars(jha1, NULL):NULL; + linphone_auth_info_set_ha1((LinphoneAuthInfo*)auth_info,ha1); + if (ha1) env->ReleaseStringUTFChars(jha1, ha1); +} + + +/* + * Class: org_linphone_core_LinphoneAuthInfoImpl + * Method: getHa1 + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getHa1 +(JNIEnv *env , jobject, jlong auth_info) { + const char* ha1 = linphone_auth_info_get_ha1((LinphoneAuthInfo*)auth_info); + if (ha1) { + return env->NewStringUTF(ha1); + } else { + return NULL; + } +} + //LinphoneAddress @@ -1075,7 +1364,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNI if (displayName) { return env->NewStringUTF(displayName); } else { - return 0; + return NULL; } } extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env @@ -1085,7 +1374,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv if (userName) { return env->NewStringUTF(userName); } else { - return 0; + return NULL; } } extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env @@ -1095,7 +1384,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* if (domain) { return env->NewStringUTF(domain); } else { - return 0; + return NULL; } } @@ -1131,10 +1420,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env ,jlong ptr) { return (jlong)((LinphoneCallLog*)ptr)->from; } -extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (jlong)((LinphoneCallLog*)ptr)->status; + return (jint)((LinphoneCallLog*)ptr)->status; } extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env ,jobject thiz @@ -1146,6 +1435,167 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv ,jlong ptr) { return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE; } +extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date); + return jvalue; +} +extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTimestamp(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return static_cast (((LinphoneCallLog*)ptr)->start_date_time); +} +extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jint)((LinphoneCallLog*)ptr)->duration; +} + +/* CallStats */ +extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jint)((LinphoneCallStats *)stats_ptr)->type; +} +extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jint)((LinphoneCallStats *)stats_ptr)->ice_state; +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth; +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth; +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) { + const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + const report_block_t *srb = NULL; + + if (!stats || !stats->sent_rtcp) + return (jfloat)0.0; + /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ + if (stats->sent_rtcp->b_cont != NULL) + msgpullup(stats->sent_rtcp, -1); + if (rtcp_is_SR(stats->sent_rtcp)) + srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0); + else if (rtcp_is_RR(stats->sent_rtcp)) + srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0); + if (!srb) + return (jfloat)0.0; + return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0); +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) { + const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + const report_block_t *rrb = NULL; + + if (!stats || !stats->received_rtcp) + return (jfloat)0.0; + /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ + if (stats->received_rtcp->b_cont != NULL) + msgpullup(stats->received_rtcp, -1); + if (rtcp_is_RR(stats->received_rtcp)) + rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0); + else if (rtcp_is_SR(stats->received_rtcp)) + rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0); + if (!rrb) + return (jfloat)0.0; + return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0); +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { + LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + LinphoneCall *call = (LinphoneCall *)call_ptr; + const LinphoneCallParams *params; + const PayloadType *pt; + const report_block_t *srb = NULL; + + if (!stats || !call || !stats->sent_rtcp) + return (jfloat)0.0; + params = linphone_call_get_current_params(call); + if (!params) + return (jfloat)0.0; + /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ + if (stats->sent_rtcp->b_cont != NULL) + msgpullup(stats->sent_rtcp, -1); + if (rtcp_is_SR(stats->sent_rtcp)) + srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0); + else if (rtcp_is_RR(stats->sent_rtcp)) + srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0); + if (!srb) + return (jfloat)0.0; + if (stats->type == LINPHONE_CALL_STATS_AUDIO) + pt = linphone_call_params_get_used_audio_codec(params); + else + pt = linphone_call_params_get_used_video_codec(params); + if (!pt || (pt->clock_rate == 0)) + return (jfloat)0.0; + return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate); +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { + LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + LinphoneCall *call = (LinphoneCall *)call_ptr; + const LinphoneCallParams *params; + const PayloadType *pt; + const report_block_t *rrb = NULL; + + if (!stats || !call || !stats->received_rtcp) + return (jfloat)0.0; + params = linphone_call_get_current_params(call); + if (!params) + return (jfloat)0.0; + /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */ + if (stats->received_rtcp->b_cont != NULL) + msgpullup(stats->received_rtcp, -1); + if (rtcp_is_SR(stats->received_rtcp)) + rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0); + else if (rtcp_is_RR(stats->received_rtcp)) + rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0); + if (!rrb) + return (jfloat)0.0; + if (stats->type == LINPHONE_CALL_STATS_AUDIO) + pt = linphone_call_params_get_used_audio_codec(params); + else + pt = linphone_call_params_get_used_video_codec(params); + if (!pt || (pt->clock_rate == 0)) + return (jfloat)0.0; + return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate); +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay; +} +extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { + LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + LinphoneCall *call = (LinphoneCall *)call_ptr; + rtp_stats_t rtp_stats; + + if (!stats || !call) + return (jlong)0; + memset(&rtp_stats, 0, sizeof(rtp_stats)); + if (stats->type == LINPHONE_CALL_STATS_AUDIO) + audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats); +#ifdef VIDEO_ENABLED + else + video_stream_get_local_rtp_stats(call->videostream, &rtp_stats); +#endif + return (jlong)rtp_stats.outoftime; +} +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) { + return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms; +} + +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLossRate(JNIEnv *env, jobject thiz,jlong stats_ptr) { + const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + return stats->local_loss_rate; +} + +extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLateRate(JNIEnv *env, jobject thiz, jlong stats_ptr) { + const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; + return stats->local_late_rate; +} + +extern "C" void Java_org_linphone_core_LinphoneCallStatsImpl_updateStats(JNIEnv *env, jobject thiz, jlong call_ptr, jint mediatype) { + if (mediatype==LINPHONE_CALL_STATS_AUDIO) + linphone_call_get_audio_stats((LinphoneCall*)call_ptr); + else + linphone_call_get_video_stats((LinphoneCall*)call_ptr); +} /*payloadType*/ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) { @@ -1165,7 +1615,7 @@ extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,j } extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) { PayloadType* pt = (PayloadType*)ptr; - return payload_type_get_rate(pt); + return (jint)payload_type_get_rate(pt); } //LinphoneCall @@ -1182,6 +1632,19 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* en return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env + ,jobject thiz + ,jlong ptr, jstring path) { + const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL; + linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath); +} + +extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env + ,jobject thiz + ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) { + linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy); +} + extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env ,jobject thiz ,jlong ptr) { @@ -1194,6 +1657,22 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEn return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr); } +extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) { + LinphoneCall *call = (LinphoneCall *)ptr; + const char *value=linphone_call_get_remote_user_agent(call); + jstring jvalue=NULL; + if (value) jvalue=env->NewStringUTF(value); + return jvalue; +} + +extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteContact(JNIEnv *env, jobject thiz, jlong ptr) { + LinphoneCall *call = (LinphoneCall *)ptr; + const char *value=linphone_call_get_remote_contact(call); + jstring jvalue = NULL; + if (value) jvalue=env->NewStringUTF(value); + return jvalue; +} + extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env ,jobject thiz ,jlong ptr) { @@ -1208,7 +1687,7 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr); + return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env @@ -1220,7 +1699,7 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEn extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr); + return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr); } extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env @@ -1242,9 +1721,8 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNI return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr); } - //LinphoneFriend -extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env ,jobject thiz ,jstring jFriendUri) { LinphoneFriend* lResult; @@ -1256,7 +1734,7 @@ extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIE } else { lResult = linphone_friend_new(); } - return (long)lResult; + return (jlong)lResult; } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env ,jobject thiz @@ -1264,10 +1742,10 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* en ,jlong linphoneAddress) { linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress); } -extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (long)linphone_friend_get_address((LinphoneFriend*)ptr); + return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env ,jobject thiz @@ -1278,7 +1756,7 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy( extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr); + return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env ,jobject thiz @@ -1289,12 +1767,12 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEn extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr); + return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr); } -extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env +extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env ,jobject thiz ,jlong ptr) { - return linphone_friend_get_status((LinphoneFriend*)ptr); + return (jint)linphone_friend_get_status((LinphoneFriend*)ptr); } extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env ,jobject thiz @@ -1306,22 +1784,142 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env ,jlong ptr) { linphone_friend_done((LinphoneFriend*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jlong lf) { + linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf); +} +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jstring jaddress) { + const char* address = env->GetStringUTFChars(jaddress, NULL); + LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address); + env->ReleaseStringUTFChars(jaddress, address); + return (jlong) lf; +} //LinphoneChatRoom -extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env ,jobject thiz ,jlong ptr) { - return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr); + return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr); } -extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env +extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jmessage) { const char* message = env->GetStringUTFChars(jmessage, NULL); - linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message); + LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message); env->ReleaseStringUTFChars(jmessage, message); + return (jlong) chatMessage; +} +extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + jobject ud = env->NewGlobalRef(thiz); + linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud); +} +extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + jstring jvalue =env->NewStringUTF(linphone_chat_message_get_text((LinphoneChatMessage*)ptr)); + return jvalue; +} + +extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env + ,jobject thiz + ,jlong ptr, jstring jheader_name) { + const char *name=env->GetStringUTFChars(jheader_name,NULL); + const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name); + env->ReleaseStringUTFChars(jheader_name, name); + return value ? env->NewStringUTF(value) : NULL; } +extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader(JNIEnv* env + ,jobject thiz + ,jlong ptr, jstring jheader_name, jstring jheader_value) { + const char *name=env->GetStringUTFChars(jheader_name,NULL); + const char *value=env->GetStringUTFChars(jheader_value,NULL); + linphone_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value); + env->ReleaseStringUTFChars(jheader_name, name); + env->ReleaseStringUTFChars(jheader_value, value); +} + +extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr)); + return jvalue; +} +extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jstring jurl) { + const char* url = env->GetStringUTFChars(jurl, NULL); + linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url); + env->ReleaseStringUTFChars(jurl, url); +} +extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr); +} + +extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr); +} + +extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getTime(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + return (jlong) linphone_chat_message_get_time((LinphoneChatMessage*)ptr); +} + +extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jstring jmessage) { + const char* message = env->GetStringUTFChars(jmessage, NULL); + linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message); + env->ReleaseStringUTFChars(jmessage, message); +} + +static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) { + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM\n"); + return; + } + + jobject listener = (jobject) ud; + jclass clazz = (jclass) env->GetObjectClass(listener); + jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V"); + + LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg)); + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); + env->CallVoidMethod( + listener, + method, + (jobject)linphone_chat_message_get_user_data(msg), + env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state)); + + if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) { + env->DeleteGlobalRef(listener); + } +} +extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env + ,jobject thiz + ,jlong ptr + ,jlong jmessage + ,jobject jlistener) { + jobject listener = env->NewGlobalRef(jlistener); + linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener); +} extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env ,jobject thiz ,jlong lc @@ -1358,12 +1956,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){ +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){ linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){ - return linphone_core_get_firewall_policy((LinphoneCore*)lc); + return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){ @@ -1380,6 +1978,37 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv return jvalue; } +//CallParams +extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_isLowBandwidthEnabled(JNIEnv *env, jobject thiz, jlong cp) { + return (jboolean) linphone_call_params_low_bandwidth_enabled((LinphoneCallParams *)cp); +} + +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableLowBandwidth(JNIEnv *env, jobject thiz, jlong cp, jboolean enable) { + linphone_call_params_enable_low_bandwidth((LinphoneCallParams *)cp, enable); +} + +extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) { + return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp); +} + +extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) { + return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp); +} + +extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong cp + ) { + return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp); +} + +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env + ,jobject thiz + ,jlong cp + ,jint jmenc) { + linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc); +} + extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){ linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw); } @@ -1389,11 +2018,34 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv } extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){ - return linphone_call_params_video_enabled((LinphoneCallParams*)lcp); + return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp); } extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){ - return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp); + return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp); +} + +extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){ + const char* header_name=env->GetStringUTFChars(jheader_name, NULL); + const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name); + env->ReleaseStringUTFChars(jheader_name, header_name); + return header_value ? env->NewStringUTF(header_value) : NULL; +} + +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){ + const char* header_name=env->GetStringUTFChars(jheader_name, NULL); + const char* header_value=env->GetStringUTFChars(jheader_value, NULL); + linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value); + env->ReleaseStringUTFChars(jheader_name, header_name); + env->ReleaseStringUTFChars(jheader_value, header_value); +} + +extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){ + if (jrecord_file){ + const char* record_file=env->GetStringUTFChars(jrecord_file, NULL); + linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file); + env->ReleaseStringUTFChars(jrecord_file, record_file); + }else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL); } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){ @@ -1404,6 +2056,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams } extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){ + if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) { + return (jlong) 0; + } return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc)); } @@ -1411,12 +2066,20 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JN return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc)); } -extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){ +extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){ linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b); } extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){ - linphone_call_camera_enabled((LinphoneCall *)lc); + return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCallImpl_startRecording(JNIEnv *env, jobject thiz, jlong lc){ + linphone_call_start_recording((LinphoneCall *)lc); +} + +extern "C" void Java_org_linphone_core_LinphoneCallImpl_stopRecording(JNIEnv *env, jobject thiz, jlong lc){ + linphone_call_stop_recording((LinphoneCall *)lc); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){ @@ -1432,7 +2095,6 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params); } - extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){ MSVideoSize vsize; vsize.width = (int)width; @@ -1456,6 +2118,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEn linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseSipInfoForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){ + linphone_core_set_use_info_for_dtmf((LinphoneCore *)lc, (bool) use); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseRfc2833ForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){ + linphone_core_set_use_rfc2833_for_dtmf((LinphoneCore *)lc, (bool) use); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){ linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime); } @@ -1464,15 +2134,23 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *e linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime); } -extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) { - return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr); +extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) { + return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) { linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay); } extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) { - linphone_call_get_duration((LinphoneCall *) ptr); + return (jint)linphone_call_get_duration((LinphoneCall *) ptr); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSipDscp(JNIEnv* env,jobject thiz,jlong ptr, jint dscp){ + linphone_core_set_sip_dscp((LinphoneCore*)ptr,dscp); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSipDscp(JNIEnv* env,jobject thiz,jlong ptr){ + return linphone_core_get_sip_dscp((LinphoneCore*)ptr); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) { @@ -1511,19 +2189,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNI } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { - return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); + return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_pause_all_calls((LinphoneCore *) pCore); + return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { - return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); + return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_is_in_conference((LinphoneCore *) pCore); + return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) { - return 0 == linphone_core_enter_conference((LinphoneCore *) pCore); + return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore)); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) { linphone_core_leave_conference((LinphoneCore *) pCore); @@ -1531,9 +2209,11 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv * extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) { linphone_core_add_all_to_conference((LinphoneCore *) pCore); } + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall); } + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) { linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall); } @@ -1542,8 +2222,24 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIE linphone_core_terminate_conference((LinphoneCore *) pCore); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) { - return linphone_core_get_conference_size((LinphoneCore *) pCore); + return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){ + int err=-1; + if (jpath){ + const char *path=env->GetStringUTFChars(jpath, NULL); + err=linphone_core_start_conference_recording((LinphoneCore*)pCore,path); + env->ReleaseStringUTFChars(jpath,path); + } + return err; +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_stopConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore){ + int err=linphone_core_stop_conference_recording((LinphoneCore*)pCore); + return err; } + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) { linphone_core_terminate_all_calls((LinphoneCore *) pCore); } @@ -1553,16 +2249,17 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,j return lcd->getCall(env,lCall); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) { - return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); + return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore)); } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL); - linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); + jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); env->ReleaseStringUTFChars(jReferTo, cReferTo); + return err; } -extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { - linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall); +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { + return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) { @@ -1597,7 +2294,7 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *e break; ms_message("Existing device %d : %s\n", i, devices[i]); if (i==id) { - return linphone_core_set_video_device(lc, devices[i]); + return (jint)linphone_core_set_video_device(lc, devices[i]); } } return -1; @@ -1633,7 +2330,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToke } extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) { LinphoneCall *call = (LinphoneCall *) ptr; - return linphone_call_get_authentication_token_verified(call); + return (jboolean)linphone_call_get_authentication_token_verified(call); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) { LinphoneCall *call = (LinphoneCall *) ptr; @@ -1642,19 +2339,22 @@ extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVe extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) { LinphoneCall *call = (LinphoneCall *) ptr; - return linphone_call_get_play_volume(call); + return (jfloat)linphone_call_get_play_volume(call); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){ - return linphone_core_sound_resources_locked((LinphoneCore *) ptr); + return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr); } // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working) // Implemented directly in msandroid.cpp (sound filters for Android). -extern "C" void msandroid_hack_speaker_state(bool speakerOn); - -extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){ - msandroid_hack_speaker_state(speakerOn); +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_forceSpeakerState(JNIEnv *env, jobject thiz, jlong ptr, jboolean speakerOn) { + LinphoneCore *lc = (LinphoneCore *)ptr; + LinphoneCall *call = linphone_core_get_current_call(lc); + if (call && call->audiostream && call->audiostream->soundread) { + bool_t on = speakerOn; + ms_filter_call_method(call->audiostream->soundread, MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE, &on); + } } // End Galaxy S hack functions @@ -1668,46 +2368,60 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env, extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore, jstring jHost, jint port, jint mirror, jint delay) { -#ifdef TUNNEL_ENABLED - LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; + LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; + if (!tunnel) return; + const char* cHost=env->GetStringUTFChars(jHost, NULL); - linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay); + LinphoneTunnelConfig *tunnelconfig = linphone_tunnel_config_new(); + linphone_tunnel_config_set_host(tunnelconfig, cHost); + linphone_tunnel_config_set_port(tunnelconfig, port); + linphone_tunnel_config_set_delay(tunnelconfig, delay); + linphone_tunnel_config_set_remote_udp_mirror_port(tunnelconfig, mirror); + linphone_tunnel_add_server(tunnel, tunnelconfig); env->ReleaseStringUTFChars(jHost, cHost); -#endif } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore, + jstring jHost, jint port, jstring username, jstring password) { + + LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; + if (!tunnel) return; + const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL; + const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL; + const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL; + linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword); + if (cHost) env->ReleaseStringUTFChars(jHost, cHost); + if (cUsername) env->ReleaseStringUTFChars(username, cUsername); + if (cPassword) env->ReleaseStringUTFChars(password, cPassword); +} + + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_auto_detect(tunnel); -#endif } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_clean_servers(tunnel); -#endif } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_enable(tunnel, enable); -#endif } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){ const char* cname=env->GetStringUTFChars(name, NULL); const char* cversion=env->GetStringUTFChars(version, NULL); - linphone_core_set_user_agent(cname,cversion); + linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion); env->ReleaseStringUTFChars(name, cname); env->ReleaseStringUTFChars(version, cversion); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){ - return linphone_core_tunnel_available(); + return (jboolean)linphone_core_tunnel_available(); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){ @@ -1717,6 +2431,101 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *e linphone_core_set_video_policy((LinphoneCore *)lc, &vpol); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) { + const char *cpath = env->GetStringUTFChars(path, NULL); + linphone_core_set_static_picture((LinphoneCore *)lc, cpath); + env->ReleaseStringUTFChars(path, cpath); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) { ms_set_cpu_count(count); } + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) { + linphone_core_set_audio_port((LinphoneCore *)lc, port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) { + linphone_core_set_video_port((LinphoneCore *)lc, port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) { + linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) { + linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioDscp(JNIEnv* env,jobject thiz,jlong ptr, jint dscp){ + linphone_core_set_audio_dscp((LinphoneCore*)ptr,dscp); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getAudioDscp(JNIEnv* env,jobject thiz,jlong ptr){ + return linphone_core_get_audio_dscp((LinphoneCore*)ptr); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoDscp(JNIEnv* env,jobject thiz,jlong ptr, jint dscp){ + linphone_core_set_video_dscp((LinphoneCore*)ptr,dscp); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDscp(JNIEnv* env,jobject thiz,jlong ptr){ + return linphone_core_get_video_dscp((LinphoneCore*)ptr); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) { + linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout); +} + +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) { + linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout); +} + +extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) { + jstring jvalue =env->NewStringUTF(linphone_core_get_version()); + return jvalue; +} + +extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getConfig(JNIEnv *env, jobject thiz, jlong lc) { + return (jlong) linphone_core_get_config((LinphoneCore *)lc); +} + +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_upnpAvailable(JNIEnv *env, jobject thiz, jlong lc) { + return (jboolean) linphone_core_upnp_available((LinphoneCore *)lc); +} + +extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getUpnpState(JNIEnv *env, jobject thiz, jlong lc) { + return (jint) linphone_core_get_upnp_state((LinphoneCore *)lc); +} + +extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getUpnpExternalIpaddress(JNIEnv *env, jobject thiz, jlong lc) { + jstring jvalue = env->NewStringUTF(linphone_core_get_upnp_external_ipaddress((LinphoneCore *)lc)); + return jvalue; +} + +extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImpl(JNIEnv *env, jobject thiz, jstring file) { + const char *cfile = env->GetStringUTFChars(file, NULL); + LpConfig *lp = lp_config_new(cfile); + env->ReleaseStringUTFChars(file, cfile); + return (jlong) lp; +} + +extern "C" void Java_org_linphone_core_LpConfigImpl_sync(JNIEnv *env, jobject thiz, jlong lpc) { + LpConfig *lp = (LpConfig *)lpc; + lp_config_sync(lp); +} + +extern "C" void Java_org_linphone_core_LpConfigImpl_delete(JNIEnv *env, jobject thiz, jlong lpc) { + LpConfig *lp = (LpConfig *)lpc; + lp_config_destroy(lp); +} + +extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc, + jstring section, jstring key, jint value) { + const char *csection = env->GetStringUTFChars(section, NULL); + const char *ckey = env->GetStringUTFChars(key, NULL); + lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value); + env->ReleaseStringUTFChars(section, csection); + env->ReleaseStringUTFChars(key, ckey); +} +