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" jlong 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" jlong 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" int 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 linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
587 extern "C" jlong 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 linphone_core_in_call((LinphoneCore*)lc);
642 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
646 return 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 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 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" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
713 return 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" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
754 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 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" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
831 return 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 linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
852 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
856 return 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" long 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 (long)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 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 linphone_core_keep_alive_enabled((LinphoneCore*)lc);
957 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
961 return linphone_core_start_echo_calibration((LinphoneCore*)lc
962 , LinphoneCoreData::ecCalibrationStatus
963 , data?env->NewGlobalRef(data):NULL);
967 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
971 return (int)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" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
982 return (long)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
985 extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
986 return (long)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
989 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
993 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
996 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
1000 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1003 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1007 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1010 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
1014 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
1017 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1022 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1027 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1028 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1029 return (jlong) proxy;
1032 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1033 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1035 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1036 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1037 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1038 env->ReleaseStringUTFChars(jidentity, identity);
1040 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1041 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1043 return env->NewStringUTF(identity);
1048 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1049 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1050 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1051 env->ReleaseStringUTFChars(jproxy, proxy);
1054 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1055 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1057 return env->NewStringUTF(proxy);
1062 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1063 const char* params = env->GetStringUTFChars(jparams, NULL);
1064 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1065 env->ReleaseStringUTFChars(jparams, params);
1067 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1068 if (jroute != NULL) {
1069 const char* route = env->GetStringUTFChars(jroute, NULL);
1070 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1071 env->ReleaseStringUTFChars(jroute, route);
1074 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1077 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1078 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1080 return env->NewStringUTF(route);
1086 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1087 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1089 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1090 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1092 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1093 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1095 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1096 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1098 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1099 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1101 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1103 ms_error("cannot normalized null number");
1105 const char* number = env->GetStringUTFChars(jnumber, NULL);
1106 int len = env->GetStringLength(jnumber);
1108 ms_warning("cannot normalize empty number");
1111 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1112 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1113 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1114 env->ReleaseStringUTFChars(jnumber, number);
1115 return normalizedNumber;
1117 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1118 const char* iso = env->GetStringUTFChars(jiso, NULL);
1119 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1120 env->ReleaseStringUTFChars(jiso, iso);
1121 return (jint) prefix;
1123 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1126 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1128 return env->NewStringUTF(domain);
1133 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1134 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1137 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1141 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1142 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1143 env->ReleaseStringUTFChars(jprefix, prefix);
1145 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1149 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1151 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1152 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1157 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1165 const char* username = env->GetStringUTFChars(jusername, NULL);
1166 const char* userid = env->GetStringUTFChars(juserid, NULL);
1167 const char* password = env->GetStringUTFChars(jpassword, NULL);
1168 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1169 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1170 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1172 env->ReleaseStringUTFChars(jusername, username);
1173 env->ReleaseStringUTFChars(juserid, userid);
1174 env->ReleaseStringUTFChars(jpassword, password);
1175 env->ReleaseStringUTFChars(jha1, ha1);
1176 env->ReleaseStringUTFChars(jrealm, realm);
1180 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1183 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1188 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1191 ,jstring jdisplayName) {
1192 const char* uri = env->GetStringUTFChars(juri, NULL);
1193 LinphoneAddress* address = linphone_address_new(uri);
1194 if (jdisplayName && address) {
1195 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1196 linphone_address_set_display_name(address,displayName);
1197 env->ReleaseStringUTFChars(jdisplayName, displayName);
1199 env->ReleaseStringUTFChars(juri, uri);
1201 return (jlong) address;
1203 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1206 linphone_address_destroy((LinphoneAddress*)ptr);
1209 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1212 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1214 return env->NewStringUTF(displayName);
1219 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1222 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1224 return env->NewStringUTF(userName);
1229 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1232 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1234 return env->NewStringUTF(domain);
1240 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1243 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1244 jstring juri =env->NewStringUTF(uri);
1248 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1251 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1252 jstring juri =env->NewStringUTF(uri);
1256 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1259 ,jstring jdisplayName) {
1260 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1261 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1262 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1267 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1270 return (jlong)((LinphoneCallLog*)ptr)->from;
1272 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1275 return (jlong)((LinphoneCallLog*)ptr)->status;
1277 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1280 return (jlong)((LinphoneCallLog*)ptr)->to;
1282 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1285 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1287 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1290 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1293 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1296 return ((LinphoneCallLog*)ptr)->duration;
1300 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1301 return (int)((LinphoneCallStats *)stats_ptr)->type;
1303 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1304 return (int)((LinphoneCallStats *)stats_ptr)->ice_state;
1306 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1307 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1309 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1310 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1312 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1313 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1314 const report_block_t *srb = NULL;
1316 if (!stats || !stats->sent_rtcp)
1318 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1319 if (stats->sent_rtcp->b_cont != NULL)
1320 msgpullup(stats->sent_rtcp, -1);
1321 if (rtcp_is_SR(stats->sent_rtcp))
1322 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1323 else if (rtcp_is_RR(stats->sent_rtcp))
1324 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1327 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1329 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1330 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1331 const report_block_t *rrb = NULL;
1333 if (!stats || !stats->received_rtcp)
1335 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1336 if (stats->received_rtcp->b_cont != NULL)
1337 msgpullup(stats->received_rtcp, -1);
1338 if (rtcp_is_RR(stats->received_rtcp))
1339 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1340 else if (rtcp_is_SR(stats->received_rtcp))
1341 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1344 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1346 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1347 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1348 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1349 const LinphoneCallParams *params;
1350 const PayloadType *pt;
1351 const report_block_t *srb = NULL;
1353 if (!stats || !call || !stats->sent_rtcp)
1355 params = linphone_call_get_current_params(call);
1358 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1359 if (stats->sent_rtcp->b_cont != NULL)
1360 msgpullup(stats->sent_rtcp, -1);
1361 if (rtcp_is_SR(stats->sent_rtcp))
1362 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1363 else if (rtcp_is_RR(stats->sent_rtcp))
1364 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1367 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1368 pt = linphone_call_params_get_used_audio_codec(params);
1370 pt = linphone_call_params_get_used_video_codec(params);
1371 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1373 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1374 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1375 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1376 const LinphoneCallParams *params;
1377 const PayloadType *pt;
1378 const report_block_t *rrb = NULL;
1380 if (!stats || !call || !stats->received_rtcp)
1382 params = linphone_call_get_current_params(call);
1385 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1386 if (stats->received_rtcp->b_cont != NULL)
1387 msgpullup(stats->received_rtcp, -1);
1388 if (rtcp_is_SR(stats->received_rtcp))
1389 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1390 else if (rtcp_is_RR(stats->received_rtcp))
1391 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1394 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1395 pt = linphone_call_params_get_used_audio_codec(params);
1397 pt = linphone_call_params_get_used_video_codec(params);
1398 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1400 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1401 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1403 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1404 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1405 LinphoneCall *call = (LinphoneCall *)call_ptr;
1406 rtp_stats_t rtp_stats;
1408 if (!stats || !call)
1410 memset(&rtp_stats, 0, sizeof(rtp_stats));
1411 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1412 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1413 #ifdef VIDEO_ENABLED
1415 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1417 return (jlong)rtp_stats.outoftime;
1419 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1420 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1424 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1425 PayloadType* pt = (PayloadType*)ptr;
1426 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1427 ,payload_type_get_mime(pt)
1428 ,payload_type_get_rate(pt)
1429 ,payload_type_get_bitrate(pt));
1430 jstring jvalue =env->NewStringUTF(value);
1434 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1435 PayloadType* pt = (PayloadType*)ptr;
1436 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1439 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1440 PayloadType* pt = (PayloadType*)ptr;
1441 return payload_type_get_rate(pt);
1445 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1448 LinphoneCall *call=(LinphoneCall*)ptr;
1449 linphone_call_unref(call);
1452 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1455 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1458 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1460 ,jlong ptr, jstring path) {
1461 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1462 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1465 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1467 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1468 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1471 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1474 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1477 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1480 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1483 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1486 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1488 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1492 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1494 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1497 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1500 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1504 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1506 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1509 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1512 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1515 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1516 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1519 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1522 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1525 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1528 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1533 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1535 ,jstring jFriendUri) {
1536 LinphoneFriend* lResult;
1539 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1540 lResult= linphone_friend_new_with_addr(friendUri);
1541 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1543 lResult = linphone_friend_new();
1545 return (long)lResult;
1547 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1550 ,jlong linphoneAddress) {
1551 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1553 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1556 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1558 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1562 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1564 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1567 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1569 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1573 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1575 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1578 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1580 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1583 return linphone_friend_get_status((LinphoneFriend*)ptr);
1585 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1588 return linphone_friend_edit((LinphoneFriend*)ptr);
1590 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1593 linphone_friend_done((LinphoneFriend*)ptr);
1596 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1599 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1601 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1604 ,jstring jmessage) {
1605 const char* message = env->GetStringUTFChars(jmessage, NULL);
1606 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1607 env->ReleaseStringUTFChars(jmessage, message);
1609 return (jlong) chatMessage;
1611 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1614 jobject ud = env->NewGlobalRef(thiz);
1615 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1617 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1620 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1623 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1626 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1629 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1633 const char* url = env->GetStringUTFChars(jurl, NULL);
1634 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1635 env->ReleaseStringUTFChars(jurl, url);
1637 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1640 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1642 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1645 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1647 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1650 ,jstring jmessage) {
1651 const char* message = env->GetStringUTFChars(jmessage, NULL);
1652 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1653 env->ReleaseStringUTFChars(jmessage, message);
1656 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1658 jint result = jvm->AttachCurrentThread(&env,NULL);
1660 ms_error("cannot attach VM\n");
1664 jobject listener = (jobject) ud;
1665 jclass clazz = (jclass) env->GetObjectClass(listener);
1666 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1668 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1669 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1670 env->CallVoidMethod(
1673 (jobject)linphone_chat_message_get_user_data(msg),
1674 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1676 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1677 env->DeleteGlobalRef(listener);
1680 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1684 ,jobject jlistener) {
1685 jobject listener = env->NewGlobalRef(jlistener);
1686 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1688 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1692 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1693 if (oldWindow != NULL) {
1694 env->DeleteGlobalRef(oldWindow);
1697 obj = env->NewGlobalRef(obj);
1699 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1702 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1706 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1707 if (oldWindow != NULL) {
1708 env->DeleteGlobalRef(oldWindow);
1711 obj = env->NewGlobalRef(obj);
1713 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1716 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1720 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1724 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1725 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1728 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1729 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1732 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1733 const char* server = NULL;
1734 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1735 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1736 if (server) env->ReleaseStringUTFChars(jserver,server);
1739 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1740 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1741 if (ret==NULL) return NULL;
1742 jstring jvalue =env->NewStringUTF(ret);
1746 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1747 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1750 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1751 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1754 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1755 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1758 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1759 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1762 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1763 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1765 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1766 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1769 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1770 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1773 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1776 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1777 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1780 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1781 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1784 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1785 linphone_call_camera_enabled((LinphoneCall *)lc);
1788 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1789 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1790 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1793 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1794 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1797 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1798 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1802 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1804 vsize.width = (int)width;
1805 vsize.height = (int)height;
1806 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1809 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1810 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1811 jintArray arr = env->NewIntArray(2);
1812 int tVsize [2]= {vsize.width,vsize.height};
1813 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1817 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1818 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1821 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1822 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1825 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1826 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1829 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1830 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1833 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1834 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1836 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1837 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1840 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1841 linphone_call_get_duration((LinphoneCall *) ptr);
1844 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1846 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1859 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1860 LinphoneCore *lc = (LinphoneCore *) ptr;
1866 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1869 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1870 ,jlong lc, jboolean enable) {
1871 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1874 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1875 ,jlong ptr, jint db) {
1876 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1879 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1880 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1882 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1883 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1885 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1886 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1888 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1889 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1891 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1892 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1894 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1895 linphone_core_leave_conference((LinphoneCore *) pCore);
1897 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1898 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1900 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1901 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1903 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1904 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1907 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1908 linphone_core_terminate_conference((LinphoneCore *) pCore);
1910 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1911 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1913 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1914 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1916 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1917 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1918 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1919 return lcd->getCall(env,lCall);
1921 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1922 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1925 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1926 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1927 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1928 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1930 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1931 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1934 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1936 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1937 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1938 env->ReleaseStringUTFChars(jFile, cFile);
1940 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1944 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1945 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1946 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1947 env->ReleaseStringUTFChars(jUri, cUri);
1948 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1949 return (jobject) lcdata->getCall(env,call);
1953 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1954 LinphoneCore* lc = (LinphoneCore *) pCore;
1955 const char** devices = linphone_core_get_video_devices(lc);
1956 if (devices == NULL) {
1957 ms_error("No existing video devices\n");
1961 for(i=0; i<=id; i++) {
1962 if (devices[i] == NULL)
1964 ms_message("Existing device %d : %s\n", i, devices[i]);
1966 return linphone_core_set_video_device(lc, devices[i]);
1972 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1973 LinphoneCore* lc = (LinphoneCore *) pCore;
1974 const char** devices = linphone_core_get_video_devices(lc);
1975 if (devices == NULL) {
1976 ms_error("No existing video devices\n");
1979 const char* cam = linphone_core_get_video_device(lc);
1981 ms_error("No current video device\n");
1984 while(devices[i] != NULL) {
1985 if (strcmp(devices[i], cam) == 0)
1990 ms_warning("Returning default (0) device\n");
1994 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1995 LinphoneCall *call = (LinphoneCall *) ptr;
1996 const char* token = linphone_call_get_authentication_token(call);
1997 if (token == NULL) return NULL;
1998 return env->NewStringUTF(token);
2000 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2001 LinphoneCall *call = (LinphoneCall *) ptr;
2002 return linphone_call_get_authentication_token_verified(call);
2004 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2005 LinphoneCall *call = (LinphoneCall *) ptr;
2006 linphone_call_set_authentication_token_verified(call, verified);
2009 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2010 LinphoneCall *call = (LinphoneCall *) ptr;
2011 return linphone_call_get_play_volume(call);
2014 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2015 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2018 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2019 // Implemented directly in msandroid.cpp (sound filters for Android).
2020 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
2022 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
2023 msandroid_hack_speaker_state(speakerOn);
2025 // End Galaxy S hack functions
2028 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2029 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2031 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2032 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2035 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2036 jstring jHost, jint port, jint mirror, jint delay) {
2037 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2038 if (!tunnel) return;
2039 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2040 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2041 env->ReleaseStringUTFChars(jHost, cHost);
2044 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2045 jstring jHost, jint port, jstring username, jstring password) {
2047 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2048 if (!tunnel) return;
2049 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2050 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2051 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2052 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2053 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2054 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2055 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2059 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2060 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2061 linphone_tunnel_auto_detect(tunnel);
2065 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2066 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2067 linphone_tunnel_clean_servers(tunnel);
2070 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2071 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2072 linphone_tunnel_enable(tunnel, enable);
2076 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2077 const char* cname=env->GetStringUTFChars(name, NULL);
2078 const char* cversion=env->GetStringUTFChars(version, NULL);
2079 linphone_core_set_user_agent(cname,cversion);
2080 env->ReleaseStringUTFChars(name, cname);
2081 env->ReleaseStringUTFChars(version, cversion);
2084 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2085 return linphone_core_tunnel_available();
2088 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2089 LinphoneVideoPolicy vpol;
2090 vpol.automatically_initiate = autoInitiate;
2091 vpol.automatically_accept = autoAccept;
2092 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2095 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2096 ms_set_cpu_count(count);
2099 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2100 jstring jvalue =env->NewStringUTF(linphone_core_get_version());