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.
21 #include "linphonecore_jni.h"
23 #include "linphonecore_utils.h"
24 #include <ortp/zrtp.h>
27 #include "linphone_tunnel.h"
31 #include "mediastreamer2/mediastream.h"
33 #include "mediastreamer2/msjava.h"
35 #include <cpu-features.h>
38 #include <android/log.h>
39 extern "C" void libmsilbc_init();
41 extern "C" void libmsx264_init();
44 extern "C" void libmsamr_init();
47 extern "C" void libmssilk_init();
50 extern "C" void libmsbcg729_init();
57 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
63 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
64 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
65 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
66 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
67 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
68 default: prio = ANDROID_LOG_DEFAULT; break;
70 vsnprintf(str, sizeof(str) - 1, fmt, args);
71 str[sizeof(str) - 1] = '\0';
72 if (strlen(str) < 512) {
73 __android_log_write(prio, LOG_DOMAIN, str);
76 while ((next = strchr(current, '\n')) != NULL) {
78 __android_log_write(prio, LOG_DOMAIN, current);
81 __android_log_write(prio, LOG_DOMAIN, current);
85 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
86 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
90 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
96 return JNI_VERSION_1_2;
101 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
105 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
107 linphone_core_disable_logs();
112 class LinphoneCoreData {
114 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
116 core = env->NewGlobalRef(lc);
117 listener = env->NewGlobalRef(alistener);
118 userdata = auserdata?env->NewGlobalRef(auserdata):0;
119 memset(&vTable,0,sizeof(vTable));
120 vTable.show = showInterfaceCb;
121 vTable.auth_info_requested = authInfoRequested;
122 vTable.display_status = displayStatusCb;
123 vTable.display_message = displayMessageCb;
124 vTable.display_warning = displayMessageCb;
125 vTable.global_state_changed = globalStateChange;
126 vTable.registration_state_changed = registrationStateChange;
127 vTable.call_state_changed = callStateChange;
128 vTable.call_encryption_changed = callEncryptionChange;
129 vTable.text_received = text_received;
130 vTable.message_received = message_received;
131 vTable.dtmf_received = dtmf_received;
132 vTable.new_subscription_request = new_subscription_request;
133 vTable.notify_presence_recv = notify_presence_recv;
134 vTable.call_stats_updated = callStatsUpdated;
136 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
138 /*displayStatus(LinphoneCore lc,String message);*/
139 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
141 /*void generalState(LinphoneCore lc,int state); */
142 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
143 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
144 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
146 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
147 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
148 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
149 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
151 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
152 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
153 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
154 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
156 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
157 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
159 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
160 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
162 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
163 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
165 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
166 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
167 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
168 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
170 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
171 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
173 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
174 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
176 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
177 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
178 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
179 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
181 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
182 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
184 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
185 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
187 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
188 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
190 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
191 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
193 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
194 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
196 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
197 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
199 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
200 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
201 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
202 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
205 ~LinphoneCoreData() {
207 jvm->AttachCurrentThread(&env,NULL);
208 env->DeleteGlobalRef(core);
209 env->DeleteGlobalRef(listener);
210 if (userdata) env->DeleteGlobalRef(userdata);
211 env->DeleteGlobalRef(listenerClass);
212 env->DeleteGlobalRef(globalStateClass);
213 env->DeleteGlobalRef(registrationStateClass);
214 env->DeleteGlobalRef(callStateClass);
215 env->DeleteGlobalRef(callStatsClass);
216 env->DeleteGlobalRef(chatMessageStateClass);
217 env->DeleteGlobalRef(proxyClass);
218 env->DeleteGlobalRef(callClass);
219 env->DeleteGlobalRef(chatMessageClass);
220 env->DeleteGlobalRef(chatRoomClass);
221 env->DeleteGlobalRef(friendClass);
228 jclass listenerClass;
229 jmethodID displayStatusId;
230 jmethodID newSubscriptionRequestId;
231 jmethodID notifyPresenceReceivedId;
232 jmethodID textReceivedId;
233 jmethodID messageReceivedId;
234 jmethodID dtmfReceivedId;
235 jmethodID callStatsUpdatedId;
237 jclass globalStateClass;
238 jmethodID globalStateId;
239 jmethodID globalStateFromIntId;
241 jclass registrationStateClass;
242 jmethodID registrationStateId;
243 jmethodID registrationStateFromIntId;
245 jclass callStateClass;
246 jmethodID callStateId;
247 jmethodID callStateFromIntId;
249 jclass callStatsClass;
250 jmethodID callStatsId;
251 jmethodID callSetAudioStatsId;
252 jmethodID callSetVideoStatsId;
254 jclass chatMessageStateClass;
255 jmethodID chatMessageStateFromIntId;
257 jmethodID callEncryptionChangedId;
259 jclass ecCalibratorStatusClass;
260 jmethodID ecCalibrationStatusId;
261 jmethodID ecCalibratorStatusFromIntId;
264 jmethodID proxyCtrId;
269 jclass chatMessageClass;
270 jmethodID chatMessageCtrId;
272 jclass chatRoomClass;
273 jmethodID chatRoomCtrId;
276 jmethodID friendCtrId;
279 jmethodID addressCtrId;
281 LinphoneCoreVTable vTable;
283 static void showInterfaceCb(LinphoneCore *lc) {
286 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
289 static void displayStatusCb(LinphoneCore *lc, const char *message) {
291 jint result = jvm->AttachCurrentThread(&env,NULL);
293 ms_error("cannot attach VM\n");
296 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
297 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
299 static void displayMessageCb(LinphoneCore *lc, const char *message) {
302 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
305 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
307 jint result = jvm->AttachCurrentThread(&env,NULL);
309 ms_error("cannot attach VM\n");
312 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
313 env->CallVoidMethod(lcData->listener
314 ,lcData->globalStateId
316 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
317 message ? env->NewStringUTF(message) : NULL);
319 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
321 jint result = jvm->AttachCurrentThread(&env,NULL);
323 ms_error("cannot attach VM\n");
326 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
327 env->CallVoidMethod(lcData->listener
328 ,lcData->registrationStateId
330 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
331 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
332 message ? env->NewStringUTF(message) : NULL);
334 jobject getCall(JNIEnv *env , LinphoneCall *call){
338 void *up=linphone_call_get_user_pointer(call);
341 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
342 jobj=env->NewGlobalRef(jobj);
343 linphone_call_set_user_pointer(call,(void*)jobj);
344 linphone_call_ref(call);
352 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
354 jint result = jvm->AttachCurrentThread(&env,NULL);
357 ms_error("cannot attach VM\n");
360 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
361 env->CallVoidMethod(lcData->listener
364 ,(jcall=lcData->getCall(env,call))
365 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
366 message ? env->NewStringUTF(message) : NULL);
367 if (state==LinphoneCallReleased){
368 linphone_call_set_user_pointer(call,NULL);
369 env->DeleteGlobalRef(jcall);
372 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
374 jint result = jvm->AttachCurrentThread(&env,NULL);
376 ms_error("cannot attach VM\n");
379 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
380 env->CallVoidMethod(lcData->listener
381 ,lcData->callEncryptionChangedId
383 ,lcData->getCall(env,call)
385 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
387 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
389 jint result = jvm->AttachCurrentThread(&env,NULL);
391 ms_error("cannot attach VM\n");
394 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
395 env->CallVoidMethod(lcData->listener
396 ,lcData->notifyPresenceReceivedId
398 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
400 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
402 jint result = jvm->AttachCurrentThread(&env,NULL);
404 ms_error("cannot attach VM\n");
407 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
408 env->CallVoidMethod(lcData->listener
409 ,lcData->newSubscriptionRequestId
411 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
412 ,url ? env->NewStringUTF(url) : NULL);
414 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
416 jint result = jvm->AttachCurrentThread(&env,NULL);
418 ms_error("cannot attach VM\n");
421 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
422 env->CallVoidMethod(lcData->listener
423 ,lcData->dtmfReceivedId
425 ,lcData->getCall(env,call)
428 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
430 jint result = jvm->AttachCurrentThread(&env,NULL);
432 ms_error("cannot attach VM\n");
435 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
436 env->CallVoidMethod(lcData->listener
437 ,lcData->textReceivedId
439 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
440 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
441 ,message ? env->NewStringUTF(message) : NULL);
443 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
445 jint result = jvm->AttachCurrentThread(&env,NULL);
447 ms_error("cannot attach VM\n");
450 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
451 env->CallVoidMethod(lcData->listener
452 ,lcData->messageReceivedId
454 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
455 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
457 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
459 jint result = jvm->AttachCurrentThread(&env,NULL);
461 ms_error("cannot attach VM\n");
464 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
465 env->CallVoidMethod(lcData->listener
466 ,lcData->ecCalibrationStatusId
468 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
470 ,data ? data : NULL);
471 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
472 //final state, releasing global ref
473 env->DeleteGlobalRef((jobject)data);
477 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
481 jint result = jvm->AttachCurrentThread(&env,NULL);
483 ms_error("cannot attach VM\n");
486 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
487 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
488 callobj = lcData->getCall(env, call);
489 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
490 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
492 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
493 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
498 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
502 ,jstring jfactoryConfig
505 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
506 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
507 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
510 libmsilbc_init(); // requires an fpu
524 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
528 //clear auth info list
529 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
530 //clear existing proxy config
531 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
533 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
534 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
537 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
540 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
541 linphone_core_destroy((LinphoneCore*)lc);
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
546 linphone_core_clear_proxy_config((LinphoneCore*)lc);
549 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
553 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
555 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
558 LinphoneProxyConfig *config=0;
559 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
560 return (jlong)config;
563 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
564 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
565 int proxyCount = ms_list_size(proxies);
566 jlongArray jProxies = env->NewLongArray(proxyCount);
567 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
569 for (int i = 0; i < proxyCount; i++ ) {
570 jInternalArray[i] = (unsigned long) (proxies->data);
571 proxies = proxies->next;
574 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
579 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
584 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
585 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
587 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
590 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
591 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
594 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
595 linphone_core_refresh_registers((LinphoneCore*)lc);
598 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
602 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
604 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
607 linphone_core_iterate((LinphoneCore*)lc);
609 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
613 const char* uri = env->GetStringUTFChars(juri, NULL);
614 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
615 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
616 env->ReleaseStringUTFChars(juri, uri);
617 return lcd->getCall(env,lCall);
619 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
623 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
624 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
627 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
631 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
634 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
637 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
639 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
643 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
645 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
649 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
651 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
656 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
659 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
664 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
667 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
672 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
675 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
679 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
682 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
686 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
688 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
691 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
693 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
696 ,jboolean isReachable) {
697 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
700 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
703 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
706 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
710 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
713 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
716 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
719 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
723 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
726 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
730 const char* url = env->GetStringUTFChars(jurl, NULL);
731 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
732 env->ReleaseStringUTFChars(jurl, url);
735 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
739 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
741 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
746 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
748 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
751 linphone_core_stop_dtmf((LinphoneCore*)lc);
754 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
757 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
760 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
763 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
766 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
768 ,jlong lc, jlong log) {
769 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
772 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
775 linphone_core_clear_call_logs((LinphoneCore*)lc);
777 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
780 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
782 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
788 const char* mime = env->GetStringUTFChars(jmime, NULL);
789 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
790 env->ReleaseStringUTFChars(jmime, mime);
793 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
796 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
797 int codecsCount = ms_list_size(codecs);
798 jlongArray jCodecs = env->NewLongArray(codecsCount);
799 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
801 for (int i = 0; i < codecsCount; i++ ) {
802 jInternalArray[i] = (unsigned long) (codecs->data);
803 codecs = codecs->next;
806 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
811 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
814 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
815 int codecsCount = ms_list_size(codecs);
816 jlongArray jCodecs = env->NewLongArray(codecsCount);
817 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
819 for (int i = 0; i < codecsCount; i++ ) {
820 jInternalArray[i] = (unsigned long) (codecs->data);
821 codecs = codecs->next;
824 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
829 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
834 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
836 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
840 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
842 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
846 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
848 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
852 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
855 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
859 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
862 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
866 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
868 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
870 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
875 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
877 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
881 ,jstring jalternative_contact
883 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
884 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
885 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
888 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
893 const char* to = env->GetStringUTFChars(jto, NULL);
894 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
895 env->ReleaseStringUTFChars(jto, to);
896 return (jlong)lResult;
899 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
902 ,jboolean vcap_enabled
903 ,jboolean display_enabled) {
904 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
907 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
910 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
912 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
916 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
917 linphone_core_set_play_file((LinphoneCore*)lc,path);
918 if (path) env->ReleaseStringUTFChars(jpath, path);
920 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
924 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
925 linphone_core_set_ring((LinphoneCore*)lc,path);
926 if (path) env->ReleaseStringUTFChars(jpath, path);
928 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
932 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
934 return env->NewStringUTF(path);
939 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
943 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
944 linphone_core_set_root_ca((LinphoneCore*)lc,path);
945 if (path) env->ReleaseStringUTFChars(jpath, path);
947 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
951 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
954 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
957 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
960 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
964 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
965 , LinphoneCoreData::ecCalibrationStatus
966 , data?env->NewGlobalRef(data):NULL);
970 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
974 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
977 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
981 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
984 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
988 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
991 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
995 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
998 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1003 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1008 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1009 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1010 return (jlong) proxy;
1013 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1014 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1016 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1017 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1018 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1019 env->ReleaseStringUTFChars(jidentity, identity);
1021 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1022 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1024 return env->NewStringUTF(identity);
1029 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1030 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1031 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1032 env->ReleaseStringUTFChars(jproxy, proxy);
1035 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1036 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1038 return env->NewStringUTF(proxy);
1043 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1044 const char* params = env->GetStringUTFChars(jparams, NULL);
1045 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1046 env->ReleaseStringUTFChars(jparams, params);
1048 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1049 if (jroute != NULL) {
1050 const char* route = env->GetStringUTFChars(jroute, NULL);
1051 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1052 env->ReleaseStringUTFChars(jroute, route);
1055 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1058 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1059 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1061 return env->NewStringUTF(route);
1067 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1068 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1070 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1071 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1073 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1074 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1076 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1077 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1079 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1080 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1082 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1084 ms_error("cannot normalized null number");
1086 const char* number = env->GetStringUTFChars(jnumber, NULL);
1087 int len = env->GetStringLength(jnumber);
1089 ms_warning("cannot normalize empty number");
1092 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1093 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1094 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1095 env->ReleaseStringUTFChars(jnumber, number);
1096 return normalizedNumber;
1098 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1099 const char* iso = env->GetStringUTFChars(jiso, NULL);
1100 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1101 env->ReleaseStringUTFChars(jiso, iso);
1102 return (jint) prefix;
1104 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1107 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1109 return env->NewStringUTF(domain);
1114 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1115 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1118 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1122 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1123 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1124 env->ReleaseStringUTFChars(jprefix, prefix);
1126 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1130 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1132 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1133 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1138 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1146 const char* username = env->GetStringUTFChars(jusername, NULL);
1147 const char* userid = env->GetStringUTFChars(juserid, NULL);
1148 const char* password = env->GetStringUTFChars(jpassword, NULL);
1149 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1150 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1151 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1153 env->ReleaseStringUTFChars(jusername, username);
1154 env->ReleaseStringUTFChars(juserid, userid);
1155 env->ReleaseStringUTFChars(jpassword, password);
1156 env->ReleaseStringUTFChars(jha1, ha1);
1157 env->ReleaseStringUTFChars(jrealm, realm);
1161 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1164 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1169 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1172 ,jstring jdisplayName) {
1173 const char* uri = env->GetStringUTFChars(juri, NULL);
1174 LinphoneAddress* address = linphone_address_new(uri);
1175 if (jdisplayName && address) {
1176 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1177 linphone_address_set_display_name(address,displayName);
1178 env->ReleaseStringUTFChars(jdisplayName, displayName);
1180 env->ReleaseStringUTFChars(juri, uri);
1182 return (jlong) address;
1184 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1187 linphone_address_destroy((LinphoneAddress*)ptr);
1190 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1193 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1195 return env->NewStringUTF(displayName);
1200 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1203 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1205 return env->NewStringUTF(userName);
1210 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1213 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1215 return env->NewStringUTF(domain);
1221 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1224 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1225 jstring juri =env->NewStringUTF(uri);
1229 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1232 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1233 jstring juri =env->NewStringUTF(uri);
1237 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1240 ,jstring jdisplayName) {
1241 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1242 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1243 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1248 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1251 return (jlong)((LinphoneCallLog*)ptr)->from;
1253 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1256 return (jint)((LinphoneCallLog*)ptr)->status;
1258 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1261 return (jlong)((LinphoneCallLog*)ptr)->to;
1263 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1266 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1268 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1271 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1274 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1277 return (jint)((LinphoneCallLog*)ptr)->duration;
1281 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1282 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1284 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1285 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1287 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1288 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1290 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1291 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1293 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1294 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1295 const report_block_t *srb = NULL;
1297 if (!stats || !stats->sent_rtcp)
1299 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1300 if (stats->sent_rtcp->b_cont != NULL)
1301 msgpullup(stats->sent_rtcp, -1);
1302 if (rtcp_is_SR(stats->sent_rtcp))
1303 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1304 else if (rtcp_is_RR(stats->sent_rtcp))
1305 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1308 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1310 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1311 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1312 const report_block_t *rrb = NULL;
1314 if (!stats || !stats->received_rtcp)
1316 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1317 if (stats->received_rtcp->b_cont != NULL)
1318 msgpullup(stats->received_rtcp, -1);
1319 if (rtcp_is_RR(stats->received_rtcp))
1320 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1321 else if (rtcp_is_SR(stats->received_rtcp))
1322 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1325 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1327 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1328 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1329 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1330 const LinphoneCallParams *params;
1331 const PayloadType *pt;
1332 const report_block_t *srb = NULL;
1334 if (!stats || !call || !stats->sent_rtcp)
1336 params = linphone_call_get_current_params(call);
1339 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1340 if (stats->sent_rtcp->b_cont != NULL)
1341 msgpullup(stats->sent_rtcp, -1);
1342 if (rtcp_is_SR(stats->sent_rtcp))
1343 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1344 else if (rtcp_is_RR(stats->sent_rtcp))
1345 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1348 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1349 pt = linphone_call_params_get_used_audio_codec(params);
1351 pt = linphone_call_params_get_used_video_codec(params);
1352 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1354 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1355 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1356 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1357 const LinphoneCallParams *params;
1358 const PayloadType *pt;
1359 const report_block_t *rrb = NULL;
1361 if (!stats || !call || !stats->received_rtcp)
1363 params = linphone_call_get_current_params(call);
1366 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1367 if (stats->received_rtcp->b_cont != NULL)
1368 msgpullup(stats->received_rtcp, -1);
1369 if (rtcp_is_SR(stats->received_rtcp))
1370 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1371 else if (rtcp_is_RR(stats->received_rtcp))
1372 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1375 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1376 pt = linphone_call_params_get_used_audio_codec(params);
1378 pt = linphone_call_params_get_used_video_codec(params);
1379 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1381 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1382 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1384 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1385 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1386 LinphoneCall *call = (LinphoneCall *)call_ptr;
1387 rtp_stats_t rtp_stats;
1389 if (!stats || !call)
1391 memset(&rtp_stats, 0, sizeof(rtp_stats));
1392 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1393 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1394 #ifdef VIDEO_ENABLED
1396 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1398 return (jlong)rtp_stats.outoftime;
1400 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1401 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1405 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1406 PayloadType* pt = (PayloadType*)ptr;
1407 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1408 ,payload_type_get_mime(pt)
1409 ,payload_type_get_rate(pt)
1410 ,payload_type_get_bitrate(pt));
1411 jstring jvalue =env->NewStringUTF(value);
1415 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1416 PayloadType* pt = (PayloadType*)ptr;
1417 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1420 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1421 PayloadType* pt = (PayloadType*)ptr;
1422 return (jint)payload_type_get_rate(pt);
1426 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1429 LinphoneCall *call=(LinphoneCall*)ptr;
1430 linphone_call_unref(call);
1433 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1436 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1439 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1441 ,jlong ptr, jstring path) {
1442 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1443 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1446 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1448 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1449 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1452 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1455 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1458 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1461 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1464 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1467 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1469 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1473 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1475 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1478 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1481 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1485 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1487 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1490 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1493 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1496 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1497 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1500 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1503 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1506 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1509 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1514 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1516 ,jstring jFriendUri) {
1517 LinphoneFriend* lResult;
1520 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1521 lResult= linphone_friend_new_with_addr(friendUri);
1522 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1524 lResult = linphone_friend_new();
1526 return (jlong)lResult;
1528 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1531 ,jlong linphoneAddress) {
1532 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1534 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1537 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1539 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1543 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1545 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1548 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1550 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1554 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1556 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1559 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1561 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1564 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1566 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1569 return linphone_friend_edit((LinphoneFriend*)ptr);
1571 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1574 linphone_friend_done((LinphoneFriend*)ptr);
1576 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1580 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1582 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1585 ,jstring jaddress) {
1586 const char* address = env->GetStringUTFChars(jaddress, NULL);
1587 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1588 env->ReleaseStringUTFChars(jaddress, address);
1592 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1595 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1597 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1600 ,jstring jmessage) {
1601 const char* message = env->GetStringUTFChars(jmessage, NULL);
1602 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1603 env->ReleaseStringUTFChars(jmessage, message);
1605 return (jlong) chatMessage;
1607 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1610 jobject ud = env->NewGlobalRef(thiz);
1611 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1613 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1616 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1619 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1622 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1625 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1629 const char* url = env->GetStringUTFChars(jurl, NULL);
1630 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1631 env->ReleaseStringUTFChars(jurl, url);
1633 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1636 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1638 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1641 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1643 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1646 ,jstring jmessage) {
1647 const char* message = env->GetStringUTFChars(jmessage, NULL);
1648 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1649 env->ReleaseStringUTFChars(jmessage, message);
1652 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1654 jint result = jvm->AttachCurrentThread(&env,NULL);
1656 ms_error("cannot attach VM\n");
1660 jobject listener = (jobject) ud;
1661 jclass clazz = (jclass) env->GetObjectClass(listener);
1662 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1664 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1665 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1666 env->CallVoidMethod(
1669 (jobject)linphone_chat_message_get_user_data(msg),
1670 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1672 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1673 env->DeleteGlobalRef(listener);
1676 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1680 ,jobject jlistener) {
1681 jobject listener = env->NewGlobalRef(jlistener);
1682 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1684 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1688 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1689 if (oldWindow != NULL) {
1690 env->DeleteGlobalRef(oldWindow);
1693 obj = env->NewGlobalRef(obj);
1695 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1698 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1702 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1703 if (oldWindow != NULL) {
1704 env->DeleteGlobalRef(oldWindow);
1707 obj = env->NewGlobalRef(obj);
1709 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1712 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1716 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1720 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1721 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1724 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1725 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1728 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1729 const char* server = NULL;
1730 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1731 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1732 if (server) env->ReleaseStringUTFChars(jserver,server);
1735 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1736 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1737 if (ret==NULL) return NULL;
1738 jstring jvalue =env->NewStringUTF(ret);
1744 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1745 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1748 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1749 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1752 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
1756 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
1759 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1763 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1766 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1767 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1770 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1771 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1774 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1775 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1778 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1779 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1782 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1783 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1785 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1786 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1789 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1790 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1793 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1796 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1797 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1800 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1801 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1804 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1805 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
1808 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1809 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1810 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1813 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1814 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1817 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1818 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1822 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1824 vsize.width = (int)width;
1825 vsize.height = (int)height;
1826 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1829 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1830 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1831 jintArray arr = env->NewIntArray(2);
1832 int tVsize [2]= {vsize.width,vsize.height};
1833 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1837 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1838 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1841 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1842 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1845 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1846 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1849 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1850 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1853 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1854 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1856 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1857 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1860 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1861 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
1864 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1866 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1879 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1880 LinphoneCore *lc = (LinphoneCore *) ptr;
1886 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1889 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1890 ,jlong lc, jboolean enable) {
1891 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1894 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1895 ,jlong ptr, jint db) {
1896 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1899 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1900 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1902 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1903 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
1905 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1906 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1908 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1909 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
1911 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1912 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
1914 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1915 linphone_core_leave_conference((LinphoneCore *) pCore);
1917 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1918 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1920 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1921 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1923 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1924 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1927 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1928 linphone_core_terminate_conference((LinphoneCore *) pCore);
1930 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1931 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
1933 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1934 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1936 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1937 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1938 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1939 return lcd->getCall(env,lCall);
1941 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1942 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1945 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1946 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1947 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1948 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1951 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1952 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1955 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1957 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1958 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1959 env->ReleaseStringUTFChars(jFile, cFile);
1961 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1965 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1966 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1967 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1968 env->ReleaseStringUTFChars(jUri, cUri);
1969 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1970 return (jobject) lcdata->getCall(env,call);
1974 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1975 LinphoneCore* lc = (LinphoneCore *) pCore;
1976 const char** devices = linphone_core_get_video_devices(lc);
1977 if (devices == NULL) {
1978 ms_error("No existing video devices\n");
1982 for(i=0; i<=id; i++) {
1983 if (devices[i] == NULL)
1985 ms_message("Existing device %d : %s\n", i, devices[i]);
1987 return (jint)linphone_core_set_video_device(lc, devices[i]);
1993 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1994 LinphoneCore* lc = (LinphoneCore *) pCore;
1995 const char** devices = linphone_core_get_video_devices(lc);
1996 if (devices == NULL) {
1997 ms_error("No existing video devices\n");
2000 const char* cam = linphone_core_get_video_device(lc);
2002 ms_error("No current video device\n");
2005 while(devices[i] != NULL) {
2006 if (strcmp(devices[i], cam) == 0)
2011 ms_warning("Returning default (0) device\n");
2015 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2016 LinphoneCall *call = (LinphoneCall *) ptr;
2017 const char* token = linphone_call_get_authentication_token(call);
2018 if (token == NULL) return NULL;
2019 return env->NewStringUTF(token);
2021 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2022 LinphoneCall *call = (LinphoneCall *) ptr;
2023 return (jboolean)linphone_call_get_authentication_token_verified(call);
2025 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2026 LinphoneCall *call = (LinphoneCall *) ptr;
2027 linphone_call_set_authentication_token_verified(call, verified);
2030 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2031 LinphoneCall *call = (LinphoneCall *) ptr;
2032 return (jfloat)linphone_call_get_play_volume(call);
2035 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2036 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2039 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2040 // Implemented directly in msandroid.cpp (sound filters for Android).
2041 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
2043 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
2044 msandroid_hack_speaker_state(speakerOn);
2046 // End Galaxy S hack functions
2049 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2050 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2052 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2053 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2056 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2057 jstring jHost, jint port, jint mirror, jint delay) {
2058 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2059 if (!tunnel) return;
2060 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2061 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2062 env->ReleaseStringUTFChars(jHost, cHost);
2065 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2066 jstring jHost, jint port, jstring username, jstring password) {
2068 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2069 if (!tunnel) return;
2070 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2071 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2072 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2073 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2074 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2075 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2076 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2080 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2081 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2082 linphone_tunnel_auto_detect(tunnel);
2086 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2087 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2088 linphone_tunnel_clean_servers(tunnel);
2091 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2092 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2093 linphone_tunnel_enable(tunnel, enable);
2097 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2098 const char* cname=env->GetStringUTFChars(name, NULL);
2099 const char* cversion=env->GetStringUTFChars(version, NULL);
2100 linphone_core_set_user_agent(cname,cversion);
2101 env->ReleaseStringUTFChars(name, cname);
2102 env->ReleaseStringUTFChars(version, cversion);
2105 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2106 return (jboolean)linphone_core_tunnel_available();
2109 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2110 LinphoneVideoPolicy vpol;
2111 vpol.automatically_initiate = autoInitiate;
2112 vpol.automatically_accept = autoAccept;
2113 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2116 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2117 ms_set_cpu_count(count);
2120 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2121 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2124 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2125 linphone_core_set_video_port((LinphoneCore *)lc, port);
2128 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2129 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2132 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2133 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2136 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2137 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2140 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2141 linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout);
2144 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2145 jstring jvalue =env->NewStringUTF(linphone_core_get_version());