X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=coreapi%2Flinphonecore_jni.cc;h=02ac62c7a8498c546a1d49f557b7fe1cca97dabc;hb=e1830ee3077b47d1557a1292e8c8b80cd01fc403;hp=85bd102595b2d5c5b004199c10bc623e00f003d9;hpb=cc07a4336f1dd227d5d1d847e51c20f99e20b654;p=linphone diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 85bd1025..02ac62c7 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -23,9 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphonecore_utils.h" #include -#ifdef TUNNEL_ENABLED -#include "linphone_tunnel.h" -#endif extern "C" { #include "mediastreamer2/mediastream.h" @@ -34,6 +31,8 @@ extern "C" { #include "private.h" #include +#include "lpconfig.h" + #ifdef ANDROID #include extern "C" void libmsilbc_init(); @@ -52,13 +51,31 @@ 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){ - int prio; - char str[4096]; +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; case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break; @@ -67,19 +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; } - vsnprintf(str, sizeof(str) - 1, fmt, args); - str[sizeof(str) - 1] = '\0'; - if (strlen(str) < 512) { - __android_log_write(prio, LOG_DOMAIN, str); - } else { - current = str; - while ((next = strchr(current, '\n')) != NULL) { - *next = '\0'; - __android_log_write(prio, LOG_DOMAIN, current); - current = next + 1; - } - __android_log_write(prio, LOG_DOMAIN, current); - } + linphone_android_log_handler(prio, fmt, args); } int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() { @@ -100,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(); } @@ -525,10 +532,6 @@ 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); @@ -542,6 +545,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env delete lcData; } +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); } @@ -631,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) { @@ -703,6 +729,13 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReacha 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 @@ -963,10 +996,24 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI ,jobject data) { return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc , LinphoneCoreData::ecCalibrationStatus + , NULL + , NULL , data?env->NewGlobalRef(data):NULL); } +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 @@ -1101,6 +1148,12 @@ extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso( 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) { @@ -1136,33 +1189,150 @@ extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnable //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* userid = env->GetStringUTFChars(juserid, NULL); - const char* password = env->GetStringUTFChars(jpassword, NULL); - const char* ha1 = env->GetStringUTFChars(jha1, NULL); - const char* realm = env->GetStringUTFChars(jrealm, NULL); - jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm); - - env->ReleaseStringUTFChars(jusername, username); - env->ReleaseStringUTFChars(juserid, userid); - env->ReleaseStringUTFChars(jpassword, password); - env->ReleaseStringUTFChars(jha1, ha1); - env->ReleaseStringUTFChars(jrealm, realm); - 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 @@ -1271,6 +1441,11 @@ extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEn 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) { @@ -1326,7 +1501,7 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRa } extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) { LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr; - const LinphoneCall *call = (LinphoneCall *)call_ptr; + LinphoneCall *call = (LinphoneCall *)call_ptr; const LinphoneCallParams *params; const PayloadType *pt; const report_block_t *srb = NULL; @@ -1349,11 +1524,13 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarr 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; - const LinphoneCall *call = (LinphoneCall *)call_ptr; + LinphoneCall *call = (LinphoneCall *)call_ptr; const LinphoneCallParams *params; const PayloadType *pt; const report_block_t *rrb = NULL; @@ -1376,6 +1553,8 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverIntera 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) { @@ -1401,6 +1580,23 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSi 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) { PayloadType* pt = (PayloadType*)ptr; @@ -1461,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) { @@ -1509,7 +1721,6 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNI return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr); } - //LinphoneFriend extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env ,jobject thiz @@ -1610,12 +1821,32 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEn jobject ud = env->NewGlobalRef(thiz); linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud); } -extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env +extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env ,jobject thiz ,jlong ptr) { - jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)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) { @@ -1635,11 +1866,19 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* ,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 @@ -1740,6 +1979,13 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv } //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); @@ -1779,6 +2025,29 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenc 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){ return linphone_call_params_destroy((LinphoneCallParams*)lc); } @@ -1805,6 +2074,14 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv 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){ LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc); return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params)); @@ -1818,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; @@ -1842,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); } @@ -1861,6 +2145,14 @@ extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env 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) { LCSipTransports tr; linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr); @@ -1917,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); } @@ -1930,6 +2224,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIE extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong 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); } @@ -2038,10 +2348,13 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked // 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 @@ -2057,8 +2370,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror jstring jHost, jint port, jint mirror, jint delay) { 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); } @@ -2080,7 +2399,6 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEn extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) { LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_auto_detect(tunnel); - } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) { @@ -2097,7 +2415,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env 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); } @@ -2113,6 +2431,12 @@ 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); } @@ -2133,6 +2457,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv 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); } @@ -2145,3 +2485,47 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* e 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); +} +