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" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
463 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
464 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
466 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
469 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
470 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
473 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
477 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
479 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
482 linphone_core_iterate((LinphoneCore*)lc);
484 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
488 const char* uri = env->GetStringUTFChars(juri, NULL);
489 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
490 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
491 env->ReleaseStringUTFChars(juri, uri);
492 return lcd->getCall(env,lCall);
494 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
498 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
499 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
502 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
506 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
509 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
512 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
514 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
518 return linphone_core_in_call((LinphoneCore*)lc);
520 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
524 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
526 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
531 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
534 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
538 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
540 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
543 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
548 ,jboolean isReachable) {
549 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
556 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
559 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
562 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
565 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
569 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
572 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
576 const char* url = env->GetStringUTFChars(jurl, NULL);
577 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
578 env->ReleaseStringUTFChars(jurl, url);
581 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
585 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
587 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
592 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
594 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
597 linphone_core_stop_dtmf((LinphoneCore*)lc);
600 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
603 linphone_core_clear_call_logs((LinphoneCore*)lc);
605 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
608 return linphone_core_is_mic_muted((LinphoneCore*)lc);
610 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
615 const char* mime = env->GetStringUTFChars(jmime, NULL);
616 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
617 env->ReleaseStringUTFChars(jmime, mime);
620 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
623 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
624 int codecsCount = ms_list_size(codecs);
625 jlongArray jCodecs = env->NewLongArray(codecsCount);
626 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
628 for (int i = 0; i < codecsCount; i++ ) {
629 jInternalArray[i] = (unsigned long) (codecs->data);
630 codecs = codecs->next;
633 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
638 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
641 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
642 int codecsCount = ms_list_size(codecs);
643 jlongArray jCodecs = env->NewLongArray(codecsCount);
644 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
646 for (int i = 0; i < codecsCount; i++ ) {
647 jInternalArray[i] = (unsigned long) (codecs->data);
648 codecs = codecs->next;
651 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
656 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
661 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
663 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
667 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
669 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
673 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
675 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
679 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
682 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
686 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
689 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
693 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
695 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
697 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
702 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
704 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
708 ,jstring jalternative_contact
710 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
711 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
712 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
715 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
720 const char* to = env->GetStringUTFChars(jto, NULL);
721 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
722 env->ReleaseStringUTFChars(jto, to);
723 return (long)lResult;
726 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
729 ,jboolean vcap_enabled
730 ,jboolean display_enabled) {
731 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
734 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
737 return linphone_core_video_enabled((LinphoneCore*)lc);
739 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
743 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
744 linphone_core_set_play_file((LinphoneCore*)lc,path);
745 if (path) env->ReleaseStringUTFChars(jpath, path);
747 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
751 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
752 linphone_core_set_ring((LinphoneCore*)lc,path);
753 if (path) env->ReleaseStringUTFChars(jpath, path);
755 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
759 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
761 return env->NewStringUTF(path);
766 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
770 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
771 linphone_core_set_root_ca((LinphoneCore*)lc,path);
772 if (path) env->ReleaseStringUTFChars(jpath, path);
774 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
778 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
781 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
784 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
787 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
791 return linphone_core_start_echo_calibration((LinphoneCore*)lc
792 , LinphoneCoreData::ecCalibrationStatus
793 , data?env->NewGlobalRef(data):NULL);
797 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
801 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
804 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
808 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
811 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
815 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
818 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
822 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
825 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
829 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
832 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
836 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
839 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
844 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
849 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
850 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
851 return (jlong) proxy;
854 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
855 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
857 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
858 const char* identity = env->GetStringUTFChars(jidentity, NULL);
859 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
860 env->ReleaseStringUTFChars(jidentity, identity);
862 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
863 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
865 return env->NewStringUTF(identity);
870 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
871 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
872 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
873 env->ReleaseStringUTFChars(jproxy, proxy);
876 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
877 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
879 return env->NewStringUTF(proxy);
884 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
885 if (jroute != NULL) {
886 const char* route = env->GetStringUTFChars(jroute, NULL);
887 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
888 env->ReleaseStringUTFChars(jroute, route);
891 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
894 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
895 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
897 return env->NewStringUTF(route);
903 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
904 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
906 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
907 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
909 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
910 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
912 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
913 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
915 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
916 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
918 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
920 ms_error("cannot normalized null number");
922 const char* number = env->GetStringUTFChars(jnumber, NULL);
923 int len = env->GetStringLength(jnumber);
925 ms_warning("cannot normalize empty number");
928 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
929 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
930 jstring normalizedNumber = env->NewStringUTF(targetBuff);
931 env->ReleaseStringUTFChars(jnumber, number);
932 return normalizedNumber;
934 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
937 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
939 return env->NewStringUTF(domain);
944 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
945 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
948 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
952 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
953 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
954 env->ReleaseStringUTFChars(jprefix, prefix);
956 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
960 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
962 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
963 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
968 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
976 const char* username = env->GetStringUTFChars(jusername, NULL);
977 const char* password = env->GetStringUTFChars(jpassword, NULL);
978 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
980 env->ReleaseStringUTFChars(jusername, username);
981 env->ReleaseStringUTFChars(jpassword, password);
985 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
988 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
993 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
996 ,jstring jdisplayName) {
997 const char* uri = env->GetStringUTFChars(juri, NULL);
998 LinphoneAddress* address = linphone_address_new(uri);
999 if (jdisplayName && address) {
1000 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1001 linphone_address_set_display_name(address,displayName);
1002 env->ReleaseStringUTFChars(jdisplayName, displayName);
1004 env->ReleaseStringUTFChars(juri, uri);
1006 return (jlong) address;
1008 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1011 linphone_address_destroy((LinphoneAddress*)ptr);
1014 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1017 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1019 return env->NewStringUTF(displayName);
1024 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1027 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1029 return env->NewStringUTF(userName);
1034 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1037 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1039 return env->NewStringUTF(domain);
1045 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1048 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1049 jstring juri =env->NewStringUTF(uri);
1053 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1056 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1057 jstring juri =env->NewStringUTF(uri);
1061 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1064 ,jstring jdisplayName) {
1065 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1066 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1067 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1072 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1075 return (jlong)((LinphoneCallLog*)ptr)->from;
1077 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1080 return (jlong)((LinphoneCallLog*)ptr)->to;
1082 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1085 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1089 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1090 PayloadType* pt = (PayloadType*)ptr;
1091 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1092 ,payload_type_get_mime(pt)
1093 ,payload_type_get_rate(pt)
1094 ,payload_type_get_bitrate(pt));
1095 jstring jvalue =env->NewStringUTF(value);
1099 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1100 PayloadType* pt = (PayloadType*)ptr;
1101 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1104 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1105 PayloadType* pt = (PayloadType*)ptr;
1106 return payload_type_get_rate(pt);
1110 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1113 LinphoneCall *call=(LinphoneCall*)ptr;
1114 linphone_call_unref(call);
1117 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1120 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1123 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1126 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1129 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1132 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1135 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1138 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1140 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1144 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1146 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1149 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1152 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1156 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1158 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1161 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1164 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1167 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1168 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1171 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1174 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1177 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1180 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1185 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1187 ,jstring jFriendUri) {
1188 LinphoneFriend* lResult;
1191 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1192 lResult= linphone_friend_new_with_addr(friendUri);
1193 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1195 lResult = linphone_friend_new();
1197 return (long)lResult;
1199 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1202 ,jlong linphoneAddress) {
1203 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1205 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1208 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1210 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1214 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1216 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1219 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1221 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1225 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1227 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1230 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1232 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1235 return linphone_friend_get_status((LinphoneFriend*)ptr);
1237 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1240 return linphone_friend_edit((LinphoneFriend*)ptr);
1242 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1245 linphone_friend_done((LinphoneFriend*)ptr);
1248 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1251 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1253 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1256 ,jstring jmessage) {
1257 const char* message = env->GetStringUTFChars(jmessage, NULL);
1258 linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1259 env->ReleaseStringUTFChars(jmessage, message);
1263 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1267 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1268 if (oldWindow != NULL) {
1269 env->DeleteGlobalRef(oldWindow);
1272 obj = env->NewGlobalRef(obj);
1274 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1277 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1281 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1282 if (oldWindow != NULL) {
1283 env->DeleteGlobalRef(oldWindow);
1286 obj = env->NewGlobalRef(obj);
1288 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1291 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1295 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1299 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1300 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1303 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1304 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1307 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1308 const char* server = NULL;
1309 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1310 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1311 if (server) env->ReleaseStringUTFChars(jserver,server);
1314 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1315 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1316 if (ret==NULL) return NULL;
1317 jstring jvalue =env->NewStringUTF(ret);
1321 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1322 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1325 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1326 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1329 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1330 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1333 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1334 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1337 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1338 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1340 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1341 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1344 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1345 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1348 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1349 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1352 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1353 linphone_call_camera_enabled((LinphoneCall *)lc);
1356 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1357 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1358 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1361 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1362 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1365 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1366 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1370 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1372 vsize.width = (int)width;
1373 vsize.height = (int)height;
1374 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1377 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1378 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1379 jintArray arr = env->NewIntArray(2);
1380 int tVsize [2]= {vsize.width,vsize.height};
1381 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1385 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1386 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1389 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1390 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1393 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1394 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1397 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1398 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1401 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1402 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1404 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1405 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1408 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1409 linphone_call_get_duration((LinphoneCall *) ptr);
1412 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1414 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1427 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1428 LinphoneCore *lc = (LinphoneCore *) ptr;
1434 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1437 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1438 ,jlong lc, jboolean enable) {
1439 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1442 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1443 ,jlong ptr, jint db) {
1444 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1447 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1448 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1450 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1451 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1453 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1454 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1456 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1457 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1459 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1460 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1462 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1463 linphone_core_leave_conference((LinphoneCore *) pCore);
1465 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1466 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1468 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1469 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1471 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1472 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1475 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1476 linphone_core_terminate_conference((LinphoneCore *) pCore);
1478 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1479 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1481 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1482 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1484 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1485 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1486 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1487 return lcd->getCall(env,lCall);
1489 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1490 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1493 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1494 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1495 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1496 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1498 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1499 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1502 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1504 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1505 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1506 env->ReleaseStringUTFChars(jFile, cFile);
1508 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1512 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1513 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1514 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1515 env->ReleaseStringUTFChars(jUri, cUri);
1516 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1517 return (jobject) lcdata->getCall(env,call);
1521 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1522 LinphoneCore* lc = (LinphoneCore *) pCore;
1523 const char** devices = linphone_core_get_video_devices(lc);
1524 if (devices == NULL) {
1525 ms_error("No existing video devices\n");
1529 for(i=0; i<=id; i++) {
1530 if (devices[i] == NULL)
1532 ms_message("Existing device %d : %s\n", i, devices[i]);
1534 return linphone_core_set_video_device(lc, devices[i]);
1540 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1541 LinphoneCore* lc = (LinphoneCore *) pCore;
1542 const char** devices = linphone_core_get_video_devices(lc);
1543 if (devices == NULL) {
1544 ms_error("No existing video devices\n");
1547 const char* cam = linphone_core_get_video_device(lc);
1549 ms_error("No current video device\n");
1552 while(devices[i] != NULL) {
1553 if (strcmp(devices[i], cam) == 0)
1558 ms_warning("Returning default (0) device\n");
1562 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1563 LinphoneCall *call = (LinphoneCall *) ptr;
1564 const char* token = linphone_call_get_authentication_token(call);
1565 if (token == NULL) return NULL;
1566 return env->NewStringUTF(token);
1568 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1569 LinphoneCall *call = (LinphoneCall *) ptr;
1570 return linphone_call_get_authentication_token_verified(call);
1572 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1573 LinphoneCall *call = (LinphoneCall *) ptr;
1574 linphone_call_set_authentication_token_verified(call, verified);
1578 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1579 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1582 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1583 // Implemented directly in msandroid.cpp (sound filters for Android).
1584 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1586 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1587 msandroid_hack_speaker_state(speakerOn);
1589 // End Galaxy S hack functions
1592 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1593 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1595 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1596 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1599 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1600 jstring jHost, jint port, jint mirror, jint delay) {
1601 #ifdef TUNNEL_ENABLED
1602 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1603 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1604 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1605 env->ReleaseStringUTFChars(jHost, cHost);
1609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1610 #ifdef TUNNEL_ENABLED
1611 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1612 linphone_tunnel_auto_detect(tunnel);
1616 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1617 #ifdef TUNNEL_ENABLED
1618 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1619 linphone_tunnel_clean_servers(tunnel);
1623 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1624 #ifdef TUNNEL_ENABLED
1625 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1626 linphone_tunnel_enable(tunnel, enable);
1630 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnableLogs(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1631 #ifdef TUNNEL_ENABLED
1632 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1633 linphone_tunnel_enable_logs(tunnel, enable);
1637 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1638 return linphone_core_tunnel_available();