]> sjero.net Git - linphone/blob - coreapi/linphonecore_jni.cc
Added missing JNI method refreshRegisters
[linphone] / coreapi / linphonecore_jni.cc
1 /*
2 linphonecore_jni.cc
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
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.
9
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.
14
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.
18  */
19 #include <jni.h>
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
22
23 #ifdef TUNNEL_ENABLED
24 #include "linphone_tunnel.h"
25 #endif
26
27 extern "C" {
28 #include "mediastreamer2/mediastream.h"
29 }
30 #include "mediastreamer2/msjava.h"
31 #include "private.h"
32 #include <cpu-features.h>
33
34 #ifdef ANDROID
35 #include <android/log.h>
36 extern "C" void libmsilbc_init();
37 #ifdef HAVE_X264
38 extern "C" void libmsx264_init();
39 #endif
40 #ifdef HAVE_AMR
41 extern "C" void libmsamr_init();
42 #endif
43 #ifdef HAVE_SILK
44 extern "C" void libmssilk_init();
45 #endif
46 #ifdef HAVE_G729
47 extern "C" void libmsbcg729_init();
48 #endif
49 #endif /*ANDROID*/
50
51 static JavaVM *jvm=0;
52
53 #ifdef ANDROID
54 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
55         int prio;
56         switch(lev){
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;
63         }
64         __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
65 }
66
67 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
68         return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
69 }
70 #endif /*ANDROID*/
71
72 JNIEXPORT jint JNICALL  JNI_OnLoad(JavaVM *ajvm, void *reserved)
73 {
74 #ifdef ANDROID
75         ms_set_jvm(ajvm);
76 #endif /*ANDROID*/
77         jvm=ajvm;
78         return JNI_VERSION_1_2;
79 }
80
81
82 //LinphoneFactory
83 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv*  env
84                 ,jobject  thiz
85                 ,jboolean isDebug) {
86         if (isDebug) {
87                 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
88         } else {
89                 linphone_core_disable_logs();
90         }
91 }
92 // LinphoneCore
93
94 class LinphoneCoreData {
95 public:
96         LinphoneCoreData(JNIEnv*  env, jobject lc,jobject alistener, jobject auserdata) {
97
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;
114
115                 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
116
117                 /*displayStatus(LinphoneCore lc,String message);*/
118                 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
119
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;");
124
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;");
129
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;");
134
135                 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
136                 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
137
138                 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
139                 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
140                 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
141                 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
142
143                 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
144                 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
145
146                 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
147                 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
148
149                 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
150                 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
151
152                 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
153                 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
154
155                 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
156                 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
157
158                 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
159                 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
160
161                 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
162                 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
163
164                 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
165                 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
166
167         }
168
169         ~LinphoneCoreData() {
170                 JNIEnv *env = 0;
171                 jvm->AttachCurrentThread(&env,NULL);
172                 env->DeleteGlobalRef(core);
173                 env->DeleteGlobalRef(listener);
174                 if (userdata) env->DeleteGlobalRef(userdata);
175                 env->DeleteGlobalRef(listenerClass);
176                 env->DeleteGlobalRef(globalStateClass);
177                 env->DeleteGlobalRef(registrationStateClass);
178                 env->DeleteGlobalRef(callStateClass);
179                 env->DeleteGlobalRef(proxyClass);
180                 env->DeleteGlobalRef(callClass);
181                 env->DeleteGlobalRef(chatRoomClass);
182                 env->DeleteGlobalRef(friendClass);
183
184         }
185         jobject core;
186         jobject listener;
187         jobject userdata;
188
189         jclass listenerClass;
190         jmethodID displayStatusId;
191         jmethodID newSubscriptionRequestId;
192         jmethodID notifyPresenceReceivedId;
193         jmethodID textReceivedId;
194
195         jclass globalStateClass;
196         jmethodID globalStateId;
197         jmethodID globalStateFromIntId;
198
199         jclass registrationStateClass;
200         jmethodID registrationStateId;
201         jmethodID registrationStateFromIntId;
202
203         jclass callStateClass;
204         jmethodID callStateId;
205         jmethodID callStateFromIntId;
206
207         jmethodID callEncryptionChangedId;
208
209         jclass ecCalibratorStatusClass;
210         jmethodID ecCalibrationStatusId;
211         jmethodID ecCalibratorStatusFromIntId;
212
213         jclass proxyClass;
214         jmethodID proxyCtrId;
215
216         jclass callClass;
217         jmethodID callCtrId;
218
219         jclass chatRoomClass;
220         jmethodID chatRoomCtrId;
221
222         jclass friendClass;
223         jmethodID friendCtrId;
224
225         jclass addressClass;
226         jmethodID addressCtrId;
227
228         LinphoneCoreVTable vTable;
229
230         static void showInterfaceCb(LinphoneCore *lc) {
231
232         }
233         static void byeReceivedCb(LinphoneCore *lc, const char *from) {
234
235         }
236         static void displayStatusCb(LinphoneCore *lc, const char *message) {
237                 JNIEnv *env = 0;
238                 jint result = jvm->AttachCurrentThread(&env,NULL);
239                 if (result != 0) {
240                         ms_error("cannot attach VM\n");
241                         return;
242                 }
243                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
244                 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
245         }
246         static void displayMessageCb(LinphoneCore *lc, const char *message) {
247
248         }
249         static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
250
251         }
252         static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
253                 JNIEnv *env = 0;
254                 jint result = jvm->AttachCurrentThread(&env,NULL);
255                 if (result != 0) {
256                         ms_error("cannot attach VM\n");
257                         return;
258                 }
259                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
260                 env->CallVoidMethod(lcData->listener
261                                                         ,lcData->globalStateId
262                                                         ,lcData->core
263                                                         ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
264                                                         message ? env->NewStringUTF(message) : NULL);
265         }
266         static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
267                 JNIEnv *env = 0;
268                 jint result = jvm->AttachCurrentThread(&env,NULL);
269                 if (result != 0) {
270                         ms_error("cannot attach VM\n");
271                         return;
272                 }
273                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
274                 env->CallVoidMethod(lcData->listener
275                                                         ,lcData->registrationStateId
276                                                         ,lcData->core
277                                                         ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
278                                                         ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
279                                                         message ? env->NewStringUTF(message) : NULL);
280         }
281         jobject getCall(JNIEnv *env , LinphoneCall *call){
282                 jobject jobj=0;
283
284                 if (call!=NULL){
285                         void *up=linphone_call_get_user_pointer(call);
286                         
287                         if (up==NULL){
288                                 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
289                                 jobj=env->NewGlobalRef(jobj);
290                                 linphone_call_set_user_pointer(call,(void*)jobj);
291                                 linphone_call_ref(call);
292                         }else{
293                                 jobj=(jobject)up;
294                         }
295                 }
296                 return jobj;
297         }
298
299         static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
300                 JNIEnv *env = 0;
301                 jint result = jvm->AttachCurrentThread(&env,NULL);
302                 jobject jcall;
303                 if (result != 0) {
304                         ms_error("cannot attach VM\n");
305                         return;
306                 }
307                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
308                 env->CallVoidMethod(lcData->listener
309                                                         ,lcData->callStateId
310                                                         ,lcData->core
311                                                         ,(jcall=lcData->getCall(env,call))
312                                                         ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
313                                                         message ? env->NewStringUTF(message) : NULL);
314                 if (state==LinphoneCallReleased){
315                         linphone_call_set_user_pointer(call,NULL);
316                         env->DeleteGlobalRef(jcall);
317                 }
318         }
319         static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
320                 JNIEnv *env = 0;
321                 jint result = jvm->AttachCurrentThread(&env,NULL);
322                 if (result != 0) {
323                         ms_error("cannot attach VM\n");
324                         return;
325                 }
326                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
327                 env->CallVoidMethod(lcData->listener
328                                                         ,lcData->callEncryptionChangedId
329                                                         ,lcData->core
330                                                         ,lcData->getCall(env,call)
331                                                         ,encrypted
332                                                         ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
333         }
334         static void notify_presence_recv (LinphoneCore *lc,  LinphoneFriend *my_friend) {
335                 JNIEnv *env = 0;
336                 jint result = jvm->AttachCurrentThread(&env,NULL);
337                 if (result != 0) {
338                         ms_error("cannot attach VM\n");
339                         return;
340                 }
341                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
342                 env->CallVoidMethod(lcData->listener
343                                                         ,lcData->notifyPresenceReceivedId
344                                                         ,lcData->core
345                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
346         }
347         static void new_subscription_request (LinphoneCore *lc,  LinphoneFriend *my_friend, const char* url) {
348                 JNIEnv *env = 0;
349                 jint result = jvm->AttachCurrentThread(&env,NULL);
350                 if (result != 0) {
351                         ms_error("cannot attach VM\n");
352                         return;
353                 }
354                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
355                 env->CallVoidMethod(lcData->listener
356                                                         ,lcData->newSubscriptionRequestId
357                                                         ,lcData->core
358                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
359                                                         ,url ? env->NewStringUTF(url) : NULL);
360         }
361         static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
362                 JNIEnv *env = 0;
363                 jint result = jvm->AttachCurrentThread(&env,NULL);
364                 if (result != 0) {
365                         ms_error("cannot attach VM\n");
366                         return;
367                 }
368                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
369                 env->CallVoidMethod(lcData->listener
370                                                         ,lcData->textReceivedId
371                                                         ,lcData->core
372                                                         ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
373                                                         ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
374                                                         ,message ? env->NewStringUTF(message) : NULL);
375         }
376         static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
377                 JNIEnv *env = 0;
378                 jint result = jvm->AttachCurrentThread(&env,NULL);
379                 if (result != 0) {
380                         ms_error("cannot attach VM\n");
381                         return;
382                 }
383                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
384                 env->CallVoidMethod(lcData->listener
385                                                         ,lcData->ecCalibrationStatusId
386                                                         ,lcData->core
387                                                         ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
388                                                         ,delay_ms
389                                                         ,data ? data : NULL);
390                 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
391                         //final state, releasing global ref
392                         env->DeleteGlobalRef((jobject)data);
393                 }
394
395         }
396
397
398 };
399 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*  env
400                 ,jobject  thiz
401                 ,jobject jlistener
402                 ,jstring juserConfig
403                 ,jstring jfactoryConfig
404                 ,jobject  juserdata){
405
406         const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
407         const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
408         LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
409
410 #ifdef HAVE_ILBC
411         libmsilbc_init(); // requires an fpu
412 #endif
413 #ifdef HAVE_X264
414         libmsx264_init();
415 #endif
416 #ifdef HAVE_AMR
417         libmsamr_init();
418 #endif
419 #ifdef HAVE_SILK
420         libmssilk_init();
421 #endif
422 #ifdef HAVE_G729
423         libmsbcg729_init();
424 #endif
425         jlong nativePtr = (jlong)linphone_core_new(     &ldata->vTable
426                         ,userConfig
427                         ,factoryConfig
428                         ,ldata);
429         //clear auth info list
430         linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
431         //clear existing proxy config
432         linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
433
434         if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
435         if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
436         return nativePtr;
437 }
438 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv*  env
439                 ,jobject  thiz
440                 ,jlong lc) {
441         LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
442         linphone_core_destroy((LinphoneCore*)lc);
443         delete lcData;
444 }
445
446 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
447         linphone_core_clear_proxy_config((LinphoneCore*)lc);
448 }
449
450 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig(  JNIEnv*  env
451                 ,jobject  thiz
452                 ,jlong lc
453                 ,jlong pc) {
454         linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
455 }
456 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv*  env
457                 ,jobject  thiz
458                 ,jlong lc) {
459         LinphoneProxyConfig *config=0;
460         linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
461         return (jlong)config;
462 }
463
464 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
465         const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
466         int proxyCount = ms_list_size(proxies);
467         jlongArray jProxies = env->NewLongArray(proxyCount);
468         jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
469
470         for (int i = 0; i < proxyCount; i++ ) {
471                 jInternalArray[i] = (unsigned long) (proxies->data);
472                 proxies = proxies->next;
473         }
474
475         env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
476
477         return jProxies;
478 }
479
480 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig(  JNIEnv*  env
481                 ,jobject  thiz
482                 ,jobject jproxyCfg
483                 ,jlong lc
484                 ,jlong pc) {
485         LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
486         linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
487
488         return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
489 }
490
491 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
492         linphone_core_clear_all_auth_info((LinphoneCore*)lc);
493 }
494
495 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
496         linphone_core_refresh_registers((LinphoneCore*)lc);
497 }
498
499 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo(    JNIEnv*  env
500                 ,jobject  thiz
501                 ,jlong lc
502                 ,jlong pc) {
503         linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
504 }
505 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate(        JNIEnv*  env
506                 ,jobject  thiz
507                 ,jlong lc) {
508         linphone_core_iterate((LinphoneCore*)lc);
509 }
510 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite(      JNIEnv*  env
511                 ,jobject  thiz
512                 ,jlong lc
513                 ,jstring juri) {
514         const char* uri = env->GetStringUTFChars(juri, NULL);
515         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
516         LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
517         env->ReleaseStringUTFChars(juri, uri);
518         return lcd->getCall(env,lCall);
519 }
520 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress(       JNIEnv*  env
521                 ,jobject  thiz
522                 ,jlong lc
523                 ,jlong to) {
524         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
525         return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
526 }
527
528 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall(  JNIEnv*  env
529                 ,jobject  thiz
530                 ,jlong lc
531                 ,jlong call) {
532         linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
533 }
534
535 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress(      JNIEnv*  env
536                 ,jobject  thiz
537                 ,jlong lc) {
538         return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
539 }
540 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall(   JNIEnv*  env
541                 ,jobject  thiz
542                 ,jlong lc) {
543
544         return linphone_core_in_call((LinphoneCore*)lc);
545 }
546 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending(    JNIEnv*  env
547                 ,jobject  thiz
548                 ,jlong lc) {
549
550         return linphone_core_inc_invite_pending((LinphoneCore*)lc);
551 }
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall(     JNIEnv*  env
553                 ,jobject  thiz
554                 ,jlong lc
555                 ,jlong call) {
556
557         linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
558 }
559
560 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
561                 jobject thiz,
562                 jlong lc,
563                 jlong call,
564                 jlong params){
565         linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
566 }
567
568 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
569                 jobject thiz,
570                 jlong lc,
571                 jlong call,
572                 jlong params){
573         linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
574 }
575
576 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
577                 jobject thiz,
578                 jlong lc,
579                 jlong call){
580         linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
581 }
582
583 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog(    JNIEnv*  env
584                 ,jobject  thiz
585                 ,jlong lc
586                 ,jint position) {
587                 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
588 }
589 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs(    JNIEnv*  env
590                 ,jobject  thiz
591                 ,jlong lc) {
592                 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
593 }
594 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable(       JNIEnv*  env
595                 ,jobject  thiz
596                 ,jlong lc
597                 ,jboolean isReachable) {
598                 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
599 }
600
601 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain(        JNIEnv*  env
602                 ,jobject  thiz
603                 ,jlong lc
604                 ,jfloat gain) {
605                 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
606 }
607
608 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain(       JNIEnv*  env
609                 ,jobject  thiz
610                 ,jlong lc) {
611                 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
612 }
613
614 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic(        JNIEnv*  env
615                 ,jobject  thiz
616                 ,jlong lc
617                 ,jboolean isMuted) {
618                 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
619 }
620
621 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl(  JNIEnv*  env
622                 ,jobject  thiz
623                 ,jlong lc
624                 ,jstring jurl) {
625         const char* url = env->GetStringUTFChars(jurl, NULL);
626         jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
627         env->ReleaseStringUTFChars(jurl, url);
628         return result;
629 }
630 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf(       JNIEnv*  env
631                 ,jobject  thiz
632                 ,jlong lc
633                 ,jchar dtmf) {
634         linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
635 }
636 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf(       JNIEnv*  env
637                 ,jobject  thiz
638                 ,jlong lc
639                 ,jchar dtmf
640                 ,jint duration) {
641         linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
642 }
643 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf(       JNIEnv*  env
644                 ,jobject  thiz
645                 ,jlong lc) {
646         linphone_core_stop_dtmf((LinphoneCore*)lc);
647 }
648
649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv*  env
650                                                                                                                                                 ,jobject  thiz
651                                                                                                                                                 ,jlong lc) {
652         linphone_core_get_missed_calls_count((LinphoneCore*)lc);
653 }
654
655 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv*  env
656                                                                                                                                                 ,jobject  thiz
657                                                                                                                                                 ,jlong lc) {
658         linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
659 }
660
661 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv*  env
662                                                                                                                                                 ,jobject  thiz
663                                                                                                                                                 ,jlong lc, jlong log) {
664         linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
665 }
666
667 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv*  env
668                                                                                                                                                 ,jobject  thiz
669                                                                                                                                                 ,jlong lc) {
670         linphone_core_clear_call_logs((LinphoneCore*)lc);
671 }
672 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv*  env
673                 ,jobject  thiz
674                 ,jlong lc) {
675         return linphone_core_is_mic_muted((LinphoneCore*)lc);
676 }
677 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv*  env
678                                                                                                                                                         ,jobject  thiz
679                                                                                                                                                         ,jlong lc
680                                                                                                                                                         ,jstring jmime
681                                                                                                                                                         ,jint rate) {
682         const char* mime = env->GetStringUTFChars(jmime, NULL);
683         jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
684         env->ReleaseStringUTFChars(jmime, mime);
685         return result;
686 }
687 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv*  env
688                                                                                                                                                         ,jobject  thiz
689                                                                                                                                                         ,jlong lc) {
690         const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
691         int codecsCount = ms_list_size(codecs);
692         jlongArray jCodecs = env->NewLongArray(codecsCount);
693         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
694
695         for (int i = 0; i < codecsCount; i++ ) {
696                 jInternalArray[i] = (unsigned long) (codecs->data);
697                 codecs = codecs->next;
698         }
699
700         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
701
702         return jCodecs;
703 }
704
705 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv*  env
706                                                                                                                                                         ,jobject  thiz
707                                                                                                                                                         ,jlong lc) {
708         const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
709         int codecsCount = ms_list_size(codecs);
710         jlongArray jCodecs = env->NewLongArray(codecsCount);
711         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
712
713         for (int i = 0; i < codecsCount; i++ ) {
714                 jInternalArray[i] = (unsigned long) (codecs->data);
715                 codecs = codecs->next;
716         }
717
718         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
719
720         return jCodecs;
721 }
722
723 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv*  env
724                                                                                                                                                         ,jobject  thiz
725                                                                                                                                                         ,jlong lc
726                                                                                                                                                         ,jlong pt
727                                                                                                                                                         ,jboolean enable) {
728         return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
729 }
730 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv*  env
731                                                                                                                                                         ,jobject  thiz
732                                                                                                                                                         ,jlong lc
733                                                                                                                                                         ,jboolean enable) {
734         linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
735 }
736 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv*  env
737                                                                                                                                                         ,jobject  thiz
738                                                                                                                                                         ,jlong lc
739                                                                                                                                                         ,jboolean enable) {
740         linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
741 }
742 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv*  env
743                                                                                                                                                         ,jobject  thiz
744                                                                                                                                                         ,jlong lc
745                                                                                                                                                         ) {
746         return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
747 }
748
749 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv*  env
750                                                                                                                                                         ,jobject  thiz
751                                                                                                                                                         ,jlong lc
752                                                                                                                                                         ) {
753         return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
754 }
755
756 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv*  env
757                                                                                                                                                         ,jobject  thiz
758                                                                                                                                                         ,jlong lc
759                                                                                                                                                         ) {
760         LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
761         
762         return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
763 }
764 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv*  env
765                                                                                                                                                         ,jobject  thiz
766                                                                                                                                                         ,jlong lc
767                                                                                                                                                         ,jlong aFriend
768                                                                                                                                                         ) {
769         linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
770 }
771 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*  env
772                                                                                                                                                         ,jobject  thiz
773                                                                                                                                                         ,jlong lc
774                                                                                                                                                         ,jint minute_away
775                                                                                                                                                         ,jstring jalternative_contact
776                                                                                                                                                         ,jint status) {
777         const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
778         linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
779         if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
780 }
781
782 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
783                                                                                                                                                         ,jobject  thiz
784                                                                                                                                                         ,jlong lc
785                                                                                                                                                         ,jstring jto) {
786
787         const char* to = env->GetStringUTFChars(jto, NULL);
788         LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
789         env->ReleaseStringUTFChars(jto, to);
790         return (long)lResult;
791 }
792
793 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv*  env
794                                                                                                                                                         ,jobject  thiz
795                                                                                                                                                         ,jlong lc
796                                                                                                                                                         ,jboolean vcap_enabled
797                                                                                                                                                         ,jboolean display_enabled) {
798         linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
799
800 }
801 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv*  env
802                                                                                                                                                         ,jobject  thiz
803                                                                                                                                                         ,jlong lc) {
804         return linphone_core_video_enabled((LinphoneCore*)lc);
805 }
806 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv*  env
807                                                                                                                                                         ,jobject  thiz
808                                                                                                                                                         ,jlong lc
809                                                                                                                                                         ,jstring jpath) {
810         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
811         linphone_core_set_play_file((LinphoneCore*)lc,path);
812         if (path) env->ReleaseStringUTFChars(jpath, path);
813 }
814 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv*  env
815                                                                                                                                                         ,jobject  thiz
816                                                                                                                                                         ,jlong lc
817                                                                                                                                                         ,jstring jpath) {
818         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
819         linphone_core_set_ring((LinphoneCore*)lc,path);
820         if (path) env->ReleaseStringUTFChars(jpath, path);
821 }
822 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
823                                                                                                                                                         ,jobject  thiz
824                                                                                                                                                         ,jlong lc
825                                                                                                                                                         ) {
826         const char* path = linphone_core_get_ring((LinphoneCore*)lc);
827         if (path) {
828                 return env->NewStringUTF(path);
829         } else {
830                 return NULL;
831         }
832 }
833 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv*  env
834                                                                                                                                                         ,jobject  thiz
835                                                                                                                                                         ,jlong lc
836                                                                                                                                                         ,jstring jpath) {
837         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
838         linphone_core_set_root_ca((LinphoneCore*)lc,path);
839         if (path) env->ReleaseStringUTFChars(jpath, path);
840 }
841 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv*  env
842                                                                                                                                 ,jobject  thiz
843                                                                                                                                 ,jlong lc
844                                                                                                                                 ,jboolean enable) {
845         linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
846
847 }
848 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv*  env
849                                                                                                                                 ,jobject  thiz
850                                                                                                                                 ,jlong lc) {
851         return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
852
853 }
854 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv*  env
855                                                                                                                                                                 ,jobject  thiz
856                                                                                                                                                                 ,jlong lc
857                                                                                                                                                                 ,jobject data) {
858         return linphone_core_start_echo_calibration((LinphoneCore*)lc
859                                                                                                         , LinphoneCoreData::ecCalibrationStatus
860                                                                                                         , data?env->NewGlobalRef(data):NULL);
861
862 }
863
864 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv*  env
865                                                                                                                                                         ,jobject  thiz
866                                                                                                                                                         ,jlong lc
867                                                                                                                                                         ) {
868         return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
869 }
870
871 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv*  env
872                                                                                                                                                         ,jobject  thiz
873                                                                                                                                                         ,jlong lc
874                                                                                                                                                         ,int menc) {
875         linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
876 }
877
878 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv*  env
879                                                                                                                                                         ,jobject  thiz
880                                                                                                                                                         ,jlong cp
881                                                                                                                                                         ) {
882         return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
883 }
884
885 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv*  env
886                                                                                                                                                         ,jobject  thiz
887                                                                                                                                                         ,jlong lc, jint menc
888                                                                                                                                                         ) {
889         return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
890 }
891
892 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv*  env
893                                                                                                                                                         ,jobject  thiz
894                                                                                                                                                         ,jlong cp
895                                                                                                                                                         ,int jmenc) {
896         linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
897 }
898
899 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv*  env
900                                                                                                                                                         ,jobject  thiz
901                                                                                                                                                         ,jlong lc
902                                                                                                                                                         ) {
903         return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
904 }
905
906 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv*  env
907                                                                                                                                                         ,jobject  thiz
908                                                                                                                                                         ,jlong lc
909                                                                                                                                                         , jboolean yesno
910                                                                                                                                                         ) {
911         linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
912 }
913
914 //ProxyConfig
915
916 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
917         LinphoneProxyConfig* proxy = linphone_proxy_config_new();
918         return  (jlong) proxy;
919 }
920
921 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv*  env,jobject  thiz,jlong ptr) {
922         linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
923 }
924 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
925         const char* identity = env->GetStringUTFChars(jidentity, NULL);
926         linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
927         env->ReleaseStringUTFChars(jidentity, identity);
928 }
929 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
930         const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
931         if (identity) {
932                 return env->NewStringUTF(identity);
933         } else {
934                 return NULL;
935         }
936 }
937 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
938         const char* proxy = env->GetStringUTFChars(jproxy, NULL);
939         int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
940         env->ReleaseStringUTFChars(jproxy, proxy);
941         return err;
942 }
943 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
944         const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
945         if (proxy) {
946                 return env->NewStringUTF(proxy);
947         } else {
948                 return NULL;
949         }
950 }
951 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
952         if (jroute != NULL) {
953                 const char* route = env->GetStringUTFChars(jroute, NULL);
954                 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
955                 env->ReleaseStringUTFChars(jroute, route);
956                 return err;
957         } else {
958                 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
959         }
960 }
961 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
962         const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
963         if (route) {
964                 return env->NewStringUTF(route);
965         } else {
966                 return NULL;
967         }
968 }
969
970 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
971         linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
972 }
973 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
974         return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
975 }
976 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
977         return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
978 }
979 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
980         linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
981 }
982 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
983         linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
984 }
985 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
986         if (jnumber == 0) {
987                 ms_error("cannot normalized null number");
988         }
989         const char* number = env->GetStringUTFChars(jnumber, NULL);
990         int len = env->GetStringLength(jnumber);
991         if (len == 0) {
992                 ms_warning("cannot normalize empty number");
993                 return jnumber;
994         }
995         char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
996         linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
997         jstring normalizedNumber = env->NewStringUTF(targetBuff);
998         env->ReleaseStringUTFChars(jnumber, number);
999         return normalizedNumber;
1000 }
1001 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1002                                                                                                                                                         ,jobject thiz
1003                                                                                                                                                         ,jlong proxyCfg) {
1004         const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1005         if (domain) {
1006                 return env->NewStringUTF(domain);
1007         } else {
1008                 return NULL;
1009         }
1010 }
1011 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1012         linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1013 }
1014
1015 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1016                                                                                                                                         ,jobject thiz
1017                                                                                                                                         ,jlong proxyCfg
1018                                                                                                                                         ,jstring jprefix) {
1019         const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1020         linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1021         env->ReleaseStringUTFChars(jprefix, prefix);
1022 }
1023 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1024                                                                                                                                                                 ,jobject thiz
1025                                                                                                                                                                 ,jlong proxyCfg
1026                                                                                                                                                                 ,jboolean val) {
1027         linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1028 }
1029 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1030         return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1031 }
1032
1033 //Auth Info
1034
1035 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1036                 , jobject thiz
1037                 , jstring jusername
1038                 , jstring juserid
1039                 , jstring jpassword
1040                 , jstring jha1
1041                 , jstring jrealm) {
1042
1043         const char* username = env->GetStringUTFChars(jusername, NULL);
1044         const char* password = env->GetStringUTFChars(jpassword, NULL);
1045         jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1046
1047         env->ReleaseStringUTFChars(jusername, username);
1048         env->ReleaseStringUTFChars(jpassword, password);
1049         return auth;
1050
1051 }
1052 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1053                 , jobject thiz
1054                 , jlong ptr) {
1055         linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1056 }
1057
1058 //LinphoneAddress
1059
1060 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv*  env
1061                                                                                                                                                                         ,jobject  thiz
1062                                                                                                                                                                         ,jstring juri
1063                                                                                                                                                                         ,jstring jdisplayName) {
1064         const char* uri = env->GetStringUTFChars(juri, NULL);
1065         LinphoneAddress* address = linphone_address_new(uri);
1066         if (jdisplayName && address) {
1067                 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1068                 linphone_address_set_display_name(address,displayName);
1069                 env->ReleaseStringUTFChars(jdisplayName, displayName);
1070         }
1071         env->ReleaseStringUTFChars(juri, uri);
1072
1073         return  (jlong) address;
1074 }
1075 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv*  env
1076                                                                                                                                                 ,jobject  thiz
1077                                                                                                                                                 ,jlong ptr) {
1078         linphone_address_destroy((LinphoneAddress*)ptr);
1079 }
1080
1081 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv*  env
1082                                                                                                                                                 ,jobject  thiz
1083                                                                                                                                                 ,jlong ptr) {
1084         const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1085         if (displayName) {
1086                 return env->NewStringUTF(displayName);
1087         } else {
1088                 return 0;
1089         }
1090 }
1091 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv*  env
1092                                                                                                                                                 ,jobject  thiz
1093                                                                                                                                                 ,jlong ptr) {
1094         const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1095         if (userName) {
1096                 return env->NewStringUTF(userName);
1097         } else {
1098                 return 0;
1099         }
1100 }
1101 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv*  env
1102                                                                                                                                                 ,jobject  thiz
1103                                                                                                                                                 ,jlong ptr) {
1104         const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1105         if (domain) {
1106                 return env->NewStringUTF(domain);
1107         } else {
1108                 return 0;
1109         }
1110 }
1111
1112 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv*  env
1113                                                                                                                                                 ,jobject  thiz
1114                                                                                                                                                 ,jlong ptr) {
1115         char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1116         jstring juri =env->NewStringUTF(uri);
1117         ms_free(uri);
1118         return juri;
1119 }
1120 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv*  env
1121                                                                                                                                                 ,jobject  thiz
1122                                                                                                                                                 ,jlong ptr) {
1123         char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1124         jstring juri =env->NewStringUTF(uri);
1125         ms_free(uri);
1126         return juri;
1127 }
1128 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv*  env
1129                                                                                                                                                 ,jobject  thiz
1130                                                                                                                                                 ,jlong address
1131                                                                                                                                                 ,jstring jdisplayName) {
1132         const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1133         linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1134         if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1135 }
1136
1137
1138 //CallLog
1139 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv*  env
1140                                                                                                                                                 ,jobject  thiz
1141                                                                                                                                                 ,jlong ptr) {
1142         return (jlong)((LinphoneCallLog*)ptr)->from;
1143 }
1144 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv*  env
1145                                                                                                                                                 ,jobject  thiz
1146                                                                                                                                                 ,jlong ptr) {
1147         return (jlong)((LinphoneCallLog*)ptr)->status;
1148 }
1149 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv*  env
1150                                                                                                                                                 ,jobject  thiz
1151                                                                                                                                                 ,jlong ptr) {
1152         return (jlong)((LinphoneCallLog*)ptr)->to;
1153 }
1154 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv*  env
1155                                                                                                                                                 ,jobject  thiz
1156                                                                                                                                                 ,jlong ptr) {
1157         return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1158 }
1159 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv*  env
1160                                                                                                                                                 ,jobject  thiz
1161                                                                                                                                                 ,jlong ptr) {
1162         jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1163         return jvalue;
1164 }
1165 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv*  env
1166                                                                                                                                                 ,jobject  thiz
1167                                                                                                                                                 ,jlong ptr) {
1168         return ((LinphoneCallLog*)ptr)->duration;
1169 }
1170
1171 /*payloadType*/
1172 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env,jobject  thiz,jlong ptr) {
1173         PayloadType* pt = (PayloadType*)ptr;
1174         char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1175                                                                         ,payload_type_get_mime(pt)
1176                                                                         ,payload_type_get_rate(pt)
1177                                                                         ,payload_type_get_bitrate(pt));
1178         jstring jvalue =env->NewStringUTF(value);
1179         ms_free(value);
1180         return jvalue;
1181 }
1182 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv*  env,jobject  thiz,jlong ptr) {
1183         PayloadType* pt = (PayloadType*)ptr;
1184         jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1185         return jvalue;
1186 }
1187 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv*  env,jobject  thiz, jlong ptr) {
1188         PayloadType* pt = (PayloadType*)ptr;
1189         return payload_type_get_rate(pt);
1190 }
1191
1192 //LinphoneCall
1193 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv*  env
1194                                                                                                                                                 ,jobject  thiz
1195                                                                                                                                                 ,jlong ptr) {
1196         LinphoneCall *call=(LinphoneCall*)ptr;
1197         linphone_call_unref(call);
1198 }
1199
1200 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog(    JNIEnv*  env
1201                                                                                                                                                 ,jobject  thiz
1202                                                                                                                                                 ,jlong ptr) {
1203         return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1204 }
1205
1206 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot(   JNIEnv*  env
1207                                                                                                                                                 ,jobject  thiz
1208                                                                                                                                                 ,jlong ptr, jstring path) {
1209         const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1210         linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1211 }
1212
1213 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo(              JNIEnv*  env
1214                                                                                                                                                 ,jobject  thiz
1215                                                                                                                                                 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1216         linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1217 }
1218
1219 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv*  env
1220                                                                                                                                                 ,jobject  thiz
1221                                                                                                                                                 ,jlong ptr) {
1222         return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1223 }
1224
1225 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress(      JNIEnv*  env
1226                                                                                                                                                 ,jobject  thiz
1227                                                                                                                                                 ,jlong ptr) {
1228         return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1229 }
1230
1231 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(       JNIEnv*  env
1232                                                                                                                                                 ,jobject  thiz
1233                                                                                                                                                 ,jlong ptr) {
1234         return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1235 }
1236 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv*  env
1237                                                                                                                                                 ,jobject  thiz
1238                                                                                                                                                 ,jlong ptr
1239                                                                                                                                                 ,jboolean value) {
1240         linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1241 }
1242 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled(  JNIEnv*  env
1243                                                                                                                                                 ,jobject  thiz
1244                                                                                                                                                 ,jlong ptr) {
1245         return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1246 }
1247
1248 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter(      JNIEnv*  env
1249                                                                                                                                                 ,jobject  thiz
1250                                                                                                                                                 ,jlong ptr
1251                                                                                                                                                 ,jboolean value) {
1252         linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1253 }
1254 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled(       JNIEnv*  env
1255                                                                                                                                                 ,jobject  thiz
1256                                                                                                                                                 ,jlong ptr) {
1257         return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1258 }
1259
1260 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall(     JNIEnv*  env
1261                                                                                                                                                 ,jobject  thiz
1262                                                                                                                                                 ,jlong ptr) {
1263         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));       
1264         return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1265 }
1266
1267 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality(    JNIEnv*  env
1268                                                                                                                                                 ,jobject  thiz
1269                                                                                                                                                 ,jlong ptr) {
1270         return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1271 }
1272
1273 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality(    JNIEnv*  env
1274                                                                                                                                                 ,jobject  thiz
1275                                                                                                                                                 ,jlong ptr) {
1276         return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1277 }
1278
1279
1280 //LinphoneFriend
1281 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
1282                                                                                                                                                 ,jobject  thiz
1283                                                                                                                                                 ,jstring jFriendUri) {
1284         LinphoneFriend* lResult;
1285
1286         if (jFriendUri) {
1287                 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1288                 lResult= linphone_friend_new_with_addr(friendUri);
1289                 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1290         } else {
1291                 lResult = linphone_friend_new();
1292         }
1293         return (long)lResult;
1294 }
1295 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
1296                                                                                                                                                 ,jobject  thiz
1297                                                                                                                                                 ,jlong ptr
1298                                                                                                                                                 ,jlong linphoneAddress) {
1299         linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1300 }
1301 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv*  env
1302                                                                                                                                                 ,jobject  thiz
1303                                                                                                                                                 ,jlong ptr) {
1304         return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1305 }
1306 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv*  env
1307                                                                                                                                                 ,jobject  thiz
1308                                                                                                                                                 ,jlong ptr
1309                                                                                                                                                 ,jint policy) {
1310         linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1311 }
1312 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv*  env
1313                                                                                                                                                 ,jobject  thiz
1314                                                                                                                                                 ,jlong ptr) {
1315         return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1316 }
1317 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv*  env
1318                                                                                                                                                 ,jobject  thiz
1319                                                                                                                                                 ,jlong ptr
1320                                                                                                                                                 ,jboolean value) {
1321         linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1322 }
1323 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv*  env
1324                                                                                                                                                 ,jobject  thiz
1325                                                                                                                                                 ,jlong ptr) {
1326         return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1327 }
1328 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv*  env
1329                                                                                                                                                 ,jobject  thiz
1330                                                                                                                                                 ,jlong ptr) {
1331         return linphone_friend_get_status((LinphoneFriend*)ptr);
1332 }
1333 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv*  env
1334                                                                                                                                                 ,jobject  thiz
1335                                                                                                                                                 ,jlong ptr) {
1336         return linphone_friend_edit((LinphoneFriend*)ptr);
1337 }
1338 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv*  env
1339                                                                                                                                                 ,jobject  thiz
1340                                                                                                                                                 ,jlong ptr) {
1341          linphone_friend_done((LinphoneFriend*)ptr);
1342 }
1343 //LinphoneChatRoom
1344 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv*  env
1345                                                                                                                                                 ,jobject  thiz
1346                                                                                                                                                 ,jlong ptr) {
1347         return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1348 }
1349 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*  env
1350                                                                                                                                                 ,jobject  thiz
1351                                                                                                                                                 ,jlong ptr
1352                                                                                                                                                 ,jstring jmessage) {
1353         const char* message = env->GetStringUTFChars(jmessage, NULL);
1354         linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1355         env->ReleaseStringUTFChars(jmessage, message);
1356
1357 }
1358
1359 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1360                                                                                                                                                 ,jobject thiz
1361                                                                                                                                                 ,jlong lc
1362                                                                                                                                                 ,jobject obj) {
1363         jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1364         if (oldWindow != NULL) {
1365                 env->DeleteGlobalRef(oldWindow);
1366         }
1367         if (obj != NULL) {
1368                 obj = env->NewGlobalRef(obj);
1369         }
1370         linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1371 }
1372
1373 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1374                                                                                                                                                 ,jobject thiz
1375                                                                                                                                                 ,jlong lc
1376                                                                                                                                                 ,jobject obj) {
1377         jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1378         if (oldWindow != NULL) {
1379                 env->DeleteGlobalRef(oldWindow);
1380         }
1381         if (obj != NULL) {
1382                 obj = env->NewGlobalRef(obj);
1383         }
1384         linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1385 }
1386
1387 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1388                                                                                                                                                 ,jobject thiz
1389                                                                                                                                                 ,jlong lc
1390                                                                                                                                                 ,jint rotation) {
1391         linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1392 }
1393
1394
1395 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1396         linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1397 }
1398
1399 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1400         return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1401 }
1402
1403 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1404         const char* server = NULL;
1405         if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1406         linphone_core_set_stun_server((LinphoneCore*)lc,server);
1407         if (server) env->ReleaseStringUTFChars(jserver,server);
1408 }
1409
1410 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1411         const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1412         if (ret==NULL) return NULL;
1413         jstring jvalue =env->NewStringUTF(ret);
1414         return jvalue;
1415 }
1416
1417 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1418         linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1419 }
1420
1421 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1422         linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1423 }
1424
1425 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1426         return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1427 }
1428
1429 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1430         return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1431 }
1432
1433 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1434         return linphone_call_params_destroy((LinphoneCallParams*)lc);
1435 }
1436 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1437         return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1438 }
1439
1440 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1441         return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1442 }
1443
1444 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1445         return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1446 }
1447
1448 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1449         linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1450 }
1451
1452 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1453         linphone_call_camera_enabled((LinphoneCall *)lc);
1454 }
1455
1456 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1457         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1458         return  lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1459 }
1460
1461 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1462         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1463 }
1464
1465 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1466         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1467 }
1468
1469
1470 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1471         MSVideoSize vsize;
1472         vsize.width = (int)width;
1473         vsize.height = (int)height;
1474         linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1475 }
1476
1477 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1478         MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1479     jintArray arr = env->NewIntArray(2);
1480         int tVsize [2]= {vsize.width,vsize.height};
1481     env->SetIntArrayRegion(arr, 0, 2, tVsize);
1482     return arr;
1483 }
1484
1485 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1486         linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1487 }
1488
1489 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1490         linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1491 }
1492
1493 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1494         linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1495 }
1496
1497 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1498         linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1499 }
1500
1501 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv*  env,jobject thiz,jlong ptr) {
1502         return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1503 }
1504 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv*  env,jobject thiz,jlong ptr,jint delay) {
1505         linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1506 }
1507
1508 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv*  env,jobject thiz,jlong ptr) {
1509         linphone_call_get_duration((LinphoneCall *) ptr);
1510 }
1511
1512 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1513         LCSipTransports tr;
1514         linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1515                 switch (code) {
1516         case 0:
1517                 return tr.udp_port;
1518         case 1:
1519                 return tr.tcp_port;
1520         case 3:
1521                 return tr.tls_port;
1522         default:
1523                 return -2;
1524         }
1525 }
1526
1527 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv*  env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1528         LinphoneCore *lc = (LinphoneCore *) ptr;
1529         LCSipTransports tr;
1530         tr.udp_port = udp;
1531         tr.tcp_port = tcp;
1532         tr.tls_port = tls;
1533
1534         linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1535 }
1536
1537 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject  thiz
1538               ,jlong lc, jboolean enable) {
1539               linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1540 }
1541
1542 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject  thiz
1543               ,jlong ptr, jint db) {
1544         linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1545 }
1546
1547 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1548         return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1549 }
1550 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1551         return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1552 }
1553 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1554         return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1555 }
1556 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1557         return linphone_core_is_in_conference((LinphoneCore *) pCore);
1558 }
1559 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1560         return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1561 }
1562 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1563         linphone_core_leave_conference((LinphoneCore *) pCore);
1564 }
1565 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1566         linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1567 }
1568 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1569         linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1570 }
1571 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1572         linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1573 }
1574
1575 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1576         linphone_core_terminate_conference((LinphoneCore *) pCore);
1577 }
1578 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1579         return linphone_core_get_conference_size((LinphoneCore *) pCore);
1580 }
1581 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1582         linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1583 }
1584 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1585         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1586         LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1587         return lcd->getCall(env,lCall);
1588 }
1589 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1590         return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1591 }
1592
1593 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1594         const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1595         linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1596         env->ReleaseStringUTFChars(jReferTo, cReferTo);
1597 }
1598 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1599         linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1600 }
1601
1602 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1603         if (jFile) {
1604                 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1605                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1606                 env->ReleaseStringUTFChars(jFile, cFile);
1607         } else {
1608                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1609         }
1610 }
1611
1612 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1613         const char* cUri=env->GetStringUTFChars(jUri, NULL);
1614         LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1615         env->ReleaseStringUTFChars(jUri, cUri);
1616         LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1617         return (jobject) lcdata->getCall(env,call);
1618 }
1619
1620
1621 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1622         LinphoneCore* lc = (LinphoneCore *) pCore;
1623         const char** devices = linphone_core_get_video_devices(lc);
1624         if (devices == NULL) {
1625                 ms_error("No existing video devices\n");
1626                 return -1;
1627         }
1628         int i;
1629         for(i=0; i<=id; i++) {
1630                 if (devices[i] == NULL)
1631                         break;
1632                 ms_message("Existing device %d : %s\n", i, devices[i]);
1633                 if (i==id) {
1634                         return linphone_core_set_video_device(lc, devices[i]);
1635                 }
1636         }
1637         return -1;
1638 }
1639
1640 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1641         LinphoneCore* lc = (LinphoneCore *) pCore;
1642         const char** devices = linphone_core_get_video_devices(lc);
1643         if (devices == NULL) {
1644                 ms_error("No existing video devices\n");
1645                 return -1;
1646         }
1647         const char* cam = linphone_core_get_video_device(lc);
1648         if (cam == NULL) {
1649                 ms_error("No current video device\n");
1650         } else {
1651                 int i=0;
1652                 while(devices[i] != NULL) {
1653                         if (strcmp(devices[i], cam) == 0)
1654                                 return i;
1655                         i++;
1656                 }
1657         }
1658         ms_warning("Returning default (0) device\n");
1659         return 0;
1660 }
1661
1662 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv*  env,jobject thiz,jlong ptr) {
1663         LinphoneCall *call = (LinphoneCall *) ptr;
1664         const char* token = linphone_call_get_authentication_token(call);
1665         if (token == NULL) return NULL;
1666         return env->NewStringUTF(token);
1667 }
1668 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv*  env,jobject thiz,jlong ptr) {
1669         LinphoneCall *call = (LinphoneCall *) ptr;
1670         return linphone_call_get_authentication_token_verified(call);
1671 }
1672 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv*  env,jobject thiz,jlong ptr,jboolean verified) {
1673         LinphoneCall *call = (LinphoneCall *) ptr;
1674         linphone_call_set_authentication_token_verified(call, verified);
1675 }
1676
1677 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1678         LinphoneCall *call = (LinphoneCall *) ptr;
1679         return linphone_call_get_play_volume(call);
1680 }
1681
1682 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1683         return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1684 }
1685
1686 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1687 // Implemented directly in msandroid.cpp (sound filters for Android).
1688 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1689
1690 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv*  env,jobject thiz,jboolean speakerOn){
1691         msandroid_hack_speaker_state(speakerOn);
1692 }
1693 // End Galaxy S hack functions
1694
1695
1696 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1697         return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1698 }
1699 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1700         linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1701 }
1702
1703 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1704                 jstring jHost, jint port, jint mirror, jint delay) {
1705         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1706         if (!tunnel) return;
1707         const char* cHost=env->GetStringUTFChars(jHost, NULL);
1708         linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1709         env->ReleaseStringUTFChars(jHost, cHost);
1710 }
1711
1712 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1713                 jstring jHost, jint port, jstring username, jstring password) {
1714
1715         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1716         if (!tunnel) return;
1717         const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1718         const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1719         const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1720         linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1721         if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1722         if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1723         if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1724 }
1725
1726
1727 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1728         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1729         linphone_tunnel_auto_detect(tunnel);
1730
1731 }
1732
1733 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1734         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1735         linphone_tunnel_clean_servers(tunnel);
1736 }
1737
1738 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1739         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1740         linphone_tunnel_enable(tunnel, enable);
1741 }
1742
1743
1744 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
1745         const char* cname=env->GetStringUTFChars(name, NULL);
1746         const char* cversion=env->GetStringUTFChars(version, NULL);
1747         linphone_core_set_user_agent(cname,cversion);
1748         env->ReleaseStringUTFChars(name, cname);
1749         env->ReleaseStringUTFChars(version, cversion);
1750 }
1751
1752 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1753         return linphone_core_tunnel_available();
1754 }
1755
1756 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1757         LinphoneVideoPolicy vpol;
1758         vpol.automatically_initiate = autoInitiate;
1759         vpol.automatically_accept = autoAccept;
1760         linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
1761 }
1762
1763 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
1764         ms_set_cpu_count(count);
1765 }