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 listernerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
100 /*displayStatus(LinphoneCore lc,String message);*/
101 displayStatusId = env->GetMethodID(listernerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
103 /*void generalState(LinphoneCore lc,int state); */
104 globalStateId = env->GetMethodID(listernerClass,"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(listernerClass,"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(listernerClass,"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(listernerClass,"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(listernerClass,"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(listernerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
129 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
130 notifyPresenceReceivedId = env->GetMethodID(listernerClass,"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(listernerClass,"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(listernerClass);
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 listernerClass;
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_enableKeepAlive(JNIEnv* env
705 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
708 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
711 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
714 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
718 return linphone_core_start_echo_calibration((LinphoneCore*)lc
719 , LinphoneCoreData::ecCalibrationStatus
720 , data?env->NewGlobalRef(data):NULL);
728 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
729 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
730 return (jlong) proxy;
733 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
734 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
736 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
737 const char* identity = env->GetStringUTFChars(jidentity, NULL);
738 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
739 env->ReleaseStringUTFChars(jidentity, identity);
741 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
742 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
744 return env->NewStringUTF(identity);
749 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
750 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
751 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
752 env->ReleaseStringUTFChars(jproxy, proxy);
755 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
756 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
758 return env->NewStringUTF(proxy);
763 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
764 if (jroute != NULL) {
765 const char* route = env->GetStringUTFChars(jroute, NULL);
766 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
767 env->ReleaseStringUTFChars(jroute, route);
770 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
773 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
774 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
776 return env->NewStringUTF(route);
782 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
783 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
785 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
786 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
788 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
789 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
791 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
792 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
794 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
795 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
797 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
799 ms_error("cannot normalized null number");
801 const char* number = env->GetStringUTFChars(jnumber, NULL);
802 int len = env->GetStringLength(jnumber);
804 ms_warning("cannot normalize empty number");
807 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
808 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
809 jstring normalizedNumber = env->NewStringUTF(targetBuff);
810 env->ReleaseStringUTFChars(jnumber, number);
811 return normalizedNumber;
813 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
816 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
818 return env->NewStringUTF(domain);
823 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
824 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
827 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
831 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
832 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
833 env->ReleaseStringUTFChars(jprefix, prefix);
835 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
839 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
841 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
842 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
847 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
855 const char* username = env->GetStringUTFChars(jusername, NULL);
856 const char* password = env->GetStringUTFChars(jpassword, NULL);
857 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
859 env->ReleaseStringUTFChars(jusername, username);
860 env->ReleaseStringUTFChars(jpassword, password);
864 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
867 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
872 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
875 ,jstring jdisplayName) {
876 const char* uri = env->GetStringUTFChars(juri, NULL);
877 LinphoneAddress* address = linphone_address_new(uri);
878 if (jdisplayName && address) {
879 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
880 linphone_address_set_display_name(address,displayName);
881 env->ReleaseStringUTFChars(jdisplayName, displayName);
883 env->ReleaseStringUTFChars(juri, uri);
885 return (jlong) address;
887 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
890 linphone_address_destroy((LinphoneAddress*)ptr);
893 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
896 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
898 return env->NewStringUTF(displayName);
903 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
906 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
908 return env->NewStringUTF(userName);
913 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
916 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
918 return env->NewStringUTF(domain);
924 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
927 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
928 jstring juri =env->NewStringUTF(uri);
932 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
935 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
936 jstring juri =env->NewStringUTF(uri);
940 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
943 ,jstring jdisplayName) {
944 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
945 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
946 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
951 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
954 return (jlong)((LinphoneCallLog*)ptr)->from;
956 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
959 return (jlong)((LinphoneCallLog*)ptr)->to;
961 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
964 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
968 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
969 PayloadType* pt = (PayloadType*)ptr;
970 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
971 ,payload_type_get_mime(pt)
972 ,payload_type_get_rate(pt)
973 ,payload_type_get_bitrate(pt));
974 jstring jvalue =env->NewStringUTF(value);
978 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
979 PayloadType* pt = (PayloadType*)ptr;
980 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
983 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
984 PayloadType* pt = (PayloadType*)ptr;
985 return payload_type_get_rate(pt);
989 extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv* env
992 linphone_call_ref((LinphoneCall*)ptr);
995 extern "C" void Java_org_linphone_core_LinphoneCallImpl_unref(JNIEnv* env
998 linphone_call_unref((LinphoneCall*)ptr);
1001 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1004 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1007 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1010 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1013 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1016 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1019 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1022 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1024 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1028 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1030 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1033 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1036 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1040 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1042 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1045 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1048 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1051 return (jlong)linphone_call_get_replaced_call((LinphoneCall*)ptr);
1054 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1057 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1060 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1063 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1068 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1070 ,jstring jFriendUri) {
1071 LinphoneFriend* lResult;
1074 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1075 lResult= linphone_friend_new_with_addr(friendUri);
1076 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1078 lResult = linphone_friend_new();
1080 return (long)lResult;
1082 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1085 ,jlong linphoneAddress) {
1086 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1088 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1091 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1093 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1097 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1099 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1102 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1104 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1108 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1110 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1113 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1115 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1118 return linphone_friend_get_status((LinphoneFriend*)ptr);
1120 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1123 return linphone_friend_edit((LinphoneFriend*)ptr);
1125 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1128 linphone_friend_done((LinphoneFriend*)ptr);
1131 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1134 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1136 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1139 ,jstring jmessage) {
1140 const char* message = env->GetStringUTFChars(jmessage, NULL);
1141 linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1142 env->ReleaseStringUTFChars(jmessage, message);
1146 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1150 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1154 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1155 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1158 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1159 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1162 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1163 const char* server = NULL;
1164 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1165 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1166 if (server) env->ReleaseStringUTFChars(jserver,server);
1169 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1170 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1171 if (ret==NULL) return NULL;
1172 jstring jvalue =env->NewStringUTF(ret);
1176 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1177 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1180 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1181 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1184 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1185 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1187 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1188 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1190 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1191 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1194 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1195 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1198 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1199 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1202 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1203 return (jlong) linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params);
1206 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1207 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1210 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1211 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1215 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1217 vsize.width = (int)width;
1218 vsize.height = (int)height;
1219 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1222 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1223 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1224 jintArray arr = env->NewIntArray(2);
1225 int tVsize [2]= {vsize.width,vsize.height};
1226 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1230 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1231 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1234 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1235 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1238 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1239 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1242 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1243 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1246 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1247 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1249 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1250 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1253 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1254 linphone_call_get_duration((LinphoneCall *) ptr);
1257 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1259 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1272 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1273 LinphoneCore *lc = (LinphoneCore *) ptr;
1279 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1282 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1283 ,jlong lc, jboolean enable) {
1284 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1287 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1288 ,jlong ptr, jint db) {
1289 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1292 extern "C" jboolean Java_org_linphone_core_Version_nativeHasNeon(JNIEnv *env){
1293 if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0)
1299 extern "C" jboolean Java_org_linphone_core_Version_nativeHasZrtp(JNIEnv *env){
1300 return ortp_zrtp_available();
1303 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1304 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1306 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1307 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1309 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1310 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1313 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1315 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1316 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1317 env->ReleaseStringUTFChars(jFile, cFile);
1319 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1323 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1324 LinphoneCall *call = (LinphoneCall *) ptr;
1325 const char* token = linphone_call_get_authentication_token(call);
1326 if (token == NULL) return NULL;
1327 return env->NewStringUTF(token);
1329 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1330 LinphoneCall *call = (LinphoneCall *) ptr;
1331 return linphone_call_get_authentication_token_verified(call);
1333 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_areStreamsEncrypted(JNIEnv* env,jobject thiz,jlong ptr) {
1334 return linphone_call_are_all_streams_encrypted((LinphoneCall *) ptr);