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 "mediastreamer2/mediastream.h"
26 #include "mediastreamer2/msjava.h"
28 #include <cpu-features.h>
31 #include <android/log.h>
32 extern "C" void libmsilbc_init();
34 extern "C" void libmsx264_init();
37 extern "C" void libmsamr_init();
40 extern "C" void libmssilk_init();
47 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
50 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
51 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
52 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
53 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
54 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
55 default: prio = ANDROID_LOG_DEFAULT; break;
57 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
60 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
61 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
65 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
71 return JNI_VERSION_1_2;
76 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
80 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
82 linphone_core_disable_logs();
87 class LinphoneCoreData {
89 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
91 core = env->NewGlobalRef(lc);
92 listener = env->NewGlobalRef(alistener);
93 userdata = auserdata?env->NewGlobalRef(auserdata):0;
94 memset(&vTable,0,sizeof(vTable));
95 vTable.show = showInterfaceCb;
96 vTable.auth_info_requested = authInfoRequested;
97 vTable.display_status = displayStatusCb;
98 vTable.display_message = displayMessageCb;
99 vTable.display_warning = displayMessageCb;
100 vTable.global_state_changed = globalStateChange;
101 vTable.registration_state_changed = registrationStateChange;
102 vTable.call_state_changed = callStateChange;
103 vTable.call_encryption_changed = callEncryptionChange;
104 vTable.text_received = text_received;
105 vTable.new_subscription_request = new_subscription_request;
106 vTable.notify_presence_recv = notify_presence_recv;
108 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
110 /*displayStatus(LinphoneCore lc,String message);*/
111 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
113 /*void generalState(LinphoneCore lc,int state); */
114 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
115 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
116 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
118 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
119 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
120 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
121 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
123 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
124 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
125 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
126 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
128 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
129 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
131 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
132 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
133 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
134 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
136 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
137 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
139 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
140 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
142 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
143 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
145 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
146 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
148 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
149 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
151 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
152 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
154 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
155 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
157 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
158 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
162 ~LinphoneCoreData() {
164 jvm->AttachCurrentThread(&env,NULL);
165 env->DeleteGlobalRef(core);
166 env->DeleteGlobalRef(listener);
167 if (userdata) env->DeleteGlobalRef(userdata);
168 env->DeleteGlobalRef(listenerClass);
169 env->DeleteGlobalRef(globalStateClass);
170 env->DeleteGlobalRef(registrationStateClass);
171 env->DeleteGlobalRef(callStateClass);
172 env->DeleteGlobalRef(proxyClass);
173 env->DeleteGlobalRef(callClass);
174 env->DeleteGlobalRef(chatRoomClass);
175 env->DeleteGlobalRef(friendClass);
182 jclass listenerClass;
183 jmethodID displayStatusId;
184 jmethodID newSubscriptionRequestId;
185 jmethodID notifyPresenceReceivedId;
186 jmethodID textReceivedId;
188 jclass globalStateClass;
189 jmethodID globalStateId;
190 jmethodID globalStateFromIntId;
192 jclass registrationStateClass;
193 jmethodID registrationStateId;
194 jmethodID registrationStateFromIntId;
196 jclass callStateClass;
197 jmethodID callStateId;
198 jmethodID callStateFromIntId;
200 jmethodID callEncryptionChangedId;
202 jclass ecCalibratorStatusClass;
203 jmethodID ecCalibrationStatusId;
204 jmethodID ecCalibratorStatusFromIntId;
207 jmethodID proxyCtrId;
212 jclass chatRoomClass;
213 jmethodID chatRoomCtrId;
216 jmethodID friendCtrId;
219 jmethodID addressCtrId;
221 LinphoneCoreVTable vTable;
223 static void showInterfaceCb(LinphoneCore *lc) {
226 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
229 static void displayStatusCb(LinphoneCore *lc, const char *message) {
231 jint result = jvm->AttachCurrentThread(&env,NULL);
233 ms_error("cannot attach VM\n");
236 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
237 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
239 static void displayMessageCb(LinphoneCore *lc, const char *message) {
242 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
245 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
247 jint result = jvm->AttachCurrentThread(&env,NULL);
249 ms_error("cannot attach VM\n");
252 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
253 env->CallVoidMethod(lcData->listener
254 ,lcData->globalStateId
256 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
257 message ? env->NewStringUTF(message) : NULL);
259 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
261 jint result = jvm->AttachCurrentThread(&env,NULL);
263 ms_error("cannot attach VM\n");
266 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
267 env->CallVoidMethod(lcData->listener
268 ,lcData->registrationStateId
270 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
271 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
272 message ? env->NewStringUTF(message) : NULL);
274 jobject getCall(JNIEnv *env , LinphoneCall *call){
278 void *up=linphone_call_get_user_pointer(call);
281 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
282 jobj=env->NewGlobalRef(jobj);
283 linphone_call_set_user_pointer(call,(void*)jobj);
284 linphone_call_ref(call);
292 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
294 jint result = jvm->AttachCurrentThread(&env,NULL);
297 ms_error("cannot attach VM\n");
300 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
301 env->CallVoidMethod(lcData->listener
304 ,(jcall=lcData->getCall(env,call))
305 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
306 message ? env->NewStringUTF(message) : NULL);
307 if (state==LinphoneCallReleased){
308 linphone_call_set_user_pointer(call,NULL);
309 env->DeleteGlobalRef(jcall);
312 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
314 jint result = jvm->AttachCurrentThread(&env,NULL);
316 ms_error("cannot attach VM\n");
319 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
320 env->CallVoidMethod(lcData->listener
321 ,lcData->callEncryptionChangedId
323 ,lcData->getCall(env,call)
325 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
327 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
329 jint result = jvm->AttachCurrentThread(&env,NULL);
331 ms_error("cannot attach VM\n");
334 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
335 env->CallVoidMethod(lcData->listener
336 ,lcData->notifyPresenceReceivedId
338 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
340 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
342 jint result = jvm->AttachCurrentThread(&env,NULL);
344 ms_error("cannot attach VM\n");
347 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
348 env->CallVoidMethod(lcData->listener
349 ,lcData->newSubscriptionRequestId
351 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
352 ,url ? env->NewStringUTF(url) : NULL);
354 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
356 jint result = jvm->AttachCurrentThread(&env,NULL);
358 ms_error("cannot attach VM\n");
361 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
362 env->CallVoidMethod(lcData->listener
363 ,lcData->textReceivedId
365 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
366 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
367 ,message ? env->NewStringUTF(message) : NULL);
369 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
371 jint result = jvm->AttachCurrentThread(&env,NULL);
373 ms_error("cannot attach VM\n");
376 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
377 env->CallVoidMethod(lcData->listener
378 ,lcData->ecCalibrationStatusId
380 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
382 ,data ? data : NULL);
383 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
384 //final state, releasing global ref
385 env->DeleteGlobalRef((jobject)data);
392 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
396 ,jstring jfactoryConfig
399 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
400 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
401 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
404 libmsilbc_init(); // requires an fpu
415 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
419 //clear auth info list
420 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
421 //clear existing proxy config
422 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
424 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
425 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
428 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
431 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
432 linphone_core_destroy((LinphoneCore*)lc);
436 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
437 linphone_core_clear_proxy_config((LinphoneCore*)lc);
440 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
444 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
446 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
449 LinphoneProxyConfig *config=0;
450 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
451 return (jlong)config;
454 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
459 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
460 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
462 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
465 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
466 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
469 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
473 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
475 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
478 linphone_core_iterate((LinphoneCore*)lc);
480 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
484 const char* uri = env->GetStringUTFChars(juri, NULL);
485 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
486 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
487 env->ReleaseStringUTFChars(juri, uri);
488 return lcd->getCall(env,lCall);
490 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
494 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
495 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
498 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
502 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
505 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
508 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
510 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
514 return linphone_core_in_call((LinphoneCore*)lc);
516 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
520 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
522 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
527 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
530 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
534 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
536 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
539 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
541 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
544 ,jboolean isReachable) {
545 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
548 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
552 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
555 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
558 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
561 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
565 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
568 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
572 const char* url = env->GetStringUTFChars(jurl, NULL);
573 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
574 env->ReleaseStringUTFChars(jurl, url);
577 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
581 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
583 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
588 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
590 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
593 linphone_core_stop_dtmf((LinphoneCore*)lc);
596 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
599 linphone_core_clear_call_logs((LinphoneCore*)lc);
601 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
604 return linphone_core_is_mic_muted((LinphoneCore*)lc);
606 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
611 const char* mime = env->GetStringUTFChars(jmime, NULL);
612 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
613 env->ReleaseStringUTFChars(jmime, mime);
616 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
619 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
620 int codecsCount = ms_list_size(codecs);
621 jlongArray jCodecs = env->NewLongArray(codecsCount);
622 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
624 for (int i = 0; i < codecsCount; i++ ) {
625 jInternalArray[i] = (unsigned long) (codecs->data);
626 codecs = codecs->next;
629 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
634 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
637 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
638 int codecsCount = ms_list_size(codecs);
639 jlongArray jCodecs = env->NewLongArray(codecsCount);
640 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
642 for (int i = 0; i < codecsCount; i++ ) {
643 jInternalArray[i] = (unsigned long) (codecs->data);
644 codecs = codecs->next;
647 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
652 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
657 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
659 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
663 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
665 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
669 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
671 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
675 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
678 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
682 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
684 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
686 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
691 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
693 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
697 ,jstring jalternative_contact
699 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
700 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
701 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
704 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
709 const char* to = env->GetStringUTFChars(jto, NULL);
710 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
711 env->ReleaseStringUTFChars(jto, to);
712 return (long)lResult;
715 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
718 ,jboolean vcap_enabled
719 ,jboolean display_enabled) {
720 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
723 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
726 return linphone_core_video_enabled((LinphoneCore*)lc);
728 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
732 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
733 linphone_core_set_ring((LinphoneCore*)lc,path);
734 if (path) env->ReleaseStringUTFChars(jpath, path);
736 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
740 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
742 return env->NewStringUTF(path);
747 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
751 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
752 linphone_core_set_root_ca((LinphoneCore*)lc,path);
753 if (path) env->ReleaseStringUTFChars(jpath, path);
755 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
759 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
762 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
765 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
768 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
772 return linphone_core_start_echo_calibration((LinphoneCore*)lc
773 , LinphoneCoreData::ecCalibrationStatus
774 , data?env->NewGlobalRef(data):NULL);
778 static enum LinphoneMediaEncryption media_encryption_string_to_enum(const char* menc) {
780 return LinphoneMediaEncryptionNone;
781 else if (strcasecmp(menc, "none")==0)
782 return LinphoneMediaEncryptionNone;
783 else if (strcasecmp(menc, "srtp")==0)
784 return LinphoneMediaEncryptionSRTP;
785 else if (strcasecmp(menc, "zrtp")==0)
786 return LinphoneMediaEncryptionZRTP;
788 return LinphoneMediaEncryptionNone;
791 static jstring media_encryption_enum_to_jstring(JNIEnv* env, enum LinphoneMediaEncryption enc) {
793 case LinphoneMediaEncryptionSRTP:
794 return env->NewStringUTF("srtp");
795 case LinphoneMediaEncryptionZRTP:
796 return env->NewStringUTF("zrtp");
797 case LinphoneMediaEncryptionNone:
798 return env->NewStringUTF("none");
804 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
808 return media_encryption_enum_to_jstring(env,
809 linphone_core_get_media_encryption((LinphoneCore*)lc));
811 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
815 const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL;
817 linphone_core_set_media_encryption((LinphoneCore*)lc,
818 media_encryption_string_to_enum(menc));
820 if (menc) env->ReleaseStringUTFChars(jmenc, menc);
823 extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
827 return media_encryption_enum_to_jstring(env,
828 linphone_call_params_get_media_encryption((LinphoneCallParams*)lc));
830 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
834 const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL;
835 linphone_call_params_set_media_encryption((LinphoneCallParams*)lc,
836 media_encryption_string_to_enum(menc));
837 if (menc) env->ReleaseStringUTFChars(jmenc, menc);
840 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
844 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
847 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
852 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
857 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
858 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
859 return (jlong) proxy;
862 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
863 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
865 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
866 const char* identity = env->GetStringUTFChars(jidentity, NULL);
867 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
868 env->ReleaseStringUTFChars(jidentity, identity);
870 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
871 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
873 return env->NewStringUTF(identity);
878 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
879 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
880 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
881 env->ReleaseStringUTFChars(jproxy, proxy);
884 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
885 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
887 return env->NewStringUTF(proxy);
892 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
893 if (jroute != NULL) {
894 const char* route = env->GetStringUTFChars(jroute, NULL);
895 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
896 env->ReleaseStringUTFChars(jroute, route);
899 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
902 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
903 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
905 return env->NewStringUTF(route);
911 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
912 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
914 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
915 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
917 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
918 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
920 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
921 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
923 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
924 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
926 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
928 ms_error("cannot normalized null number");
930 const char* number = env->GetStringUTFChars(jnumber, NULL);
931 int len = env->GetStringLength(jnumber);
933 ms_warning("cannot normalize empty number");
936 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
937 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
938 jstring normalizedNumber = env->NewStringUTF(targetBuff);
939 env->ReleaseStringUTFChars(jnumber, number);
940 return normalizedNumber;
942 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
945 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
947 return env->NewStringUTF(domain);
952 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
953 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
956 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
960 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
961 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
962 env->ReleaseStringUTFChars(jprefix, prefix);
964 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
968 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
970 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
971 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
976 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
984 const char* username = env->GetStringUTFChars(jusername, NULL);
985 const char* password = env->GetStringUTFChars(jpassword, NULL);
986 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
988 env->ReleaseStringUTFChars(jusername, username);
989 env->ReleaseStringUTFChars(jpassword, password);
993 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
996 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1001 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1004 ,jstring jdisplayName) {
1005 const char* uri = env->GetStringUTFChars(juri, NULL);
1006 LinphoneAddress* address = linphone_address_new(uri);
1007 if (jdisplayName && address) {
1008 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1009 linphone_address_set_display_name(address,displayName);
1010 env->ReleaseStringUTFChars(jdisplayName, displayName);
1012 env->ReleaseStringUTFChars(juri, uri);
1014 return (jlong) address;
1016 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1019 linphone_address_destroy((LinphoneAddress*)ptr);
1022 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1025 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1027 return env->NewStringUTF(displayName);
1032 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1035 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1037 return env->NewStringUTF(userName);
1042 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1045 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1047 return env->NewStringUTF(domain);
1053 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1056 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1057 jstring juri =env->NewStringUTF(uri);
1061 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1064 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1065 jstring juri =env->NewStringUTF(uri);
1069 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1072 ,jstring jdisplayName) {
1073 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1074 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1075 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1080 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1083 return (jlong)((LinphoneCallLog*)ptr)->from;
1085 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1088 return (jlong)((LinphoneCallLog*)ptr)->to;
1090 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1093 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1097 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1098 PayloadType* pt = (PayloadType*)ptr;
1099 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1100 ,payload_type_get_mime(pt)
1101 ,payload_type_get_rate(pt)
1102 ,payload_type_get_bitrate(pt));
1103 jstring jvalue =env->NewStringUTF(value);
1107 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1108 PayloadType* pt = (PayloadType*)ptr;
1109 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1112 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1113 PayloadType* pt = (PayloadType*)ptr;
1114 return payload_type_get_rate(pt);
1118 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1121 LinphoneCall *call=(LinphoneCall*)ptr;
1122 linphone_call_unref(call);
1125 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1128 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1131 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1134 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1137 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1140 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1143 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1146 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1148 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1152 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1154 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1157 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1160 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1164 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1166 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1169 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1172 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1175 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1176 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1179 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1182 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1185 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1188 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1193 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1195 ,jstring jFriendUri) {
1196 LinphoneFriend* lResult;
1199 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1200 lResult= linphone_friend_new_with_addr(friendUri);
1201 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1203 lResult = linphone_friend_new();
1205 return (long)lResult;
1207 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1210 ,jlong linphoneAddress) {
1211 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1213 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1216 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1218 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1222 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1224 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1227 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1229 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1233 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1235 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1238 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1240 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1243 return linphone_friend_get_status((LinphoneFriend*)ptr);
1245 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1248 return linphone_friend_edit((LinphoneFriend*)ptr);
1250 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1253 linphone_friend_done((LinphoneFriend*)ptr);
1256 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1259 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1261 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1264 ,jstring jmessage) {
1265 const char* message = env->GetStringUTFChars(jmessage, NULL);
1266 linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
1267 env->ReleaseStringUTFChars(jmessage, message);
1271 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1275 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1276 if (oldWindow != NULL) {
1277 env->DeleteGlobalRef(oldWindow);
1280 obj = env->NewGlobalRef(obj);
1282 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1285 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1289 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1290 if (oldWindow != NULL) {
1291 env->DeleteGlobalRef(oldWindow);
1294 obj = env->NewGlobalRef(obj);
1296 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1299 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1303 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1307 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1308 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1311 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1312 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1315 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1316 const char* server = NULL;
1317 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1318 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1319 if (server) env->ReleaseStringUTFChars(jserver,server);
1322 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1323 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1324 if (ret==NULL) return NULL;
1325 jstring jvalue =env->NewStringUTF(ret);
1329 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1330 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1333 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1334 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1337 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1338 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1341 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1342 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1345 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1346 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1348 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1349 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1352 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1353 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1356 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1357 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1360 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1361 linphone_call_camera_enabled((LinphoneCall *)lc);
1364 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1365 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1366 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1369 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1370 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1373 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1374 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1378 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1380 vsize.width = (int)width;
1381 vsize.height = (int)height;
1382 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1385 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1386 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1387 jintArray arr = env->NewIntArray(2);
1388 int tVsize [2]= {vsize.width,vsize.height};
1389 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1393 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1394 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1397 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1398 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1401 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1402 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1405 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1406 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1409 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1410 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1412 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1413 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1416 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1417 linphone_call_get_duration((LinphoneCall *) ptr);
1420 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1422 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1435 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1436 LinphoneCore *lc = (LinphoneCore *) ptr;
1442 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1445 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1446 ,jlong lc, jboolean enable) {
1447 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1450 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1451 ,jlong ptr, jint db) {
1452 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1455 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1456 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1458 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1459 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1461 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1462 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1464 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1465 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1467 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1468 linphone_core_enter_conference((LinphoneCore *) pCore);
1470 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1471 linphone_core_leave_conference((LinphoneCore *) pCore);
1473 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1474 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1476 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1477 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1479 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1480 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1483 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1484 linphone_core_terminate_conference((LinphoneCore *) pCore);
1486 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1487 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1489 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1490 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1492 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1493 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1494 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1495 return lcd->getCall(env,lCall);
1497 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1498 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1501 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1502 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1503 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1504 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1506 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1507 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1510 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1512 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1513 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1514 env->ReleaseStringUTFChars(jFile, cFile);
1516 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1520 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1521 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1522 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1523 env->ReleaseStringUTFChars(jUri, cUri);
1524 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1525 return (jobject) lcdata->getCall(env,call);
1529 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1530 LinphoneCore* lc = (LinphoneCore *) pCore;
1531 const char** devices = linphone_core_get_video_devices(lc);
1532 if (devices == NULL) {
1533 ms_error("No existing video devices\n");
1537 for(i=0; i<=id; i++) {
1538 if (devices[i] == NULL)
1540 ms_message("Existing device %d : %s\n", i, devices[i]);
1542 return linphone_core_set_video_device(lc, devices[i]);
1548 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1549 LinphoneCore* lc = (LinphoneCore *) pCore;
1550 const char** devices = linphone_core_get_video_devices(lc);
1551 if (devices == NULL) {
1552 ms_error("No existing video devices\n");
1555 const char* cam = linphone_core_get_video_device(lc);
1557 ms_error("No current video device\n");
1560 while(devices[i] != NULL) {
1561 if (strcmp(devices[i], cam) == 0)
1566 ms_warning("Returning default (0) device\n");
1570 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1571 LinphoneCall *call = (LinphoneCall *) ptr;
1572 const char* token = linphone_call_get_authentication_token(call);
1573 if (token == NULL) return NULL;
1574 return env->NewStringUTF(token);
1576 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1577 LinphoneCall *call = (LinphoneCall *) ptr;
1578 return linphone_call_get_authentication_token_verified(call);
1581 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1582 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1585 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1586 // Implemented directly in msandroid.cpp (sound filters for Android).
1587 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1589 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1590 msandroid_hack_speaker_state(speakerOn);
1592 // End Galaxy S hack functions
1595 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1596 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1598 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1599 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);