3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "linphonecore_jni.h"
23 #include "linphonecore_utils.h"
24 #include <ortp/zrtp.h>
28 #include "mediastreamer2/mediastream.h"
30 #include "mediastreamer2/msjava.h"
32 #include <cpu-features.h>
37 #include <android/log.h>
38 extern "C" void libmsilbc_init();
40 extern "C" void libmsx264_init();
43 extern "C" void libmsamr_init();
46 extern "C" void libmssilk_init();
49 extern "C" void libmsbcg729_init();
54 static const char* LogDomain = "Linphone";
57 void linphone_android_log_handler(int prio, const char *fmt, va_list args) {
62 vsnprintf(str, sizeof(str) - 1, fmt, args);
63 str[sizeof(str) - 1] = '\0';
64 if (strlen(str) < 512) {
65 __android_log_write(prio, LogDomain, str);
68 while ((next = strchr(current, '\n')) != NULL) {
70 __android_log_write(prio, LogDomain, current);
73 __android_log_write(prio, LogDomain, current);
77 static void linphone_android_ortp_log_handler(OrtpLogLevel lev, const char *fmt, va_list args) {
80 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
81 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
82 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
83 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
84 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
85 default: prio = ANDROID_LOG_DEFAULT; break;
87 linphone_android_log_handler(prio, fmt, args);
90 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
91 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
95 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
101 return JNI_VERSION_1_2;
106 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
109 ,jstring jdebugTag) {
111 LogDomain = env->GetStringUTFChars(jdebugTag, NULL);
112 linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler);
114 linphone_core_disable_logs();
119 class LinphoneCoreData {
121 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
123 core = env->NewGlobalRef(lc);
124 listener = env->NewGlobalRef(alistener);
125 userdata = auserdata?env->NewGlobalRef(auserdata):0;
126 memset(&vTable,0,sizeof(vTable));
127 vTable.show = showInterfaceCb;
128 vTable.auth_info_requested = authInfoRequested;
129 vTable.display_status = displayStatusCb;
130 vTable.display_message = displayMessageCb;
131 vTable.display_warning = displayMessageCb;
132 vTable.global_state_changed = globalStateChange;
133 vTable.registration_state_changed = registrationStateChange;
134 vTable.call_state_changed = callStateChange;
135 vTable.call_encryption_changed = callEncryptionChange;
136 vTable.text_received = text_received;
137 vTable.message_received = message_received;
138 vTable.dtmf_received = dtmf_received;
139 vTable.new_subscription_request = new_subscription_request;
140 vTable.notify_presence_recv = notify_presence_recv;
141 vTable.call_stats_updated = callStatsUpdated;
143 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
145 /*displayStatus(LinphoneCore lc,String message);*/
146 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
148 /*void generalState(LinphoneCore lc,int state); */
149 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
150 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
151 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
153 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
154 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
155 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
156 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
158 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
159 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
160 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
161 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
163 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
164 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
166 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
167 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
169 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
170 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
172 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
173 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
174 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
175 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
177 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
178 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
180 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
181 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
183 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
184 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
185 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
186 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
188 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
189 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
191 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
192 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
194 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
195 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
197 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
198 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
200 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
201 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
203 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
204 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
206 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
207 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
208 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
209 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
212 ~LinphoneCoreData() {
214 jvm->AttachCurrentThread(&env,NULL);
215 env->DeleteGlobalRef(core);
216 env->DeleteGlobalRef(listener);
217 if (userdata) env->DeleteGlobalRef(userdata);
218 env->DeleteGlobalRef(listenerClass);
219 env->DeleteGlobalRef(globalStateClass);
220 env->DeleteGlobalRef(registrationStateClass);
221 env->DeleteGlobalRef(callStateClass);
222 env->DeleteGlobalRef(callStatsClass);
223 env->DeleteGlobalRef(chatMessageStateClass);
224 env->DeleteGlobalRef(proxyClass);
225 env->DeleteGlobalRef(callClass);
226 env->DeleteGlobalRef(chatMessageClass);
227 env->DeleteGlobalRef(chatRoomClass);
228 env->DeleteGlobalRef(friendClass);
235 jclass listenerClass;
236 jmethodID displayStatusId;
237 jmethodID newSubscriptionRequestId;
238 jmethodID notifyPresenceReceivedId;
239 jmethodID textReceivedId;
240 jmethodID messageReceivedId;
241 jmethodID dtmfReceivedId;
242 jmethodID callStatsUpdatedId;
244 jclass globalStateClass;
245 jmethodID globalStateId;
246 jmethodID globalStateFromIntId;
248 jclass registrationStateClass;
249 jmethodID registrationStateId;
250 jmethodID registrationStateFromIntId;
252 jclass callStateClass;
253 jmethodID callStateId;
254 jmethodID callStateFromIntId;
256 jclass callStatsClass;
257 jmethodID callStatsId;
258 jmethodID callSetAudioStatsId;
259 jmethodID callSetVideoStatsId;
261 jclass chatMessageStateClass;
262 jmethodID chatMessageStateFromIntId;
264 jmethodID callEncryptionChangedId;
266 jclass ecCalibratorStatusClass;
267 jmethodID ecCalibrationStatusId;
268 jmethodID ecCalibratorStatusFromIntId;
271 jmethodID proxyCtrId;
276 jclass chatMessageClass;
277 jmethodID chatMessageCtrId;
279 jclass chatRoomClass;
280 jmethodID chatRoomCtrId;
283 jmethodID friendCtrId;
286 jmethodID addressCtrId;
288 LinphoneCoreVTable vTable;
290 static void showInterfaceCb(LinphoneCore *lc) {
293 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
296 static void displayStatusCb(LinphoneCore *lc, const char *message) {
298 jint result = jvm->AttachCurrentThread(&env,NULL);
300 ms_error("cannot attach VM\n");
303 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
304 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
306 static void displayMessageCb(LinphoneCore *lc, const char *message) {
309 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
312 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
314 jint result = jvm->AttachCurrentThread(&env,NULL);
316 ms_error("cannot attach VM\n");
319 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
320 env->CallVoidMethod(lcData->listener
321 ,lcData->globalStateId
323 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
324 message ? env->NewStringUTF(message) : NULL);
326 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
328 jint result = jvm->AttachCurrentThread(&env,NULL);
330 ms_error("cannot attach VM\n");
333 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
334 env->CallVoidMethod(lcData->listener
335 ,lcData->registrationStateId
337 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
338 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
339 message ? env->NewStringUTF(message) : NULL);
341 jobject getCall(JNIEnv *env , LinphoneCall *call){
345 void *up=linphone_call_get_user_pointer(call);
348 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
349 jobj=env->NewGlobalRef(jobj);
350 linphone_call_set_user_pointer(call,(void*)jobj);
351 linphone_call_ref(call);
359 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
361 jint result = jvm->AttachCurrentThread(&env,NULL);
364 ms_error("cannot attach VM\n");
367 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
368 env->CallVoidMethod(lcData->listener
371 ,(jcall=lcData->getCall(env,call))
372 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
373 message ? env->NewStringUTF(message) : NULL);
374 if (state==LinphoneCallReleased){
375 linphone_call_set_user_pointer(call,NULL);
376 env->DeleteGlobalRef(jcall);
379 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
381 jint result = jvm->AttachCurrentThread(&env,NULL);
383 ms_error("cannot attach VM\n");
386 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
387 env->CallVoidMethod(lcData->listener
388 ,lcData->callEncryptionChangedId
390 ,lcData->getCall(env,call)
392 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
394 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
396 jint result = jvm->AttachCurrentThread(&env,NULL);
398 ms_error("cannot attach VM\n");
401 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
402 env->CallVoidMethod(lcData->listener
403 ,lcData->notifyPresenceReceivedId
405 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
407 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
409 jint result = jvm->AttachCurrentThread(&env,NULL);
411 ms_error("cannot attach VM\n");
414 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
415 env->CallVoidMethod(lcData->listener
416 ,lcData->newSubscriptionRequestId
418 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
419 ,url ? env->NewStringUTF(url) : NULL);
421 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
423 jint result = jvm->AttachCurrentThread(&env,NULL);
425 ms_error("cannot attach VM\n");
428 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
429 env->CallVoidMethod(lcData->listener
430 ,lcData->dtmfReceivedId
432 ,lcData->getCall(env,call)
435 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
437 jint result = jvm->AttachCurrentThread(&env,NULL);
439 ms_error("cannot attach VM\n");
442 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
443 env->CallVoidMethod(lcData->listener
444 ,lcData->textReceivedId
446 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
447 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
448 ,message ? env->NewStringUTF(message) : NULL);
450 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
452 jint result = jvm->AttachCurrentThread(&env,NULL);
454 ms_error("cannot attach VM\n");
457 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
458 env->CallVoidMethod(lcData->listener
459 ,lcData->messageReceivedId
461 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
462 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
464 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
466 jint result = jvm->AttachCurrentThread(&env,NULL);
468 ms_error("cannot attach VM\n");
471 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
472 env->CallVoidMethod(lcData->listener
473 ,lcData->ecCalibrationStatusId
475 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
477 ,data ? data : NULL);
478 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
479 //final state, releasing global ref
480 env->DeleteGlobalRef((jobject)data);
484 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
488 jint result = jvm->AttachCurrentThread(&env,NULL);
490 ms_error("cannot attach VM\n");
493 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
494 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
495 callobj = lcData->getCall(env, call);
496 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
497 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
499 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
500 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
505 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
509 ,jstring jfactoryConfig
512 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
513 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
514 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
517 libmsilbc_init(); // requires an fpu
531 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
536 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
537 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
540 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
543 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
544 linphone_core_destroy((LinphoneCore*)lc);
548 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) {
549 const char* displayname = env->GetStringUTFChars(jdisplayname, NULL);
550 const char* username = env->GetStringUTFChars(jusername, NULL);
552 LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc);
553 if (parsed != NULL) {
554 linphone_address_set_display_name(parsed, displayname);
555 linphone_address_set_username(parsed, username);
556 char *contact = linphone_address_as_string(parsed);
557 linphone_core_set_primary_contact((LinphoneCore*)lc, contact);
560 env->ReleaseStringUTFChars(jdisplayname, displayname);
561 env->ReleaseStringUTFChars(jusername, username);
564 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
565 linphone_core_clear_proxy_config((LinphoneCore*)lc);
568 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
572 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
574 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
577 LinphoneProxyConfig *config=0;
578 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
579 return (jlong)config;
582 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
583 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
584 int proxyCount = ms_list_size(proxies);
585 jlongArray jProxies = env->NewLongArray(proxyCount);
586 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
588 for (int i = 0; i < proxyCount; i++ ) {
589 jInternalArray[i] = (unsigned long) (proxies->data);
590 proxies = proxies->next;
593 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
598 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
603 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
604 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
606 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
610 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
613 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
614 linphone_core_refresh_registers((LinphoneCore*)lc);
617 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
621 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
623 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
626 linphone_core_iterate((LinphoneCore*)lc);
628 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
632 const char* uri = env->GetStringUTFChars(juri, NULL);
633 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
634 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
635 env->ReleaseStringUTFChars(juri, uri);
636 return lcd->getCall(env,lCall);
638 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
642 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
643 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
646 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
650 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
653 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_declineCall( JNIEnv* env
656 ,jlong call, jint reason) {
657 linphone_core_decline_call((LinphoneCore*)lc,(LinphoneCall*)call,(LinphoneReason)reason);
660 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
663 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
665 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
669 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
671 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
675 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
677 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
682 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
685 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
690 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
693 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
698 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
705 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
708 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
712 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
714 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
717 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
719 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
722 ,jboolean isReachable) {
723 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
726 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
729 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
732 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMicrophoneGain(JNIEnv* env
736 linphone_core_set_mic_gain_db((LinphoneCore*)lc,gain);
739 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
743 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
746 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
749 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
752 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
756 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
759 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
763 const char* url = env->GetStringUTFChars(jurl, NULL);
764 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
765 env->ReleaseStringUTFChars(jurl, url);
768 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
772 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
774 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
779 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
781 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
784 linphone_core_stop_dtmf((LinphoneCore*)lc);
787 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
790 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
793 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
796 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
799 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
801 ,jlong lc, jlong log) {
802 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
805 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
808 linphone_core_clear_call_logs((LinphoneCore*)lc);
810 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
813 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
815 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
821 const char* mime = env->GetStringUTFChars(jmime, NULL);
822 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
823 env->ReleaseStringUTFChars(jmime, mime);
826 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
829 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
830 int codecsCount = ms_list_size(codecs);
831 jlongArray jCodecs = env->NewLongArray(codecsCount);
832 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
834 for (int i = 0; i < codecsCount; i++ ) {
835 jInternalArray[i] = (unsigned long) (codecs->data);
836 codecs = codecs->next;
839 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
844 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
847 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
848 int codecsCount = ms_list_size(codecs);
849 jlongArray jCodecs = env->NewLongArray(codecsCount);
850 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
852 for (int i = 0; i < codecsCount; i++ ) {
853 jInternalArray[i] = (unsigned long) (codecs->data);
854 codecs = codecs->next;
857 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
862 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
867 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
869 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
873 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
875 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
879 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
881 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
885 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
888 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
892 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
895 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
899 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
901 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
903 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
908 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
910 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
914 ,jstring jalternative_contact
916 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
917 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
918 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
921 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
926 const char* to = env->GetStringUTFChars(jto, NULL);
927 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
928 env->ReleaseStringUTFChars(jto, to);
929 return (jlong)lResult;
932 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
935 ,jboolean vcap_enabled
936 ,jboolean display_enabled) {
937 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
940 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
943 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
945 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
949 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
950 linphone_core_set_play_file((LinphoneCore*)lc,path);
951 if (path) env->ReleaseStringUTFChars(jpath, path);
953 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
957 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
958 linphone_core_set_ring((LinphoneCore*)lc,path);
959 if (path) env->ReleaseStringUTFChars(jpath, path);
961 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
965 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
967 return env->NewStringUTF(path);
972 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
976 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
977 linphone_core_set_root_ca((LinphoneCore*)lc,path);
978 if (path) env->ReleaseStringUTFChars(jpath, path);
980 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
984 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
987 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
990 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
993 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
997 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
998 , LinphoneCoreData::ecCalibrationStatus
999 , data?env->NewGlobalRef(data):NULL);
1003 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_needsEchoCalibration(JNIEnv *env, jobject thiz, jlong lc){
1005 MSSndCardManager *m=ms_snd_card_manager_get();
1006 const char *card=linphone_core_get_capture_device((LinphoneCore*)lc);
1007 sndcard=ms_snd_card_manager_get_card(m,card);
1008 if (sndcard == NULL){
1009 ms_error("Could not get soundcard.");
1012 return (ms_snd_card_get_capabilities(sndcard) & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER) || (ms_snd_card_get_minimal_latency(sndcard)>0);
1015 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
1019 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
1022 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
1026 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1029 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
1031 ,jlong lc, jint menc
1033 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1036 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
1040 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
1043 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1048 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1053 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1054 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1055 return (jlong) proxy;
1058 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1059 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1061 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1062 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1063 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1064 env->ReleaseStringUTFChars(jidentity, identity);
1066 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1067 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1069 return env->NewStringUTF(identity);
1074 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1075 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1076 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1077 env->ReleaseStringUTFChars(jproxy, proxy);
1080 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1081 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1083 return env->NewStringUTF(proxy);
1088 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1089 const char* params = env->GetStringUTFChars(jparams, NULL);
1090 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1091 env->ReleaseStringUTFChars(jparams, params);
1093 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1094 if (jroute != NULL) {
1095 const char* route = env->GetStringUTFChars(jroute, NULL);
1096 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1097 env->ReleaseStringUTFChars(jroute, route);
1100 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1103 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1104 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1106 return env->NewStringUTF(route);
1112 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1113 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1115 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1116 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1118 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1119 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1121 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1122 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1124 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1125 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1127 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1129 ms_error("cannot normalized null number");
1131 const char* number = env->GetStringUTFChars(jnumber, NULL);
1132 int len = env->GetStringLength(jnumber);
1134 ms_warning("cannot normalize empty number");
1137 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1138 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1139 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1140 env->ReleaseStringUTFChars(jnumber, number);
1141 return normalizedNumber;
1143 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1144 const char* iso = env->GetStringUTFChars(jiso, NULL);
1145 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1146 env->ReleaseStringUTFChars(jiso, iso);
1147 return (jint) prefix;
1149 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromE164(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring je164) {
1150 const char* e164 = env->GetStringUTFChars(je164, NULL);
1151 int prefix = linphone_dial_plan_lookup_ccc_from_e164(e164);
1152 env->ReleaseStringUTFChars(je164, e164);
1153 return (jint) prefix;
1155 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1158 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1160 return env->NewStringUTF(domain);
1165 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1166 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1169 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1173 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1174 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1175 env->ReleaseStringUTFChars(jprefix, prefix);
1177 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1181 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1183 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1184 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1189 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1191 return (jlong)linphone_auth_info_new(NULL,NULL,NULL,NULL,NULL);
1193 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1196 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1199 * Class: org_linphone_core_LinphoneAuthInfoImpl
1200 * Method: getPassword
1201 * Signature: (J)Ljava/lang/String;
1203 JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getPassword
1204 (JNIEnv *env , jobject, jlong auth_info) {
1205 const char* passwd = linphone_auth_info_get_passwd((LinphoneAuthInfo*)auth_info);
1207 return env->NewStringUTF(passwd);
1214 * Class: org_linphone_core_LinphoneAuthInfoImpl
1216 * Signature: (J)Ljava/lang/String;
1218 JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getRealm
1219 (JNIEnv *env , jobject, jlong auth_info) {
1220 const char* realm = linphone_auth_info_get_realm((LinphoneAuthInfo*)auth_info);
1222 return env->NewStringUTF(realm);
1230 * Class: org_linphone_core_LinphoneAuthInfoImpl
1231 * Method: getUsername
1232 * Signature: (J)Ljava/lang/String;
1234 JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUsername
1235 (JNIEnv *env , jobject, jlong auth_info) {
1236 const char* username = linphone_auth_info_get_username((LinphoneAuthInfo*)auth_info);
1238 return env->NewStringUTF(username);
1245 * Class: org_linphone_core_LinphoneAuthInfoImpl
1246 * Method: setPassword
1247 * Signature: (JLjava/lang/String;)V
1249 JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword
1250 (JNIEnv *env, jobject, jlong auth_info, jstring jpassword) {
1251 const char* password = jpassword?env->GetStringUTFChars(jpassword, NULL):NULL;
1252 linphone_auth_info_set_passwd((LinphoneAuthInfo*)auth_info,password);
1253 if (password) env->ReleaseStringUTFChars(jpassword, password);
1257 * Class: org_linphone_core_LinphoneAuthInfoImpl
1259 * Signature: (JLjava/lang/String;)V
1261 JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm
1262 (JNIEnv *env, jobject, jlong auth_info, jstring jrealm) {
1263 const char* realm = jrealm?env->GetStringUTFChars(jrealm, NULL):NULL;
1264 linphone_auth_info_set_realm((LinphoneAuthInfo*)auth_info,realm);
1265 if (realm) env->ReleaseStringUTFChars(jrealm, realm);
1268 * Class: org_linphone_core_LinphoneAuthInfoImpl
1269 * Method: setUsername
1270 * Signature: (JLjava/lang/String;)V
1272 JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername
1273 (JNIEnv *env, jobject, jlong auth_info, jstring jusername) {
1274 const char* username = jusername?env->GetStringUTFChars(jusername, NULL):NULL;
1275 linphone_auth_info_set_username((LinphoneAuthInfo*)auth_info,username);
1276 if (username) env->ReleaseStringUTFChars(jusername, username);
1280 * Class: org_linphone_core_LinphoneAuthInfoImpl
1281 * Method: setAuthUserId
1282 * Signature: (JLjava/lang/String;)V
1284 JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUserId
1285 (JNIEnv *env, jobject, jlong auth_info, jstring juserid) {
1286 const char* userid = juserid?env->GetStringUTFChars(juserid, NULL):NULL;
1287 linphone_auth_info_set_userid((LinphoneAuthInfo*)auth_info,userid);
1288 if (userid) env->ReleaseStringUTFChars(juserid, userid);
1292 * Class: org_linphone_core_LinphoneAuthInfoImpl
1293 * Method: getAuthUserId
1294 * Signature: (J)Ljava/lang/String;
1296 JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUserId
1297 (JNIEnv *env , jobject, jlong auth_info) {
1298 const char* userid = linphone_auth_info_get_userid((LinphoneAuthInfo*)auth_info);
1300 return env->NewStringUTF(userid);
1307 * Class: org_linphone_core_LinphoneAuthInfoImpl
1309 * Signature: (JLjava/lang/String;)V
1311 JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setHa1
1312 (JNIEnv *env, jobject, jlong auth_info, jstring jha1) {
1313 const char* ha1 = jha1?env->GetStringUTFChars(jha1, NULL):NULL;
1314 linphone_auth_info_set_ha1((LinphoneAuthInfo*)auth_info,ha1);
1315 if (ha1) env->ReleaseStringUTFChars(jha1, ha1);
1320 * Class: org_linphone_core_LinphoneAuthInfoImpl
1322 * Signature: (J)Ljava/lang/String;
1324 JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getHa1
1325 (JNIEnv *env , jobject, jlong auth_info) {
1326 const char* ha1 = linphone_auth_info_get_ha1((LinphoneAuthInfo*)auth_info);
1328 return env->NewStringUTF(ha1);
1337 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1340 ,jstring jdisplayName) {
1341 const char* uri = env->GetStringUTFChars(juri, NULL);
1342 LinphoneAddress* address = linphone_address_new(uri);
1343 if (jdisplayName && address) {
1344 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1345 linphone_address_set_display_name(address,displayName);
1346 env->ReleaseStringUTFChars(jdisplayName, displayName);
1348 env->ReleaseStringUTFChars(juri, uri);
1350 return (jlong) address;
1352 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1355 linphone_address_destroy((LinphoneAddress*)ptr);
1358 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1361 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1363 return env->NewStringUTF(displayName);
1368 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1371 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1373 return env->NewStringUTF(userName);
1378 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1381 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1383 return env->NewStringUTF(domain);
1389 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1392 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1393 jstring juri =env->NewStringUTF(uri);
1397 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1400 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1401 jstring juri =env->NewStringUTF(uri);
1405 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1408 ,jstring jdisplayName) {
1409 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1410 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1411 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1416 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1419 return (jlong)((LinphoneCallLog*)ptr)->from;
1421 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1424 return (jint)((LinphoneCallLog*)ptr)->status;
1426 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1429 return (jlong)((LinphoneCallLog*)ptr)->to;
1431 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1434 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1436 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1439 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1442 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTimestamp(JNIEnv* env
1445 return static_cast<long> (((LinphoneCallLog*)ptr)->start_date_time);
1447 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1450 return (jint)((LinphoneCallLog*)ptr)->duration;
1454 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1455 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1457 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1458 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1460 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1461 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1463 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1464 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1466 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1467 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1468 const report_block_t *srb = NULL;
1470 if (!stats || !stats->sent_rtcp)
1472 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1473 if (stats->sent_rtcp->b_cont != NULL)
1474 msgpullup(stats->sent_rtcp, -1);
1475 if (rtcp_is_SR(stats->sent_rtcp))
1476 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1477 else if (rtcp_is_RR(stats->sent_rtcp))
1478 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1481 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1483 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1484 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1485 const report_block_t *rrb = NULL;
1487 if (!stats || !stats->received_rtcp)
1489 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1490 if (stats->received_rtcp->b_cont != NULL)
1491 msgpullup(stats->received_rtcp, -1);
1492 if (rtcp_is_RR(stats->received_rtcp))
1493 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1494 else if (rtcp_is_SR(stats->received_rtcp))
1495 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1498 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1500 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1501 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1502 LinphoneCall *call = (LinphoneCall *)call_ptr;
1503 const LinphoneCallParams *params;
1504 const PayloadType *pt;
1505 const report_block_t *srb = NULL;
1507 if (!stats || !call || !stats->sent_rtcp)
1509 params = linphone_call_get_current_params(call);
1512 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1513 if (stats->sent_rtcp->b_cont != NULL)
1514 msgpullup(stats->sent_rtcp, -1);
1515 if (rtcp_is_SR(stats->sent_rtcp))
1516 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1517 else if (rtcp_is_RR(stats->sent_rtcp))
1518 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1521 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1522 pt = linphone_call_params_get_used_audio_codec(params);
1524 pt = linphone_call_params_get_used_video_codec(params);
1525 if (!pt || (pt->clock_rate == 0))
1527 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1529 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1530 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1531 LinphoneCall *call = (LinphoneCall *)call_ptr;
1532 const LinphoneCallParams *params;
1533 const PayloadType *pt;
1534 const report_block_t *rrb = NULL;
1536 if (!stats || !call || !stats->received_rtcp)
1538 params = linphone_call_get_current_params(call);
1541 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1542 if (stats->received_rtcp->b_cont != NULL)
1543 msgpullup(stats->received_rtcp, -1);
1544 if (rtcp_is_SR(stats->received_rtcp))
1545 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1546 else if (rtcp_is_RR(stats->received_rtcp))
1547 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1550 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1551 pt = linphone_call_params_get_used_audio_codec(params);
1553 pt = linphone_call_params_get_used_video_codec(params);
1554 if (!pt || (pt->clock_rate == 0))
1556 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1558 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1559 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1561 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1562 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1563 LinphoneCall *call = (LinphoneCall *)call_ptr;
1564 rtp_stats_t rtp_stats;
1566 if (!stats || !call)
1568 memset(&rtp_stats, 0, sizeof(rtp_stats));
1569 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1570 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1571 #ifdef VIDEO_ENABLED
1573 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1575 return (jlong)rtp_stats.outoftime;
1577 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1578 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1581 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLossRate(JNIEnv *env, jobject thiz,jlong stats_ptr) {
1582 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1583 return stats->local_loss_rate;
1586 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLateRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1587 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1588 return stats->local_late_rate;
1591 extern "C" void Java_org_linphone_core_LinphoneCallStatsImpl_updateStats(JNIEnv *env, jobject thiz, jlong call_ptr, jint mediatype) {
1592 if (mediatype==LINPHONE_CALL_STATS_AUDIO)
1593 linphone_call_get_audio_stats((LinphoneCall*)call_ptr);
1595 linphone_call_get_video_stats((LinphoneCall*)call_ptr);
1599 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1600 PayloadType* pt = (PayloadType*)ptr;
1601 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1602 ,payload_type_get_mime(pt)
1603 ,payload_type_get_rate(pt)
1604 ,payload_type_get_bitrate(pt));
1605 jstring jvalue =env->NewStringUTF(value);
1609 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1610 PayloadType* pt = (PayloadType*)ptr;
1611 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1614 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1615 PayloadType* pt = (PayloadType*)ptr;
1616 return (jint)payload_type_get_rate(pt);
1620 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1623 LinphoneCall *call=(LinphoneCall*)ptr;
1624 linphone_call_unref(call);
1627 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1630 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1633 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1635 ,jlong ptr, jstring path) {
1636 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1637 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1640 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1642 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1643 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1646 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1649 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1652 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1655 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1658 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) {
1659 LinphoneCall *call = (LinphoneCall *)ptr;
1660 const char *value=linphone_call_get_remote_user_agent(call);
1661 jstring jvalue=NULL;
1662 if (value) jvalue=env->NewStringUTF(value);
1666 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteContact(JNIEnv *env, jobject thiz, jlong ptr) {
1667 LinphoneCall *call = (LinphoneCall *)ptr;
1668 const char *value=linphone_call_get_remote_contact(call);
1669 jstring jvalue = NULL;
1670 if (value) jvalue=env->NewStringUTF(value);
1674 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1677 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1679 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1683 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1685 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1688 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1691 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1695 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1697 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1700 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1703 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1706 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1707 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1710 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1713 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1716 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1719 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1723 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1725 ,jstring jFriendUri) {
1726 LinphoneFriend* lResult;
1729 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1730 lResult= linphone_friend_new_with_addr(friendUri);
1731 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1733 lResult = linphone_friend_new();
1735 return (jlong)lResult;
1737 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1740 ,jlong linphoneAddress) {
1741 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1743 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1746 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1748 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1752 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1754 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1757 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1759 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1763 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1765 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1768 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1770 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1773 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1775 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1778 return linphone_friend_edit((LinphoneFriend*)ptr);
1780 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1783 linphone_friend_done((LinphoneFriend*)ptr);
1785 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1789 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1791 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1794 ,jstring jaddress) {
1795 const char* address = env->GetStringUTFChars(jaddress, NULL);
1796 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1797 env->ReleaseStringUTFChars(jaddress, address);
1801 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1804 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1806 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1809 ,jstring jmessage) {
1810 const char* message = env->GetStringUTFChars(jmessage, NULL);
1811 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1812 env->ReleaseStringUTFChars(jmessage, message);
1814 return (jlong) chatMessage;
1816 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1819 jobject ud = env->NewGlobalRef(thiz);
1820 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1822 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env
1825 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_text((LinphoneChatMessage*)ptr));
1829 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env
1831 ,jlong ptr, jstring jheader_name) {
1832 const char *name=env->GetStringUTFChars(jheader_name,NULL);
1833 const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name);
1834 env->ReleaseStringUTFChars(jheader_name, name);
1835 return value ? env->NewStringUTF(value) : NULL;
1838 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader(JNIEnv* env
1840 ,jlong ptr, jstring jheader_name, jstring jheader_value) {
1841 const char *name=env->GetStringUTFChars(jheader_name,NULL);
1842 const char *value=env->GetStringUTFChars(jheader_value,NULL);
1843 linphone_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value);
1844 env->ReleaseStringUTFChars(jheader_name, name);
1845 env->ReleaseStringUTFChars(jheader_value, value);
1848 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1851 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1854 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1858 const char* url = env->GetStringUTFChars(jurl, NULL);
1859 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1860 env->ReleaseStringUTFChars(jurl, url);
1862 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1865 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1868 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1871 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1874 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getTime(JNIEnv* env
1877 return (jlong) linphone_chat_message_get_time((LinphoneChatMessage*)ptr);
1880 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1883 ,jstring jmessage) {
1884 const char* message = env->GetStringUTFChars(jmessage, NULL);
1885 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1886 env->ReleaseStringUTFChars(jmessage, message);
1889 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1891 jint result = jvm->AttachCurrentThread(&env,NULL);
1893 ms_error("cannot attach VM\n");
1897 jobject listener = (jobject) ud;
1898 jclass clazz = (jclass) env->GetObjectClass(listener);
1899 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1901 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1902 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1903 env->CallVoidMethod(
1906 (jobject)linphone_chat_message_get_user_data(msg),
1907 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1909 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1910 env->DeleteGlobalRef(listener);
1913 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1917 ,jobject jlistener) {
1918 jobject listener = env->NewGlobalRef(jlistener);
1919 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1921 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1925 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1926 if (oldWindow != NULL) {
1927 env->DeleteGlobalRef(oldWindow);
1930 obj = env->NewGlobalRef(obj);
1932 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1935 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1939 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1940 if (oldWindow != NULL) {
1941 env->DeleteGlobalRef(oldWindow);
1944 obj = env->NewGlobalRef(obj);
1946 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1949 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1953 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1957 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1958 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1961 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1962 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1965 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1966 const char* server = NULL;
1967 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1968 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1969 if (server) env->ReleaseStringUTFChars(jserver,server);
1972 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1973 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1974 if (ret==NULL) return NULL;
1975 jstring jvalue =env->NewStringUTF(ret);
1980 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_isLowBandwidthEnabled(JNIEnv *env, jobject thiz, jlong cp) {
1981 return (jboolean) linphone_call_params_low_bandwidth_enabled((LinphoneCallParams *)cp);
1984 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableLowBandwidth(JNIEnv *env, jobject thiz, jlong cp, jboolean enable) {
1985 linphone_call_params_enable_low_bandwidth((LinphoneCallParams *)cp, enable);
1988 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1989 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1992 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1993 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1996 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
2000 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
2003 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
2007 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
2010 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
2011 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
2014 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
2015 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
2018 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
2019 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
2022 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
2023 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
2026 extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){
2027 const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
2028 const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name);
2029 env->ReleaseStringUTFChars(jheader_name, header_name);
2030 return header_value ? env->NewStringUTF(header_value) : NULL;
2033 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){
2034 const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
2035 const char* header_value=env->GetStringUTFChars(jheader_value, NULL);
2036 linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value);
2037 env->ReleaseStringUTFChars(jheader_name, header_name);
2038 env->ReleaseStringUTFChars(jheader_value, header_value);
2041 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){
2043 const char* record_file=env->GetStringUTFChars(jrecord_file, NULL);
2044 linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file);
2045 env->ReleaseStringUTFChars(jrecord_file, record_file);
2046 }else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL);
2049 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
2050 return linphone_call_params_destroy((LinphoneCallParams*)lc);
2052 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
2053 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
2056 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
2057 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
2060 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
2063 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
2064 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
2067 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
2068 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
2071 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
2072 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
2075 extern "C" void Java_org_linphone_core_LinphoneCallImpl_startRecording(JNIEnv *env, jobject thiz, jlong lc){
2076 linphone_call_start_recording((LinphoneCall *)lc);
2079 extern "C" void Java_org_linphone_core_LinphoneCallImpl_stopRecording(JNIEnv *env, jobject thiz, jlong lc){
2080 linphone_call_stop_recording((LinphoneCall *)lc);
2083 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
2084 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
2085 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
2088 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
2089 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
2092 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
2093 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
2096 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
2098 vsize.width = (int)width;
2099 vsize.height = (int)height;
2100 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
2103 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
2104 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
2105 jintArray arr = env->NewIntArray(2);
2106 int tVsize [2]= {vsize.width,vsize.height};
2107 env->SetIntArrayRegion(arr, 0, 2, tVsize);
2111 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
2112 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
2115 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
2116 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
2119 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseSipInfoForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
2120 linphone_core_set_use_info_for_dtmf((LinphoneCore *)lc, (bool) use);
2123 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseRfc2833ForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
2124 linphone_core_set_use_rfc2833_for_dtmf((LinphoneCore *)lc, (bool) use);
2127 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
2128 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
2131 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
2132 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
2135 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
2136 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
2138 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
2139 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
2142 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
2143 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
2146 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
2148 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
2161 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
2162 LinphoneCore *lc = (LinphoneCore *) ptr;
2168 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
2171 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
2172 ,jlong lc, jboolean enable) {
2173 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
2176 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
2177 ,jlong ptr, jint db) {
2178 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
2181 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2182 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2184 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2185 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
2187 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2188 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2190 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
2191 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
2193 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
2194 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
2196 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
2197 linphone_core_leave_conference((LinphoneCore *) pCore);
2199 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
2200 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
2203 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2204 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2207 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2208 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2211 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
2212 linphone_core_terminate_conference((LinphoneCore *) pCore);
2214 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
2215 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
2218 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){
2221 const char *path=env->GetStringUTFChars(jpath, NULL);
2222 err=linphone_core_start_conference_recording((LinphoneCore*)pCore,path);
2223 env->ReleaseStringUTFChars(jpath,path);
2228 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_stopConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore){
2229 int err=linphone_core_stop_conference_recording((LinphoneCore*)pCore);
2233 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2234 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
2236 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
2237 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
2238 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
2239 return lcd->getCall(env,lCall);
2241 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
2242 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
2245 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
2246 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
2247 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
2248 env->ReleaseStringUTFChars(jReferTo, cReferTo);
2251 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
2252 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
2255 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
2257 const char* cFile=env->GetStringUTFChars(jFile, NULL);
2258 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
2259 env->ReleaseStringUTFChars(jFile, cFile);
2261 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
2265 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
2266 const char* cUri=env->GetStringUTFChars(jUri, NULL);
2267 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
2268 env->ReleaseStringUTFChars(jUri, cUri);
2269 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
2270 return (jobject) lcdata->getCall(env,call);
2274 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
2275 LinphoneCore* lc = (LinphoneCore *) pCore;
2276 const char** devices = linphone_core_get_video_devices(lc);
2277 if (devices == NULL) {
2278 ms_error("No existing video devices\n");
2282 for(i=0; i<=id; i++) {
2283 if (devices[i] == NULL)
2285 ms_message("Existing device %d : %s\n", i, devices[i]);
2287 return (jint)linphone_core_set_video_device(lc, devices[i]);
2293 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
2294 LinphoneCore* lc = (LinphoneCore *) pCore;
2295 const char** devices = linphone_core_get_video_devices(lc);
2296 if (devices == NULL) {
2297 ms_error("No existing video devices\n");
2300 const char* cam = linphone_core_get_video_device(lc);
2302 ms_error("No current video device\n");
2305 while(devices[i] != NULL) {
2306 if (strcmp(devices[i], cam) == 0)
2311 ms_warning("Returning default (0) device\n");
2315 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2316 LinphoneCall *call = (LinphoneCall *) ptr;
2317 const char* token = linphone_call_get_authentication_token(call);
2318 if (token == NULL) return NULL;
2319 return env->NewStringUTF(token);
2321 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2322 LinphoneCall *call = (LinphoneCall *) ptr;
2323 return (jboolean)linphone_call_get_authentication_token_verified(call);
2325 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2326 LinphoneCall *call = (LinphoneCall *) ptr;
2327 linphone_call_set_authentication_token_verified(call, verified);
2330 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2331 LinphoneCall *call = (LinphoneCall *) ptr;
2332 return (jfloat)linphone_call_get_play_volume(call);
2335 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2336 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2339 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2340 // Implemented directly in msandroid.cpp (sound filters for Android).
2341 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_forceSpeakerState(JNIEnv *env, jobject thiz, jlong ptr, jboolean speakerOn) {
2342 LinphoneCore *lc = (LinphoneCore *)ptr;
2343 LinphoneCall *call = linphone_core_get_current_call(lc);
2344 if (call && call->audiostream && call->audiostream->soundread) {
2345 bool_t on = speakerOn;
2346 ms_filter_call_method(call->audiostream->soundread, MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE, &on);
2349 // End Galaxy S hack functions
2352 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2353 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2355 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2356 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2359 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2360 jstring jHost, jint port, jint mirror, jint delay) {
2361 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2362 if (!tunnel) return;
2364 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2365 LinphoneTunnelConfig *tunnelconfig = linphone_tunnel_config_new();
2366 linphone_tunnel_config_set_host(tunnelconfig, cHost);
2367 linphone_tunnel_config_set_port(tunnelconfig, port);
2368 linphone_tunnel_config_set_delay(tunnelconfig, delay);
2369 linphone_tunnel_config_set_remote_udp_mirror_port(tunnelconfig, mirror);
2370 linphone_tunnel_add_server(tunnel, tunnelconfig);
2371 env->ReleaseStringUTFChars(jHost, cHost);
2374 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2375 jstring jHost, jint port, jstring username, jstring password) {
2377 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2378 if (!tunnel) return;
2379 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2380 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2381 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2382 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2383 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2384 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2385 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2389 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2390 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2391 linphone_tunnel_auto_detect(tunnel);
2394 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2395 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2396 linphone_tunnel_clean_servers(tunnel);
2399 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2400 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2401 linphone_tunnel_enable(tunnel, enable);
2405 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2406 const char* cname=env->GetStringUTFChars(name, NULL);
2407 const char* cversion=env->GetStringUTFChars(version, NULL);
2408 linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion);
2409 env->ReleaseStringUTFChars(name, cname);
2410 env->ReleaseStringUTFChars(version, cversion);
2413 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2414 return (jboolean)linphone_core_tunnel_available();
2417 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2418 LinphoneVideoPolicy vpol;
2419 vpol.automatically_initiate = autoInitiate;
2420 vpol.automatically_accept = autoAccept;
2421 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2424 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) {
2425 const char *cpath = env->GetStringUTFChars(path, NULL);
2426 linphone_core_set_static_picture((LinphoneCore *)lc, cpath);
2427 env->ReleaseStringUTFChars(path, cpath);
2430 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2431 ms_set_cpu_count(count);
2434 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2435 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2438 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2439 linphone_core_set_video_port((LinphoneCore *)lc, port);
2442 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2443 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2446 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2447 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2450 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2451 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2454 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2455 linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout);
2458 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2459 jstring jvalue =env->NewStringUTF(linphone_core_get_version());
2463 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getConfig(JNIEnv *env, jobject thiz, jlong lc) {
2464 return (jlong) linphone_core_get_config((LinphoneCore *)lc);
2467 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_upnpAvailable(JNIEnv *env, jobject thiz, jlong lc) {
2468 return (jboolean) linphone_core_upnp_available((LinphoneCore *)lc);
2471 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getUpnpState(JNIEnv *env, jobject thiz, jlong lc) {
2472 return (jint) linphone_core_get_upnp_state((LinphoneCore *)lc);
2475 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getUpnpExternalIpaddress(JNIEnv *env, jobject thiz, jlong lc) {
2476 jstring jvalue = env->NewStringUTF(linphone_core_get_upnp_external_ipaddress((LinphoneCore *)lc));
2480 extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImpl(JNIEnv *env, jobject thiz, jstring file) {
2481 const char *cfile = env->GetStringUTFChars(file, NULL);
2482 LpConfig *lp = lp_config_new(cfile);
2483 env->ReleaseStringUTFChars(file, cfile);
2487 extern "C" void Java_org_linphone_core_LpConfigImpl_sync(JNIEnv *env, jobject thiz, jlong lpc) {
2488 LpConfig *lp = (LpConfig *)lpc;
2492 extern "C" void Java_org_linphone_core_LpConfigImpl_delete(JNIEnv *env, jobject thiz, jlong lpc) {
2493 LpConfig *lp = (LpConfig *)lpc;
2494 lp_config_destroy(lp);
2497 extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc,
2498 jstring section, jstring key, jint value) {
2499 const char *csection = env->GetStringUTFChars(section, NULL);
2500 const char *ckey = env->GetStringUTFChars(key, NULL);
2501 lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value);
2502 env->ReleaseStringUTFChars(section, csection);
2503 env->ReleaseStringUTFChars(key, ckey);