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();
47 extern "C" void libmsbcg729_init();
54 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
57 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
58 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
59 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
60 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
61 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
62 default: prio = ANDROID_LOG_DEFAULT; break;
64 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
67 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
68 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
72 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
78 return JNI_VERSION_1_2;
83 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
87 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
89 linphone_core_disable_logs();
94 class LinphoneCoreData {
96 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
98 core = env->NewGlobalRef(lc);
99 listener = env->NewGlobalRef(alistener);
100 userdata = auserdata?env->NewGlobalRef(auserdata):0;
101 memset(&vTable,0,sizeof(vTable));
102 vTable.show = showInterfaceCb;
103 vTable.auth_info_requested = authInfoRequested;
104 vTable.display_status = displayStatusCb;
105 vTable.display_message = displayMessageCb;
106 vTable.display_warning = displayMessageCb;
107 vTable.global_state_changed = globalStateChange;
108 vTable.registration_state_changed = registrationStateChange;
109 vTable.call_state_changed = callStateChange;
110 vTable.call_encryption_changed = callEncryptionChange;
111 vTable.text_received = text_received;
112 vTable.new_subscription_request = new_subscription_request;
113 vTable.notify_presence_recv = notify_presence_recv;
115 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
117 /*displayStatus(LinphoneCore lc,String message);*/
118 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
120 /*void generalState(LinphoneCore lc,int state); */
121 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
122 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
123 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
125 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
126 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
127 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
128 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
130 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
131 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
132 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
133 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
135 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
136 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
138 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
139 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
140 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
141 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
143 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
144 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
146 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
147 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
149 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
150 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
152 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
153 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
155 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
156 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
158 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
159 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
161 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
162 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
164 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
165 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
169 ~LinphoneCoreData() {
171 jvm->AttachCurrentThread(&env,NULL);
172 env->DeleteGlobalRef(core);
173 env->DeleteGlobalRef(listener);
174 if (userdata) env->DeleteGlobalRef(userdata);
175 env->DeleteGlobalRef(listenerClass);
176 env->DeleteGlobalRef(globalStateClass);
177 env->DeleteGlobalRef(registrationStateClass);
178 env->DeleteGlobalRef(callStateClass);
179 env->DeleteGlobalRef(proxyClass);
180 env->DeleteGlobalRef(callClass);
181 env->DeleteGlobalRef(chatRoomClass);
182 env->DeleteGlobalRef(friendClass);
189 jclass listenerClass;
190 jmethodID displayStatusId;
191 jmethodID newSubscriptionRequestId;
192 jmethodID notifyPresenceReceivedId;
193 jmethodID textReceivedId;
195 jclass globalStateClass;
196 jmethodID globalStateId;
197 jmethodID globalStateFromIntId;
199 jclass registrationStateClass;
200 jmethodID registrationStateId;
201 jmethodID registrationStateFromIntId;
203 jclass callStateClass;
204 jmethodID callStateId;
205 jmethodID callStateFromIntId;
207 jmethodID callEncryptionChangedId;
209 jclass ecCalibratorStatusClass;
210 jmethodID ecCalibrationStatusId;
211 jmethodID ecCalibratorStatusFromIntId;
214 jmethodID proxyCtrId;
219 jclass chatRoomClass;
220 jmethodID chatRoomCtrId;
223 jmethodID friendCtrId;
226 jmethodID addressCtrId;
228 LinphoneCoreVTable vTable;
230 static void showInterfaceCb(LinphoneCore *lc) {
233 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
236 static void displayStatusCb(LinphoneCore *lc, const char *message) {
238 jint result = jvm->AttachCurrentThread(&env,NULL);
240 ms_error("cannot attach VM\n");
243 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
244 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
246 static void displayMessageCb(LinphoneCore *lc, const char *message) {
249 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
252 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
254 jint result = jvm->AttachCurrentThread(&env,NULL);
256 ms_error("cannot attach VM\n");
259 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
260 env->CallVoidMethod(lcData->listener
261 ,lcData->globalStateId
263 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
264 message ? env->NewStringUTF(message) : NULL);
266 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
268 jint result = jvm->AttachCurrentThread(&env,NULL);
270 ms_error("cannot attach VM\n");
273 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
274 env->CallVoidMethod(lcData->listener
275 ,lcData->registrationStateId
277 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
278 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
279 message ? env->NewStringUTF(message) : NULL);
281 jobject getCall(JNIEnv *env , LinphoneCall *call){
285 void *up=linphone_call_get_user_pointer(call);
288 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
289 jobj=env->NewGlobalRef(jobj);
290 linphone_call_set_user_pointer(call,(void*)jobj);
291 linphone_call_ref(call);
299 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
301 jint result = jvm->AttachCurrentThread(&env,NULL);
304 ms_error("cannot attach VM\n");
307 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
308 env->CallVoidMethod(lcData->listener
311 ,(jcall=lcData->getCall(env,call))
312 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
313 message ? env->NewStringUTF(message) : NULL);
314 if (state==LinphoneCallReleased){
315 linphone_call_set_user_pointer(call,NULL);
316 env->DeleteGlobalRef(jcall);
319 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
321 jint result = jvm->AttachCurrentThread(&env,NULL);
323 ms_error("cannot attach VM\n");
326 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
327 env->CallVoidMethod(lcData->listener
328 ,lcData->callEncryptionChangedId
330 ,lcData->getCall(env,call)
332 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
334 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
336 jint result = jvm->AttachCurrentThread(&env,NULL);
338 ms_error("cannot attach VM\n");
341 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
342 env->CallVoidMethod(lcData->listener
343 ,lcData->notifyPresenceReceivedId
345 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
347 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
349 jint result = jvm->AttachCurrentThread(&env,NULL);
351 ms_error("cannot attach VM\n");
354 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
355 env->CallVoidMethod(lcData->listener
356 ,lcData->newSubscriptionRequestId
358 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
359 ,url ? env->NewStringUTF(url) : NULL);
361 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
363 jint result = jvm->AttachCurrentThread(&env,NULL);
365 ms_error("cannot attach VM\n");
368 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
369 env->CallVoidMethod(lcData->listener
370 ,lcData->textReceivedId
372 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
373 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
374 ,message ? env->NewStringUTF(message) : NULL);
376 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
378 jint result = jvm->AttachCurrentThread(&env,NULL);
380 ms_error("cannot attach VM\n");
383 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
384 env->CallVoidMethod(lcData->listener
385 ,lcData->ecCalibrationStatusId
387 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
389 ,data ? data : NULL);
390 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
391 //final state, releasing global ref
392 env->DeleteGlobalRef((jobject)data);
399 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
403 ,jstring jfactoryConfig
406 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
407 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
408 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
411 libmsilbc_init(); // requires an fpu
425 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
429 //clear auth info list
430 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
431 //clear existing proxy config
432 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
434 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
435 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
438 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
441 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
442 linphone_core_destroy((LinphoneCore*)lc);
446 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
447 linphone_core_clear_proxy_config((LinphoneCore*)lc);
450 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
454 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
456 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
459 LinphoneProxyConfig *config=0;
460 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
461 return (jlong)config;
464 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
465 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
466 int proxyCount = ms_list_size(proxies);
467 jlongArray jProxies = env->NewLongArray(proxyCount);
468 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
470 for (int i = 0; i < proxyCount; i++ ) {
471 jInternalArray[i] = (unsigned long) (proxies->data);
472 proxies = proxies->next;
475 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
480 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
485 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
486 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
488 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
491 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
492 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
495 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
499 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
501 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
504 linphone_core_iterate((LinphoneCore*)lc);
506 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
510 const char* uri = env->GetStringUTFChars(juri, NULL);
511 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
512 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
513 env->ReleaseStringUTFChars(juri, uri);
514 return lcd->getCall(env,lCall);
516 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
520 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
521 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
524 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
528 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
531 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
534 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
536 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
540 return linphone_core_in_call((LinphoneCore*)lc);
542 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
546 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
548 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
553 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
556 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
561 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
564 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
569 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
572 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
577 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
580 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
584 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
586 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
589 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
591 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
594 ,jboolean isReachable) {
595 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
598 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
602 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
605 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
608 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
611 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
615 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
618 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
622 const char* url = env->GetStringUTFChars(jurl, NULL);
623 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
624 env->ReleaseStringUTFChars(jurl, url);
627 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
631 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
633 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
638 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
640 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
643 linphone_core_stop_dtmf((LinphoneCore*)lc);
646 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
649 linphone_core_clear_call_logs((LinphoneCore*)lc);
651 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
654 return linphone_core_is_mic_muted((LinphoneCore*)lc);
656 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
661 const char* mime = env->GetStringUTFChars(jmime, NULL);
662 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
663 env->ReleaseStringUTFChars(jmime, mime);
666 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
669 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
670 int codecsCount = ms_list_size(codecs);
671 jlongArray jCodecs = env->NewLongArray(codecsCount);
672 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
674 for (int i = 0; i < codecsCount; i++ ) {
675 jInternalArray[i] = (unsigned long) (codecs->data);
676 codecs = codecs->next;
679 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
684 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
687 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
688 int codecsCount = ms_list_size(codecs);
689 jlongArray jCodecs = env->NewLongArray(codecsCount);
690 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
692 for (int i = 0; i < codecsCount; i++ ) {
693 jInternalArray[i] = (unsigned long) (codecs->data);
694 codecs = codecs->next;
697 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
702 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
707 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
713 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
715 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
719 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
721 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
725 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
728 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
732 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
735 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
739 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
741 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
743 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
748 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
750 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
754 ,jstring jalternative_contact
756 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
757 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
758 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
761 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
766 const char* to = env->GetStringUTFChars(jto, NULL);
767 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
768 env->ReleaseStringUTFChars(jto, to);
769 return (long)lResult;
772 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
775 ,jboolean vcap_enabled
776 ,jboolean display_enabled) {
777 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
780 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
783 return linphone_core_video_enabled((LinphoneCore*)lc);
785 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
789 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
790 linphone_core_set_play_file((LinphoneCore*)lc,path);
791 if (path) env->ReleaseStringUTFChars(jpath, path);
793 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
797 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
798 linphone_core_set_ring((LinphoneCore*)lc,path);
799 if (path) env->ReleaseStringUTFChars(jpath, path);
801 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
805 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
807 return env->NewStringUTF(path);
812 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
816 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
817 linphone_core_set_root_ca((LinphoneCore*)lc,path);
818 if (path) env->ReleaseStringUTFChars(jpath, path);
820 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
824 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
827 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
830 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
833 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
837 return linphone_core_start_echo_calibration((LinphoneCore*)lc
838 , LinphoneCoreData::ecCalibrationStatus
839 , data?env->NewGlobalRef(data):NULL);
843 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
847 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
850 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
854 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
857 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
861 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
864 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
868 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
871 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
875 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
878 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
882 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
885 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
890 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
895 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
896 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
897 return (jlong) proxy;
900 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
901 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
903 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
904 const char* identity = env->GetStringUTFChars(jidentity, NULL);
905 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
906 env->ReleaseStringUTFChars(jidentity, identity);
908 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
909 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
911 return env->NewStringUTF(identity);
916 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
917 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
918 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
919 env->ReleaseStringUTFChars(jproxy, proxy);
922 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
923 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
925 return env->NewStringUTF(proxy);
930 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
931 if (jroute != NULL) {
932 const char* route = env->GetStringUTFChars(jroute, NULL);
933 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
934 env->ReleaseStringUTFChars(jroute, route);
937 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
940 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
941 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
943 return env->NewStringUTF(route);
949 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
950 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
952 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
953 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
955 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
956 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
958 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
959 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
961 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
962 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
964 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
966 ms_error("cannot normalized null number");
968 const char* number = env->GetStringUTFChars(jnumber, NULL);
969 int len = env->GetStringLength(jnumber);
971 ms_warning("cannot normalize empty number");
974 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
975 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
976 jstring normalizedNumber = env->NewStringUTF(targetBuff);
977 env->ReleaseStringUTFChars(jnumber, number);
978 return normalizedNumber;
980 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
983 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
985 return env->NewStringUTF(domain);
990 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
991 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
994 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
998 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
999 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1000 env->ReleaseStringUTFChars(jprefix, prefix);
1002 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1006 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1008 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1009 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1014 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1022 const char* username = env->GetStringUTFChars(jusername, NULL);
1023 const char* password = env->GetStringUTFChars(jpassword, NULL);
1024 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1026 env->ReleaseStringUTFChars(jusername, username);
1027 env->ReleaseStringUTFChars(jpassword, password);
1031 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1034 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1039 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1042 ,jstring jdisplayName) {
1043 const char* uri = env->GetStringUTFChars(juri, NULL);
1044 LinphoneAddress* address = linphone_address_new(uri);
1045 if (jdisplayName && address) {
1046 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1047 linphone_address_set_display_name(address,displayName);
1048 env->ReleaseStringUTFChars(jdisplayName, displayName);
1050 env->ReleaseStringUTFChars(juri, uri);
1052 return (jlong) address;
1054 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1057 linphone_address_destroy((LinphoneAddress*)ptr);
1060 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1063 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1065 return env->NewStringUTF(displayName);
1070 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1073 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1075 return env->NewStringUTF(userName);
1080 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1083 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1085 return env->NewStringUTF(domain);
1091 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1094 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1095 jstring juri =env->NewStringUTF(uri);
1099 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1102 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1103 jstring juri =env->NewStringUTF(uri);
1107 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1110 ,jstring jdisplayName) {
1111 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1112 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1113 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1118 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1121 return (jlong)((LinphoneCallLog*)ptr)->from;
1123 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1126 return (jlong)((LinphoneCallLog*)ptr)->to;
1128 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1131 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1135 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1136 PayloadType* pt = (PayloadType*)ptr;
1137 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1138 ,payload_type_get_mime(pt)
1139 ,payload_type_get_rate(pt)
1140 ,payload_type_get_bitrate(pt));
1141 jstring jvalue =env->NewStringUTF(value);
1145 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1146 PayloadType* pt = (PayloadType*)ptr;
1147 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1150 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1151 PayloadType* pt = (PayloadType*)ptr;
1152 return payload_type_get_rate(pt);
1156 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1159 LinphoneCall *call=(LinphoneCall*)ptr;
1160 linphone_call_unref(call);
1163 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1166 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1169 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1172 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1175 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1178 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1181 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1184 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1186 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1190 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1192 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1195 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1198 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1202 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1204 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1207 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1210 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1213 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1214 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1217 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1220 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1223 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1226 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1231 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1233 ,jstring jFriendUri) {
1234 LinphoneFriend* lResult;
1237 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1238 lResult= linphone_friend_new_with_addr(friendUri);
1239 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1241 lResult = linphone_friend_new();
1243 return (long)lResult;
1245 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1248 ,jlong linphoneAddress) {
1249 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1251 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1254 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1256 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1260 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1262 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1265 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1267 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1271 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1273 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1276 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1278 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1281 return linphone_friend_get_status((LinphoneFriend*)ptr);
1283 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1286 return linphone_friend_edit((LinphoneFriend*)ptr);
1288 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1291 linphone_friend_done((LinphoneFriend*)ptr);
1294 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1297 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1299 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1302 ,jstring jmessage) {
1303 const char* message = env->GetStringUTFChars(jmessage, NULL);
1304 linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1305 env->ReleaseStringUTFChars(jmessage, message);
1309 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1313 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1314 if (oldWindow != NULL) {
1315 env->DeleteGlobalRef(oldWindow);
1318 obj = env->NewGlobalRef(obj);
1320 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1323 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1327 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1328 if (oldWindow != NULL) {
1329 env->DeleteGlobalRef(oldWindow);
1332 obj = env->NewGlobalRef(obj);
1334 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1337 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1341 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1345 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1346 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1349 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1350 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1353 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1354 const char* server = NULL;
1355 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1356 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1357 if (server) env->ReleaseStringUTFChars(jserver,server);
1360 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1361 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1362 if (ret==NULL) return NULL;
1363 jstring jvalue =env->NewStringUTF(ret);
1367 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1368 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1371 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1372 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1375 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1376 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1379 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1380 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1383 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1384 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1386 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1387 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1390 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1391 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1394 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1395 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1398 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1399 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1402 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1403 linphone_call_camera_enabled((LinphoneCall *)lc);
1406 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1407 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1408 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1411 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1412 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1415 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1416 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1420 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1422 vsize.width = (int)width;
1423 vsize.height = (int)height;
1424 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1427 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1428 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1429 jintArray arr = env->NewIntArray(2);
1430 int tVsize [2]= {vsize.width,vsize.height};
1431 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1435 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1436 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1439 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1440 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1443 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1444 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1447 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1448 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1451 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1452 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1454 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1455 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1458 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1459 linphone_call_get_duration((LinphoneCall *) ptr);
1462 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1464 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1477 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1478 LinphoneCore *lc = (LinphoneCore *) ptr;
1484 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1487 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1488 ,jlong lc, jboolean enable) {
1489 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1492 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1493 ,jlong ptr, jint db) {
1494 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1497 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1498 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1500 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1501 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1503 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1504 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1506 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1507 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1509 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1510 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1512 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1513 linphone_core_leave_conference((LinphoneCore *) pCore);
1515 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1516 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1518 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1519 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1521 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1522 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1525 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1526 linphone_core_terminate_conference((LinphoneCore *) pCore);
1528 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1529 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1531 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1532 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1534 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1535 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1536 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1537 return lcd->getCall(env,lCall);
1539 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1540 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1543 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1544 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1545 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1546 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1548 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1549 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1554 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1555 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1556 env->ReleaseStringUTFChars(jFile, cFile);
1558 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1562 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1563 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1564 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1565 env->ReleaseStringUTFChars(jUri, cUri);
1566 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1567 return (jobject) lcdata->getCall(env,call);
1571 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1572 LinphoneCore* lc = (LinphoneCore *) pCore;
1573 const char** devices = linphone_core_get_video_devices(lc);
1574 if (devices == NULL) {
1575 ms_error("No existing video devices\n");
1579 for(i=0; i<=id; i++) {
1580 if (devices[i] == NULL)
1582 ms_message("Existing device %d : %s\n", i, devices[i]);
1584 return linphone_core_set_video_device(lc, devices[i]);
1590 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1591 LinphoneCore* lc = (LinphoneCore *) pCore;
1592 const char** devices = linphone_core_get_video_devices(lc);
1593 if (devices == NULL) {
1594 ms_error("No existing video devices\n");
1597 const char* cam = linphone_core_get_video_device(lc);
1599 ms_error("No current video device\n");
1602 while(devices[i] != NULL) {
1603 if (strcmp(devices[i], cam) == 0)
1608 ms_warning("Returning default (0) device\n");
1612 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1613 LinphoneCall *call = (LinphoneCall *) ptr;
1614 const char* token = linphone_call_get_authentication_token(call);
1615 if (token == NULL) return NULL;
1616 return env->NewStringUTF(token);
1618 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1619 LinphoneCall *call = (LinphoneCall *) ptr;
1620 return linphone_call_get_authentication_token_verified(call);
1622 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1623 LinphoneCall *call = (LinphoneCall *) ptr;
1624 linphone_call_set_authentication_token_verified(call, verified);
1627 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1628 LinphoneCall *call = (LinphoneCall *) ptr;
1629 return linphone_call_get_play_volume(call);
1632 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1633 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1636 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1637 // Implemented directly in msandroid.cpp (sound filters for Android).
1638 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1640 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1641 msandroid_hack_speaker_state(speakerOn);
1643 // End Galaxy S hack functions
1646 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1647 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1650 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1653 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1654 jstring jHost, jint port, jint mirror, jint delay) {
1655 #ifdef TUNNEL_ENABLED
1656 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1657 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1658 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1659 env->ReleaseStringUTFChars(jHost, cHost);
1663 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1664 #ifdef TUNNEL_ENABLED
1665 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1666 linphone_tunnel_auto_detect(tunnel);
1670 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1671 #ifdef TUNNEL_ENABLED
1672 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1673 linphone_tunnel_clean_servers(tunnel);
1677 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1678 #ifdef TUNNEL_ENABLED
1679 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1680 linphone_tunnel_enable(tunnel, enable);
1684 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnableLogs(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1685 #ifdef TUNNEL_ENABLED
1686 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1687 linphone_tunnel_enable_logs(tunnel, enable);
1691 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1692 return linphone_core_tunnel_available();
1695 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1696 LinphoneVideoPolicy vpol;
1697 vpol.automatically_initiate = autoInitiate;
1698 vpol.automatically_accept = autoAccept;
1699 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);