3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
23 #include "mediastreamer2/msjava.h"
25 #include <cpu-features.h>
28 #include <android/log.h>
29 extern "C" void libmsilbc_init();
31 extern "C" void libmsx264_init();
34 extern "C" void libmsamr_init();
41 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
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;
51 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
55 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
61 return JNI_VERSION_1_2;
66 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
70 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
72 linphone_core_disable_logs();
77 class LinphoneCoreData {
79 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
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;
98 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
100 /*displayStatus(LinphoneCore lc,String message);*/
101 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
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;");
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;");
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;");
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");
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;");
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");
129 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
130 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
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");
135 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
136 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
138 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
139 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
141 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
142 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
144 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
145 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
147 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
148 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
152 ~LinphoneCoreData() {
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);
172 jclass listenerClass;
173 jmethodID displayStatusId;
174 jmethodID newSubscriptionRequestId;
175 jmethodID notifyPresenceReceivedId;
176 jmethodID textReceivedId;
178 jclass globalStateClass;
179 jmethodID globalStateId;
180 jmethodID globalStateFromIntId;
182 jclass registrationStateClass;
183 jmethodID registrationStateId;
184 jmethodID registrationStateFromIntId;
186 jclass callStateClass;
187 jmethodID callStateId;
188 jmethodID callStateFromIntId;
190 jmethodID callEncryptionChangedId;
192 jclass ecCalibratorStatusClass;
193 jmethodID ecCalibrationStatusId;
194 jmethodID ecCalibratorStatusFromIntId;
197 jmethodID proxyCtrId;
202 jclass chatRoomClass;
203 jmethodID chatRoomCtrId;
206 jmethodID friendCtrId;
209 jmethodID addressCtrId;
211 LinphoneCoreVTable vTable;
213 static void showInterfaceCb(LinphoneCore *lc) {
216 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
219 static void displayStatusCb(LinphoneCore *lc, const char *message) {
221 jint result = jvm->AttachCurrentThread(&env,NULL);
223 ms_error("cannot attach VM\n");
226 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
227 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
229 static void displayMessageCb(LinphoneCore *lc, const char *message) {
232 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
235 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
237 jint result = jvm->AttachCurrentThread(&env,NULL);
239 ms_error("cannot attach VM\n");
242 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
243 env->CallVoidMethod(lcData->listener
244 ,lcData->globalStateId
246 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
247 message ? env->NewStringUTF(message) : NULL);
249 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
251 jint result = jvm->AttachCurrentThread(&env,NULL);
253 ms_error("cannot attach VM\n");
256 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
257 env->CallVoidMethod(lcData->listener
258 ,lcData->registrationStateId
260 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
261 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
262 message ? env->NewStringUTF(message) : NULL);
264 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
266 jint result = jvm->AttachCurrentThread(&env,NULL);
268 ms_error("cannot attach VM\n");
271 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
272 env->CallVoidMethod(lcData->listener
275 ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call)
276 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
277 message ? env->NewStringUTF(message) : NULL);
279 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
281 jint result = jvm->AttachCurrentThread(&env,NULL);
283 ms_error("cannot attach VM\n");
286 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
287 env->CallVoidMethod(lcData->listener
288 ,lcData->callEncryptionChangedId
290 ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call)
292 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
294 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
296 jint result = jvm->AttachCurrentThread(&env,NULL);
298 ms_error("cannot attach VM\n");
301 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
302 env->CallVoidMethod(lcData->listener
303 ,lcData->notifyPresenceReceivedId
305 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
307 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
309 jint result = jvm->AttachCurrentThread(&env,NULL);
311 ms_error("cannot attach VM\n");
314 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
315 env->CallVoidMethod(lcData->listener
316 ,lcData->newSubscriptionRequestId
318 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
319 ,url ? env->NewStringUTF(url) : NULL);
321 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
323 jint result = jvm->AttachCurrentThread(&env,NULL);
325 ms_error("cannot attach VM\n");
328 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
329 env->CallVoidMethod(lcData->listener
330 ,lcData->textReceivedId
332 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
333 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
334 ,message ? env->NewStringUTF(message) : NULL);
336 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
338 jint result = jvm->AttachCurrentThread(&env,NULL);
340 ms_error("cannot attach VM\n");
343 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
344 env->CallVoidMethod(lcData->listener
345 ,lcData->ecCalibrationStatusId
347 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
349 ,data ? data : NULL);
350 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
351 //final state, releasing global ref
352 env->DeleteGlobalRef((jobject)data);
359 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
363 ,jstring jfactoryConfig
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);
371 libmsilbc_init(); // requires an fpu
379 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
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);
388 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
389 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
392 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
395 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
396 linphone_core_destroy((LinphoneCore*)lc);
400 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
401 linphone_core_clear_proxy_config((LinphoneCore*)lc);
404 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
408 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
410 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
413 LinphoneProxyConfig *config=0;
414 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
415 return (jlong)config;
418 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
423 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
424 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
426 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
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);
433 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
437 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
439 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
442 linphone_core_iterate((LinphoneCore*)lc);
444 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
448 const char* uri = env->GetStringUTFChars(juri, NULL);
449 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
450 env->ReleaseStringUTFChars(juri, uri);
453 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
457 return (jlong) linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to);
460 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
464 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
467 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
470 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
472 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
476 return linphone_core_in_call((LinphoneCore*)lc);
478 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
482 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
484 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
489 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
492 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
496 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
498 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
501 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
503 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
506 ,jboolean isReachable) {
507 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
510 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
514 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
517 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
520 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
523 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
527 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
530 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
534 const char* url = env->GetStringUTFChars(jurl, NULL);
535 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
536 env->ReleaseStringUTFChars(jurl, url);
539 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
543 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
550 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
555 linphone_core_stop_dtmf((LinphoneCore*)lc);
558 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
561 linphone_core_clear_call_logs((LinphoneCore*)lc);
563 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
566 return linphone_core_is_mic_muted((LinphoneCore*)lc);
568 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
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);
578 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
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);
586 for (int i = 0; i < codecsCount; i++ ) {
587 jInternalArray[i] = (unsigned long) (codecs->data);
588 codecs = codecs->next;
591 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
596 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
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);
604 for (int i = 0; i < codecsCount; i++ ) {
605 jInternalArray[i] = (unsigned long) (codecs->data);
606 codecs = codecs->next;
609 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
614 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
619 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
621 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
625 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
627 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
631 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
634 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
638 return (jlong)linphone_core_get_current_call((LinphoneCore*)lc);
640 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
645 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
647 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
651 ,jstring jalternative_contact
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);
658 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
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;
669 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
672 ,jboolean vcap_enabled
673 ,jboolean display_enabled) {
674 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
677 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
680 return linphone_core_video_enabled((LinphoneCore*)lc);
682 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
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);
690 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
694 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
696 return env->NewStringUTF(path);
701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
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);
709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
713 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
716 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
719 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
722 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
726 return linphone_core_start_echo_calibration((LinphoneCore*)lc
727 , LinphoneCoreData::ecCalibrationStatus
728 , data?env->NewGlobalRef(data):NULL);
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;
741 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
742 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
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);
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);
752 return env->NewStringUTF(identity);
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);
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);
766 return env->NewStringUTF(proxy);
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);
778 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
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);
784 return env->NewStringUTF(route);
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);
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);
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);
799 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
800 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
802 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
803 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
805 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
807 ms_error("cannot normalized null number");
809 const char* number = env->GetStringUTFChars(jnumber, NULL);
810 int len = env->GetStringLength(jnumber);
812 ms_warning("cannot normalize empty number");
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;
821 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
824 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
826 return env->NewStringUTF(domain);
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);
835 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
839 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
840 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
841 env->ReleaseStringUTFChars(jprefix, prefix);
843 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
847 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
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);
855 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
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);
867 env->ReleaseStringUTFChars(jusername, username);
868 env->ReleaseStringUTFChars(jpassword, password);
872 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
875 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
880 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
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);
891 env->ReleaseStringUTFChars(juri, uri);
893 return (jlong) address;
895 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
898 linphone_address_destroy((LinphoneAddress*)ptr);
901 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
904 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
906 return env->NewStringUTF(displayName);
911 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
914 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
916 return env->NewStringUTF(userName);
921 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
924 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
926 return env->NewStringUTF(domain);
932 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
935 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
936 jstring juri =env->NewStringUTF(uri);
940 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
943 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
944 jstring juri =env->NewStringUTF(uri);
948 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
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);
959 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
962 return (jlong)((LinphoneCallLog*)ptr)->from;
964 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
967 return (jlong)((LinphoneCallLog*)ptr)->to;
969 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
972 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
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);
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));
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);
997 extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv* env
1000 linphone_call_ref((LinphoneCall*)ptr);
1003 extern "C" void Java_org_linphone_core_LinphoneCallImpl_unref(JNIEnv* env
1006 linphone_call_unref((LinphoneCall*)ptr);
1009 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1012 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1015 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1018 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1021 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1024 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1027 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1030 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1032 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1036 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1038 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1041 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1044 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1048 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1050 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1053 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1056 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1059 return (jlong)linphone_call_get_replaced_call((LinphoneCall*)ptr);
1062 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1065 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1068 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1071 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1076 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1078 ,jstring jFriendUri) {
1079 LinphoneFriend* lResult;
1082 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1083 lResult= linphone_friend_new_with_addr(friendUri);
1084 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1086 lResult = linphone_friend_new();
1088 return (long)lResult;
1090 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1093 ,jlong linphoneAddress) {
1094 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1096 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1099 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1101 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1105 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1107 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1110 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1112 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1116 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1118 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1121 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1123 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1126 return linphone_friend_get_status((LinphoneFriend*)ptr);
1128 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1131 return linphone_friend_edit((LinphoneFriend*)ptr);
1133 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1136 linphone_friend_done((LinphoneFriend*)ptr);
1139 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1142 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1144 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
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);
1154 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1158 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
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);
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);
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);
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);
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);
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);
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);
1195 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1196 return linphone_call_params_destroy((LinphoneCallParams*)lc);
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);
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));
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);
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);
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);
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);
1223 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1225 vsize.width = (int)width;
1226 vsize.height = (int)height;
1227 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
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);
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);
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);
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);
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);
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);
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);
1261 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1262 linphone_call_get_duration((LinphoneCall *) ptr);
1265 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1267 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
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;
1287 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
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);
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);
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)
1307 extern "C" jboolean Java_org_linphone_core_Version_nativeHasZrtp(JNIEnv *env){
1308 return ortp_zrtp_available();
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);
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);
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);
1321 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1323 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1324 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1325 env->ReleaseStringUTFChars(jFile, cFile);
1327 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
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);
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);
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);