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
535 //clear auth info list
536 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
537 //clear existing proxy config
538 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
540 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
541 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
544 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
547 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
548 linphone_core_destroy((LinphoneCore*)lc);
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) {
553 const char* displayname = env->GetStringUTFChars(jdisplayname, NULL);
554 const char* username = env->GetStringUTFChars(jusername, NULL);
556 LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc);
557 if (parsed != NULL) {
558 linphone_address_set_display_name(parsed, displayname);
559 linphone_address_set_username(parsed, username);
560 char *contact = linphone_address_as_string(parsed);
561 linphone_core_set_primary_contact((LinphoneCore*)lc, contact);
564 env->ReleaseStringUTFChars(jdisplayname, displayname);
565 env->ReleaseStringUTFChars(jusername, username);
568 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
569 linphone_core_clear_proxy_config((LinphoneCore*)lc);
572 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
576 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
578 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
581 LinphoneProxyConfig *config=0;
582 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
583 return (jlong)config;
586 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
587 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
588 int proxyCount = ms_list_size(proxies);
589 jlongArray jProxies = env->NewLongArray(proxyCount);
590 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
592 for (int i = 0; i < proxyCount; i++ ) {
593 jInternalArray[i] = (unsigned long) (proxies->data);
594 proxies = proxies->next;
597 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
602 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
607 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
608 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
610 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
613 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
614 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
617 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
618 linphone_core_refresh_registers((LinphoneCore*)lc);
621 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
625 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
627 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
630 linphone_core_iterate((LinphoneCore*)lc);
632 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
636 const char* uri = env->GetStringUTFChars(juri, NULL);
637 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
638 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
639 env->ReleaseStringUTFChars(juri, uri);
640 return lcd->getCall(env,lCall);
642 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
646 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
647 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
650 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
654 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
657 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
660 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
662 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
666 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
668 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
672 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
674 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
679 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
682 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
687 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
690 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
695 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
698 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
702 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
705 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
709 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
711 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
714 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
716 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
719 ,jboolean isReachable) {
720 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
723 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
726 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
729 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMicrophoneGain(JNIEnv* env
733 linphone_core_set_mic_gain_db((LinphoneCore*)lc,gain);
736 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
740 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
743 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
746 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
749 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
753 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
756 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
760 const char* url = env->GetStringUTFChars(jurl, NULL);
761 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
762 env->ReleaseStringUTFChars(jurl, url);
765 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
769 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
771 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
776 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
778 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
781 linphone_core_stop_dtmf((LinphoneCore*)lc);
784 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
787 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
790 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
793 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
796 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
798 ,jlong lc, jlong log) {
799 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
802 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
805 linphone_core_clear_call_logs((LinphoneCore*)lc);
807 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
810 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
812 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
818 const char* mime = env->GetStringUTFChars(jmime, NULL);
819 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
820 env->ReleaseStringUTFChars(jmime, mime);
823 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
826 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
827 int codecsCount = ms_list_size(codecs);
828 jlongArray jCodecs = env->NewLongArray(codecsCount);
829 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
831 for (int i = 0; i < codecsCount; i++ ) {
832 jInternalArray[i] = (unsigned long) (codecs->data);
833 codecs = codecs->next;
836 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
841 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
844 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
845 int codecsCount = ms_list_size(codecs);
846 jlongArray jCodecs = env->NewLongArray(codecsCount);
847 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
849 for (int i = 0; i < codecsCount; i++ ) {
850 jInternalArray[i] = (unsigned long) (codecs->data);
851 codecs = codecs->next;
854 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
859 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
864 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
866 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
870 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
872 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
876 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
878 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
882 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
885 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
889 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
892 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
896 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
898 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
900 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
905 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
907 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
911 ,jstring jalternative_contact
913 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
914 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
915 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
918 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
923 const char* to = env->GetStringUTFChars(jto, NULL);
924 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
925 env->ReleaseStringUTFChars(jto, to);
926 return (jlong)lResult;
929 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
932 ,jboolean vcap_enabled
933 ,jboolean display_enabled) {
934 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
937 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
940 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
942 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
946 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
947 linphone_core_set_play_file((LinphoneCore*)lc,path);
948 if (path) env->ReleaseStringUTFChars(jpath, path);
950 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
954 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
955 linphone_core_set_ring((LinphoneCore*)lc,path);
956 if (path) env->ReleaseStringUTFChars(jpath, path);
958 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
962 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
964 return env->NewStringUTF(path);
969 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
973 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
974 linphone_core_set_root_ca((LinphoneCore*)lc,path);
975 if (path) env->ReleaseStringUTFChars(jpath, path);
977 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
981 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
984 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
987 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
990 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
994 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
995 , LinphoneCoreData::ecCalibrationStatus
996 , data?env->NewGlobalRef(data):NULL);
1000 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
1004 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
1007 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
1011 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1014 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
1016 ,jlong lc, jint menc
1018 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1021 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
1025 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
1028 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1033 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1038 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1039 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1040 return (jlong) proxy;
1043 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1044 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1046 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1047 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1048 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1049 env->ReleaseStringUTFChars(jidentity, identity);
1051 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1052 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1054 return env->NewStringUTF(identity);
1059 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1060 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1061 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1062 env->ReleaseStringUTFChars(jproxy, proxy);
1065 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1066 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1068 return env->NewStringUTF(proxy);
1073 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1074 const char* params = env->GetStringUTFChars(jparams, NULL);
1075 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1076 env->ReleaseStringUTFChars(jparams, params);
1078 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1079 if (jroute != NULL) {
1080 const char* route = env->GetStringUTFChars(jroute, NULL);
1081 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1082 env->ReleaseStringUTFChars(jroute, route);
1085 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1088 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1089 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1091 return env->NewStringUTF(route);
1097 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1098 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1100 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1101 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1103 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1104 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1106 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1107 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1109 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1110 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1112 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1114 ms_error("cannot normalized null number");
1116 const char* number = env->GetStringUTFChars(jnumber, NULL);
1117 int len = env->GetStringLength(jnumber);
1119 ms_warning("cannot normalize empty number");
1122 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1123 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1124 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1125 env->ReleaseStringUTFChars(jnumber, number);
1126 return normalizedNumber;
1128 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1129 const char* iso = env->GetStringUTFChars(jiso, NULL);
1130 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1131 env->ReleaseStringUTFChars(jiso, iso);
1132 return (jint) prefix;
1134 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromE164(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring je164) {
1135 const char* e164 = env->GetStringUTFChars(je164, NULL);
1136 int prefix = linphone_dial_plan_lookup_ccc_from_e164(e164);
1137 env->ReleaseStringUTFChars(je164, e164);
1138 return (jint) prefix;
1140 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1143 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1145 return env->NewStringUTF(domain);
1150 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1151 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1154 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1158 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1159 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1160 env->ReleaseStringUTFChars(jprefix, prefix);
1162 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1166 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1168 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1169 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1174 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1182 const char* username = env->GetStringUTFChars(jusername, NULL);
1183 const char* userid = env->GetStringUTFChars(juserid, NULL);
1184 const char* password = env->GetStringUTFChars(jpassword, NULL);
1185 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1186 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1187 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1189 env->ReleaseStringUTFChars(jusername, username);
1190 env->ReleaseStringUTFChars(juserid, userid);
1191 env->ReleaseStringUTFChars(jpassword, password);
1192 env->ReleaseStringUTFChars(jha1, ha1);
1193 env->ReleaseStringUTFChars(jrealm, realm);
1197 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1200 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1205 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1208 ,jstring jdisplayName) {
1209 const char* uri = env->GetStringUTFChars(juri, NULL);
1210 LinphoneAddress* address = linphone_address_new(uri);
1211 if (jdisplayName && address) {
1212 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1213 linphone_address_set_display_name(address,displayName);
1214 env->ReleaseStringUTFChars(jdisplayName, displayName);
1216 env->ReleaseStringUTFChars(juri, uri);
1218 return (jlong) address;
1220 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1223 linphone_address_destroy((LinphoneAddress*)ptr);
1226 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1229 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1231 return env->NewStringUTF(displayName);
1236 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1239 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1241 return env->NewStringUTF(userName);
1246 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1249 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1251 return env->NewStringUTF(domain);
1257 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1260 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1261 jstring juri =env->NewStringUTF(uri);
1265 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1268 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1269 jstring juri =env->NewStringUTF(uri);
1273 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1276 ,jstring jdisplayName) {
1277 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1278 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1279 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1284 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1287 return (jlong)((LinphoneCallLog*)ptr)->from;
1289 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1292 return (jint)((LinphoneCallLog*)ptr)->status;
1294 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1297 return (jlong)((LinphoneCallLog*)ptr)->to;
1299 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1302 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1304 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1307 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1310 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTimestamp(JNIEnv* env
1313 return static_cast<long> (((LinphoneCallLog*)ptr)->start_date_time);
1315 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1318 return (jint)((LinphoneCallLog*)ptr)->duration;
1322 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1323 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1325 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1326 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1328 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1329 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1331 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1332 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1334 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1335 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1336 const report_block_t *srb = NULL;
1338 if (!stats || !stats->sent_rtcp)
1340 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1341 if (stats->sent_rtcp->b_cont != NULL)
1342 msgpullup(stats->sent_rtcp, -1);
1343 if (rtcp_is_SR(stats->sent_rtcp))
1344 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1345 else if (rtcp_is_RR(stats->sent_rtcp))
1346 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1349 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1351 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1352 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1353 const report_block_t *rrb = NULL;
1355 if (!stats || !stats->received_rtcp)
1357 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1358 if (stats->received_rtcp->b_cont != NULL)
1359 msgpullup(stats->received_rtcp, -1);
1360 if (rtcp_is_RR(stats->received_rtcp))
1361 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1362 else if (rtcp_is_SR(stats->received_rtcp))
1363 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1366 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1368 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1369 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1370 LinphoneCall *call = (LinphoneCall *)call_ptr;
1371 const LinphoneCallParams *params;
1372 const PayloadType *pt;
1373 const report_block_t *srb = NULL;
1375 if (!stats || !call || !stats->sent_rtcp)
1377 params = linphone_call_get_current_params(call);
1380 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1381 if (stats->sent_rtcp->b_cont != NULL)
1382 msgpullup(stats->sent_rtcp, -1);
1383 if (rtcp_is_SR(stats->sent_rtcp))
1384 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1385 else if (rtcp_is_RR(stats->sent_rtcp))
1386 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1389 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1390 pt = linphone_call_params_get_used_audio_codec(params);
1392 pt = linphone_call_params_get_used_video_codec(params);
1393 if (!pt || (pt->clock_rate == 0))
1395 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1397 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1398 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1399 LinphoneCall *call = (LinphoneCall *)call_ptr;
1400 const LinphoneCallParams *params;
1401 const PayloadType *pt;
1402 const report_block_t *rrb = NULL;
1404 if (!stats || !call || !stats->received_rtcp)
1406 params = linphone_call_get_current_params(call);
1409 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1410 if (stats->received_rtcp->b_cont != NULL)
1411 msgpullup(stats->received_rtcp, -1);
1412 if (rtcp_is_SR(stats->received_rtcp))
1413 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1414 else if (rtcp_is_RR(stats->received_rtcp))
1415 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1418 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1419 pt = linphone_call_params_get_used_audio_codec(params);
1421 pt = linphone_call_params_get_used_video_codec(params);
1422 if (!pt || (pt->clock_rate == 0))
1424 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1426 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1427 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1429 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1430 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1431 LinphoneCall *call = (LinphoneCall *)call_ptr;
1432 rtp_stats_t rtp_stats;
1434 if (!stats || !call)
1436 memset(&rtp_stats, 0, sizeof(rtp_stats));
1437 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1438 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1439 #ifdef VIDEO_ENABLED
1441 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1443 return (jlong)rtp_stats.outoftime;
1445 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1446 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1450 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1451 PayloadType* pt = (PayloadType*)ptr;
1452 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1453 ,payload_type_get_mime(pt)
1454 ,payload_type_get_rate(pt)
1455 ,payload_type_get_bitrate(pt));
1456 jstring jvalue =env->NewStringUTF(value);
1460 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1461 PayloadType* pt = (PayloadType*)ptr;
1462 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1465 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1466 PayloadType* pt = (PayloadType*)ptr;
1467 return (jint)payload_type_get_rate(pt);
1471 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1474 LinphoneCall *call=(LinphoneCall*)ptr;
1475 linphone_call_unref(call);
1478 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1481 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1484 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1486 ,jlong ptr, jstring path) {
1487 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1488 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1491 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1493 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1494 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1497 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1500 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1503 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1506 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1509 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) {
1510 LinphoneCall *call = (LinphoneCall *)ptr;
1511 const char *value=linphone_call_get_remote_user_agent(call);
1512 jstring jvalue=NULL;
1513 if (value) jvalue=env->NewStringUTF(value);
1517 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteContact(JNIEnv *env, jobject thiz, jlong ptr) {
1518 LinphoneCall *call = (LinphoneCall *)ptr;
1519 const char *value=linphone_call_get_remote_contact(call);
1520 jstring jvalue = NULL;
1521 if (value) jvalue=env->NewStringUTF(value);
1525 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1528 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1530 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1534 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1536 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1539 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1542 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1546 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1548 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1551 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1554 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1557 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1558 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1561 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1564 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1567 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1570 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1575 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1577 ,jstring jFriendUri) {
1578 LinphoneFriend* lResult;
1581 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1582 lResult= linphone_friend_new_with_addr(friendUri);
1583 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1585 lResult = linphone_friend_new();
1587 return (jlong)lResult;
1589 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1592 ,jlong linphoneAddress) {
1593 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1595 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1598 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1600 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1604 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1606 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1609 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1611 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1615 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1617 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1620 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1622 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1625 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1627 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1630 return linphone_friend_edit((LinphoneFriend*)ptr);
1632 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1635 linphone_friend_done((LinphoneFriend*)ptr);
1637 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1641 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1643 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1646 ,jstring jaddress) {
1647 const char* address = env->GetStringUTFChars(jaddress, NULL);
1648 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1649 env->ReleaseStringUTFChars(jaddress, address);
1653 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1656 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1658 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1661 ,jstring jmessage) {
1662 const char* message = env->GetStringUTFChars(jmessage, NULL);
1663 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1664 env->ReleaseStringUTFChars(jmessage, message);
1666 return (jlong) chatMessage;
1668 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1671 jobject ud = env->NewGlobalRef(thiz);
1672 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1674 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getText(JNIEnv* env
1677 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_text((LinphoneChatMessage*)ptr));
1681 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env
1683 ,jlong ptr, jstring jheader_name) {
1684 const char *name=env->GetStringUTFChars(jheader_name,NULL);
1685 const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name);
1686 env->ReleaseStringUTFChars(jheader_name, name);
1687 return value ? env->NewStringUTF(value) : NULL;
1690 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader(JNIEnv* env
1692 ,jlong ptr, jstring jheader_name, jstring jheader_value) {
1693 const char *name=env->GetStringUTFChars(jheader_name,NULL);
1694 const char *value=env->GetStringUTFChars(jheader_value,NULL);
1695 linphone_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value);
1696 env->ReleaseStringUTFChars(jheader_name, name);
1697 env->ReleaseStringUTFChars(jheader_value, value);
1700 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1703 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1706 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1710 const char* url = env->GetStringUTFChars(jurl, NULL);
1711 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1712 env->ReleaseStringUTFChars(jurl, url);
1714 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1717 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1720 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1723 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1726 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1729 ,jstring jmessage) {
1730 const char* message = env->GetStringUTFChars(jmessage, NULL);
1731 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1732 env->ReleaseStringUTFChars(jmessage, message);
1735 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1737 jint result = jvm->AttachCurrentThread(&env,NULL);
1739 ms_error("cannot attach VM\n");
1743 jobject listener = (jobject) ud;
1744 jclass clazz = (jclass) env->GetObjectClass(listener);
1745 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1747 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1748 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1749 env->CallVoidMethod(
1752 (jobject)linphone_chat_message_get_user_data(msg),
1753 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1755 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1756 env->DeleteGlobalRef(listener);
1759 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1763 ,jobject jlistener) {
1764 jobject listener = env->NewGlobalRef(jlistener);
1765 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1767 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1771 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1772 if (oldWindow != NULL) {
1773 env->DeleteGlobalRef(oldWindow);
1776 obj = env->NewGlobalRef(obj);
1778 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1781 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1785 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1786 if (oldWindow != NULL) {
1787 env->DeleteGlobalRef(oldWindow);
1790 obj = env->NewGlobalRef(obj);
1792 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1795 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1799 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1803 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1804 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1807 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1808 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1811 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1812 const char* server = NULL;
1813 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1814 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1815 if (server) env->ReleaseStringUTFChars(jserver,server);
1818 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1819 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1820 if (ret==NULL) return NULL;
1821 jstring jvalue =env->NewStringUTF(ret);
1826 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_isLowBandwidthEnabled(JNIEnv *env, jobject thiz, jlong cp) {
1827 return (jboolean) linphone_call_params_low_bandwidth_enabled((LinphoneCallParams *)cp);
1830 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableLowBandwidth(JNIEnv *env, jobject thiz, jlong cp, jboolean enable) {
1831 linphone_call_params_enable_low_bandwidth((LinphoneCallParams *)cp, enable);
1834 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1835 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1838 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1839 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1842 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
1846 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
1849 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1853 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1856 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1857 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1860 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1861 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1864 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1865 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1868 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1869 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1872 extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){
1873 const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
1874 const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name);
1875 env->ReleaseStringUTFChars(jheader_name, header_name);
1876 return header_value ? env->NewStringUTF(header_value) : NULL;
1879 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){
1880 const char* header_name=env->GetStringUTFChars(jheader_name, NULL);
1881 const char* header_value=env->GetStringUTFChars(jheader_value, NULL);
1882 linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value);
1883 env->ReleaseStringUTFChars(jheader_name, header_name);
1884 env->ReleaseStringUTFChars(jheader_value, header_value);
1887 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){
1889 const char* record_file=env->GetStringUTFChars(jrecord_file, NULL);
1890 linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file);
1891 env->ReleaseStringUTFChars(jrecord_file, record_file);
1892 }else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL);
1895 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1896 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1898 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1899 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1902 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1903 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1906 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1909 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1910 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1913 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1914 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1917 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1918 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
1921 extern "C" void Java_org_linphone_core_LinphoneCallImpl_startRecording(JNIEnv *env, jobject thiz, jlong lc){
1922 linphone_call_start_recording((LinphoneCall *)lc);
1925 extern "C" void Java_org_linphone_core_LinphoneCallImpl_stopRecording(JNIEnv *env, jobject thiz, jlong lc){
1926 linphone_call_stop_recording((LinphoneCall *)lc);
1929 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1930 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1931 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1934 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1935 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1938 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1939 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1942 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1944 vsize.width = (int)width;
1945 vsize.height = (int)height;
1946 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1949 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1950 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1951 jintArray arr = env->NewIntArray(2);
1952 int tVsize [2]= {vsize.width,vsize.height};
1953 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1957 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1958 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1961 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1962 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1965 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseSipInfoForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
1966 linphone_core_set_use_info_for_dtmf((LinphoneCore *)lc, (bool) use);
1969 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseRfc2833ForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
1970 linphone_core_set_use_rfc2833_for_dtmf((LinphoneCore *)lc, (bool) use);
1973 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1974 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1977 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1978 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1981 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1982 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1984 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1985 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1988 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1989 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
1992 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1994 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
2007 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
2008 LinphoneCore *lc = (LinphoneCore *) ptr;
2014 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
2017 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
2018 ,jlong lc, jboolean enable) {
2019 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
2022 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
2023 ,jlong ptr, jint db) {
2024 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
2027 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2028 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2030 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2031 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
2033 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2034 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2036 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
2037 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
2039 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
2040 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
2042 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
2043 linphone_core_leave_conference((LinphoneCore *) pCore);
2045 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
2046 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
2048 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2049 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2051 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
2052 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
2055 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
2056 linphone_core_terminate_conference((LinphoneCore *) pCore);
2058 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
2059 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
2061 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2062 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
2064 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
2065 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
2066 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
2067 return lcd->getCall(env,lCall);
2069 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
2070 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
2073 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
2074 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
2075 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
2076 env->ReleaseStringUTFChars(jReferTo, cReferTo);
2079 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
2080 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
2083 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
2085 const char* cFile=env->GetStringUTFChars(jFile, NULL);
2086 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
2087 env->ReleaseStringUTFChars(jFile, cFile);
2089 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
2093 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
2094 const char* cUri=env->GetStringUTFChars(jUri, NULL);
2095 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
2096 env->ReleaseStringUTFChars(jUri, cUri);
2097 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
2098 return (jobject) lcdata->getCall(env,call);
2102 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
2103 LinphoneCore* lc = (LinphoneCore *) pCore;
2104 const char** devices = linphone_core_get_video_devices(lc);
2105 if (devices == NULL) {
2106 ms_error("No existing video devices\n");
2110 for(i=0; i<=id; i++) {
2111 if (devices[i] == NULL)
2113 ms_message("Existing device %d : %s\n", i, devices[i]);
2115 return (jint)linphone_core_set_video_device(lc, devices[i]);
2121 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
2122 LinphoneCore* lc = (LinphoneCore *) pCore;
2123 const char** devices = linphone_core_get_video_devices(lc);
2124 if (devices == NULL) {
2125 ms_error("No existing video devices\n");
2128 const char* cam = linphone_core_get_video_device(lc);
2130 ms_error("No current video device\n");
2133 while(devices[i] != NULL) {
2134 if (strcmp(devices[i], cam) == 0)
2139 ms_warning("Returning default (0) device\n");
2143 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2144 LinphoneCall *call = (LinphoneCall *) ptr;
2145 const char* token = linphone_call_get_authentication_token(call);
2146 if (token == NULL) return NULL;
2147 return env->NewStringUTF(token);
2149 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2150 LinphoneCall *call = (LinphoneCall *) ptr;
2151 return (jboolean)linphone_call_get_authentication_token_verified(call);
2153 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2154 LinphoneCall *call = (LinphoneCall *) ptr;
2155 linphone_call_set_authentication_token_verified(call, verified);
2158 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2159 LinphoneCall *call = (LinphoneCall *) ptr;
2160 return (jfloat)linphone_call_get_play_volume(call);
2163 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2164 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2167 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2168 // Implemented directly in msandroid.cpp (sound filters for Android).
2169 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_forceSpeakerState(JNIEnv *env, jobject thiz, jlong ptr, jboolean speakerOn) {
2170 LinphoneCore *lc = (LinphoneCore *)ptr;
2171 LinphoneCall *call = linphone_core_get_current_call(lc);
2172 if (call && call->audiostream && call->audiostream->soundread) {
2173 bool_t on = speakerOn;
2174 ms_filter_call_method(call->audiostream->soundread, MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE, &on);
2177 // End Galaxy S hack functions
2180 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2181 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2183 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2184 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2187 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2188 jstring jHost, jint port, jint mirror, jint delay) {
2189 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2190 if (!tunnel) return;
2192 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2193 LinphoneTunnelConfig *tunnelconfig = linphone_tunnel_config_new();
2194 linphone_tunnel_config_set_host(tunnelconfig, cHost);
2195 linphone_tunnel_config_set_port(tunnelconfig, port);
2196 linphone_tunnel_config_set_delay(tunnelconfig, delay);
2197 linphone_tunnel_config_set_remote_udp_mirror_port(tunnelconfig, mirror);
2198 linphone_tunnel_add_server(tunnel, tunnelconfig);
2199 env->ReleaseStringUTFChars(jHost, cHost);
2202 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2203 jstring jHost, jint port, jstring username, jstring password) {
2205 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2206 if (!tunnel) return;
2207 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2208 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2209 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2210 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2211 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2212 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2213 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2217 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2218 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2219 linphone_tunnel_auto_detect(tunnel);
2222 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2223 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2224 linphone_tunnel_clean_servers(tunnel);
2227 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2228 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2229 linphone_tunnel_enable(tunnel, enable);
2233 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2234 const char* cname=env->GetStringUTFChars(name, NULL);
2235 const char* cversion=env->GetStringUTFChars(version, NULL);
2236 linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion);
2237 env->ReleaseStringUTFChars(name, cname);
2238 env->ReleaseStringUTFChars(version, cversion);
2241 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2242 return (jboolean)linphone_core_tunnel_available();
2245 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2246 LinphoneVideoPolicy vpol;
2247 vpol.automatically_initiate = autoInitiate;
2248 vpol.automatically_accept = autoAccept;
2249 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2252 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) {
2253 const char *cpath = env->GetStringUTFChars(path, NULL);
2254 linphone_core_set_static_picture((LinphoneCore *)lc, cpath);
2255 env->ReleaseStringUTFChars(path, cpath);
2258 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2259 ms_set_cpu_count(count);
2262 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2263 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2266 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2267 linphone_core_set_video_port((LinphoneCore *)lc, port);
2270 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2271 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2274 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2275 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2278 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2279 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2282 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2283 linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout);
2286 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2287 jstring jvalue =env->NewStringUTF(linphone_core_get_version());
2291 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getConfig(JNIEnv *env, jobject thiz, jlong lc) {
2292 return (jlong) linphone_core_get_config((LinphoneCore *)lc);
2295 extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImpl(JNIEnv *env, jobject thiz, jstring file) {
2296 const char *cfile = env->GetStringUTFChars(file, NULL);
2297 LpConfig *lp = lp_config_new(cfile);
2298 env->ReleaseStringUTFChars(file, cfile);
2302 extern "C" void Java_org_linphone_core_LpConfigImpl_sync(JNIEnv *env, jobject thiz, jlong lpc) {
2303 LpConfig *lp = (LpConfig *)lpc;
2307 extern "C" void Java_org_linphone_core_LpConfigImpl_delete(JNIEnv *env, jobject thiz, jlong lpc) {
2308 LpConfig *lp = (LpConfig *)lpc;
2309 lp_config_destroy(lp);
2312 extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc,
2313 jstring section, jstring key, jint value) {
2314 const char *csection = env->GetStringUTFChars(section, NULL);
2315 const char *ckey = env->GetStringUTFChars(key, NULL);
2316 lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value);
2317 env->ReleaseStringUTFChars(section, csection);
2318 env->ReleaseStringUTFChars(key, ckey);