3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
24 #include "linphone_tunnel.h"
28 #include "mediastreamer2/mediastream.h"
30 #include "mediastreamer2/msjava.h"
32 #include <cpu-features.h>
35 #include <android/log.h>
36 extern "C" void libmsilbc_init();
38 extern "C" void libmsx264_init();
41 extern "C" void libmsamr_init();
44 extern "C" void libmssilk_init();
47 extern "C" void libmsbcg729_init();
54 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
60 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
61 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
62 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
63 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
64 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
65 default: prio = ANDROID_LOG_DEFAULT; break;
67 vsnprintf(str, sizeof(str) - 1, fmt, args);
68 str[sizeof(str) - 1] = '\0';
69 if (strlen(str) < 512) {
70 __android_log_write(prio, LOG_DOMAIN, str);
73 while ((next = strchr(current, '\n')) != NULL) {
75 __android_log_write(prio, LOG_DOMAIN, current);
78 __android_log_write(prio, LOG_DOMAIN, current);
82 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
83 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
87 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
93 return JNI_VERSION_1_2;
98 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
102 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
104 linphone_core_disable_logs();
109 class LinphoneCoreData {
111 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
113 core = env->NewGlobalRef(lc);
114 listener = env->NewGlobalRef(alistener);
115 userdata = auserdata?env->NewGlobalRef(auserdata):0;
116 memset(&vTable,0,sizeof(vTable));
117 vTable.show = showInterfaceCb;
118 vTable.auth_info_requested = authInfoRequested;
119 vTable.display_status = displayStatusCb;
120 vTable.display_message = displayMessageCb;
121 vTable.display_warning = displayMessageCb;
122 vTable.global_state_changed = globalStateChange;
123 vTable.registration_state_changed = registrationStateChange;
124 vTable.call_state_changed = callStateChange;
125 vTable.call_encryption_changed = callEncryptionChange;
126 vTable.text_received = text_received;
127 vTable.message_received = message_received;
128 vTable.dtmf_received = dtmf_received;
129 vTable.new_subscription_request = new_subscription_request;
130 vTable.notify_presence_recv = notify_presence_recv;
131 vTable.call_stats_updated = callStatsUpdated;
133 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
135 /*displayStatus(LinphoneCore lc,String message);*/
136 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
138 /*void generalState(LinphoneCore lc,int state); */
139 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
140 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
141 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
143 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
144 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
145 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
146 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
148 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
149 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
150 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
151 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
153 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
154 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
156 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
157 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
159 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
160 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
162 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
163 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
164 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
165 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
167 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
168 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
170 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
171 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
173 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
174 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
175 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
176 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
178 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
179 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
181 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
182 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
184 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
185 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
187 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
188 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
190 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
191 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
193 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
194 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
196 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
197 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
198 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
199 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
202 ~LinphoneCoreData() {
204 jvm->AttachCurrentThread(&env,NULL);
205 env->DeleteGlobalRef(core);
206 env->DeleteGlobalRef(listener);
207 if (userdata) env->DeleteGlobalRef(userdata);
208 env->DeleteGlobalRef(listenerClass);
209 env->DeleteGlobalRef(globalStateClass);
210 env->DeleteGlobalRef(registrationStateClass);
211 env->DeleteGlobalRef(callStateClass);
212 env->DeleteGlobalRef(callStatsClass);
213 env->DeleteGlobalRef(chatMessageStateClass);
214 env->DeleteGlobalRef(proxyClass);
215 env->DeleteGlobalRef(callClass);
216 env->DeleteGlobalRef(chatMessageClass);
217 env->DeleteGlobalRef(chatRoomClass);
218 env->DeleteGlobalRef(friendClass);
225 jclass listenerClass;
226 jmethodID displayStatusId;
227 jmethodID newSubscriptionRequestId;
228 jmethodID notifyPresenceReceivedId;
229 jmethodID textReceivedId;
230 jmethodID messageReceivedId;
231 jmethodID dtmfReceivedId;
232 jmethodID callStatsUpdatedId;
234 jclass globalStateClass;
235 jmethodID globalStateId;
236 jmethodID globalStateFromIntId;
238 jclass registrationStateClass;
239 jmethodID registrationStateId;
240 jmethodID registrationStateFromIntId;
242 jclass callStateClass;
243 jmethodID callStateId;
244 jmethodID callStateFromIntId;
246 jclass callStatsClass;
247 jmethodID callStatsId;
248 jmethodID callSetAudioStatsId;
249 jmethodID callSetVideoStatsId;
251 jclass chatMessageStateClass;
252 jmethodID chatMessageStateFromIntId;
254 jmethodID callEncryptionChangedId;
256 jclass ecCalibratorStatusClass;
257 jmethodID ecCalibrationStatusId;
258 jmethodID ecCalibratorStatusFromIntId;
261 jmethodID proxyCtrId;
266 jclass chatMessageClass;
267 jmethodID chatMessageCtrId;
269 jclass chatRoomClass;
270 jmethodID chatRoomCtrId;
273 jmethodID friendCtrId;
276 jmethodID addressCtrId;
278 LinphoneCoreVTable vTable;
280 static void showInterfaceCb(LinphoneCore *lc) {
283 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
286 static void displayStatusCb(LinphoneCore *lc, const char *message) {
288 jint result = jvm->AttachCurrentThread(&env,NULL);
290 ms_error("cannot attach VM\n");
293 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
294 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
296 static void displayMessageCb(LinphoneCore *lc, const char *message) {
299 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
302 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
304 jint result = jvm->AttachCurrentThread(&env,NULL);
306 ms_error("cannot attach VM\n");
309 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
310 env->CallVoidMethod(lcData->listener
311 ,lcData->globalStateId
313 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
314 message ? env->NewStringUTF(message) : NULL);
316 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
318 jint result = jvm->AttachCurrentThread(&env,NULL);
320 ms_error("cannot attach VM\n");
323 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
324 env->CallVoidMethod(lcData->listener
325 ,lcData->registrationStateId
327 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
328 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
329 message ? env->NewStringUTF(message) : NULL);
331 jobject getCall(JNIEnv *env , LinphoneCall *call){
335 void *up=linphone_call_get_user_pointer(call);
338 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
339 jobj=env->NewGlobalRef(jobj);
340 linphone_call_set_user_pointer(call,(void*)jobj);
341 linphone_call_ref(call);
349 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
351 jint result = jvm->AttachCurrentThread(&env,NULL);
354 ms_error("cannot attach VM\n");
357 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
358 env->CallVoidMethod(lcData->listener
361 ,(jcall=lcData->getCall(env,call))
362 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
363 message ? env->NewStringUTF(message) : NULL);
364 if (state==LinphoneCallReleased){
365 linphone_call_set_user_pointer(call,NULL);
366 env->DeleteGlobalRef(jcall);
369 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
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->callEncryptionChangedId
380 ,lcData->getCall(env,call)
382 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
384 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
386 jint result = jvm->AttachCurrentThread(&env,NULL);
388 ms_error("cannot attach VM\n");
391 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
392 env->CallVoidMethod(lcData->listener
393 ,lcData->notifyPresenceReceivedId
395 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
397 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
399 jint result = jvm->AttachCurrentThread(&env,NULL);
401 ms_error("cannot attach VM\n");
404 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
405 env->CallVoidMethod(lcData->listener
406 ,lcData->newSubscriptionRequestId
408 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
409 ,url ? env->NewStringUTF(url) : NULL);
411 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
413 jint result = jvm->AttachCurrentThread(&env,NULL);
415 ms_error("cannot attach VM\n");
418 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
419 env->CallVoidMethod(lcData->listener
420 ,lcData->dtmfReceivedId
422 ,lcData->getCall(env,call)
425 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
427 jint result = jvm->AttachCurrentThread(&env,NULL);
429 ms_error("cannot attach VM\n");
432 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
433 env->CallVoidMethod(lcData->listener
434 ,lcData->textReceivedId
436 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
437 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
438 ,message ? env->NewStringUTF(message) : NULL);
440 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
442 jint result = jvm->AttachCurrentThread(&env,NULL);
444 ms_error("cannot attach VM\n");
447 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
448 env->CallVoidMethod(lcData->listener
449 ,lcData->messageReceivedId
451 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
452 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
454 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
456 jint result = jvm->AttachCurrentThread(&env,NULL);
458 ms_error("cannot attach VM\n");
461 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
462 env->CallVoidMethod(lcData->listener
463 ,lcData->ecCalibrationStatusId
465 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
467 ,data ? data : NULL);
468 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
469 //final state, releasing global ref
470 env->DeleteGlobalRef((jobject)data);
474 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
478 jint result = jvm->AttachCurrentThread(&env,NULL);
480 ms_error("cannot attach VM\n");
483 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
484 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
485 callobj = lcData->getCall(env, call);
486 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
487 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
489 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
490 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
495 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
499 ,jstring jfactoryConfig
502 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
503 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
504 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
507 libmsilbc_init(); // requires an fpu
521 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
525 //clear auth info list
526 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
527 //clear existing proxy config
528 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
530 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
531 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
534 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
537 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
538 linphone_core_destroy((LinphoneCore*)lc);
542 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
543 linphone_core_clear_proxy_config((LinphoneCore*)lc);
546 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
550 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
552 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
555 LinphoneProxyConfig *config=0;
556 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
557 return (jlong)config;
560 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
561 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
562 int proxyCount = ms_list_size(proxies);
563 jlongArray jProxies = env->NewLongArray(proxyCount);
564 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
566 for (int i = 0; i < proxyCount; i++ ) {
567 jInternalArray[i] = (unsigned long) (proxies->data);
568 proxies = proxies->next;
571 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
576 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
581 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
582 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
584 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
587 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
588 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
591 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
592 linphone_core_refresh_registers((LinphoneCore*)lc);
595 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
599 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
601 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
604 linphone_core_iterate((LinphoneCore*)lc);
606 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
610 const char* uri = env->GetStringUTFChars(juri, NULL);
611 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
612 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
613 env->ReleaseStringUTFChars(juri, uri);
614 return lcd->getCall(env,lCall);
616 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
620 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
621 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
624 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
628 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
631 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
634 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
636 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
640 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
642 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
646 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
648 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
653 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
656 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
661 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
664 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
669 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
672 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
676 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
679 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
683 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
685 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
688 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
690 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
693 ,jboolean isReachable) {
694 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
697 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
700 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
703 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
707 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
710 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
713 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
716 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
720 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
723 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
727 const char* url = env->GetStringUTFChars(jurl, NULL);
728 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
729 env->ReleaseStringUTFChars(jurl, url);
732 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
736 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
738 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
743 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
745 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
748 linphone_core_stop_dtmf((LinphoneCore*)lc);
751 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
754 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
757 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
760 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
763 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
765 ,jlong lc, jlong log) {
766 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
769 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
772 linphone_core_clear_call_logs((LinphoneCore*)lc);
774 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
777 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
779 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
785 const char* mime = env->GetStringUTFChars(jmime, NULL);
786 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
787 env->ReleaseStringUTFChars(jmime, mime);
790 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
793 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
794 int codecsCount = ms_list_size(codecs);
795 jlongArray jCodecs = env->NewLongArray(codecsCount);
796 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
798 for (int i = 0; i < codecsCount; i++ ) {
799 jInternalArray[i] = (unsigned long) (codecs->data);
800 codecs = codecs->next;
803 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
808 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
811 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
812 int codecsCount = ms_list_size(codecs);
813 jlongArray jCodecs = env->NewLongArray(codecsCount);
814 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
816 for (int i = 0; i < codecsCount; i++ ) {
817 jInternalArray[i] = (unsigned long) (codecs->data);
818 codecs = codecs->next;
821 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
826 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
831 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
833 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
837 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
839 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
843 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
845 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
849 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
852 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
856 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
859 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
863 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
865 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
867 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
872 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
874 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
878 ,jstring jalternative_contact
880 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
881 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
882 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
885 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
890 const char* to = env->GetStringUTFChars(jto, NULL);
891 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
892 env->ReleaseStringUTFChars(jto, to);
893 return (jlong)lResult;
896 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
899 ,jboolean vcap_enabled
900 ,jboolean display_enabled) {
901 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
904 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
907 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
909 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
913 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
914 linphone_core_set_play_file((LinphoneCore*)lc,path);
915 if (path) env->ReleaseStringUTFChars(jpath, path);
917 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
921 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
922 linphone_core_set_ring((LinphoneCore*)lc,path);
923 if (path) env->ReleaseStringUTFChars(jpath, path);
925 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
929 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
931 return env->NewStringUTF(path);
936 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
940 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
941 linphone_core_set_root_ca((LinphoneCore*)lc,path);
942 if (path) env->ReleaseStringUTFChars(jpath, path);
944 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
948 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
951 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
954 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
957 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
961 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
962 , LinphoneCoreData::ecCalibrationStatus
963 , data?env->NewGlobalRef(data):NULL);
967 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
971 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
974 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
978 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
981 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
985 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
988 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
992 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
995 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1000 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1005 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1006 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1007 return (jlong) proxy;
1010 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1011 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1013 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1014 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1015 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1016 env->ReleaseStringUTFChars(jidentity, identity);
1018 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1019 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1021 return env->NewStringUTF(identity);
1026 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1027 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1028 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1029 env->ReleaseStringUTFChars(jproxy, proxy);
1032 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1033 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1035 return env->NewStringUTF(proxy);
1040 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1041 const char* params = env->GetStringUTFChars(jparams, NULL);
1042 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1043 env->ReleaseStringUTFChars(jparams, params);
1045 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1046 if (jroute != NULL) {
1047 const char* route = env->GetStringUTFChars(jroute, NULL);
1048 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1049 env->ReleaseStringUTFChars(jroute, route);
1052 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1055 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1056 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1058 return env->NewStringUTF(route);
1064 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1065 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1067 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1068 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1070 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1071 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1073 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1074 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1076 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1077 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1079 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1081 ms_error("cannot normalized null number");
1083 const char* number = env->GetStringUTFChars(jnumber, NULL);
1084 int len = env->GetStringLength(jnumber);
1086 ms_warning("cannot normalize empty number");
1089 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1090 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1091 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1092 env->ReleaseStringUTFChars(jnumber, number);
1093 return normalizedNumber;
1095 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1096 const char* iso = env->GetStringUTFChars(jiso, NULL);
1097 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1098 env->ReleaseStringUTFChars(jiso, iso);
1099 return (jint) prefix;
1101 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1104 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1106 return env->NewStringUTF(domain);
1111 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1112 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1115 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1119 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1120 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1121 env->ReleaseStringUTFChars(jprefix, prefix);
1123 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1127 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1129 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1130 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1135 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1143 const char* username = env->GetStringUTFChars(jusername, NULL);
1144 const char* userid = env->GetStringUTFChars(juserid, NULL);
1145 const char* password = env->GetStringUTFChars(jpassword, NULL);
1146 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1147 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1148 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1150 env->ReleaseStringUTFChars(jusername, username);
1151 env->ReleaseStringUTFChars(juserid, userid);
1152 env->ReleaseStringUTFChars(jpassword, password);
1153 env->ReleaseStringUTFChars(jha1, ha1);
1154 env->ReleaseStringUTFChars(jrealm, realm);
1158 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1161 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1166 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1169 ,jstring jdisplayName) {
1170 const char* uri = env->GetStringUTFChars(juri, NULL);
1171 LinphoneAddress* address = linphone_address_new(uri);
1172 if (jdisplayName && address) {
1173 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1174 linphone_address_set_display_name(address,displayName);
1175 env->ReleaseStringUTFChars(jdisplayName, displayName);
1177 env->ReleaseStringUTFChars(juri, uri);
1179 return (jlong) address;
1181 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1184 linphone_address_destroy((LinphoneAddress*)ptr);
1187 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1190 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1192 return env->NewStringUTF(displayName);
1197 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1200 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1202 return env->NewStringUTF(userName);
1207 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1210 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1212 return env->NewStringUTF(domain);
1218 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1221 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1222 jstring juri =env->NewStringUTF(uri);
1226 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1229 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1230 jstring juri =env->NewStringUTF(uri);
1234 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1237 ,jstring jdisplayName) {
1238 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1239 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1240 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1245 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1248 return (jlong)((LinphoneCallLog*)ptr)->from;
1250 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1253 return (jint)((LinphoneCallLog*)ptr)->status;
1255 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1258 return (jlong)((LinphoneCallLog*)ptr)->to;
1260 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1263 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1265 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1268 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1271 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1274 return (jint)((LinphoneCallLog*)ptr)->duration;
1278 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1279 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1281 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1282 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1284 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1285 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1287 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1288 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1290 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1291 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1292 const report_block_t *srb = NULL;
1294 if (!stats || !stats->sent_rtcp)
1296 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1297 if (stats->sent_rtcp->b_cont != NULL)
1298 msgpullup(stats->sent_rtcp, -1);
1299 if (rtcp_is_SR(stats->sent_rtcp))
1300 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1301 else if (rtcp_is_RR(stats->sent_rtcp))
1302 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1305 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1307 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1308 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1309 const report_block_t *rrb = NULL;
1311 if (!stats || !stats->received_rtcp)
1313 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1314 if (stats->received_rtcp->b_cont != NULL)
1315 msgpullup(stats->received_rtcp, -1);
1316 if (rtcp_is_RR(stats->received_rtcp))
1317 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1318 else if (rtcp_is_SR(stats->received_rtcp))
1319 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1322 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1324 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1325 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1326 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1327 const LinphoneCallParams *params;
1328 const PayloadType *pt;
1329 const report_block_t *srb = NULL;
1331 if (!stats || !call || !stats->sent_rtcp)
1333 params = linphone_call_get_current_params(call);
1336 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1337 if (stats->sent_rtcp->b_cont != NULL)
1338 msgpullup(stats->sent_rtcp, -1);
1339 if (rtcp_is_SR(stats->sent_rtcp))
1340 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1341 else if (rtcp_is_RR(stats->sent_rtcp))
1342 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1345 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1346 pt = linphone_call_params_get_used_audio_codec(params);
1348 pt = linphone_call_params_get_used_video_codec(params);
1349 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1351 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1352 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1353 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1354 const LinphoneCallParams *params;
1355 const PayloadType *pt;
1356 const report_block_t *rrb = NULL;
1358 if (!stats || !call || !stats->received_rtcp)
1360 params = linphone_call_get_current_params(call);
1363 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1364 if (stats->received_rtcp->b_cont != NULL)
1365 msgpullup(stats->received_rtcp, -1);
1366 if (rtcp_is_SR(stats->received_rtcp))
1367 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1368 else if (rtcp_is_RR(stats->received_rtcp))
1369 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1372 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1373 pt = linphone_call_params_get_used_audio_codec(params);
1375 pt = linphone_call_params_get_used_video_codec(params);
1376 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1378 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1379 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1381 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1382 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1383 LinphoneCall *call = (LinphoneCall *)call_ptr;
1384 rtp_stats_t rtp_stats;
1386 if (!stats || !call)
1388 memset(&rtp_stats, 0, sizeof(rtp_stats));
1389 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1390 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1391 #ifdef VIDEO_ENABLED
1393 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1395 return (jlong)rtp_stats.outoftime;
1397 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1398 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1402 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1403 PayloadType* pt = (PayloadType*)ptr;
1404 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1405 ,payload_type_get_mime(pt)
1406 ,payload_type_get_rate(pt)
1407 ,payload_type_get_bitrate(pt));
1408 jstring jvalue =env->NewStringUTF(value);
1412 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1413 PayloadType* pt = (PayloadType*)ptr;
1414 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1417 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1418 PayloadType* pt = (PayloadType*)ptr;
1419 return (jint)payload_type_get_rate(pt);
1423 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1426 LinphoneCall *call=(LinphoneCall*)ptr;
1427 linphone_call_unref(call);
1430 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1433 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1436 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1438 ,jlong ptr, jstring path) {
1439 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1440 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1443 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1445 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1446 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1449 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1452 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1455 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1458 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1461 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1464 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1466 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1470 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1472 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1475 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1478 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1482 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1484 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1487 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1490 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1493 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1494 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1497 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1500 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1503 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1506 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1511 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1513 ,jstring jFriendUri) {
1514 LinphoneFriend* lResult;
1517 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1518 lResult= linphone_friend_new_with_addr(friendUri);
1519 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1521 lResult = linphone_friend_new();
1523 return (jlong)lResult;
1525 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1528 ,jlong linphoneAddress) {
1529 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1531 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1534 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1536 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1540 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1542 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1545 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1547 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1551 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1553 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1556 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1558 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1561 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1563 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1566 return linphone_friend_edit((LinphoneFriend*)ptr);
1568 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1571 linphone_friend_done((LinphoneFriend*)ptr);
1573 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1577 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1579 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1582 ,jstring jaddress) {
1583 const char* address = env->GetStringUTFChars(jaddress, NULL);
1584 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1585 env->ReleaseStringUTFChars(jaddress, address);
1589 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1592 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1594 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1597 ,jstring jmessage) {
1598 const char* message = env->GetStringUTFChars(jmessage, NULL);
1599 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1600 env->ReleaseStringUTFChars(jmessage, message);
1602 return (jlong) chatMessage;
1604 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1607 jobject ud = env->NewGlobalRef(thiz);
1608 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1610 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1613 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1616 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1619 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1622 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1626 const char* url = env->GetStringUTFChars(jurl, NULL);
1627 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1628 env->ReleaseStringUTFChars(jurl, url);
1630 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1633 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1635 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1638 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1640 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1643 ,jstring jmessage) {
1644 const char* message = env->GetStringUTFChars(jmessage, NULL);
1645 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1646 env->ReleaseStringUTFChars(jmessage, message);
1649 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1651 jint result = jvm->AttachCurrentThread(&env,NULL);
1653 ms_error("cannot attach VM\n");
1657 jobject listener = (jobject) ud;
1658 jclass clazz = (jclass) env->GetObjectClass(listener);
1659 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1661 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1662 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1663 env->CallVoidMethod(
1666 (jobject)linphone_chat_message_get_user_data(msg),
1667 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1669 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1670 env->DeleteGlobalRef(listener);
1673 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1677 ,jobject jlistener) {
1678 jobject listener = env->NewGlobalRef(jlistener);
1679 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1681 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1685 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1686 if (oldWindow != NULL) {
1687 env->DeleteGlobalRef(oldWindow);
1690 obj = env->NewGlobalRef(obj);
1692 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1695 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1699 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1700 if (oldWindow != NULL) {
1701 env->DeleteGlobalRef(oldWindow);
1704 obj = env->NewGlobalRef(obj);
1706 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1713 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1717 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1718 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1721 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1722 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1725 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1726 const char* server = NULL;
1727 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1728 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1729 if (server) env->ReleaseStringUTFChars(jserver,server);
1732 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1733 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1734 if (ret==NULL) return NULL;
1735 jstring jvalue =env->NewStringUTF(ret);
1741 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1742 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1745 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1746 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1749 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
1753 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
1756 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1760 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1763 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1764 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1767 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1768 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1771 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1772 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1775 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1776 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1779 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1780 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1782 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1783 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1786 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1787 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1790 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1793 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1794 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1797 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1798 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1801 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1802 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
1805 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1806 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1807 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1810 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1811 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1814 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1815 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1819 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1821 vsize.width = (int)width;
1822 vsize.height = (int)height;
1823 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1826 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1827 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1828 jintArray arr = env->NewIntArray(2);
1829 int tVsize [2]= {vsize.width,vsize.height};
1830 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1834 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1835 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1838 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1839 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1842 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1843 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1846 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1847 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1850 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1851 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1853 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1854 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1857 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1858 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
1861 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1863 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1876 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1877 LinphoneCore *lc = (LinphoneCore *) ptr;
1883 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1886 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1887 ,jlong lc, jboolean enable) {
1888 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1891 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1892 ,jlong ptr, jint db) {
1893 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1896 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1897 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1899 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1900 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
1902 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1903 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1905 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1906 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
1908 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1909 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
1911 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1912 linphone_core_leave_conference((LinphoneCore *) pCore);
1914 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1915 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1917 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1918 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1920 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1921 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1924 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1925 linphone_core_terminate_conference((LinphoneCore *) pCore);
1927 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1928 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
1930 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1931 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1933 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1934 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1935 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1936 return lcd->getCall(env,lCall);
1938 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1939 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1942 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1943 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1944 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1945 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1948 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1949 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1952 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1954 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1955 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1956 env->ReleaseStringUTFChars(jFile, cFile);
1958 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1962 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1963 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1964 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1965 env->ReleaseStringUTFChars(jUri, cUri);
1966 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1967 return (jobject) lcdata->getCall(env,call);
1971 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1972 LinphoneCore* lc = (LinphoneCore *) pCore;
1973 const char** devices = linphone_core_get_video_devices(lc);
1974 if (devices == NULL) {
1975 ms_error("No existing video devices\n");
1979 for(i=0; i<=id; i++) {
1980 if (devices[i] == NULL)
1982 ms_message("Existing device %d : %s\n", i, devices[i]);
1984 return (jint)linphone_core_set_video_device(lc, devices[i]);
1990 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1991 LinphoneCore* lc = (LinphoneCore *) pCore;
1992 const char** devices = linphone_core_get_video_devices(lc);
1993 if (devices == NULL) {
1994 ms_error("No existing video devices\n");
1997 const char* cam = linphone_core_get_video_device(lc);
1999 ms_error("No current video device\n");
2002 while(devices[i] != NULL) {
2003 if (strcmp(devices[i], cam) == 0)
2008 ms_warning("Returning default (0) device\n");
2012 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2013 LinphoneCall *call = (LinphoneCall *) ptr;
2014 const char* token = linphone_call_get_authentication_token(call);
2015 if (token == NULL) return NULL;
2016 return env->NewStringUTF(token);
2018 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2019 LinphoneCall *call = (LinphoneCall *) ptr;
2020 return (jboolean)linphone_call_get_authentication_token_verified(call);
2022 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2023 LinphoneCall *call = (LinphoneCall *) ptr;
2024 linphone_call_set_authentication_token_verified(call, verified);
2027 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2028 LinphoneCall *call = (LinphoneCall *) ptr;
2029 return (jfloat)linphone_call_get_play_volume(call);
2032 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2033 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2036 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2037 // Implemented directly in msandroid.cpp (sound filters for Android).
2038 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
2040 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
2041 msandroid_hack_speaker_state(speakerOn);
2043 // End Galaxy S hack functions
2046 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2047 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2049 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2050 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2053 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2054 jstring jHost, jint port, jint mirror, jint delay) {
2055 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2056 if (!tunnel) return;
2057 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2058 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2059 env->ReleaseStringUTFChars(jHost, cHost);
2062 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2063 jstring jHost, jint port, jstring username, jstring password) {
2065 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2066 if (!tunnel) return;
2067 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2068 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2069 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2070 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2071 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2072 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2073 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2077 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2078 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2079 linphone_tunnel_auto_detect(tunnel);
2083 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2084 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2085 linphone_tunnel_clean_servers(tunnel);
2088 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2089 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2090 linphone_tunnel_enable(tunnel, enable);
2094 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2095 const char* cname=env->GetStringUTFChars(name, NULL);
2096 const char* cversion=env->GetStringUTFChars(version, NULL);
2097 linphone_core_set_user_agent(cname,cversion);
2098 env->ReleaseStringUTFChars(name, cname);
2099 env->ReleaseStringUTFChars(version, cversion);
2102 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2103 return (jboolean)linphone_core_tunnel_available();
2106 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2107 LinphoneVideoPolicy vpol;
2108 vpol.automatically_initiate = autoInitiate;
2109 vpol.automatically_accept = autoAccept;
2110 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2113 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2114 ms_set_cpu_count(count);
2117 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2118 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2121 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2122 linphone_core_set_video_port((LinphoneCore *)lc, port);
2125 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2126 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2129 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2130 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2133 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2134 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2137 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2138 jstring jvalue =env->NewStringUTF(linphone_core_get_version());