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