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){
57 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
58 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
59 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
60 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
61 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
62 default: prio = ANDROID_LOG_DEFAULT; break;
64 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
67 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
68 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
72 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
78 return JNI_VERSION_1_2;
83 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
87 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
89 linphone_core_disable_logs();
94 class LinphoneCoreData {
96 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
98 core = env->NewGlobalRef(lc);
99 listener = env->NewGlobalRef(alistener);
100 userdata = auserdata?env->NewGlobalRef(auserdata):0;
101 memset(&vTable,0,sizeof(vTable));
102 vTable.show = showInterfaceCb;
103 vTable.auth_info_requested = authInfoRequested;
104 vTable.display_status = displayStatusCb;
105 vTable.display_message = displayMessageCb;
106 vTable.display_warning = displayMessageCb;
107 vTable.global_state_changed = globalStateChange;
108 vTable.registration_state_changed = registrationStateChange;
109 vTable.call_state_changed = callStateChange;
110 vTable.call_encryption_changed = callEncryptionChange;
111 vTable.text_received = text_received;
112 vTable.message_received = message_received;
113 vTable.dtmf_received = dtmf_received;
114 vTable.new_subscription_request = new_subscription_request;
115 vTable.notify_presence_recv = notify_presence_recv;
116 vTable.call_stats_updated = callStatsUpdated;
118 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
120 /*displayStatus(LinphoneCore lc,String message);*/
121 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
123 /*void generalState(LinphoneCore lc,int state); */
124 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
125 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
126 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
128 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
129 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
130 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
131 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
133 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
134 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
135 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
136 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
138 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
139 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
141 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
142 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
144 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
145 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
147 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
148 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
149 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
150 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
152 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
153 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
155 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
156 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
158 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
159 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
160 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
161 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
163 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
164 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
166 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
167 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
169 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
170 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
172 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
173 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
175 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
176 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
178 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
179 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
181 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
182 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
183 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
184 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
187 ~LinphoneCoreData() {
189 jvm->AttachCurrentThread(&env,NULL);
190 env->DeleteGlobalRef(core);
191 env->DeleteGlobalRef(listener);
192 if (userdata) env->DeleteGlobalRef(userdata);
193 env->DeleteGlobalRef(listenerClass);
194 env->DeleteGlobalRef(globalStateClass);
195 env->DeleteGlobalRef(registrationStateClass);
196 env->DeleteGlobalRef(callStateClass);
197 env->DeleteGlobalRef(callStatsClass);
198 env->DeleteGlobalRef(chatMessageStateClass);
199 env->DeleteGlobalRef(proxyClass);
200 env->DeleteGlobalRef(callClass);
201 env->DeleteGlobalRef(chatMessageClass);
202 env->DeleteGlobalRef(chatRoomClass);
203 env->DeleteGlobalRef(friendClass);
210 jclass listenerClass;
211 jmethodID displayStatusId;
212 jmethodID newSubscriptionRequestId;
213 jmethodID notifyPresenceReceivedId;
214 jmethodID textReceivedId;
215 jmethodID messageReceivedId;
216 jmethodID dtmfReceivedId;
217 jmethodID callStatsUpdatedId;
219 jclass globalStateClass;
220 jmethodID globalStateId;
221 jmethodID globalStateFromIntId;
223 jclass registrationStateClass;
224 jmethodID registrationStateId;
225 jmethodID registrationStateFromIntId;
227 jclass callStateClass;
228 jmethodID callStateId;
229 jmethodID callStateFromIntId;
231 jclass callStatsClass;
232 jmethodID callStatsId;
233 jmethodID callSetAudioStatsId;
234 jmethodID callSetVideoStatsId;
236 jclass chatMessageStateClass;
237 jmethodID chatMessageStateFromIntId;
239 jmethodID callEncryptionChangedId;
241 jclass ecCalibratorStatusClass;
242 jmethodID ecCalibrationStatusId;
243 jmethodID ecCalibratorStatusFromIntId;
246 jmethodID proxyCtrId;
251 jclass chatMessageClass;
252 jmethodID chatMessageCtrId;
254 jclass chatRoomClass;
255 jmethodID chatRoomCtrId;
258 jmethodID friendCtrId;
261 jmethodID addressCtrId;
263 LinphoneCoreVTable vTable;
265 static void showInterfaceCb(LinphoneCore *lc) {
268 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
271 static void displayStatusCb(LinphoneCore *lc, const char *message) {
273 jint result = jvm->AttachCurrentThread(&env,NULL);
275 ms_error("cannot attach VM\n");
278 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
279 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
281 static void displayMessageCb(LinphoneCore *lc, const char *message) {
284 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
287 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
289 jint result = jvm->AttachCurrentThread(&env,NULL);
291 ms_error("cannot attach VM\n");
294 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
295 env->CallVoidMethod(lcData->listener
296 ,lcData->globalStateId
298 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
299 message ? env->NewStringUTF(message) : NULL);
301 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
303 jint result = jvm->AttachCurrentThread(&env,NULL);
305 ms_error("cannot attach VM\n");
308 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
309 env->CallVoidMethod(lcData->listener
310 ,lcData->registrationStateId
312 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
313 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
314 message ? env->NewStringUTF(message) : NULL);
316 jobject getCall(JNIEnv *env , LinphoneCall *call){
320 void *up=linphone_call_get_user_pointer(call);
323 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
324 jobj=env->NewGlobalRef(jobj);
325 linphone_call_set_user_pointer(call,(void*)jobj);
326 linphone_call_ref(call);
334 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
336 jint result = jvm->AttachCurrentThread(&env,NULL);
339 ms_error("cannot attach VM\n");
342 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
343 env->CallVoidMethod(lcData->listener
346 ,(jcall=lcData->getCall(env,call))
347 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
348 message ? env->NewStringUTF(message) : NULL);
349 if (state==LinphoneCallReleased){
350 linphone_call_set_user_pointer(call,NULL);
351 env->DeleteGlobalRef(jcall);
354 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
356 jint result = jvm->AttachCurrentThread(&env,NULL);
358 ms_error("cannot attach VM\n");
361 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
362 env->CallVoidMethod(lcData->listener
363 ,lcData->callEncryptionChangedId
365 ,lcData->getCall(env,call)
367 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
369 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
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->notifyPresenceReceivedId
380 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
382 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
384 jint result = jvm->AttachCurrentThread(&env,NULL);
386 ms_error("cannot attach VM\n");
389 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
390 env->CallVoidMethod(lcData->listener
391 ,lcData->newSubscriptionRequestId
393 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
394 ,url ? env->NewStringUTF(url) : NULL);
396 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
398 jint result = jvm->AttachCurrentThread(&env,NULL);
400 ms_error("cannot attach VM\n");
403 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
404 env->CallVoidMethod(lcData->listener
405 ,lcData->dtmfReceivedId
407 ,lcData->getCall(env,call)
410 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
412 jint result = jvm->AttachCurrentThread(&env,NULL);
414 ms_error("cannot attach VM\n");
417 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
418 env->CallVoidMethod(lcData->listener
419 ,lcData->textReceivedId
421 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
422 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
423 ,message ? env->NewStringUTF(message) : NULL);
425 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
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->messageReceivedId
436 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
437 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
439 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
441 jint result = jvm->AttachCurrentThread(&env,NULL);
443 ms_error("cannot attach VM\n");
446 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
447 env->CallVoidMethod(lcData->listener
448 ,lcData->ecCalibrationStatusId
450 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
452 ,data ? data : NULL);
453 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
454 //final state, releasing global ref
455 env->DeleteGlobalRef((jobject)data);
459 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
463 jint result = jvm->AttachCurrentThread(&env,NULL);
465 ms_error("cannot attach VM\n");
468 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
469 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
470 callobj = lcData->getCall(env, call);
471 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
472 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
474 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
475 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
480 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
484 ,jstring jfactoryConfig
487 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
488 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
489 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
492 libmsilbc_init(); // requires an fpu
506 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
510 //clear auth info list
511 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
512 //clear existing proxy config
513 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
515 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
516 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
519 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
522 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
523 linphone_core_destroy((LinphoneCore*)lc);
527 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
528 linphone_core_clear_proxy_config((LinphoneCore*)lc);
531 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
535 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
537 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
540 LinphoneProxyConfig *config=0;
541 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
542 return (jlong)config;
545 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
546 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
547 int proxyCount = ms_list_size(proxies);
548 jlongArray jProxies = env->NewLongArray(proxyCount);
549 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
551 for (int i = 0; i < proxyCount; i++ ) {
552 jInternalArray[i] = (unsigned long) (proxies->data);
553 proxies = proxies->next;
556 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
561 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
566 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
567 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
569 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
572 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
573 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
576 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
577 linphone_core_refresh_registers((LinphoneCore*)lc);
580 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
584 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
586 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
589 linphone_core_iterate((LinphoneCore*)lc);
591 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
595 const char* uri = env->GetStringUTFChars(juri, NULL);
596 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
597 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
598 env->ReleaseStringUTFChars(juri, uri);
599 return lcd->getCall(env,lCall);
601 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
605 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
606 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
613 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
616 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
619 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
621 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
625 return linphone_core_in_call((LinphoneCore*)lc);
627 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
631 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
633 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
638 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
641 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
646 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
654 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
657 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
661 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
664 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
668 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
670 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
673 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
675 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
678 ,jboolean isReachable) {
679 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
682 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
685 return linphone_core_is_network_reachable((LinphoneCore*)lc);
688 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
692 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
695 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
698 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
705 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
708 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
712 const char* url = env->GetStringUTFChars(jurl, NULL);
713 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
714 env->ReleaseStringUTFChars(jurl, url);
717 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
721 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
723 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
728 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
730 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
733 linphone_core_stop_dtmf((LinphoneCore*)lc);
736 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
739 linphone_core_get_missed_calls_count((LinphoneCore*)lc);
742 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
745 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
748 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
750 ,jlong lc, jlong log) {
751 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
754 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
757 linphone_core_clear_call_logs((LinphoneCore*)lc);
759 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
762 return linphone_core_is_mic_muted((LinphoneCore*)lc);
764 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
770 const char* mime = env->GetStringUTFChars(jmime, NULL);
771 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
772 env->ReleaseStringUTFChars(jmime, mime);
775 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
778 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
779 int codecsCount = ms_list_size(codecs);
780 jlongArray jCodecs = env->NewLongArray(codecsCount);
781 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
783 for (int i = 0; i < codecsCount; i++ ) {
784 jInternalArray[i] = (unsigned long) (codecs->data);
785 codecs = codecs->next;
788 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
793 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
796 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
797 int codecsCount = ms_list_size(codecs);
798 jlongArray jCodecs = env->NewLongArray(codecsCount);
799 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
801 for (int i = 0; i < codecsCount; i++ ) {
802 jInternalArray[i] = (unsigned long) (codecs->data);
803 codecs = codecs->next;
806 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
811 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
816 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
818 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
822 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
824 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
828 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
830 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
834 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
837 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
841 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
844 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
848 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
850 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
852 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
857 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
859 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
863 ,jstring jalternative_contact
865 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
866 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
867 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
870 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
875 const char* to = env->GetStringUTFChars(jto, NULL);
876 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
877 env->ReleaseStringUTFChars(jto, to);
878 return (long)lResult;
881 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
884 ,jboolean vcap_enabled
885 ,jboolean display_enabled) {
886 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
889 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
892 return linphone_core_video_enabled((LinphoneCore*)lc);
894 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
898 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
899 linphone_core_set_play_file((LinphoneCore*)lc,path);
900 if (path) env->ReleaseStringUTFChars(jpath, path);
902 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
906 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
907 linphone_core_set_ring((LinphoneCore*)lc,path);
908 if (path) env->ReleaseStringUTFChars(jpath, path);
910 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
914 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
916 return env->NewStringUTF(path);
921 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
925 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
926 linphone_core_set_root_ca((LinphoneCore*)lc,path);
927 if (path) env->ReleaseStringUTFChars(jpath, path);
929 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
933 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
936 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
939 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
942 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
946 return linphone_core_start_echo_calibration((LinphoneCore*)lc
947 , LinphoneCoreData::ecCalibrationStatus
948 , data?env->NewGlobalRef(data):NULL);
952 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
956 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
959 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
963 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
966 extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
967 return (long)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
970 extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
971 return (long)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
974 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
978 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
981 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
985 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
988 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
992 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
995 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
999 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
1002 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1007 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1012 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1013 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1014 return (jlong) proxy;
1017 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1018 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1020 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1021 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1022 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1023 env->ReleaseStringUTFChars(jidentity, identity);
1025 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1026 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1028 return env->NewStringUTF(identity);
1033 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1034 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1035 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1036 env->ReleaseStringUTFChars(jproxy, proxy);
1039 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1040 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1042 return env->NewStringUTF(proxy);
1047 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1048 const char* params = env->GetStringUTFChars(jparams, NULL);
1049 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1050 env->ReleaseStringUTFChars(jparams, params);
1052 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1053 if (jroute != NULL) {
1054 const char* route = env->GetStringUTFChars(jroute, NULL);
1055 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1056 env->ReleaseStringUTFChars(jroute, route);
1059 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1062 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1063 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1065 return env->NewStringUTF(route);
1071 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1072 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1074 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1075 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1077 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1078 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1080 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1081 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1083 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1084 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1086 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1088 ms_error("cannot normalized null number");
1090 const char* number = env->GetStringUTFChars(jnumber, NULL);
1091 int len = env->GetStringLength(jnumber);
1093 ms_warning("cannot normalize empty number");
1096 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1097 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1098 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1099 env->ReleaseStringUTFChars(jnumber, number);
1100 return normalizedNumber;
1102 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1103 const char* iso = env->GetStringUTFChars(jiso, NULL);
1104 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1105 env->ReleaseStringUTFChars(jiso, iso);
1106 return (jint) prefix;
1108 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1111 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1113 return env->NewStringUTF(domain);
1118 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1119 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1122 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1126 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1127 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1128 env->ReleaseStringUTFChars(jprefix, prefix);
1130 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1134 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1136 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1137 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1142 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1150 const char* username = env->GetStringUTFChars(jusername, NULL);
1151 const char* userid = env->GetStringUTFChars(juserid, NULL);
1152 const char* password = env->GetStringUTFChars(jpassword, NULL);
1153 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1154 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1155 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1157 env->ReleaseStringUTFChars(jusername, username);
1158 env->ReleaseStringUTFChars(juserid, userid);
1159 env->ReleaseStringUTFChars(jpassword, password);
1160 env->ReleaseStringUTFChars(jha1, ha1);
1161 env->ReleaseStringUTFChars(jrealm, realm);
1165 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1168 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1173 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1176 ,jstring jdisplayName) {
1177 const char* uri = env->GetStringUTFChars(juri, NULL);
1178 LinphoneAddress* address = linphone_address_new(uri);
1179 if (jdisplayName && address) {
1180 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1181 linphone_address_set_display_name(address,displayName);
1182 env->ReleaseStringUTFChars(jdisplayName, displayName);
1184 env->ReleaseStringUTFChars(juri, uri);
1186 return (jlong) address;
1188 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1191 linphone_address_destroy((LinphoneAddress*)ptr);
1194 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1197 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1199 return env->NewStringUTF(displayName);
1204 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1207 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1209 return env->NewStringUTF(userName);
1214 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1217 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1219 return env->NewStringUTF(domain);
1225 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1228 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1229 jstring juri =env->NewStringUTF(uri);
1233 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1236 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1237 jstring juri =env->NewStringUTF(uri);
1241 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1244 ,jstring jdisplayName) {
1245 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1246 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1247 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1252 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1255 return (jlong)((LinphoneCallLog*)ptr)->from;
1257 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1260 return (jlong)((LinphoneCallLog*)ptr)->status;
1262 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1265 return (jlong)((LinphoneCallLog*)ptr)->to;
1267 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1270 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1272 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1275 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1278 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1281 return ((LinphoneCallLog*)ptr)->duration;
1285 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1286 return (int)((LinphoneCallStats *)stats_ptr)->type;
1288 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1289 return (int)((LinphoneCallStats *)stats_ptr)->ice_state;
1291 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1292 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1294 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1295 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1297 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1298 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1299 const report_block_t *srb = NULL;
1301 if (!stats || !stats->sent_rtcp)
1303 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1304 if (stats->sent_rtcp->b_cont != NULL)
1305 msgpullup(stats->sent_rtcp, -1);
1306 if (rtcp_is_SR(stats->sent_rtcp))
1307 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1308 else if (rtcp_is_RR(stats->sent_rtcp))
1309 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1312 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1314 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1315 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1316 const report_block_t *rrb = NULL;
1318 if (!stats || !stats->received_rtcp)
1320 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1321 if (stats->received_rtcp->b_cont != NULL)
1322 msgpullup(stats->received_rtcp, -1);
1323 if (rtcp_is_RR(stats->received_rtcp))
1324 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1325 else if (rtcp_is_SR(stats->received_rtcp))
1326 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1329 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1331 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1332 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1333 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1334 const LinphoneCallParams *params;
1335 const PayloadType *pt;
1336 const report_block_t *srb = NULL;
1338 if (!stats || !call || !stats->sent_rtcp)
1340 params = linphone_call_get_current_params(call);
1343 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1344 if (stats->sent_rtcp->b_cont != NULL)
1345 msgpullup(stats->sent_rtcp, -1);
1346 if (rtcp_is_SR(stats->sent_rtcp))
1347 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1348 else if (rtcp_is_RR(stats->sent_rtcp))
1349 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1352 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1353 pt = linphone_call_params_get_used_audio_codec(params);
1355 pt = linphone_call_params_get_used_video_codec(params);
1356 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1358 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1359 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1360 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1361 const LinphoneCallParams *params;
1362 const PayloadType *pt;
1363 const report_block_t *rrb = NULL;
1365 if (!stats || !call || !stats->received_rtcp)
1367 params = linphone_call_get_current_params(call);
1370 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1371 if (stats->received_rtcp->b_cont != NULL)
1372 msgpullup(stats->received_rtcp, -1);
1373 if (rtcp_is_SR(stats->received_rtcp))
1374 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1375 else if (rtcp_is_RR(stats->received_rtcp))
1376 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1379 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1380 pt = linphone_call_params_get_used_audio_codec(params);
1382 pt = linphone_call_params_get_used_video_codec(params);
1383 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1385 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1386 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1388 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1389 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1390 LinphoneCall *call = (LinphoneCall *)call_ptr;
1391 rtp_stats_t rtp_stats;
1393 if (!stats || !call)
1395 memset(&rtp_stats, 0, sizeof(rtp_stats));
1396 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1397 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1398 #ifdef VIDEO_ENABLED
1400 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1402 return (jlong)rtp_stats.outoftime;
1404 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1405 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1409 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1410 PayloadType* pt = (PayloadType*)ptr;
1411 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1412 ,payload_type_get_mime(pt)
1413 ,payload_type_get_rate(pt)
1414 ,payload_type_get_bitrate(pt));
1415 jstring jvalue =env->NewStringUTF(value);
1419 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1420 PayloadType* pt = (PayloadType*)ptr;
1421 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1424 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1425 PayloadType* pt = (PayloadType*)ptr;
1426 return payload_type_get_rate(pt);
1430 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1433 LinphoneCall *call=(LinphoneCall*)ptr;
1434 linphone_call_unref(call);
1437 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1440 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1443 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1445 ,jlong ptr, jstring path) {
1446 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1447 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1450 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1452 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1453 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1456 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1459 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1462 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1465 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1468 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1471 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1473 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1477 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1479 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1482 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1485 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1489 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1491 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1494 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1497 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1500 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1501 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1504 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1507 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1510 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1513 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1518 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1520 ,jstring jFriendUri) {
1521 LinphoneFriend* lResult;
1524 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1525 lResult= linphone_friend_new_with_addr(friendUri);
1526 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1528 lResult = linphone_friend_new();
1530 return (long)lResult;
1532 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1535 ,jlong linphoneAddress) {
1536 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1538 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1541 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1543 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1547 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1549 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1552 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1554 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1558 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1560 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1563 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1565 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1568 return linphone_friend_get_status((LinphoneFriend*)ptr);
1570 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1573 return linphone_friend_edit((LinphoneFriend*)ptr);
1575 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1578 linphone_friend_done((LinphoneFriend*)ptr);
1581 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1584 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1586 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1589 ,jstring jmessage) {
1590 const char* message = env->GetStringUTFChars(jmessage, NULL);
1591 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1592 env->ReleaseStringUTFChars(jmessage, message);
1594 return (jlong) chatMessage;
1596 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1599 jobject ud = env->NewGlobalRef(thiz);
1600 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1602 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1605 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1608 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1611 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1614 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1618 const char* url = env->GetStringUTFChars(jurl, NULL);
1619 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1620 env->ReleaseStringUTFChars(jurl, url);
1622 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1625 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1627 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1630 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1632 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1635 ,jstring jmessage) {
1636 const char* message = env->GetStringUTFChars(jmessage, NULL);
1637 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1638 env->ReleaseStringUTFChars(jmessage, message);
1641 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1643 jint result = jvm->AttachCurrentThread(&env,NULL);
1645 ms_error("cannot attach VM\n");
1649 jobject listener = (jobject) ud;
1650 jclass clazz = (jclass) env->GetObjectClass(listener);
1651 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1653 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1654 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1655 env->CallVoidMethod(
1658 (jobject)linphone_chat_message_get_user_data(msg),
1659 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1661 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1662 env->DeleteGlobalRef(listener);
1665 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1669 ,jobject jlistener) {
1670 jobject listener = env->NewGlobalRef(jlistener);
1671 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1673 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1677 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1678 if (oldWindow != NULL) {
1679 env->DeleteGlobalRef(oldWindow);
1682 obj = env->NewGlobalRef(obj);
1684 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1687 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1691 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1692 if (oldWindow != NULL) {
1693 env->DeleteGlobalRef(oldWindow);
1696 obj = env->NewGlobalRef(obj);
1698 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1705 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1710 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1713 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1714 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1717 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1718 const char* server = NULL;
1719 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1720 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1721 if (server) env->ReleaseStringUTFChars(jserver,server);
1724 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1725 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1726 if (ret==NULL) return NULL;
1727 jstring jvalue =env->NewStringUTF(ret);
1731 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1732 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1735 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1736 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1739 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1740 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1743 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1744 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1747 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1748 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1750 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1751 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1754 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1755 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1758 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1761 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1762 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1765 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1766 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1769 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1770 linphone_call_camera_enabled((LinphoneCall *)lc);
1773 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1774 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1775 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1778 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1779 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1782 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1783 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1787 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1789 vsize.width = (int)width;
1790 vsize.height = (int)height;
1791 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1794 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1795 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1796 jintArray arr = env->NewIntArray(2);
1797 int tVsize [2]= {vsize.width,vsize.height};
1798 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1802 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1803 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1806 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1807 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1810 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1811 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1814 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1815 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1818 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1819 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1821 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1822 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1825 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1826 linphone_call_get_duration((LinphoneCall *) ptr);
1829 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1831 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1844 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1845 LinphoneCore *lc = (LinphoneCore *) ptr;
1851 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1854 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1855 ,jlong lc, jboolean enable) {
1856 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1859 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1860 ,jlong ptr, jint db) {
1861 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1864 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1865 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1867 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1868 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1870 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1871 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1873 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1874 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1876 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1877 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1879 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1880 linphone_core_leave_conference((LinphoneCore *) pCore);
1882 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1883 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1885 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1886 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1888 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1889 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1892 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1893 linphone_core_terminate_conference((LinphoneCore *) pCore);
1895 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1896 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1898 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1899 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1901 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1902 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1903 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1904 return lcd->getCall(env,lCall);
1906 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1907 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1910 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1911 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1912 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1913 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1915 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1916 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1919 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1921 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1922 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1923 env->ReleaseStringUTFChars(jFile, cFile);
1925 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1929 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1930 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1931 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1932 env->ReleaseStringUTFChars(jUri, cUri);
1933 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1934 return (jobject) lcdata->getCall(env,call);
1938 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1939 LinphoneCore* lc = (LinphoneCore *) pCore;
1940 const char** devices = linphone_core_get_video_devices(lc);
1941 if (devices == NULL) {
1942 ms_error("No existing video devices\n");
1946 for(i=0; i<=id; i++) {
1947 if (devices[i] == NULL)
1949 ms_message("Existing device %d : %s\n", i, devices[i]);
1951 return linphone_core_set_video_device(lc, devices[i]);
1957 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1958 LinphoneCore* lc = (LinphoneCore *) pCore;
1959 const char** devices = linphone_core_get_video_devices(lc);
1960 if (devices == NULL) {
1961 ms_error("No existing video devices\n");
1964 const char* cam = linphone_core_get_video_device(lc);
1966 ms_error("No current video device\n");
1969 while(devices[i] != NULL) {
1970 if (strcmp(devices[i], cam) == 0)
1975 ms_warning("Returning default (0) device\n");
1979 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1980 LinphoneCall *call = (LinphoneCall *) ptr;
1981 const char* token = linphone_call_get_authentication_token(call);
1982 if (token == NULL) return NULL;
1983 return env->NewStringUTF(token);
1985 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1986 LinphoneCall *call = (LinphoneCall *) ptr;
1987 return linphone_call_get_authentication_token_verified(call);
1989 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1990 LinphoneCall *call = (LinphoneCall *) ptr;
1991 linphone_call_set_authentication_token_verified(call, verified);
1994 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1995 LinphoneCall *call = (LinphoneCall *) ptr;
1996 return linphone_call_get_play_volume(call);
1999 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2000 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2003 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2004 // Implemented directly in msandroid.cpp (sound filters for Android).
2005 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
2007 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
2008 msandroid_hack_speaker_state(speakerOn);
2010 // End Galaxy S hack functions
2013 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2014 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2016 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2017 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2020 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2021 jstring jHost, jint port, jint mirror, jint delay) {
2022 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2023 if (!tunnel) return;
2024 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2025 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2026 env->ReleaseStringUTFChars(jHost, cHost);
2029 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2030 jstring jHost, jint port, jstring username, jstring password) {
2032 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2033 if (!tunnel) return;
2034 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2035 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2036 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2037 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2038 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2039 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2040 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2044 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2045 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2046 linphone_tunnel_auto_detect(tunnel);
2050 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2051 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2052 linphone_tunnel_clean_servers(tunnel);
2055 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2056 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2057 linphone_tunnel_enable(tunnel, enable);
2061 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2062 const char* cname=env->GetStringUTFChars(name, NULL);
2063 const char* cversion=env->GetStringUTFChars(version, NULL);
2064 linphone_core_set_user_agent(cname,cversion);
2065 env->ReleaseStringUTFChars(name, cname);
2066 env->ReleaseStringUTFChars(version, cversion);
2069 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2070 return linphone_core_tunnel_available();
2073 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2074 LinphoneVideoPolicy vpol;
2075 vpol.automatically_initiate = autoInitiate;
2076 vpol.automatically_accept = autoAccept;
2077 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2080 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2081 ms_set_cpu_count(count);
2084 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2085 jstring jvalue =env->NewStringUTF(linphone_core_get_version());