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>
24 #include "linphone_tunnel.h"
28 #include "mediastreamer2/mediastream.h"
30 #include "mediastreamer2/msjava.h"
32 #include <cpu-features.h>
35 #include <android/log.h>
36 extern "C" void libmsilbc_init();
38 extern "C" void libmsx264_init();
41 extern "C" void libmsamr_init();
44 extern "C" void libmssilk_init();
51 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
54 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
55 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
56 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
57 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
58 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
59 default: prio = ANDROID_LOG_DEFAULT; break;
61 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
64 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
65 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
69 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
75 return JNI_VERSION_1_2;
80 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
84 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
86 linphone_core_disable_logs();
91 class LinphoneCoreData {
93 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
95 core = env->NewGlobalRef(lc);
96 listener = env->NewGlobalRef(alistener);
97 userdata = auserdata?env->NewGlobalRef(auserdata):0;
98 memset(&vTable,0,sizeof(vTable));
99 vTable.show = showInterfaceCb;
100 vTable.auth_info_requested = authInfoRequested;
101 vTable.display_status = displayStatusCb;
102 vTable.display_message = displayMessageCb;
103 vTable.display_warning = displayMessageCb;
104 vTable.global_state_changed = globalStateChange;
105 vTable.registration_state_changed = registrationStateChange;
106 vTable.call_state_changed = callStateChange;
107 vTable.call_encryption_changed = callEncryptionChange;
108 vTable.text_received = text_received;
109 vTable.new_subscription_request = new_subscription_request;
110 vTable.notify_presence_recv = notify_presence_recv;
112 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
114 /*displayStatus(LinphoneCore lc,String message);*/
115 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
117 /*void generalState(LinphoneCore lc,int state); */
118 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
119 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
120 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
122 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
123 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
124 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
125 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
127 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
128 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
129 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
130 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
132 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
133 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
135 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
136 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
137 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
138 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
140 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
141 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
143 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
144 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
146 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
147 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
149 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
150 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
152 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
153 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
155 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
156 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
158 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
159 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
161 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
162 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
166 ~LinphoneCoreData() {
168 jvm->AttachCurrentThread(&env,NULL);
169 env->DeleteGlobalRef(core);
170 env->DeleteGlobalRef(listener);
171 if (userdata) env->DeleteGlobalRef(userdata);
172 env->DeleteGlobalRef(listenerClass);
173 env->DeleteGlobalRef(globalStateClass);
174 env->DeleteGlobalRef(registrationStateClass);
175 env->DeleteGlobalRef(callStateClass);
176 env->DeleteGlobalRef(proxyClass);
177 env->DeleteGlobalRef(callClass);
178 env->DeleteGlobalRef(chatRoomClass);
179 env->DeleteGlobalRef(friendClass);
186 jclass listenerClass;
187 jmethodID displayStatusId;
188 jmethodID newSubscriptionRequestId;
189 jmethodID notifyPresenceReceivedId;
190 jmethodID textReceivedId;
192 jclass globalStateClass;
193 jmethodID globalStateId;
194 jmethodID globalStateFromIntId;
196 jclass registrationStateClass;
197 jmethodID registrationStateId;
198 jmethodID registrationStateFromIntId;
200 jclass callStateClass;
201 jmethodID callStateId;
202 jmethodID callStateFromIntId;
204 jmethodID callEncryptionChangedId;
206 jclass ecCalibratorStatusClass;
207 jmethodID ecCalibrationStatusId;
208 jmethodID ecCalibratorStatusFromIntId;
211 jmethodID proxyCtrId;
216 jclass chatRoomClass;
217 jmethodID chatRoomCtrId;
220 jmethodID friendCtrId;
223 jmethodID addressCtrId;
225 LinphoneCoreVTable vTable;
227 static void showInterfaceCb(LinphoneCore *lc) {
230 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
233 static void displayStatusCb(LinphoneCore *lc, const char *message) {
235 jint result = jvm->AttachCurrentThread(&env,NULL);
237 ms_error("cannot attach VM\n");
240 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
241 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
243 static void displayMessageCb(LinphoneCore *lc, const char *message) {
246 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
249 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,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->globalStateId
260 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
261 message ? env->NewStringUTF(message) : NULL);
263 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
265 jint result = jvm->AttachCurrentThread(&env,NULL);
267 ms_error("cannot attach VM\n");
270 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
271 env->CallVoidMethod(lcData->listener
272 ,lcData->registrationStateId
274 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
275 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
276 message ? env->NewStringUTF(message) : NULL);
278 jobject getCall(JNIEnv *env , LinphoneCall *call){
282 void *up=linphone_call_get_user_pointer(call);
285 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
286 jobj=env->NewGlobalRef(jobj);
287 linphone_call_set_user_pointer(call,(void*)jobj);
288 linphone_call_ref(call);
296 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
298 jint result = jvm->AttachCurrentThread(&env,NULL);
301 ms_error("cannot attach VM\n");
304 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
305 env->CallVoidMethod(lcData->listener
308 ,(jcall=lcData->getCall(env,call))
309 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
310 message ? env->NewStringUTF(message) : NULL);
311 if (state==LinphoneCallReleased){
312 linphone_call_set_user_pointer(call,NULL);
313 env->DeleteGlobalRef(jcall);
316 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
318 jint result = jvm->AttachCurrentThread(&env,NULL);
320 ms_error("cannot attach VM\n");
323 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
324 env->CallVoidMethod(lcData->listener
325 ,lcData->callEncryptionChangedId
327 ,lcData->getCall(env,call)
329 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
331 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
333 jint result = jvm->AttachCurrentThread(&env,NULL);
335 ms_error("cannot attach VM\n");
338 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
339 env->CallVoidMethod(lcData->listener
340 ,lcData->notifyPresenceReceivedId
342 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
344 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
346 jint result = jvm->AttachCurrentThread(&env,NULL);
348 ms_error("cannot attach VM\n");
351 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
352 env->CallVoidMethod(lcData->listener
353 ,lcData->newSubscriptionRequestId
355 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
356 ,url ? env->NewStringUTF(url) : NULL);
358 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
360 jint result = jvm->AttachCurrentThread(&env,NULL);
362 ms_error("cannot attach VM\n");
365 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
366 env->CallVoidMethod(lcData->listener
367 ,lcData->textReceivedId
369 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
370 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
371 ,message ? env->NewStringUTF(message) : NULL);
373 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
375 jint result = jvm->AttachCurrentThread(&env,NULL);
377 ms_error("cannot attach VM\n");
380 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
381 env->CallVoidMethod(lcData->listener
382 ,lcData->ecCalibrationStatusId
384 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
386 ,data ? data : NULL);
387 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
388 //final state, releasing global ref
389 env->DeleteGlobalRef((jobject)data);
396 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
400 ,jstring jfactoryConfig
403 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
404 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
405 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
408 libmsilbc_init(); // requires an fpu
419 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
423 //clear auth info list
424 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
425 //clear existing proxy config
426 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
428 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
429 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
432 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
435 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
436 linphone_core_destroy((LinphoneCore*)lc);
440 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
441 linphone_core_clear_proxy_config((LinphoneCore*)lc);
444 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
448 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
450 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
453 LinphoneProxyConfig *config=0;
454 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
455 return (jlong)config;
458 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
459 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
460 int proxyCount = ms_list_size(proxies);
461 jlongArray jProxies = env->NewLongArray(proxyCount);
462 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
464 for (int i = 0; i < proxyCount; i++ ) {
465 jInternalArray[i] = (unsigned long) (proxies->data);
466 proxies = proxies->next;
469 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
474 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
479 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
480 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
482 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
485 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
486 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
489 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
493 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
495 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
498 linphone_core_iterate((LinphoneCore*)lc);
500 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
504 const char* uri = env->GetStringUTFChars(juri, NULL);
505 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
506 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
507 env->ReleaseStringUTFChars(juri, uri);
508 return lcd->getCall(env,lCall);
510 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
514 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
515 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
518 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
522 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
525 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
528 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
530 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
534 return linphone_core_in_call((LinphoneCore*)lc);
536 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
540 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
542 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
547 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
550 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
554 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
556 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
559 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
561 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
564 ,jboolean isReachable) {
565 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
568 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
572 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
575 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
578 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
581 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
585 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
588 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
592 const char* url = env->GetStringUTFChars(jurl, NULL);
593 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
594 env->ReleaseStringUTFChars(jurl, url);
597 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
601 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
603 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
608 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
610 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
613 linphone_core_stop_dtmf((LinphoneCore*)lc);
616 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
619 linphone_core_clear_call_logs((LinphoneCore*)lc);
621 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
624 return linphone_core_is_mic_muted((LinphoneCore*)lc);
626 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
631 const char* mime = env->GetStringUTFChars(jmime, NULL);
632 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
633 env->ReleaseStringUTFChars(jmime, mime);
636 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
639 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
640 int codecsCount = ms_list_size(codecs);
641 jlongArray jCodecs = env->NewLongArray(codecsCount);
642 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
644 for (int i = 0; i < codecsCount; i++ ) {
645 jInternalArray[i] = (unsigned long) (codecs->data);
646 codecs = codecs->next;
649 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
654 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
657 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
658 int codecsCount = ms_list_size(codecs);
659 jlongArray jCodecs = env->NewLongArray(codecsCount);
660 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
662 for (int i = 0; i < codecsCount; i++ ) {
663 jInternalArray[i] = (unsigned long) (codecs->data);
664 codecs = codecs->next;
667 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
672 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
677 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
679 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
683 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
685 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
689 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
691 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
695 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
698 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
702 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
705 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
709 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
711 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
713 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
718 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
720 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
724 ,jstring jalternative_contact
726 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
727 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
728 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
731 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
736 const char* to = env->GetStringUTFChars(jto, NULL);
737 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
738 env->ReleaseStringUTFChars(jto, to);
739 return (long)lResult;
742 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
745 ,jboolean vcap_enabled
746 ,jboolean display_enabled) {
747 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
750 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
753 return linphone_core_video_enabled((LinphoneCore*)lc);
755 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
759 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
760 linphone_core_set_play_file((LinphoneCore*)lc,path);
761 if (path) env->ReleaseStringUTFChars(jpath, path);
763 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
767 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
768 linphone_core_set_ring((LinphoneCore*)lc,path);
769 if (path) env->ReleaseStringUTFChars(jpath, path);
771 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
775 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
777 return env->NewStringUTF(path);
782 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
786 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
787 linphone_core_set_root_ca((LinphoneCore*)lc,path);
788 if (path) env->ReleaseStringUTFChars(jpath, path);
790 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
794 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
797 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
800 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
803 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
807 return linphone_core_start_echo_calibration((LinphoneCore*)lc
808 , LinphoneCoreData::ecCalibrationStatus
809 , data?env->NewGlobalRef(data):NULL);
813 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
817 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
820 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
824 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
827 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
831 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
834 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
838 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
841 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
845 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
848 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
852 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
855 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
860 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
865 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
866 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
867 return (jlong) proxy;
870 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
871 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
873 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
874 const char* identity = env->GetStringUTFChars(jidentity, NULL);
875 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
876 env->ReleaseStringUTFChars(jidentity, identity);
878 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
879 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
881 return env->NewStringUTF(identity);
886 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
887 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
888 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
889 env->ReleaseStringUTFChars(jproxy, proxy);
892 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
893 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
895 return env->NewStringUTF(proxy);
900 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
901 if (jroute != NULL) {
902 const char* route = env->GetStringUTFChars(jroute, NULL);
903 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
904 env->ReleaseStringUTFChars(jroute, route);
907 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
910 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
911 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
913 return env->NewStringUTF(route);
919 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
920 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
922 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
923 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
925 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
926 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
928 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
929 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
931 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
932 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
934 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
936 ms_error("cannot normalized null number");
938 const char* number = env->GetStringUTFChars(jnumber, NULL);
939 int len = env->GetStringLength(jnumber);
941 ms_warning("cannot normalize empty number");
944 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
945 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
946 jstring normalizedNumber = env->NewStringUTF(targetBuff);
947 env->ReleaseStringUTFChars(jnumber, number);
948 return normalizedNumber;
950 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
953 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
955 return env->NewStringUTF(domain);
960 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
961 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
964 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
968 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
969 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
970 env->ReleaseStringUTFChars(jprefix, prefix);
972 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
976 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
978 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
979 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
984 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
992 const char* username = env->GetStringUTFChars(jusername, NULL);
993 const char* password = env->GetStringUTFChars(jpassword, NULL);
994 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
996 env->ReleaseStringUTFChars(jusername, username);
997 env->ReleaseStringUTFChars(jpassword, password);
1001 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1004 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1009 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1012 ,jstring jdisplayName) {
1013 const char* uri = env->GetStringUTFChars(juri, NULL);
1014 LinphoneAddress* address = linphone_address_new(uri);
1015 if (jdisplayName && address) {
1016 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1017 linphone_address_set_display_name(address,displayName);
1018 env->ReleaseStringUTFChars(jdisplayName, displayName);
1020 env->ReleaseStringUTFChars(juri, uri);
1022 return (jlong) address;
1024 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1027 linphone_address_destroy((LinphoneAddress*)ptr);
1030 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1033 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1035 return env->NewStringUTF(displayName);
1040 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1043 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1045 return env->NewStringUTF(userName);
1050 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1053 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1055 return env->NewStringUTF(domain);
1061 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1064 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1065 jstring juri =env->NewStringUTF(uri);
1069 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1072 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1073 jstring juri =env->NewStringUTF(uri);
1077 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1080 ,jstring jdisplayName) {
1081 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1082 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1083 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1088 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1091 return (jlong)((LinphoneCallLog*)ptr)->from;
1093 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1096 return (jlong)((LinphoneCallLog*)ptr)->to;
1098 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1101 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1105 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1106 PayloadType* pt = (PayloadType*)ptr;
1107 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1108 ,payload_type_get_mime(pt)
1109 ,payload_type_get_rate(pt)
1110 ,payload_type_get_bitrate(pt));
1111 jstring jvalue =env->NewStringUTF(value);
1115 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1116 PayloadType* pt = (PayloadType*)ptr;
1117 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1120 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1121 PayloadType* pt = (PayloadType*)ptr;
1122 return payload_type_get_rate(pt);
1126 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1129 LinphoneCall *call=(LinphoneCall*)ptr;
1130 linphone_call_unref(call);
1133 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1136 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1139 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1142 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1145 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1148 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1151 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1154 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1156 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1160 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1162 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1165 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1168 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1172 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1174 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1177 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1180 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1183 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1184 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1187 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1190 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1193 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1196 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1201 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1203 ,jstring jFriendUri) {
1204 LinphoneFriend* lResult;
1207 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1208 lResult= linphone_friend_new_with_addr(friendUri);
1209 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1211 lResult = linphone_friend_new();
1213 return (long)lResult;
1215 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1218 ,jlong linphoneAddress) {
1219 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1221 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1224 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1226 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1230 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1232 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1235 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1237 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1241 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1243 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1246 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1248 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1251 return linphone_friend_get_status((LinphoneFriend*)ptr);
1253 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1256 return linphone_friend_edit((LinphoneFriend*)ptr);
1258 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1261 linphone_friend_done((LinphoneFriend*)ptr);
1264 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1267 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1269 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1272 ,jstring jmessage) {
1273 const char* message = env->GetStringUTFChars(jmessage, NULL);
1274 linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1275 env->ReleaseStringUTFChars(jmessage, message);
1279 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1283 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1284 if (oldWindow != NULL) {
1285 env->DeleteGlobalRef(oldWindow);
1288 obj = env->NewGlobalRef(obj);
1290 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1293 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1297 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1298 if (oldWindow != NULL) {
1299 env->DeleteGlobalRef(oldWindow);
1302 obj = env->NewGlobalRef(obj);
1304 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1307 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1311 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1315 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1316 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1319 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1320 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1323 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1324 const char* server = NULL;
1325 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1326 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1327 if (server) env->ReleaseStringUTFChars(jserver,server);
1330 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1331 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1332 if (ret==NULL) return NULL;
1333 jstring jvalue =env->NewStringUTF(ret);
1337 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1338 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1341 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1342 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1345 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1346 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1349 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1350 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1353 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1354 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1356 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1357 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1360 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1361 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1364 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1365 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1368 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1369 linphone_call_camera_enabled((LinphoneCall *)lc);
1372 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1373 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1374 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1377 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1378 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1381 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1382 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1386 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1388 vsize.width = (int)width;
1389 vsize.height = (int)height;
1390 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1393 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1394 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1395 jintArray arr = env->NewIntArray(2);
1396 int tVsize [2]= {vsize.width,vsize.height};
1397 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1401 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1402 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1405 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1406 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1409 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1410 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1413 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1414 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1417 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1418 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1420 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1421 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1424 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1425 linphone_call_get_duration((LinphoneCall *) ptr);
1428 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1430 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1443 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1444 LinphoneCore *lc = (LinphoneCore *) ptr;
1450 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1453 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1454 ,jlong lc, jboolean enable) {
1455 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1458 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1459 ,jlong ptr, jint db) {
1460 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1463 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1464 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1466 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1467 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1469 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1470 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1472 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1473 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1475 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1476 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1478 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1479 linphone_core_leave_conference((LinphoneCore *) pCore);
1481 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1482 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1484 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1485 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1487 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1488 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1491 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1492 linphone_core_terminate_conference((LinphoneCore *) pCore);
1494 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1495 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1497 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1498 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1500 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1501 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1502 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1503 return lcd->getCall(env,lCall);
1505 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1506 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1509 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1510 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1511 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1512 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1514 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1515 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1518 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1520 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1521 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1522 env->ReleaseStringUTFChars(jFile, cFile);
1524 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1528 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1529 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1530 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1531 env->ReleaseStringUTFChars(jUri, cUri);
1532 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1533 return (jobject) lcdata->getCall(env,call);
1537 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1538 LinphoneCore* lc = (LinphoneCore *) pCore;
1539 const char** devices = linphone_core_get_video_devices(lc);
1540 if (devices == NULL) {
1541 ms_error("No existing video devices\n");
1545 for(i=0; i<=id; i++) {
1546 if (devices[i] == NULL)
1548 ms_message("Existing device %d : %s\n", i, devices[i]);
1550 return linphone_core_set_video_device(lc, devices[i]);
1556 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1557 LinphoneCore* lc = (LinphoneCore *) pCore;
1558 const char** devices = linphone_core_get_video_devices(lc);
1559 if (devices == NULL) {
1560 ms_error("No existing video devices\n");
1563 const char* cam = linphone_core_get_video_device(lc);
1565 ms_error("No current video device\n");
1568 while(devices[i] != NULL) {
1569 if (strcmp(devices[i], cam) == 0)
1574 ms_warning("Returning default (0) device\n");
1578 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1579 LinphoneCall *call = (LinphoneCall *) ptr;
1580 const char* token = linphone_call_get_authentication_token(call);
1581 if (token == NULL) return NULL;
1582 return env->NewStringUTF(token);
1584 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1585 LinphoneCall *call = (LinphoneCall *) ptr;
1586 return linphone_call_get_authentication_token_verified(call);
1588 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1589 LinphoneCall *call = (LinphoneCall *) ptr;
1590 linphone_call_set_authentication_token_verified(call, verified);
1593 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1594 LinphoneCall *call = (LinphoneCall *) ptr;
1595 return linphone_call_get_play_volume(call);
1598 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1599 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1602 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1603 // Implemented directly in msandroid.cpp (sound filters for Android).
1604 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1606 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1607 msandroid_hack_speaker_state(speakerOn);
1609 // End Galaxy S hack functions
1612 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1613 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1615 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1616 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1619 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1620 jstring jHost, jint port, jint mirror, jint delay) {
1621 #ifdef TUNNEL_ENABLED
1622 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1623 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1624 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1625 env->ReleaseStringUTFChars(jHost, cHost);
1629 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1630 #ifdef TUNNEL_ENABLED
1631 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1632 linphone_tunnel_auto_detect(tunnel);
1636 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1637 #ifdef TUNNEL_ENABLED
1638 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1639 linphone_tunnel_clean_servers(tunnel);
1643 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1644 #ifdef TUNNEL_ENABLED
1645 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1646 linphone_tunnel_enable(tunnel, enable);
1650 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnableLogs(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1651 #ifdef TUNNEL_ENABLED
1652 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1653 linphone_tunnel_enable_logs(tunnel, enable);
1657 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1658 return linphone_core_tunnel_available();