3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
24 #include "linphone_tunnel.h"
28 #include "mediastreamer2/mediastream.h"
30 #include "mediastreamer2/msjava.h"
32 #include <cpu-features.h>
35 #include <android/log.h>
36 extern "C" void libmsilbc_init();
38 extern "C" void libmsx264_init();
41 extern "C" void libmsamr_init();
44 extern "C" void libmssilk_init();
47 extern "C" void libmsbcg729_init();
54 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
57 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
58 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
59 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
60 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
61 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
62 default: prio = ANDROID_LOG_DEFAULT; break;
64 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
67 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
68 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
72 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
78 return JNI_VERSION_1_2;
83 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
87 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
89 linphone_core_disable_logs();
94 class LinphoneCoreData {
96 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
98 core = env->NewGlobalRef(lc);
99 listener = env->NewGlobalRef(alistener);
100 userdata = auserdata?env->NewGlobalRef(auserdata):0;
101 memset(&vTable,0,sizeof(vTable));
102 vTable.show = showInterfaceCb;
103 vTable.auth_info_requested = authInfoRequested;
104 vTable.display_status = displayStatusCb;
105 vTable.display_message = displayMessageCb;
106 vTable.display_warning = displayMessageCb;
107 vTable.global_state_changed = globalStateChange;
108 vTable.registration_state_changed = registrationStateChange;
109 vTable.call_state_changed = callStateChange;
110 vTable.call_encryption_changed = callEncryptionChange;
111 vTable.text_received = text_received;
112 vTable.new_subscription_request = new_subscription_request;
113 vTable.notify_presence_recv = notify_presence_recv;
115 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
117 /*displayStatus(LinphoneCore lc,String message);*/
118 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
120 /*void generalState(LinphoneCore lc,int state); */
121 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
122 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
123 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
125 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
126 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
127 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
128 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
130 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
131 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
132 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
133 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
135 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
136 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
138 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
139 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
141 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
142 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
143 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
144 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
146 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
147 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
149 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
150 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
152 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
153 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
155 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
156 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
158 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
159 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
161 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
162 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
164 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
165 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
167 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
168 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
172 ~LinphoneCoreData() {
174 jvm->AttachCurrentThread(&env,NULL);
175 env->DeleteGlobalRef(core);
176 env->DeleteGlobalRef(listener);
177 if (userdata) env->DeleteGlobalRef(userdata);
178 env->DeleteGlobalRef(listenerClass);
179 env->DeleteGlobalRef(globalStateClass);
180 env->DeleteGlobalRef(registrationStateClass);
181 env->DeleteGlobalRef(callStateClass);
182 env->DeleteGlobalRef(chatMessageStateClass);
183 env->DeleteGlobalRef(proxyClass);
184 env->DeleteGlobalRef(callClass);
185 env->DeleteGlobalRef(chatRoomClass);
186 env->DeleteGlobalRef(friendClass);
193 jclass listenerClass;
194 jmethodID displayStatusId;
195 jmethodID newSubscriptionRequestId;
196 jmethodID notifyPresenceReceivedId;
197 jmethodID textReceivedId;
199 jclass globalStateClass;
200 jmethodID globalStateId;
201 jmethodID globalStateFromIntId;
203 jclass registrationStateClass;
204 jmethodID registrationStateId;
205 jmethodID registrationStateFromIntId;
207 jclass callStateClass;
208 jmethodID callStateId;
209 jmethodID callStateFromIntId;
211 jclass chatMessageStateClass;
212 jmethodID chatMessageStateFromIntId;
214 jmethodID callEncryptionChangedId;
216 jclass ecCalibratorStatusClass;
217 jmethodID ecCalibrationStatusId;
218 jmethodID ecCalibratorStatusFromIntId;
221 jmethodID proxyCtrId;
226 jclass chatRoomClass;
227 jmethodID chatRoomCtrId;
230 jmethodID friendCtrId;
233 jmethodID addressCtrId;
235 LinphoneCoreVTable vTable;
237 static void showInterfaceCb(LinphoneCore *lc) {
240 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
243 static void displayStatusCb(LinphoneCore *lc, const char *message) {
245 jint result = jvm->AttachCurrentThread(&env,NULL);
247 ms_error("cannot attach VM\n");
250 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
251 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
253 static void displayMessageCb(LinphoneCore *lc, const char *message) {
256 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
259 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
261 jint result = jvm->AttachCurrentThread(&env,NULL);
263 ms_error("cannot attach VM\n");
266 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
267 env->CallVoidMethod(lcData->listener
268 ,lcData->globalStateId
270 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
271 message ? env->NewStringUTF(message) : NULL);
273 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
275 jint result = jvm->AttachCurrentThread(&env,NULL);
277 ms_error("cannot attach VM\n");
280 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
281 env->CallVoidMethod(lcData->listener
282 ,lcData->registrationStateId
284 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
285 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
286 message ? env->NewStringUTF(message) : NULL);
288 jobject getCall(JNIEnv *env , LinphoneCall *call){
292 void *up=linphone_call_get_user_pointer(call);
295 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
296 jobj=env->NewGlobalRef(jobj);
297 linphone_call_set_user_pointer(call,(void*)jobj);
298 linphone_call_ref(call);
306 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
308 jint result = jvm->AttachCurrentThread(&env,NULL);
311 ms_error("cannot attach VM\n");
314 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
315 env->CallVoidMethod(lcData->listener
318 ,(jcall=lcData->getCall(env,call))
319 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
320 message ? env->NewStringUTF(message) : NULL);
321 if (state==LinphoneCallReleased){
322 linphone_call_set_user_pointer(call,NULL);
323 env->DeleteGlobalRef(jcall);
326 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
328 jint result = jvm->AttachCurrentThread(&env,NULL);
330 ms_error("cannot attach VM\n");
333 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
334 env->CallVoidMethod(lcData->listener
335 ,lcData->callEncryptionChangedId
337 ,lcData->getCall(env,call)
339 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
341 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
343 jint result = jvm->AttachCurrentThread(&env,NULL);
345 ms_error("cannot attach VM\n");
348 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
349 env->CallVoidMethod(lcData->listener
350 ,lcData->notifyPresenceReceivedId
352 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
354 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
356 jint result = jvm->AttachCurrentThread(&env,NULL);
358 ms_error("cannot attach VM\n");
361 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
362 env->CallVoidMethod(lcData->listener
363 ,lcData->newSubscriptionRequestId
365 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
366 ,url ? env->NewStringUTF(url) : NULL);
368 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
370 jint result = jvm->AttachCurrentThread(&env,NULL);
372 ms_error("cannot attach VM\n");
375 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
376 env->CallVoidMethod(lcData->listener
377 ,lcData->textReceivedId
379 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
380 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
381 ,message ? env->NewStringUTF(message) : NULL);
383 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
385 jint result = jvm->AttachCurrentThread(&env,NULL);
387 ms_error("cannot attach VM\n");
390 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
391 env->CallVoidMethod(lcData->listener
392 ,lcData->ecCalibrationStatusId
394 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
396 ,data ? data : NULL);
397 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
398 //final state, releasing global ref
399 env->DeleteGlobalRef((jobject)data);
406 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
410 ,jstring jfactoryConfig
413 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
414 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
415 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
418 libmsilbc_init(); // requires an fpu
432 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
436 //clear auth info list
437 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
438 //clear existing proxy config
439 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
441 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
442 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
445 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
448 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
449 linphone_core_destroy((LinphoneCore*)lc);
453 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
454 linphone_core_clear_proxy_config((LinphoneCore*)lc);
457 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
461 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
463 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
466 LinphoneProxyConfig *config=0;
467 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
468 return (jlong)config;
471 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
472 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
473 int proxyCount = ms_list_size(proxies);
474 jlongArray jProxies = env->NewLongArray(proxyCount);
475 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
477 for (int i = 0; i < proxyCount; i++ ) {
478 jInternalArray[i] = (unsigned long) (proxies->data);
479 proxies = proxies->next;
482 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
487 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
492 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
493 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
495 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
498 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
499 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
502 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
503 linphone_core_refresh_registers((LinphoneCore*)lc);
506 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
510 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
512 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
515 linphone_core_iterate((LinphoneCore*)lc);
517 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
521 const char* uri = env->GetStringUTFChars(juri, NULL);
522 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
523 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
524 env->ReleaseStringUTFChars(juri, uri);
525 return lcd->getCall(env,lCall);
527 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
531 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
532 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
535 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
539 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
542 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
545 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
547 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
551 return linphone_core_in_call((LinphoneCore*)lc);
553 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
557 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
559 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
564 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
567 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
572 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
575 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
580 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
583 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
587 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
590 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
594 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
596 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
599 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
601 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
604 ,jboolean isReachable) {
605 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
608 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
611 return linphone_core_is_network_reachable((LinphoneCore*)lc);
614 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
618 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
621 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
624 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
627 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
631 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
634 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
638 const char* url = env->GetStringUTFChars(jurl, NULL);
639 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
640 env->ReleaseStringUTFChars(jurl, url);
643 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
647 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
654 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
656 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
659 linphone_core_stop_dtmf((LinphoneCore*)lc);
662 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
665 linphone_core_get_missed_calls_count((LinphoneCore*)lc);
668 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
671 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
674 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
676 ,jlong lc, jlong log) {
677 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
680 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
683 linphone_core_clear_call_logs((LinphoneCore*)lc);
685 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
688 return linphone_core_is_mic_muted((LinphoneCore*)lc);
690 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
696 const char* mime = env->GetStringUTFChars(jmime, NULL);
697 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
698 env->ReleaseStringUTFChars(jmime, mime);
701 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
704 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
705 int codecsCount = ms_list_size(codecs);
706 jlongArray jCodecs = env->NewLongArray(codecsCount);
707 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
709 for (int i = 0; i < codecsCount; i++ ) {
710 jInternalArray[i] = (unsigned long) (codecs->data);
711 codecs = codecs->next;
714 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
719 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
722 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
723 int codecsCount = ms_list_size(codecs);
724 jlongArray jCodecs = env->NewLongArray(codecsCount);
725 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
727 for (int i = 0; i < codecsCount; i++ ) {
728 jInternalArray[i] = (unsigned long) (codecs->data);
729 codecs = codecs->next;
732 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
737 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
742 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
744 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
748 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
750 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
754 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
756 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
760 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
763 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
767 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
770 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
774 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
776 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
778 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
783 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
785 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
789 ,jstring jalternative_contact
791 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
792 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
793 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
796 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
801 const char* to = env->GetStringUTFChars(jto, NULL);
802 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
803 env->ReleaseStringUTFChars(jto, to);
804 return (long)lResult;
807 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
810 ,jboolean vcap_enabled
811 ,jboolean display_enabled) {
812 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
815 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
818 return linphone_core_video_enabled((LinphoneCore*)lc);
820 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
824 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
825 linphone_core_set_play_file((LinphoneCore*)lc,path);
826 if (path) env->ReleaseStringUTFChars(jpath, path);
828 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
832 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
833 linphone_core_set_ring((LinphoneCore*)lc,path);
834 if (path) env->ReleaseStringUTFChars(jpath, path);
836 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
840 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
842 return env->NewStringUTF(path);
847 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
851 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
852 linphone_core_set_root_ca((LinphoneCore*)lc,path);
853 if (path) env->ReleaseStringUTFChars(jpath, path);
855 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
859 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
862 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
865 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
868 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
872 return linphone_core_start_echo_calibration((LinphoneCore*)lc
873 , LinphoneCoreData::ecCalibrationStatus
874 , data?env->NewGlobalRef(data):NULL);
878 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
882 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
885 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
889 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
892 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
896 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
899 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
903 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
906 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
910 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
913 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
917 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
920 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
925 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
930 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
931 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
932 return (jlong) proxy;
935 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
936 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
938 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
939 const char* identity = env->GetStringUTFChars(jidentity, NULL);
940 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
941 env->ReleaseStringUTFChars(jidentity, identity);
943 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
944 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
946 return env->NewStringUTF(identity);
951 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
952 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
953 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
954 env->ReleaseStringUTFChars(jproxy, proxy);
957 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
958 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
960 return env->NewStringUTF(proxy);
965 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
966 const char* params = env->GetStringUTFChars(jparams, NULL);
967 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
968 env->ReleaseStringUTFChars(jparams, params);
970 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
971 if (jroute != NULL) {
972 const char* route = env->GetStringUTFChars(jroute, NULL);
973 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
974 env->ReleaseStringUTFChars(jroute, route);
977 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
980 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
981 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
983 return env->NewStringUTF(route);
989 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
990 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
992 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
993 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
995 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
996 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
998 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
999 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1001 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1002 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1004 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1006 ms_error("cannot normalized null number");
1008 const char* number = env->GetStringUTFChars(jnumber, NULL);
1009 int len = env->GetStringLength(jnumber);
1011 ms_warning("cannot normalize empty number");
1014 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1015 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1016 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1017 env->ReleaseStringUTFChars(jnumber, number);
1018 return normalizedNumber;
1020 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1023 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1025 return env->NewStringUTF(domain);
1030 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1031 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1034 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1038 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1039 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1040 env->ReleaseStringUTFChars(jprefix, prefix);
1042 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1046 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1048 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1049 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1054 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1062 const char* username = env->GetStringUTFChars(jusername, NULL);
1063 const char* password = env->GetStringUTFChars(jpassword, NULL);
1064 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1066 env->ReleaseStringUTFChars(jusername, username);
1067 env->ReleaseStringUTFChars(jpassword, password);
1071 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1074 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1079 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1082 ,jstring jdisplayName) {
1083 const char* uri = env->GetStringUTFChars(juri, NULL);
1084 LinphoneAddress* address = linphone_address_new(uri);
1085 if (jdisplayName && address) {
1086 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1087 linphone_address_set_display_name(address,displayName);
1088 env->ReleaseStringUTFChars(jdisplayName, displayName);
1090 env->ReleaseStringUTFChars(juri, uri);
1092 return (jlong) address;
1094 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1097 linphone_address_destroy((LinphoneAddress*)ptr);
1100 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1103 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1105 return env->NewStringUTF(displayName);
1110 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1113 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1115 return env->NewStringUTF(userName);
1120 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1123 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1125 return env->NewStringUTF(domain);
1131 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1134 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1135 jstring juri =env->NewStringUTF(uri);
1139 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1142 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1143 jstring juri =env->NewStringUTF(uri);
1147 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1150 ,jstring jdisplayName) {
1151 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1152 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1153 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1158 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1161 return (jlong)((LinphoneCallLog*)ptr)->from;
1163 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1166 return (jlong)((LinphoneCallLog*)ptr)->status;
1168 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1171 return (jlong)((LinphoneCallLog*)ptr)->to;
1173 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1176 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1178 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1181 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1184 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1187 return ((LinphoneCallLog*)ptr)->duration;
1191 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1192 PayloadType* pt = (PayloadType*)ptr;
1193 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1194 ,payload_type_get_mime(pt)
1195 ,payload_type_get_rate(pt)
1196 ,payload_type_get_bitrate(pt));
1197 jstring jvalue =env->NewStringUTF(value);
1201 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1202 PayloadType* pt = (PayloadType*)ptr;
1203 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1206 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1207 PayloadType* pt = (PayloadType*)ptr;
1208 return payload_type_get_rate(pt);
1212 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1215 LinphoneCall *call=(LinphoneCall*)ptr;
1216 linphone_call_unref(call);
1219 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1222 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1225 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1227 ,jlong ptr, jstring path) {
1228 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1229 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1232 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1234 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1235 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1238 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1241 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1244 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1247 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1250 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1253 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1255 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1259 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1261 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1264 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1267 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1271 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1273 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1276 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1279 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1282 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1283 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1286 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1289 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1292 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1295 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1300 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1302 ,jstring jFriendUri) {
1303 LinphoneFriend* lResult;
1306 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1307 lResult= linphone_friend_new_with_addr(friendUri);
1308 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1310 lResult = linphone_friend_new();
1312 return (long)lResult;
1314 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1317 ,jlong linphoneAddress) {
1318 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1320 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1323 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1325 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1329 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1331 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1334 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1336 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1340 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1342 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1345 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1347 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1350 return linphone_friend_get_status((LinphoneFriend*)ptr);
1352 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1355 return linphone_friend_edit((LinphoneFriend*)ptr);
1357 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1360 linphone_friend_done((LinphoneFriend*)ptr);
1363 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1366 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1368 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1371 ,jstring jmessage) {
1372 const char* message = env->GetStringUTFChars(jmessage, NULL);
1373 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1374 env->ReleaseStringUTFChars(jmessage, message);
1376 return (jlong) chatMessage;
1378 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1382 jobject ud = env->NewGlobalRef(thiz);
1383 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1385 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1388 ,jstring jmessage) {
1389 const char* message = env->GetStringUTFChars(jmessage, NULL);
1390 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1391 env->ReleaseStringUTFChars(jmessage, message);
1394 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1396 jint result = jvm->AttachCurrentThread(&env,NULL);
1398 ms_error("cannot attach VM\n");
1402 jobject listener = (jobject) ud;
1403 jclass clazz = (jclass) env->GetObjectClass(listener);
1404 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1406 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1407 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1408 env->CallVoidMethod(
1411 (jobject)linphone_chat_message_get_user_data(msg),
1412 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1414 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1415 env->DeleteGlobalRef(listener);
1418 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1422 ,jobject jlistener) {
1423 jobject listener = env->NewGlobalRef(jlistener);
1424 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1426 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1430 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1431 if (oldWindow != NULL) {
1432 env->DeleteGlobalRef(oldWindow);
1435 obj = env->NewGlobalRef(obj);
1437 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1440 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1444 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1445 if (oldWindow != NULL) {
1446 env->DeleteGlobalRef(oldWindow);
1449 obj = env->NewGlobalRef(obj);
1451 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1454 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1458 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1462 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1463 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1466 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1467 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1470 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1471 const char* server = NULL;
1472 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1473 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1474 if (server) env->ReleaseStringUTFChars(jserver,server);
1477 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1478 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1479 if (ret==NULL) return NULL;
1480 jstring jvalue =env->NewStringUTF(ret);
1484 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1485 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1488 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1489 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1492 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1493 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1496 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1497 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1500 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1501 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1503 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1504 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1507 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1508 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1511 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1512 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1515 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1516 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1519 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1520 linphone_call_camera_enabled((LinphoneCall *)lc);
1523 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1524 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1525 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1528 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1529 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1532 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1533 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1537 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1539 vsize.width = (int)width;
1540 vsize.height = (int)height;
1541 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1544 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1545 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1546 jintArray arr = env->NewIntArray(2);
1547 int tVsize [2]= {vsize.width,vsize.height};
1548 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1553 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1556 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1557 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1560 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1561 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1564 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1565 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1568 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1569 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1571 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1572 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1575 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1576 linphone_call_get_duration((LinphoneCall *) ptr);
1579 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1581 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1594 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1595 LinphoneCore *lc = (LinphoneCore *) ptr;
1601 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1604 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1605 ,jlong lc, jboolean enable) {
1606 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1610 ,jlong ptr, jint db) {
1611 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1614 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1615 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1617 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1618 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1620 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1621 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1623 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1624 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1626 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1627 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1629 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1630 linphone_core_leave_conference((LinphoneCore *) pCore);
1632 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1633 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1635 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1636 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1638 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1639 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1642 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1643 linphone_core_terminate_conference((LinphoneCore *) pCore);
1645 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1646 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1648 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1649 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1651 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1652 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1653 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1654 return lcd->getCall(env,lCall);
1656 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1657 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1660 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1661 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1662 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1663 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1665 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1666 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1669 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1671 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1672 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1673 env->ReleaseStringUTFChars(jFile, cFile);
1675 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1679 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1680 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1681 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1682 env->ReleaseStringUTFChars(jUri, cUri);
1683 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1684 return (jobject) lcdata->getCall(env,call);
1688 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1689 LinphoneCore* lc = (LinphoneCore *) pCore;
1690 const char** devices = linphone_core_get_video_devices(lc);
1691 if (devices == NULL) {
1692 ms_error("No existing video devices\n");
1696 for(i=0; i<=id; i++) {
1697 if (devices[i] == NULL)
1699 ms_message("Existing device %d : %s\n", i, devices[i]);
1701 return linphone_core_set_video_device(lc, devices[i]);
1707 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1708 LinphoneCore* lc = (LinphoneCore *) pCore;
1709 const char** devices = linphone_core_get_video_devices(lc);
1710 if (devices == NULL) {
1711 ms_error("No existing video devices\n");
1714 const char* cam = linphone_core_get_video_device(lc);
1716 ms_error("No current video device\n");
1719 while(devices[i] != NULL) {
1720 if (strcmp(devices[i], cam) == 0)
1725 ms_warning("Returning default (0) device\n");
1729 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1730 LinphoneCall *call = (LinphoneCall *) ptr;
1731 const char* token = linphone_call_get_authentication_token(call);
1732 if (token == NULL) return NULL;
1733 return env->NewStringUTF(token);
1735 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1736 LinphoneCall *call = (LinphoneCall *) ptr;
1737 return linphone_call_get_authentication_token_verified(call);
1739 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1740 LinphoneCall *call = (LinphoneCall *) ptr;
1741 linphone_call_set_authentication_token_verified(call, verified);
1744 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1745 LinphoneCall *call = (LinphoneCall *) ptr;
1746 return linphone_call_get_play_volume(call);
1749 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1750 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1753 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1754 // Implemented directly in msandroid.cpp (sound filters for Android).
1755 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1757 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1758 msandroid_hack_speaker_state(speakerOn);
1760 // End Galaxy S hack functions
1763 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1764 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1766 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1767 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1770 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1771 jstring jHost, jint port, jint mirror, jint delay) {
1772 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1773 if (!tunnel) return;
1774 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1775 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1776 env->ReleaseStringUTFChars(jHost, cHost);
1779 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1780 jstring jHost, jint port, jstring username, jstring password) {
1782 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1783 if (!tunnel) return;
1784 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1785 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1786 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1787 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1788 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1789 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1790 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1794 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1795 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1796 linphone_tunnel_auto_detect(tunnel);
1800 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1801 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1802 linphone_tunnel_clean_servers(tunnel);
1805 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1806 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1807 linphone_tunnel_enable(tunnel, enable);
1811 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
1812 const char* cname=env->GetStringUTFChars(name, NULL);
1813 const char* cversion=env->GetStringUTFChars(version, NULL);
1814 linphone_core_set_user_agent(cname,cversion);
1815 env->ReleaseStringUTFChars(name, cname);
1816 env->ReleaseStringUTFChars(version, cversion);
1819 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1820 return linphone_core_tunnel_available();
1823 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1824 LinphoneVideoPolicy vpol;
1825 vpol.automatically_initiate = autoInitiate;
1826 vpol.automatically_accept = autoAccept;
1827 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
1830 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
1831 ms_set_cpu_count(count);
1834 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
1835 jstring jvalue =env->NewStringUTF(linphone_core_get_version());