]> sjero.net Git - linphone/blob - coreapi/linphonecore_jni.cc
Change API of linphone_core_find_payload_type() to take the number of channels into...
[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,message ? env->NewStringUTF(message) : NULL);
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" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable(    JNIEnv*  env
602                 ,jobject  thiz
603                 ,jlong lc) {
604                 return linphone_core_is_network_reachable((LinphoneCore*)lc);
605 }
606
607 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain(        JNIEnv*  env
608                 ,jobject  thiz
609                 ,jlong lc
610                 ,jfloat gain) {
611                 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
612 }
613
614 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain(       JNIEnv*  env
615                 ,jobject  thiz
616                 ,jlong lc) {
617                 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
618 }
619
620 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic(        JNIEnv*  env
621                 ,jobject  thiz
622                 ,jlong lc
623                 ,jboolean isMuted) {
624                 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
625 }
626
627 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl(  JNIEnv*  env
628                 ,jobject  thiz
629                 ,jlong lc
630                 ,jstring jurl) {
631         const char* url = env->GetStringUTFChars(jurl, NULL);
632         jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
633         env->ReleaseStringUTFChars(jurl, url);
634         return result;
635 }
636 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf(       JNIEnv*  env
637                 ,jobject  thiz
638                 ,jlong lc
639                 ,jchar dtmf) {
640         linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
641 }
642 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf(       JNIEnv*  env
643                 ,jobject  thiz
644                 ,jlong lc
645                 ,jchar dtmf
646                 ,jint duration) {
647         linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
648 }
649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf(       JNIEnv*  env
650                 ,jobject  thiz
651                 ,jlong lc) {
652         linphone_core_stop_dtmf((LinphoneCore*)lc);
653 }
654
655 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv*  env
656                                                                                                                                                 ,jobject  thiz
657                                                                                                                                                 ,jlong lc) {
658         linphone_core_get_missed_calls_count((LinphoneCore*)lc);
659 }
660
661 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv*  env
662                                                                                                                                                 ,jobject  thiz
663                                                                                                                                                 ,jlong lc) {
664         linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
665 }
666
667 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv*  env
668                                                                                                                                                 ,jobject  thiz
669                                                                                                                                                 ,jlong lc, jlong log) {
670         linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
671 }
672
673 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv*  env
674                                                                                                                                                 ,jobject  thiz
675                                                                                                                                                 ,jlong lc) {
676         linphone_core_clear_call_logs((LinphoneCore*)lc);
677 }
678 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv*  env
679                 ,jobject  thiz
680                 ,jlong lc) {
681         return linphone_core_is_mic_muted((LinphoneCore*)lc);
682 }
683 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv*  env
684                                                                                                                                                         ,jobject  thiz
685                                                                                                                                                         ,jlong lc
686                                                                                                                                                         ,jstring jmime
687                                                                                                                                                         ,jint rate
688                                                                                                                                                         ,jint channels) {
689         const char* mime = env->GetStringUTFChars(jmime, NULL);
690         jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
691         env->ReleaseStringUTFChars(jmime, mime);
692         return result;
693 }
694 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv*  env
695                                                                                                                                                         ,jobject  thiz
696                                                                                                                                                         ,jlong lc) {
697         const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
698         int codecsCount = ms_list_size(codecs);
699         jlongArray jCodecs = env->NewLongArray(codecsCount);
700         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
701
702         for (int i = 0; i < codecsCount; i++ ) {
703                 jInternalArray[i] = (unsigned long) (codecs->data);
704                 codecs = codecs->next;
705         }
706
707         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
708
709         return jCodecs;
710 }
711
712 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv*  env
713                                                                                                                                                         ,jobject  thiz
714                                                                                                                                                         ,jlong lc) {
715         const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
716         int codecsCount = ms_list_size(codecs);
717         jlongArray jCodecs = env->NewLongArray(codecsCount);
718         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
719
720         for (int i = 0; i < codecsCount; i++ ) {
721                 jInternalArray[i] = (unsigned long) (codecs->data);
722                 codecs = codecs->next;
723         }
724
725         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
726
727         return jCodecs;
728 }
729
730 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv*  env
731                                                                                                                                                         ,jobject  thiz
732                                                                                                                                                         ,jlong lc
733                                                                                                                                                         ,jlong pt
734                                                                                                                                                         ,jboolean enable) {
735         return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
736 }
737 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv*  env
738                                                                                                                                                         ,jobject  thiz
739                                                                                                                                                         ,jlong lc
740                                                                                                                                                         ,jboolean enable) {
741         linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
742 }
743 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv*  env
744                                                                                                                                                         ,jobject  thiz
745                                                                                                                                                         ,jlong lc
746                                                                                                                                                         ,jboolean enable) {
747         linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
748 }
749 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv*  env
750                                                                                                                                                         ,jobject  thiz
751                                                                                                                                                         ,jlong lc
752                                                                                                                                                         ) {
753         return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
754 }
755
756 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv*  env
757                                                                                                                                                         ,jobject  thiz
758                                                                                                                                                         ,jlong lc
759                                                                                                                                                         ) {
760         return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
761 }
762
763 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv*  env
764                                                                                                                                                         ,jobject  thiz
765                                                                                                                                                         ,jlong lc
766                                                                                                                                                         ) {
767         LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
768         
769         return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
770 }
771 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv*  env
772                                                                                                                                                         ,jobject  thiz
773                                                                                                                                                         ,jlong lc
774                                                                                                                                                         ,jlong aFriend
775                                                                                                                                                         ) {
776         linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
777 }
778 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*  env
779                                                                                                                                                         ,jobject  thiz
780                                                                                                                                                         ,jlong lc
781                                                                                                                                                         ,jint minute_away
782                                                                                                                                                         ,jstring jalternative_contact
783                                                                                                                                                         ,jint status) {
784         const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
785         linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
786         if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
787 }
788
789 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
790                                                                                                                                                         ,jobject  thiz
791                                                                                                                                                         ,jlong lc
792                                                                                                                                                         ,jstring jto) {
793
794         const char* to = env->GetStringUTFChars(jto, NULL);
795         LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
796         env->ReleaseStringUTFChars(jto, to);
797         return (long)lResult;
798 }
799
800 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv*  env
801                                                                                                                                                         ,jobject  thiz
802                                                                                                                                                         ,jlong lc
803                                                                                                                                                         ,jboolean vcap_enabled
804                                                                                                                                                         ,jboolean display_enabled) {
805         linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
806
807 }
808 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv*  env
809                                                                                                                                                         ,jobject  thiz
810                                                                                                                                                         ,jlong lc) {
811         return linphone_core_video_enabled((LinphoneCore*)lc);
812 }
813 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv*  env
814                                                                                                                                                         ,jobject  thiz
815                                                                                                                                                         ,jlong lc
816                                                                                                                                                         ,jstring jpath) {
817         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
818         linphone_core_set_play_file((LinphoneCore*)lc,path);
819         if (path) env->ReleaseStringUTFChars(jpath, path);
820 }
821 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv*  env
822                                                                                                                                                         ,jobject  thiz
823                                                                                                                                                         ,jlong lc
824                                                                                                                                                         ,jstring jpath) {
825         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
826         linphone_core_set_ring((LinphoneCore*)lc,path);
827         if (path) env->ReleaseStringUTFChars(jpath, path);
828 }
829 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
830                                                                                                                                                         ,jobject  thiz
831                                                                                                                                                         ,jlong lc
832                                                                                                                                                         ) {
833         const char* path = linphone_core_get_ring((LinphoneCore*)lc);
834         if (path) {
835                 return env->NewStringUTF(path);
836         } else {
837                 return NULL;
838         }
839 }
840 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv*  env
841                                                                                                                                                         ,jobject  thiz
842                                                                                                                                                         ,jlong lc
843                                                                                                                                                         ,jstring jpath) {
844         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
845         linphone_core_set_root_ca((LinphoneCore*)lc,path);
846         if (path) env->ReleaseStringUTFChars(jpath, path);
847 }
848 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv*  env
849                                                                                                                                 ,jobject  thiz
850                                                                                                                                 ,jlong lc
851                                                                                                                                 ,jboolean enable) {
852         linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
853
854 }
855 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv*  env
856                                                                                                                                 ,jobject  thiz
857                                                                                                                                 ,jlong lc) {
858         return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
859
860 }
861 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv*  env
862                                                                                                                                                                 ,jobject  thiz
863                                                                                                                                                                 ,jlong lc
864                                                                                                                                                                 ,jobject data) {
865         return linphone_core_start_echo_calibration((LinphoneCore*)lc
866                                                                                                         , LinphoneCoreData::ecCalibrationStatus
867                                                                                                         , data?env->NewGlobalRef(data):NULL);
868
869 }
870
871 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv*  env
872                                                                                                                                                         ,jobject  thiz
873                                                                                                                                                         ,jlong lc
874                                                                                                                                                         ) {
875         return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
876 }
877
878 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv*  env
879                                                                                                                                                         ,jobject  thiz
880                                                                                                                                                         ,jlong lc
881                                                                                                                                                         ,int menc) {
882         linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
883 }
884
885 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv*  env
886                                                                                                                                                         ,jobject  thiz
887                                                                                                                                                         ,jlong cp
888                                                                                                                                                         ) {
889         return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
890 }
891
892 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv*  env
893                                                                                                                                                         ,jobject  thiz
894                                                                                                                                                         ,jlong lc, jint menc
895                                                                                                                                                         ) {
896         return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
897 }
898
899 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv*  env
900                                                                                                                                                         ,jobject  thiz
901                                                                                                                                                         ,jlong cp
902                                                                                                                                                         ,int jmenc) {
903         linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
904 }
905
906 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv*  env
907                                                                                                                                                         ,jobject  thiz
908                                                                                                                                                         ,jlong lc
909                                                                                                                                                         ) {
910         return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
911 }
912
913 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv*  env
914                                                                                                                                                         ,jobject  thiz
915                                                                                                                                                         ,jlong lc
916                                                                                                                                                         , jboolean yesno
917                                                                                                                                                         ) {
918         linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
919 }
920
921 //ProxyConfig
922
923 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
924         LinphoneProxyConfig* proxy = linphone_proxy_config_new();
925         return  (jlong) proxy;
926 }
927
928 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv*  env,jobject  thiz,jlong ptr) {
929         linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
930 }
931 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
932         const char* identity = env->GetStringUTFChars(jidentity, NULL);
933         linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
934         env->ReleaseStringUTFChars(jidentity, identity);
935 }
936 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
937         const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
938         if (identity) {
939                 return env->NewStringUTF(identity);
940         } else {
941                 return NULL;
942         }
943 }
944 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
945         const char* proxy = env->GetStringUTFChars(jproxy, NULL);
946         int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
947         env->ReleaseStringUTFChars(jproxy, proxy);
948         return err;
949 }
950 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
951         const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
952         if (proxy) {
953                 return env->NewStringUTF(proxy);
954         } else {
955                 return NULL;
956         }
957 }
958 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
959         if (jroute != NULL) {
960                 const char* route = env->GetStringUTFChars(jroute, NULL);
961                 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
962                 env->ReleaseStringUTFChars(jroute, route);
963                 return err;
964         } else {
965                 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
966         }
967 }
968 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
969         const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
970         if (route) {
971                 return env->NewStringUTF(route);
972         } else {
973                 return NULL;
974         }
975 }
976
977 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
978         linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
979 }
980 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
981         return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
982 }
983 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
984         return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
985 }
986 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
987         linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
988 }
989 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
990         linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
991 }
992 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
993         if (jnumber == 0) {
994                 ms_error("cannot normalized null number");
995         }
996         const char* number = env->GetStringUTFChars(jnumber, NULL);
997         int len = env->GetStringLength(jnumber);
998         if (len == 0) {
999                 ms_warning("cannot normalize empty number");
1000                 return jnumber;
1001         }
1002         char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1003         linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1004         jstring normalizedNumber = env->NewStringUTF(targetBuff);
1005         env->ReleaseStringUTFChars(jnumber, number);
1006         return normalizedNumber;
1007 }
1008 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1009                                                                                                                                                         ,jobject thiz
1010                                                                                                                                                         ,jlong proxyCfg) {
1011         const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1012         if (domain) {
1013                 return env->NewStringUTF(domain);
1014         } else {
1015                 return NULL;
1016         }
1017 }
1018 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1019         linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1020 }
1021
1022 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1023                                                                                                                                         ,jobject thiz
1024                                                                                                                                         ,jlong proxyCfg
1025                                                                                                                                         ,jstring jprefix) {
1026         const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1027         linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1028         env->ReleaseStringUTFChars(jprefix, prefix);
1029 }
1030 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1031                                                                                                                                                                 ,jobject thiz
1032                                                                                                                                                                 ,jlong proxyCfg
1033                                                                                                                                                                 ,jboolean val) {
1034         linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1035 }
1036 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1037         return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1038 }
1039
1040 //Auth Info
1041
1042 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1043                 , jobject thiz
1044                 , jstring jusername
1045                 , jstring juserid
1046                 , jstring jpassword
1047                 , jstring jha1
1048                 , jstring jrealm) {
1049
1050         const char* username = env->GetStringUTFChars(jusername, NULL);
1051         const char* password = env->GetStringUTFChars(jpassword, NULL);
1052         jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1053
1054         env->ReleaseStringUTFChars(jusername, username);
1055         env->ReleaseStringUTFChars(jpassword, password);
1056         return auth;
1057
1058 }
1059 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1060                 , jobject thiz
1061                 , jlong ptr) {
1062         linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1063 }
1064
1065 //LinphoneAddress
1066
1067 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv*  env
1068                                                                                                                                                                         ,jobject  thiz
1069                                                                                                                                                                         ,jstring juri
1070                                                                                                                                                                         ,jstring jdisplayName) {
1071         const char* uri = env->GetStringUTFChars(juri, NULL);
1072         LinphoneAddress* address = linphone_address_new(uri);
1073         if (jdisplayName && address) {
1074                 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1075                 linphone_address_set_display_name(address,displayName);
1076                 env->ReleaseStringUTFChars(jdisplayName, displayName);
1077         }
1078         env->ReleaseStringUTFChars(juri, uri);
1079
1080         return  (jlong) address;
1081 }
1082 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv*  env
1083                                                                                                                                                 ,jobject  thiz
1084                                                                                                                                                 ,jlong ptr) {
1085         linphone_address_destroy((LinphoneAddress*)ptr);
1086 }
1087
1088 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv*  env
1089                                                                                                                                                 ,jobject  thiz
1090                                                                                                                                                 ,jlong ptr) {
1091         const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1092         if (displayName) {
1093                 return env->NewStringUTF(displayName);
1094         } else {
1095                 return 0;
1096         }
1097 }
1098 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv*  env
1099                                                                                                                                                 ,jobject  thiz
1100                                                                                                                                                 ,jlong ptr) {
1101         const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1102         if (userName) {
1103                 return env->NewStringUTF(userName);
1104         } else {
1105                 return 0;
1106         }
1107 }
1108 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv*  env
1109                                                                                                                                                 ,jobject  thiz
1110                                                                                                                                                 ,jlong ptr) {
1111         const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1112         if (domain) {
1113                 return env->NewStringUTF(domain);
1114         } else {
1115                 return 0;
1116         }
1117 }
1118
1119 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv*  env
1120                                                                                                                                                 ,jobject  thiz
1121                                                                                                                                                 ,jlong ptr) {
1122         char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1123         jstring juri =env->NewStringUTF(uri);
1124         ms_free(uri);
1125         return juri;
1126 }
1127 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv*  env
1128                                                                                                                                                 ,jobject  thiz
1129                                                                                                                                                 ,jlong ptr) {
1130         char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1131         jstring juri =env->NewStringUTF(uri);
1132         ms_free(uri);
1133         return juri;
1134 }
1135 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv*  env
1136                                                                                                                                                 ,jobject  thiz
1137                                                                                                                                                 ,jlong address
1138                                                                                                                                                 ,jstring jdisplayName) {
1139         const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1140         linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1141         if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1142 }
1143
1144
1145 //CallLog
1146 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv*  env
1147                                                                                                                                                 ,jobject  thiz
1148                                                                                                                                                 ,jlong ptr) {
1149         return (jlong)((LinphoneCallLog*)ptr)->from;
1150 }
1151 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv*  env
1152                                                                                                                                                 ,jobject  thiz
1153                                                                                                                                                 ,jlong ptr) {
1154         return (jlong)((LinphoneCallLog*)ptr)->status;
1155 }
1156 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv*  env
1157                                                                                                                                                 ,jobject  thiz
1158                                                                                                                                                 ,jlong ptr) {
1159         return (jlong)((LinphoneCallLog*)ptr)->to;
1160 }
1161 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv*  env
1162                                                                                                                                                 ,jobject  thiz
1163                                                                                                                                                 ,jlong ptr) {
1164         return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1165 }
1166 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv*  env
1167                                                                                                                                                 ,jobject  thiz
1168                                                                                                                                                 ,jlong ptr) {
1169         jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1170         return jvalue;
1171 }
1172 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv*  env
1173                                                                                                                                                 ,jobject  thiz
1174                                                                                                                                                 ,jlong ptr) {
1175         return ((LinphoneCallLog*)ptr)->duration;
1176 }
1177
1178 /*payloadType*/
1179 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env,jobject  thiz,jlong ptr) {
1180         PayloadType* pt = (PayloadType*)ptr;
1181         char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1182                                                                         ,payload_type_get_mime(pt)
1183                                                                         ,payload_type_get_rate(pt)
1184                                                                         ,payload_type_get_bitrate(pt));
1185         jstring jvalue =env->NewStringUTF(value);
1186         ms_free(value);
1187         return jvalue;
1188 }
1189 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv*  env,jobject  thiz,jlong ptr) {
1190         PayloadType* pt = (PayloadType*)ptr;
1191         jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1192         return jvalue;
1193 }
1194 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv*  env,jobject  thiz, jlong ptr) {
1195         PayloadType* pt = (PayloadType*)ptr;
1196         return payload_type_get_rate(pt);
1197 }
1198
1199 //LinphoneCall
1200 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv*  env
1201                                                                                                                                                 ,jobject  thiz
1202                                                                                                                                                 ,jlong ptr) {
1203         LinphoneCall *call=(LinphoneCall*)ptr;
1204         linphone_call_unref(call);
1205 }
1206
1207 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog(    JNIEnv*  env
1208                                                                                                                                                 ,jobject  thiz
1209                                                                                                                                                 ,jlong ptr) {
1210         return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1211 }
1212
1213 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot(   JNIEnv*  env
1214                                                                                                                                                 ,jobject  thiz
1215                                                                                                                                                 ,jlong ptr, jstring path) {
1216         const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1217         linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1218 }
1219
1220 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo(              JNIEnv*  env
1221                                                                                                                                                 ,jobject  thiz
1222                                                                                                                                                 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1223         linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1224 }
1225
1226 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv*  env
1227                                                                                                                                                 ,jobject  thiz
1228                                                                                                                                                 ,jlong ptr) {
1229         return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1230 }
1231
1232 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress(      JNIEnv*  env
1233                                                                                                                                                 ,jobject  thiz
1234                                                                                                                                                 ,jlong ptr) {
1235         return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1236 }
1237
1238 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(       JNIEnv*  env
1239                                                                                                                                                 ,jobject  thiz
1240                                                                                                                                                 ,jlong ptr) {
1241         return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1242 }
1243 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv*  env
1244                                                                                                                                                 ,jobject  thiz
1245                                                                                                                                                 ,jlong ptr
1246                                                                                                                                                 ,jboolean value) {
1247         linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1248 }
1249 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled(  JNIEnv*  env
1250                                                                                                                                                 ,jobject  thiz
1251                                                                                                                                                 ,jlong ptr) {
1252         return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1253 }
1254
1255 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter(      JNIEnv*  env
1256                                                                                                                                                 ,jobject  thiz
1257                                                                                                                                                 ,jlong ptr
1258                                                                                                                                                 ,jboolean value) {
1259         linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1260 }
1261 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled(       JNIEnv*  env
1262                                                                                                                                                 ,jobject  thiz
1263                                                                                                                                                 ,jlong ptr) {
1264         return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1265 }
1266
1267 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall(     JNIEnv*  env
1268                                                                                                                                                 ,jobject  thiz
1269                                                                                                                                                 ,jlong ptr) {
1270         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));       
1271         return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1272 }
1273
1274 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality(    JNIEnv*  env
1275                                                                                                                                                 ,jobject  thiz
1276                                                                                                                                                 ,jlong ptr) {
1277         return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1278 }
1279
1280 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality(    JNIEnv*  env
1281                                                                                                                                                 ,jobject  thiz
1282                                                                                                                                                 ,jlong ptr) {
1283         return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1284 }
1285
1286
1287 //LinphoneFriend
1288 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
1289                                                                                                                                                 ,jobject  thiz
1290                                                                                                                                                 ,jstring jFriendUri) {
1291         LinphoneFriend* lResult;
1292
1293         if (jFriendUri) {
1294                 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1295                 lResult= linphone_friend_new_with_addr(friendUri);
1296                 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1297         } else {
1298                 lResult = linphone_friend_new();
1299         }
1300         return (long)lResult;
1301 }
1302 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
1303                                                                                                                                                 ,jobject  thiz
1304                                                                                                                                                 ,jlong ptr
1305                                                                                                                                                 ,jlong linphoneAddress) {
1306         linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1307 }
1308 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv*  env
1309                                                                                                                                                 ,jobject  thiz
1310                                                                                                                                                 ,jlong ptr) {
1311         return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1312 }
1313 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv*  env
1314                                                                                                                                                 ,jobject  thiz
1315                                                                                                                                                 ,jlong ptr
1316                                                                                                                                                 ,jint policy) {
1317         linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1318 }
1319 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv*  env
1320                                                                                                                                                 ,jobject  thiz
1321                                                                                                                                                 ,jlong ptr) {
1322         return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1323 }
1324 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv*  env
1325                                                                                                                                                 ,jobject  thiz
1326                                                                                                                                                 ,jlong ptr
1327                                                                                                                                                 ,jboolean value) {
1328         linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1329 }
1330 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv*  env
1331                                                                                                                                                 ,jobject  thiz
1332                                                                                                                                                 ,jlong ptr) {
1333         return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1334 }
1335 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv*  env
1336                                                                                                                                                 ,jobject  thiz
1337                                                                                                                                                 ,jlong ptr) {
1338         return linphone_friend_get_status((LinphoneFriend*)ptr);
1339 }
1340 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv*  env
1341                                                                                                                                                 ,jobject  thiz
1342                                                                                                                                                 ,jlong ptr) {
1343         return linphone_friend_edit((LinphoneFriend*)ptr);
1344 }
1345 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv*  env
1346                                                                                                                                                 ,jobject  thiz
1347                                                                                                                                                 ,jlong ptr) {
1348          linphone_friend_done((LinphoneFriend*)ptr);
1349 }
1350 //LinphoneChatRoom
1351 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv*  env
1352                                                                                                                                                 ,jobject  thiz
1353                                                                                                                                                 ,jlong ptr) {
1354         return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1355 }
1356 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*  env
1357                                                                                                                                                 ,jobject  thiz
1358                                                                                                                                                 ,jlong ptr
1359                                                                                                                                                 ,jstring jmessage) {
1360         const char* message = env->GetStringUTFChars(jmessage, NULL);
1361         linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1362         env->ReleaseStringUTFChars(jmessage, message);
1363
1364 }
1365
1366 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1367                                                                                                                                                 ,jobject thiz
1368                                                                                                                                                 ,jlong lc
1369                                                                                                                                                 ,jobject obj) {
1370         jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1371         if (oldWindow != NULL) {
1372                 env->DeleteGlobalRef(oldWindow);
1373         }
1374         if (obj != NULL) {
1375                 obj = env->NewGlobalRef(obj);
1376         }
1377         linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1378 }
1379
1380 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1381                                                                                                                                                 ,jobject thiz
1382                                                                                                                                                 ,jlong lc
1383                                                                                                                                                 ,jobject obj) {
1384         jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1385         if (oldWindow != NULL) {
1386                 env->DeleteGlobalRef(oldWindow);
1387         }
1388         if (obj != NULL) {
1389                 obj = env->NewGlobalRef(obj);
1390         }
1391         linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1392 }
1393
1394 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1395                                                                                                                                                 ,jobject thiz
1396                                                                                                                                                 ,jlong lc
1397                                                                                                                                                 ,jint rotation) {
1398         linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1399 }
1400
1401
1402 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1403         linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1404 }
1405
1406 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1407         return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1408 }
1409
1410 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1411         const char* server = NULL;
1412         if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1413         linphone_core_set_stun_server((LinphoneCore*)lc,server);
1414         if (server) env->ReleaseStringUTFChars(jserver,server);
1415 }
1416
1417 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1418         const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1419         if (ret==NULL) return NULL;
1420         jstring jvalue =env->NewStringUTF(ret);
1421         return jvalue;
1422 }
1423
1424 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1425         linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1426 }
1427
1428 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1429         linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1430 }
1431
1432 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1433         return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1434 }
1435
1436 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1437         return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1438 }
1439
1440 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1441         return linphone_call_params_destroy((LinphoneCallParams*)lc);
1442 }
1443 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1444         return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1445 }
1446
1447 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1448         return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1449 }
1450
1451 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1452         return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1453 }
1454
1455 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1456         linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1457 }
1458
1459 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1460         linphone_call_camera_enabled((LinphoneCall *)lc);
1461 }
1462
1463 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1464         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1465         return  lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1466 }
1467
1468 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1469         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1470 }
1471
1472 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1473         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1474 }
1475
1476
1477 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1478         MSVideoSize vsize;
1479         vsize.width = (int)width;
1480         vsize.height = (int)height;
1481         linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1482 }
1483
1484 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1485         MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1486     jintArray arr = env->NewIntArray(2);
1487         int tVsize [2]= {vsize.width,vsize.height};
1488     env->SetIntArrayRegion(arr, 0, 2, tVsize);
1489     return arr;
1490 }
1491
1492 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1493         linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1494 }
1495
1496 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1497         linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1498 }
1499
1500 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1501         linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1502 }
1503
1504 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1505         linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1506 }
1507
1508 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv*  env,jobject thiz,jlong ptr) {
1509         return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1510 }
1511 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv*  env,jobject thiz,jlong ptr,jint delay) {
1512         linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1513 }
1514
1515 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv*  env,jobject thiz,jlong ptr) {
1516         linphone_call_get_duration((LinphoneCall *) ptr);
1517 }
1518
1519 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1520         LCSipTransports tr;
1521         linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1522                 switch (code) {
1523         case 0:
1524                 return tr.udp_port;
1525         case 1:
1526                 return tr.tcp_port;
1527         case 3:
1528                 return tr.tls_port;
1529         default:
1530                 return -2;
1531         }
1532 }
1533
1534 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv*  env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1535         LinphoneCore *lc = (LinphoneCore *) ptr;
1536         LCSipTransports tr;
1537         tr.udp_port = udp;
1538         tr.tcp_port = tcp;
1539         tr.tls_port = tls;
1540
1541         linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1542 }
1543
1544 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject  thiz
1545               ,jlong lc, jboolean enable) {
1546               linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1547 }
1548
1549 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject  thiz
1550               ,jlong ptr, jint db) {
1551         linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1552 }
1553
1554 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1555         return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1556 }
1557 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1558         return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1559 }
1560 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1561         return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1562 }
1563 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1564         return linphone_core_is_in_conference((LinphoneCore *) pCore);
1565 }
1566 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1567         return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1568 }
1569 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1570         linphone_core_leave_conference((LinphoneCore *) pCore);
1571 }
1572 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1573         linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1574 }
1575 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1576         linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1577 }
1578 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1579         linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1580 }
1581
1582 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1583         linphone_core_terminate_conference((LinphoneCore *) pCore);
1584 }
1585 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1586         return linphone_core_get_conference_size((LinphoneCore *) pCore);
1587 }
1588 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1589         linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1590 }
1591 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1592         LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1593         LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1594         return lcd->getCall(env,lCall);
1595 }
1596 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1597         return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1598 }
1599
1600 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1601         const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1602         linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1603         env->ReleaseStringUTFChars(jReferTo, cReferTo);
1604 }
1605 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1606         linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1607 }
1608
1609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1610         if (jFile) {
1611                 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1612                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1613                 env->ReleaseStringUTFChars(jFile, cFile);
1614         } else {
1615                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1616         }
1617 }
1618
1619 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1620         const char* cUri=env->GetStringUTFChars(jUri, NULL);
1621         LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1622         env->ReleaseStringUTFChars(jUri, cUri);
1623         LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1624         return (jobject) lcdata->getCall(env,call);
1625 }
1626
1627
1628 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1629         LinphoneCore* lc = (LinphoneCore *) pCore;
1630         const char** devices = linphone_core_get_video_devices(lc);
1631         if (devices == NULL) {
1632                 ms_error("No existing video devices\n");
1633                 return -1;
1634         }
1635         int i;
1636         for(i=0; i<=id; i++) {
1637                 if (devices[i] == NULL)
1638                         break;
1639                 ms_message("Existing device %d : %s\n", i, devices[i]);
1640                 if (i==id) {
1641                         return linphone_core_set_video_device(lc, devices[i]);
1642                 }
1643         }
1644         return -1;
1645 }
1646
1647 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1648         LinphoneCore* lc = (LinphoneCore *) pCore;
1649         const char** devices = linphone_core_get_video_devices(lc);
1650         if (devices == NULL) {
1651                 ms_error("No existing video devices\n");
1652                 return -1;
1653         }
1654         const char* cam = linphone_core_get_video_device(lc);
1655         if (cam == NULL) {
1656                 ms_error("No current video device\n");
1657         } else {
1658                 int i=0;
1659                 while(devices[i] != NULL) {
1660                         if (strcmp(devices[i], cam) == 0)
1661                                 return i;
1662                         i++;
1663                 }
1664         }
1665         ms_warning("Returning default (0) device\n");
1666         return 0;
1667 }
1668
1669 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv*  env,jobject thiz,jlong ptr) {
1670         LinphoneCall *call = (LinphoneCall *) ptr;
1671         const char* token = linphone_call_get_authentication_token(call);
1672         if (token == NULL) return NULL;
1673         return env->NewStringUTF(token);
1674 }
1675 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv*  env,jobject thiz,jlong ptr) {
1676         LinphoneCall *call = (LinphoneCall *) ptr;
1677         return linphone_call_get_authentication_token_verified(call);
1678 }
1679 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv*  env,jobject thiz,jlong ptr,jboolean verified) {
1680         LinphoneCall *call = (LinphoneCall *) ptr;
1681         linphone_call_set_authentication_token_verified(call, verified);
1682 }
1683
1684 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1685         LinphoneCall *call = (LinphoneCall *) ptr;
1686         return linphone_call_get_play_volume(call);
1687 }
1688
1689 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1690         return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1691 }
1692
1693 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1694 // Implemented directly in msandroid.cpp (sound filters for Android).
1695 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1696
1697 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv*  env,jobject thiz,jboolean speakerOn){
1698         msandroid_hack_speaker_state(speakerOn);
1699 }
1700 // End Galaxy S hack functions
1701
1702
1703 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1704         return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1705 }
1706 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1707         linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1708 }
1709
1710 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1711                 jstring jHost, jint port, jint mirror, jint delay) {
1712         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1713         if (!tunnel) return;
1714         const char* cHost=env->GetStringUTFChars(jHost, NULL);
1715         linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1716         env->ReleaseStringUTFChars(jHost, cHost);
1717 }
1718
1719 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1720                 jstring jHost, jint port, jstring username, jstring password) {
1721
1722         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1723         if (!tunnel) return;
1724         const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1725         const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1726         const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1727         linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1728         if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1729         if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1730         if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1731 }
1732
1733
1734 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1735         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1736         linphone_tunnel_auto_detect(tunnel);
1737
1738 }
1739
1740 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1741         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1742         linphone_tunnel_clean_servers(tunnel);
1743 }
1744
1745 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1746         LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1747         linphone_tunnel_enable(tunnel, enable);
1748 }
1749
1750
1751 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
1752         const char* cname=env->GetStringUTFChars(name, NULL);
1753         const char* cversion=env->GetStringUTFChars(version, NULL);
1754         linphone_core_set_user_agent(cname,cversion);
1755         env->ReleaseStringUTFChars(name, cname);
1756         env->ReleaseStringUTFChars(version, cversion);
1757 }
1758
1759 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1760         return linphone_core_tunnel_available();
1761 }
1762
1763 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1764         LinphoneVideoPolicy vpol;
1765         vpol.automatically_initiate = autoInitiate;
1766         vpol.automatically_accept = autoAccept;
1767         linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
1768 }
1769
1770 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
1771         ms_set_cpu_count(count);
1772 }
1773
1774 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv*  env,jobject  thiz,jlong ptr) {
1775         jstring jvalue =env->NewStringUTF(linphone_core_get_version());
1776         return jvalue;
1777 }