]> sjero.net Git - linphone/blob - coreapi/linphonecore_jni.cc
Merge branch 'master' of git.savannah.nongnu.org:/srv/git/linphone
[linphone] / coreapi / linphonecore_jni.cc
1 /*
2 linphonecore_jni.cc
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19 #include <jni.h>
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
22
23 #include "mediastreamer2/msjava.h"
24
25 #include <cpu-features.h>
26
27 #ifdef ANDROID
28 #include <android/log.h>
29 extern "C" void libmsilbc_init();
30 #ifdef HAVE_X264
31 extern "C" void libmsx264_init();
32 #endif
33 #ifdef HAVE_AMR
34 extern "C" void libmsamr_init();
35 #endif
36 #endif /*ANDROID*/
37
38 static JavaVM *jvm=0;
39
40 #ifdef ANDROID
41 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
42         int prio;
43         switch(lev){
44         case ORTP_DEBUG:        prio = ANDROID_LOG_DEBUG;       break;
45         case ORTP_MESSAGE:      prio = ANDROID_LOG_INFO;        break;
46         case ORTP_WARNING:      prio = ANDROID_LOG_WARN;        break;
47         case ORTP_ERROR:        prio = ANDROID_LOG_ERROR;       break;
48         case ORTP_FATAL:        prio = ANDROID_LOG_FATAL;       break;
49         default:                prio = ANDROID_LOG_DEFAULT;     break;
50         }
51         __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
52 }
53 #endif /*ANDROID*/
54
55 JNIEXPORT jint JNICALL  JNI_OnLoad(JavaVM *ajvm, void *reserved)
56 {
57 #ifdef ANDROID
58         ms_set_jvm(ajvm);
59 #endif /*ANDROID*/
60         jvm=ajvm;
61         return JNI_VERSION_1_2;
62 }
63
64
65 //LinphoneFactory
66 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv*  env
67                 ,jobject  thiz
68                 ,jboolean isDebug) {
69         if (isDebug) {
70                 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
71         } else {
72                 linphone_core_disable_logs();
73         }
74 }
75 // LinphoneCore
76
77 class LinphoneCoreData {
78 public:
79         LinphoneCoreData(JNIEnv*  env, jobject lc,jobject alistener, jobject auserdata) {
80
81                 core = env->NewGlobalRef(lc);
82                 listener = env->NewGlobalRef(alistener);
83                 userdata = auserdata?env->NewGlobalRef(auserdata):0;
84                 memset(&vTable,0,sizeof(vTable));
85                 vTable.show = showInterfaceCb;
86                 vTable.auth_info_requested = authInfoRequested;
87                 vTable.display_status = displayStatusCb;
88                 vTable.display_message = displayMessageCb;
89                 vTable.display_warning = displayMessageCb;
90                 vTable.global_state_changed = globalStateChange;
91                 vTable.registration_state_changed = registrationStateChange;
92                 vTable.call_state_changed = callStateChange;
93                 vTable.call_encryption_changed = callEncryptionChange;
94                 vTable.text_received = text_received;
95                 vTable.new_subscription_request = new_subscription_request;
96                 vTable.notify_presence_recv = notify_presence_recv;
97
98                 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
99
100                 /*displayStatus(LinphoneCore lc,String message);*/
101                 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
102
103                 /*void generalState(LinphoneCore lc,int state); */
104                 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
105                 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
106                 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
107
108                 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
109                 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
110                 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
111                 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
112
113                 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
114                 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
115                 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
116                 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
117
118                 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
119                 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
120
121                 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
122                 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
123                 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
124                 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
125
126                 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
127                 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
128
129                 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
130                 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
131
132                 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
133                 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
134
135                 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
136                 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
137
138                 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
139                 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
140
141                 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
142                 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
143
144                 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
145                 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
146
147                 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
148                 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
149
150         }
151
152         ~LinphoneCoreData() {
153                 JNIEnv *env = 0;
154                 jvm->AttachCurrentThread(&env,NULL);
155                 env->DeleteGlobalRef(core);
156                 env->DeleteGlobalRef(listener);
157                 if (userdata) env->DeleteGlobalRef(userdata);
158                 env->DeleteGlobalRef(listenerClass);
159                 env->DeleteGlobalRef(globalStateClass);
160                 env->DeleteGlobalRef(registrationStateClass);
161                 env->DeleteGlobalRef(callStateClass);
162                 env->DeleteGlobalRef(proxyClass);
163                 env->DeleteGlobalRef(callClass);
164                 env->DeleteGlobalRef(chatRoomClass);
165                 env->DeleteGlobalRef(friendClass);
166
167         }
168         jobject core;
169         jobject listener;
170         jobject userdata;
171
172         jclass listenerClass;
173         jmethodID displayStatusId;
174         jmethodID newSubscriptionRequestId;
175         jmethodID notifyPresenceReceivedId;
176         jmethodID textReceivedId;
177
178         jclass globalStateClass;
179         jmethodID globalStateId;
180         jmethodID globalStateFromIntId;
181
182         jclass registrationStateClass;
183         jmethodID registrationStateId;
184         jmethodID registrationStateFromIntId;
185
186         jclass callStateClass;
187         jmethodID callStateId;
188         jmethodID callStateFromIntId;
189
190         jmethodID callEncryptionChangedId;
191
192         jclass ecCalibratorStatusClass;
193         jmethodID ecCalibrationStatusId;
194         jmethodID ecCalibratorStatusFromIntId;
195
196         jclass proxyClass;
197         jmethodID proxyCtrId;
198
199         jclass callClass;
200         jmethodID callCtrId;
201
202         jclass chatRoomClass;
203         jmethodID chatRoomCtrId;
204
205         jclass friendClass;
206         jmethodID friendCtrId;
207
208         jclass addressClass;
209         jmethodID addressCtrId;
210
211         LinphoneCoreVTable vTable;
212
213         static void showInterfaceCb(LinphoneCore *lc) {
214
215         }
216         static void byeReceivedCb(LinphoneCore *lc, const char *from) {
217
218         }
219         static void displayStatusCb(LinphoneCore *lc, const char *message) {
220                 JNIEnv *env = 0;
221                 jint result = jvm->AttachCurrentThread(&env,NULL);
222                 if (result != 0) {
223                         ms_error("cannot attach VM\n");
224                         return;
225                 }
226                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
227                 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
228         }
229         static void displayMessageCb(LinphoneCore *lc, const char *message) {
230
231         }
232         static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
233
234         }
235         static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
236                 JNIEnv *env = 0;
237                 jint result = jvm->AttachCurrentThread(&env,NULL);
238                 if (result != 0) {
239                         ms_error("cannot attach VM\n");
240                         return;
241                 }
242                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
243                 env->CallVoidMethod(lcData->listener
244                                                         ,lcData->globalStateId
245                                                         ,lcData->core
246                                                         ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
247                                                         message ? env->NewStringUTF(message) : NULL);
248         }
249         static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
250                 JNIEnv *env = 0;
251                 jint result = jvm->AttachCurrentThread(&env,NULL);
252                 if (result != 0) {
253                         ms_error("cannot attach VM\n");
254                         return;
255                 }
256                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
257                 env->CallVoidMethod(lcData->listener
258                                                         ,lcData->registrationStateId
259                                                         ,lcData->core
260                                                         ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
261                                                         ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
262                                                         message ? env->NewStringUTF(message) : NULL);
263         }
264         static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
265                 JNIEnv *env = 0;
266                 jint result = jvm->AttachCurrentThread(&env,NULL);
267                 if (result != 0) {
268                         ms_error("cannot attach VM\n");
269                         return;
270                 }
271                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
272                 env->CallVoidMethod(lcData->listener
273                                                         ,lcData->callStateId
274                                                         ,lcData->core
275                                                         ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call)
276                                                         ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
277                                                         message ? env->NewStringUTF(message) : NULL);
278         }
279         static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
280                 JNIEnv *env = 0;
281                 jint result = jvm->AttachCurrentThread(&env,NULL);
282                 if (result != 0) {
283                         ms_error("cannot attach VM\n");
284                         return;
285                 }
286                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
287                 env->CallVoidMethod(lcData->listener
288                                                         ,lcData->callEncryptionChangedId
289                                                         ,lcData->core
290                                                         ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call)
291                                                         ,encrypted
292                                                         ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
293         }
294         static void notify_presence_recv (LinphoneCore *lc,  LinphoneFriend *my_friend) {
295                 JNIEnv *env = 0;
296                 jint result = jvm->AttachCurrentThread(&env,NULL);
297                 if (result != 0) {
298                         ms_error("cannot attach VM\n");
299                         return;
300                 }
301                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
302                 env->CallVoidMethod(lcData->listener
303                                                         ,lcData->notifyPresenceReceivedId
304                                                         ,lcData->core
305                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
306         }
307         static void new_subscription_request (LinphoneCore *lc,  LinphoneFriend *my_friend, const char* url) {
308                 JNIEnv *env = 0;
309                 jint result = jvm->AttachCurrentThread(&env,NULL);
310                 if (result != 0) {
311                         ms_error("cannot attach VM\n");
312                         return;
313                 }
314                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
315                 env->CallVoidMethod(lcData->listener
316                                                         ,lcData->newSubscriptionRequestId
317                                                         ,lcData->core
318                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
319                                                         ,url ? env->NewStringUTF(url) : NULL);
320         }
321         static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
322                 JNIEnv *env = 0;
323                 jint result = jvm->AttachCurrentThread(&env,NULL);
324                 if (result != 0) {
325                         ms_error("cannot attach VM\n");
326                         return;
327                 }
328                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
329                 env->CallVoidMethod(lcData->listener
330                                                         ,lcData->textReceivedId
331                                                         ,lcData->core
332                                                         ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
333                                                         ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
334                                                         ,message ? env->NewStringUTF(message) : NULL);
335         }
336         static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
337                 JNIEnv *env = 0;
338                 jint result = jvm->AttachCurrentThread(&env,NULL);
339                 if (result != 0) {
340                         ms_error("cannot attach VM\n");
341                         return;
342                 }
343                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
344                 env->CallVoidMethod(lcData->listener
345                                                         ,lcData->ecCalibrationStatusId
346                                                         ,lcData->core
347                                                         ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
348                                                         ,delay_ms
349                                                         ,data ? data : NULL);
350                 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
351                         //final state, releasing global ref
352                         env->DeleteGlobalRef((jobject)data);
353                 }
354
355         }
356
357
358 };
359 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*  env
360                 ,jobject  thiz
361                 ,jobject jlistener
362                 ,jstring juserConfig
363                 ,jstring jfactoryConfig
364                 ,jobject  juserdata){
365
366         const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
367         const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
368         LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
369
370 #ifdef HAVE_ILBC
371         libmsilbc_init(); // requires an fpu
372 #endif
373 #ifdef HAVE_X264
374         libmsx264_init();
375 #endif
376 #ifdef HAVE_AMR
377         libmsamr_init();
378 #endif
379         jlong nativePtr = (jlong)linphone_core_new(     &ldata->vTable
380                         ,userConfig
381                         ,factoryConfig
382                         ,ldata);
383         //clear auth info list
384         linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
385         //clear existing proxy config
386         linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
387
388         if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
389         if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
390         return nativePtr;
391 }
392 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv*  env
393                 ,jobject  thiz
394                 ,jlong lc) {
395         LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
396         linphone_core_destroy((LinphoneCore*)lc);
397         delete lcData;
398 }
399
400 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
401         linphone_core_clear_proxy_config((LinphoneCore*)lc);
402 }
403
404 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig(  JNIEnv*  env
405                 ,jobject  thiz
406                 ,jlong lc
407                 ,jlong pc) {
408         linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
409 }
410 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv*  env
411                 ,jobject  thiz
412                 ,jlong lc) {
413         LinphoneProxyConfig *config=0;
414         linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
415         return (jlong)config;
416 }
417
418 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig(  JNIEnv*  env
419                 ,jobject  thiz
420                 ,jobject jproxyCfg
421                 ,jlong lc
422                 ,jlong pc) {
423         LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
424         linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
425
426         return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
427 }
428
429 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
430         linphone_core_clear_all_auth_info((LinphoneCore*)lc);
431 }
432
433 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo(    JNIEnv*  env
434                 ,jobject  thiz
435                 ,jlong lc
436                 ,jlong pc) {
437         linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
438 }
439 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate(        JNIEnv*  env
440                 ,jobject  thiz
441                 ,jlong lc) {
442         linphone_core_iterate((LinphoneCore*)lc);
443 }
444 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_invite(        JNIEnv*  env
445                 ,jobject  thiz
446                 ,jlong lc
447                 ,jstring juri) {
448         const char* uri = env->GetStringUTFChars(juri, NULL);
449         LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
450         env->ReleaseStringUTFChars(juri, uri);
451         return (jlong)lCall;
452 }
453 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv*  env
454                 ,jobject  thiz
455                 ,jlong lc
456                 ,jlong to) {
457         return (jlong) linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to);
458 }
459
460 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall(  JNIEnv*  env
461                 ,jobject  thiz
462                 ,jlong lc
463                 ,jlong call) {
464         linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
465 }
466
467 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress(      JNIEnv*  env
468                 ,jobject  thiz
469                 ,jlong lc) {
470         return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
471 }
472 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall(   JNIEnv*  env
473                 ,jobject  thiz
474                 ,jlong lc) {
475
476         return linphone_core_in_call((LinphoneCore*)lc);
477 }
478 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending(    JNIEnv*  env
479                 ,jobject  thiz
480                 ,jlong lc) {
481
482         return linphone_core_inc_invite_pending((LinphoneCore*)lc);
483 }
484 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall(     JNIEnv*  env
485                 ,jobject  thiz
486                 ,jlong lc
487                 ,jlong call) {
488
489         linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
490 }
491
492 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog(    JNIEnv*  env
493                 ,jobject  thiz
494                 ,jlong lc
495                 ,jint position) {
496                 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
497 }
498 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs(    JNIEnv*  env
499                 ,jobject  thiz
500                 ,jlong lc) {
501                 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
502 }
503 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable(       JNIEnv*  env
504                 ,jobject  thiz
505                 ,jlong lc
506                 ,jboolean isReachable) {
507                 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
508 }
509
510 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain(        JNIEnv*  env
511                 ,jobject  thiz
512                 ,jlong lc
513                 ,jfloat gain) {
514                 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
515 }
516
517 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain(       JNIEnv*  env
518                 ,jobject  thiz
519                 ,jlong lc) {
520                 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
521 }
522
523 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic(        JNIEnv*  env
524                 ,jobject  thiz
525                 ,jlong lc
526                 ,jboolean isMuted) {
527                 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
528 }
529
530 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl(  JNIEnv*  env
531                 ,jobject  thiz
532                 ,jlong lc
533                 ,jstring jurl) {
534         const char* url = env->GetStringUTFChars(jurl, NULL);
535         jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
536         env->ReleaseStringUTFChars(jurl, url);
537         return result;
538 }
539 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf(       JNIEnv*  env
540                 ,jobject  thiz
541                 ,jlong lc
542                 ,jchar dtmf) {
543         linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
544 }
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf(       JNIEnv*  env
546                 ,jobject  thiz
547                 ,jlong lc
548                 ,jchar dtmf
549                 ,jint duration) {
550         linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
551 }
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf(       JNIEnv*  env
553                 ,jobject  thiz
554                 ,jlong lc) {
555         linphone_core_stop_dtmf((LinphoneCore*)lc);
556 }
557
558 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv*  env
559                                                                                                                                                 ,jobject  thiz
560                                                                                                                                                 ,jlong lc) {
561         linphone_core_clear_call_logs((LinphoneCore*)lc);
562 }
563 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv*  env
564                 ,jobject  thiz
565                 ,jlong lc) {
566         return linphone_core_is_mic_muted((LinphoneCore*)lc);
567 }
568 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv*  env
569                                                                                                                                                         ,jobject  thiz
570                                                                                                                                                         ,jlong lc
571                                                                                                                                                         ,jstring jmime
572                                                                                                                                                         ,jint rate) {
573         const char* mime = env->GetStringUTFChars(jmime, NULL);
574         jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
575         env->ReleaseStringUTFChars(jmime, mime);
576         return result;
577 }
578 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv*  env
579                                                                                                                                                         ,jobject  thiz
580                                                                                                                                                         ,jlong lc) {
581         const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
582         int codecsCount = ms_list_size(codecs);
583         jlongArray jCodecs = env->NewLongArray(codecsCount);
584         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
585
586         for (int i = 0; i < codecsCount; i++ ) {
587                 jInternalArray[i] = (unsigned long) (codecs->data);
588                 codecs = codecs->next;
589         }
590
591         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
592
593         return jCodecs;
594 }
595
596 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv*  env
597                                                                                                                                                         ,jobject  thiz
598                                                                                                                                                         ,jlong lc) {
599         const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
600         int codecsCount = ms_list_size(codecs);
601         jlongArray jCodecs = env->NewLongArray(codecsCount);
602         jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
603
604         for (int i = 0; i < codecsCount; i++ ) {
605                 jInternalArray[i] = (unsigned long) (codecs->data);
606                 codecs = codecs->next;
607         }
608
609         env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
610
611         return jCodecs;
612 }
613
614 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv*  env
615                                                                                                                                                         ,jobject  thiz
616                                                                                                                                                         ,jlong lc
617                                                                                                                                                         ,jlong pt
618                                                                                                                                                         ,jboolean enable) {
619         return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
620 }
621 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv*  env
622                                                                                                                                                         ,jobject  thiz
623                                                                                                                                                         ,jlong lc
624                                                                                                                                                         ,jboolean enable) {
625         linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
626 }
627 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv*  env
628                                                                                                                                                         ,jobject  thiz
629                                                                                                                                                         ,jlong lc
630                                                                                                                                                         ) {
631         return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
632 }
633
634 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv*  env
635                                                                                                                                                         ,jobject  thiz
636                                                                                                                                                         ,jlong lc
637                                                                                                                                                         ) {
638         return (jlong)linphone_core_get_current_call((LinphoneCore*)lc);
639 }
640 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv*  env
641                                                                                                                                                         ,jobject  thiz
642                                                                                                                                                         ,jlong lc
643                                                                                                                                                         ,jlong aFriend
644                                                                                                                                                         ) {
645         linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
646 }
647 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*  env
648                                                                                                                                                         ,jobject  thiz
649                                                                                                                                                         ,jlong lc
650                                                                                                                                                         ,jint minute_away
651                                                                                                                                                         ,jstring jalternative_contact
652                                                                                                                                                         ,jint status) {
653         const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
654         linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
655         if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
656 }
657
658 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
659                                                                                                                                                         ,jobject  thiz
660                                                                                                                                                         ,jlong lc
661                                                                                                                                                         ,jstring jto) {
662
663         const char* to = env->GetStringUTFChars(jto, NULL);
664         LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
665         env->ReleaseStringUTFChars(jto, to);
666         return (long)lResult;
667 }
668
669 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv*  env
670                                                                                                                                                         ,jobject  thiz
671                                                                                                                                                         ,jlong lc
672                                                                                                                                                         ,jboolean vcap_enabled
673                                                                                                                                                         ,jboolean display_enabled) {
674         linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
675
676 }
677 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv*  env
678                                                                                                                                                         ,jobject  thiz
679                                                                                                                                                         ,jlong lc) {
680         return linphone_core_video_enabled((LinphoneCore*)lc);
681 }
682 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv*  env
683                                                                                                                                                         ,jobject  thiz
684                                                                                                                                                         ,jlong lc
685                                                                                                                                                         ,jstring jpath) {
686         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
687         linphone_core_set_ring((LinphoneCore*)lc,path);
688         if (path) env->ReleaseStringUTFChars(jpath, path);
689 }
690 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
691                                                                                                                                                         ,jobject  thiz
692                                                                                                                                                         ,jlong lc
693                                                                                                                                                         ) {
694         const char* path = linphone_core_get_ring((LinphoneCore*)lc);
695         if (path) {
696                 return env->NewStringUTF(path);
697         } else {
698                 return NULL;
699         }
700 }
701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv*  env
702                                                                                                                                                         ,jobject  thiz
703                                                                                                                                                         ,jlong lc
704                                                                                                                                                         ,jstring jpath) {
705         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
706         linphone_core_set_root_ca((LinphoneCore*)lc,path);
707         if (path) env->ReleaseStringUTFChars(jpath, path);
708 }
709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv*  env
710                                                                                                                                 ,jobject  thiz
711                                                                                                                                 ,jlong lc
712                                                                                                                                 ,jboolean enable) {
713         linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
714
715 }
716 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv*  env
717                                                                                                                                 ,jobject  thiz
718                                                                                                                                 ,jlong lc) {
719         return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
720
721 }
722 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv*  env
723                                                                                                                                                                 ,jobject  thiz
724                                                                                                                                                                 ,jlong lc
725                                                                                                                                                                 ,jobject data) {
726         return linphone_core_start_echo_calibration((LinphoneCore*)lc
727                                                                                                         , LinphoneCoreData::ecCalibrationStatus
728                                                                                                         , data?env->NewGlobalRef(data):NULL);
729
730 }
731
732
733
734 //ProxyConfig
735
736 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
737         LinphoneProxyConfig* proxy = linphone_proxy_config_new();
738         return  (jlong) proxy;
739 }
740
741 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv*  env,jobject  thiz,jlong ptr) {
742         linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
743 }
744 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
745         const char* identity = env->GetStringUTFChars(jidentity, NULL);
746         linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
747         env->ReleaseStringUTFChars(jidentity, identity);
748 }
749 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
750         const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
751         if (identity) {
752                 return env->NewStringUTF(identity);
753         } else {
754                 return NULL;
755         }
756 }
757 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
758         const char* proxy = env->GetStringUTFChars(jproxy, NULL);
759         int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
760         env->ReleaseStringUTFChars(jproxy, proxy);
761         return err;
762 }
763 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
764         const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
765         if (proxy) {
766                 return env->NewStringUTF(proxy);
767         } else {
768                 return NULL;
769         }
770 }
771 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
772         if (jroute != NULL) {
773                 const char* route = env->GetStringUTFChars(jroute, NULL);
774                 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
775                 env->ReleaseStringUTFChars(jroute, route);
776                 return err;
777         } else {
778                 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
779         }
780 }
781 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
782         const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
783         if (route) {
784                 return env->NewStringUTF(route);
785         } else {
786                 return NULL;
787         }
788 }
789
790 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
791         linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
792 }
793 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
794         return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
795 }
796 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
797         return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
798 }
799 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
800         linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
801 }
802 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
803         linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
804 }
805 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
806         if (jnumber == 0) {
807                 ms_error("cannot normalized null number");
808         }
809         const char* number = env->GetStringUTFChars(jnumber, NULL);
810         int len = env->GetStringLength(jnumber);
811         if (len == 0) {
812                 ms_warning("cannot normalize empty number");
813                 return jnumber;
814         }
815         char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
816         linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
817         jstring normalizedNumber = env->NewStringUTF(targetBuff);
818         env->ReleaseStringUTFChars(jnumber, number);
819         return normalizedNumber;
820 }
821 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
822                                                                                                                                                         ,jobject thiz
823                                                                                                                                                         ,jlong proxyCfg) {
824         const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
825         if (domain) {
826                 return env->NewStringUTF(domain);
827         } else {
828                 return NULL;
829         }
830 }
831 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
832         linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
833 }
834
835 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
836                                                                                                                                         ,jobject thiz
837                                                                                                                                         ,jlong proxyCfg
838                                                                                                                                         ,jstring jprefix) {
839         const char* prefix = env->GetStringUTFChars(jprefix, NULL);
840         linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
841         env->ReleaseStringUTFChars(jprefix, prefix);
842 }
843 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
844                                                                                                                                                                 ,jobject thiz
845                                                                                                                                                                 ,jlong proxyCfg
846                                                                                                                                                                 ,jboolean val) {
847         linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
848 }
849 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
850         return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
851 }
852
853 //Auth Info
854
855 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
856                 , jobject thiz
857                 , jstring jusername
858                 , jstring juserid
859                 , jstring jpassword
860                 , jstring jha1
861                 , jstring jrealm) {
862
863         const char* username = env->GetStringUTFChars(jusername, NULL);
864         const char* password = env->GetStringUTFChars(jpassword, NULL);
865         jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
866
867         env->ReleaseStringUTFChars(jusername, username);
868         env->ReleaseStringUTFChars(jpassword, password);
869         return auth;
870
871 }
872 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
873                 , jobject thiz
874                 , jlong ptr) {
875         linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
876 }
877
878 //LinphoneAddress
879
880 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv*  env
881                                                                                                                                                                         ,jobject  thiz
882                                                                                                                                                                         ,jstring juri
883                                                                                                                                                                         ,jstring jdisplayName) {
884         const char* uri = env->GetStringUTFChars(juri, NULL);
885         LinphoneAddress* address = linphone_address_new(uri);
886         if (jdisplayName && address) {
887                 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
888                 linphone_address_set_display_name(address,displayName);
889                 env->ReleaseStringUTFChars(jdisplayName, displayName);
890         }
891         env->ReleaseStringUTFChars(juri, uri);
892
893         return  (jlong) address;
894 }
895 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv*  env
896                                                                                                                                                 ,jobject  thiz
897                                                                                                                                                 ,jlong ptr) {
898         linphone_address_destroy((LinphoneAddress*)ptr);
899 }
900
901 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv*  env
902                                                                                                                                                 ,jobject  thiz
903                                                                                                                                                 ,jlong ptr) {
904         const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
905         if (displayName) {
906                 return env->NewStringUTF(displayName);
907         } else {
908                 return 0;
909         }
910 }
911 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv*  env
912                                                                                                                                                 ,jobject  thiz
913                                                                                                                                                 ,jlong ptr) {
914         const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
915         if (userName) {
916                 return env->NewStringUTF(userName);
917         } else {
918                 return 0;
919         }
920 }
921 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv*  env
922                                                                                                                                                 ,jobject  thiz
923                                                                                                                                                 ,jlong ptr) {
924         const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
925         if (domain) {
926                 return env->NewStringUTF(domain);
927         } else {
928                 return 0;
929         }
930 }
931
932 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv*  env
933                                                                                                                                                 ,jobject  thiz
934                                                                                                                                                 ,jlong ptr) {
935         char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
936         jstring juri =env->NewStringUTF(uri);
937         ms_free(uri);
938         return juri;
939 }
940 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv*  env
941                                                                                                                                                 ,jobject  thiz
942                                                                                                                                                 ,jlong ptr) {
943         char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
944         jstring juri =env->NewStringUTF(uri);
945         ms_free(uri);
946         return juri;
947 }
948 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv*  env
949                                                                                                                                                 ,jobject  thiz
950                                                                                                                                                 ,jlong address
951                                                                                                                                                 ,jstring jdisplayName) {
952         const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
953         linphone_address_set_display_name((LinphoneAddress*)address,displayName);
954         if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
955 }
956
957
958 //CallLog
959 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv*  env
960                                                                                                                                                 ,jobject  thiz
961                                                                                                                                                 ,jlong ptr) {
962         return (jlong)((LinphoneCallLog*)ptr)->from;
963 }
964 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv*  env
965                                                                                                                                                 ,jobject  thiz
966                                                                                                                                                 ,jlong ptr) {
967         return (jlong)((LinphoneCallLog*)ptr)->to;
968 }
969 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv*  env
970                                                                                                                                                 ,jobject  thiz
971                                                                                                                                                 ,jlong ptr) {
972         return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
973 }
974
975 /*payloadType*/
976 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env,jobject  thiz,jlong ptr) {
977         PayloadType* pt = (PayloadType*)ptr;
978         char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
979                                                                         ,payload_type_get_mime(pt)
980                                                                         ,payload_type_get_rate(pt)
981                                                                         ,payload_type_get_bitrate(pt));
982         jstring jvalue =env->NewStringUTF(value);
983         ms_free(value);
984         return jvalue;
985 }
986 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv*  env,jobject  thiz,jlong ptr) {
987         PayloadType* pt = (PayloadType*)ptr;
988         jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
989         return jvalue;
990 }
991 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv*  env,jobject  thiz, jlong ptr) {
992         PayloadType* pt = (PayloadType*)ptr;
993         return payload_type_get_rate(pt);
994 }
995
996 //LinphoneCall
997 extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv*  env
998                                                                                                                                                 ,jobject  thiz
999                                                                                                                                                 ,jlong ptr) {
1000         linphone_call_ref((LinphoneCall*)ptr);
1001 }
1002
1003 extern "C" void Java_org_linphone_core_LinphoneCallImpl_unref(JNIEnv*  env
1004                                                                                                                                                 ,jobject  thiz
1005                                                                                                                                                 ,jlong ptr) {
1006         linphone_call_unref((LinphoneCall*)ptr);
1007 }
1008
1009 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog(    JNIEnv*  env
1010                                                                                                                                                 ,jobject  thiz
1011                                                                                                                                                 ,jlong ptr) {
1012         return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1013 }
1014
1015 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv*  env
1016                                                                                                                                                 ,jobject  thiz
1017                                                                                                                                                 ,jlong ptr) {
1018         return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1019 }
1020
1021 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress(      JNIEnv*  env
1022                                                                                                                                                 ,jobject  thiz
1023                                                                                                                                                 ,jlong ptr) {
1024         return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1025 }
1026
1027 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(       JNIEnv*  env
1028                                                                                                                                                 ,jobject  thiz
1029                                                                                                                                                 ,jlong ptr) {
1030         return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1031 }
1032 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv*  env
1033                                                                                                                                                 ,jobject  thiz
1034                                                                                                                                                 ,jlong ptr
1035                                                                                                                                                 ,jboolean value) {
1036         linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1037 }
1038 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled(  JNIEnv*  env
1039                                                                                                                                                 ,jobject  thiz
1040                                                                                                                                                 ,jlong ptr) {
1041         return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1042 }
1043
1044 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter(      JNIEnv*  env
1045                                                                                                                                                 ,jobject  thiz
1046                                                                                                                                                 ,jlong ptr
1047                                                                                                                                                 ,jboolean value) {
1048         linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1049 }
1050 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled(       JNIEnv*  env
1051                                                                                                                                                 ,jobject  thiz
1052                                                                                                                                                 ,jlong ptr) {
1053         return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1054 }
1055
1056 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getReplacedCall(       JNIEnv*  env
1057                                                                                                                                                 ,jobject  thiz
1058                                                                                                                                                 ,jlong ptr) {
1059         return (jlong)linphone_call_get_replaced_call((LinphoneCall*)ptr);
1060 }
1061
1062 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality(    JNIEnv*  env
1063                                                                                                                                                 ,jobject  thiz
1064                                                                                                                                                 ,jlong ptr) {
1065         return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1066 }
1067
1068 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality(    JNIEnv*  env
1069                                                                                                                                                 ,jobject  thiz
1070                                                                                                                                                 ,jlong ptr) {
1071         return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1072 }
1073
1074
1075 //LinphoneFriend
1076 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
1077                                                                                                                                                 ,jobject  thiz
1078                                                                                                                                                 ,jstring jFriendUri) {
1079         LinphoneFriend* lResult;
1080
1081         if (jFriendUri) {
1082                 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1083                 lResult= linphone_friend_new_with_addr(friendUri);
1084                 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1085         } else {
1086                 lResult = linphone_friend_new();
1087         }
1088         return (long)lResult;
1089 }
1090 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
1091                                                                                                                                                 ,jobject  thiz
1092                                                                                                                                                 ,jlong ptr
1093                                                                                                                                                 ,jlong linphoneAddress) {
1094         linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1095 }
1096 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv*  env
1097                                                                                                                                                 ,jobject  thiz
1098                                                                                                                                                 ,jlong ptr) {
1099         return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1100 }
1101 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv*  env
1102                                                                                                                                                 ,jobject  thiz
1103                                                                                                                                                 ,jlong ptr
1104                                                                                                                                                 ,jint policy) {
1105         linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1106 }
1107 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv*  env
1108                                                                                                                                                 ,jobject  thiz
1109                                                                                                                                                 ,jlong ptr) {
1110         return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1111 }
1112 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv*  env
1113                                                                                                                                                 ,jobject  thiz
1114                                                                                                                                                 ,jlong ptr
1115                                                                                                                                                 ,jboolean value) {
1116         linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1117 }
1118 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv*  env
1119                                                                                                                                                 ,jobject  thiz
1120                                                                                                                                                 ,jlong ptr) {
1121         return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1122 }
1123 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv*  env
1124                                                                                                                                                 ,jobject  thiz
1125                                                                                                                                                 ,jlong ptr) {
1126         return linphone_friend_get_status((LinphoneFriend*)ptr);
1127 }
1128 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv*  env
1129                                                                                                                                                 ,jobject  thiz
1130                                                                                                                                                 ,jlong ptr) {
1131         return linphone_friend_edit((LinphoneFriend*)ptr);
1132 }
1133 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv*  env
1134                                                                                                                                                 ,jobject  thiz
1135                                                                                                                                                 ,jlong ptr) {
1136          linphone_friend_done((LinphoneFriend*)ptr);
1137 }
1138 //LinphoneChatRoom
1139 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv*  env
1140                                                                                                                                                 ,jobject  thiz
1141                                                                                                                                                 ,jlong ptr) {
1142         return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1143 }
1144 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*  env
1145                                                                                                                                                 ,jobject  thiz
1146                                                                                                                                                 ,jlong ptr
1147                                                                                                                                                 ,jstring jmessage) {
1148         const char* message = env->GetStringUTFChars(jmessage, NULL);
1149         linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1150         env->ReleaseStringUTFChars(jmessage, message);
1151
1152 }
1153
1154 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1155                                                                                                                                                 ,jobject thiz
1156                                                                                                                                                 ,jlong lc
1157                                                                                                                                                 ,jobject obj) {
1158         linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1159 }
1160
1161
1162 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1163         linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1164 }
1165
1166 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1167         return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1168 }
1169
1170 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1171         const char* server = NULL;
1172         if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1173         linphone_core_set_stun_server((LinphoneCore*)lc,server);
1174         if (server) env->ReleaseStringUTFChars(jserver,server);
1175 }
1176
1177 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1178         const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1179         if (ret==NULL) return NULL;
1180         jstring jvalue =env->NewStringUTF(ret);
1181         return jvalue;
1182 }
1183
1184 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1185         linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1186 }
1187
1188 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1189         linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1190 }
1191
1192 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1193         return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1194 }
1195 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1196         return linphone_call_params_destroy((LinphoneCallParams*)lc);
1197 }
1198 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1199         return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1200 }
1201
1202 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1203         return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1204 }
1205
1206 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1207         linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1208 }
1209
1210 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1211         return (jlong) linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params);
1212 }
1213
1214 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1215         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1216 }
1217
1218 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1219         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1220 }
1221
1222
1223 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1224         MSVideoSize vsize;
1225         vsize.width = (int)width;
1226         vsize.height = (int)height;
1227         linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1228 }
1229
1230 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1231         MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1232     jintArray arr = env->NewIntArray(2);
1233         int tVsize [2]= {vsize.width,vsize.height};
1234     env->SetIntArrayRegion(arr, 0, 2, tVsize);
1235     return arr;
1236 }
1237
1238 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1239         linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1240 }
1241
1242 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1243         linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1244 }
1245
1246 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1247         linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1248 }
1249
1250 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1251         linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1252 }
1253
1254 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv*  env,jobject thiz,jlong ptr) {
1255         return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1256 }
1257 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv*  env,jobject thiz,jlong ptr,jint delay) {
1258         linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1259 }
1260
1261 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv*  env,jobject thiz,jlong ptr) {
1262         linphone_call_get_duration((LinphoneCall *) ptr);
1263 }
1264         
1265 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1266         LCSipTransports tr;
1267         linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1268                 switch (code) {
1269         case 0:
1270                 return tr.udp_port;
1271         case 1:
1272                 return tr.tcp_port;
1273         case 3:
1274                 return tr.tls_port;
1275         default:
1276                 return -2;
1277         }
1278 }
1279
1280 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv*  env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1281         LinphoneCore *lc = (LinphoneCore *) ptr;
1282         LCSipTransports tr;
1283         tr.udp_port = udp;
1284         tr.tcp_port = tcp;
1285         tr.tls_port = tls;
1286         
1287         linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1288 }
1289
1290 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject  thiz
1291               ,jlong lc, jboolean enable) {
1292               linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1293 }
1294
1295 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject  thiz
1296               ,jlong ptr, jint db) {
1297         linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1298 }
1299
1300 extern "C" jboolean Java_org_linphone_core_Version_nativeHasNeon(JNIEnv *env){
1301         if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
1302         {
1303                 return 1;
1304         }
1305         return 0;
1306 }
1307 extern "C" jboolean Java_org_linphone_core_Version_nativeHasZrtp(JNIEnv *env){
1308         return ortp_zrtp_available();
1309 }
1310
1311 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1312         return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1313 }
1314 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1315         return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1316 }
1317 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1318         return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1319 }
1320
1321 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1322         if (jFile) {
1323                 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1324                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1325                 env->ReleaseStringUTFChars(jFile, cFile);
1326         } else {
1327                 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1328         }
1329 }
1330
1331 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv*  env,jobject thiz,jlong ptr) {
1332         LinphoneCall *call = (LinphoneCall *) ptr;
1333         const char* token = linphone_call_get_authentication_token(call);
1334         if (token == NULL) return NULL;
1335         return env->NewStringUTF(token);
1336 }
1337 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv*  env,jobject thiz,jlong ptr) {
1338         LinphoneCall *call = (LinphoneCall *) ptr;
1339         return linphone_call_get_authentication_token_verified(call);
1340 }
1341 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_areStreamsEncrypted(JNIEnv*  env,jobject thiz,jlong ptr) {
1342         return linphone_call_are_all_streams_encrypted((LinphoneCall *) ptr);
1343 }