3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "linphonecore_utils.h"
21 #include <ortp/zrtp.h>
24 #include "linphone_tunnel.h"
28 #include "mediastreamer2/mediastream.h"
30 #include "mediastreamer2/msjava.h"
32 #include <cpu-features.h>
35 #include <android/log.h>
36 extern "C" void libmsilbc_init();
38 extern "C" void libmsx264_init();
41 extern "C" void libmsamr_init();
44 extern "C" void libmssilk_init();
47 extern "C" void libmsbcg729_init();
54 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
57 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
58 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
59 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
60 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
61 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
62 default: prio = ANDROID_LOG_DEFAULT; break;
64 __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
67 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
68 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
72 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
78 return JNI_VERSION_1_2;
83 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
87 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
89 linphone_core_disable_logs();
94 class LinphoneCoreData {
96 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
98 core = env->NewGlobalRef(lc);
99 listener = env->NewGlobalRef(alistener);
100 userdata = auserdata?env->NewGlobalRef(auserdata):0;
101 memset(&vTable,0,sizeof(vTable));
102 vTable.show = showInterfaceCb;
103 vTable.auth_info_requested = authInfoRequested;
104 vTable.display_status = displayStatusCb;
105 vTable.display_message = displayMessageCb;
106 vTable.display_warning = displayMessageCb;
107 vTable.global_state_changed = globalStateChange;
108 vTable.registration_state_changed = registrationStateChange;
109 vTable.call_state_changed = callStateChange;
110 vTable.call_encryption_changed = callEncryptionChange;
111 vTable.text_received = text_received;
112 vTable.message_received = message_received;
113 vTable.new_subscription_request = new_subscription_request;
114 vTable.notify_presence_recv = notify_presence_recv;
115 vTable.call_stats_updated = callStatsUpdated;
117 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
119 /*displayStatus(LinphoneCore lc,String message);*/
120 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
122 /*void generalState(LinphoneCore lc,int state); */
123 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
124 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
125 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
127 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
128 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
129 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
130 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
132 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
133 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
134 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
135 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
137 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
138 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
140 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
141 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
143 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
144 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
146 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
147 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
148 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
149 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
151 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
152 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
154 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
155 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
157 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
158 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
159 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
161 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
162 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
164 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
165 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
167 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
168 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
170 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
171 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
173 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
174 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
176 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
177 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
179 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
180 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
181 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
182 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
185 ~LinphoneCoreData() {
187 jvm->AttachCurrentThread(&env,NULL);
188 env->DeleteGlobalRef(core);
189 env->DeleteGlobalRef(listener);
190 if (userdata) env->DeleteGlobalRef(userdata);
191 env->DeleteGlobalRef(listenerClass);
192 env->DeleteGlobalRef(globalStateClass);
193 env->DeleteGlobalRef(registrationStateClass);
194 env->DeleteGlobalRef(callStateClass);
195 env->DeleteGlobalRef(callStatsClass);
196 env->DeleteGlobalRef(chatMessageStateClass);
197 env->DeleteGlobalRef(proxyClass);
198 env->DeleteGlobalRef(callClass);
199 env->DeleteGlobalRef(chatMessageClass);
200 env->DeleteGlobalRef(chatRoomClass);
201 env->DeleteGlobalRef(friendClass);
208 jclass listenerClass;
209 jmethodID displayStatusId;
210 jmethodID newSubscriptionRequestId;
211 jmethodID notifyPresenceReceivedId;
212 jmethodID textReceivedId;
213 jmethodID messageReceivedId;
214 jmethodID callStatsUpdatedId;
216 jclass globalStateClass;
217 jmethodID globalStateId;
218 jmethodID globalStateFromIntId;
220 jclass registrationStateClass;
221 jmethodID registrationStateId;
222 jmethodID registrationStateFromIntId;
224 jclass callStateClass;
225 jmethodID callStateId;
226 jmethodID callStateFromIntId;
228 jclass callStatsClass;
229 jmethodID callStatsId;
230 jmethodID callSetAudioStatsId;
231 jmethodID callSetVideoStatsId;
233 jclass chatMessageStateClass;
234 jmethodID chatMessageStateFromIntId;
236 jmethodID callEncryptionChangedId;
238 jclass ecCalibratorStatusClass;
239 jmethodID ecCalibrationStatusId;
240 jmethodID ecCalibratorStatusFromIntId;
243 jmethodID proxyCtrId;
248 jclass chatMessageClass;
249 jmethodID chatMessageCtrId;
251 jclass chatRoomClass;
252 jmethodID chatRoomCtrId;
255 jmethodID friendCtrId;
258 jmethodID addressCtrId;
260 LinphoneCoreVTable vTable;
262 static void showInterfaceCb(LinphoneCore *lc) {
265 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
268 static void displayStatusCb(LinphoneCore *lc, const char *message) {
270 jint result = jvm->AttachCurrentThread(&env,NULL);
272 ms_error("cannot attach VM\n");
275 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
276 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
278 static void displayMessageCb(LinphoneCore *lc, const char *message) {
281 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
284 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
286 jint result = jvm->AttachCurrentThread(&env,NULL);
288 ms_error("cannot attach VM\n");
291 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
292 env->CallVoidMethod(lcData->listener
293 ,lcData->globalStateId
295 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
296 message ? env->NewStringUTF(message) : NULL);
298 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
300 jint result = jvm->AttachCurrentThread(&env,NULL);
302 ms_error("cannot attach VM\n");
305 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
306 env->CallVoidMethod(lcData->listener
307 ,lcData->registrationStateId
309 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
310 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
311 message ? env->NewStringUTF(message) : NULL);
313 jobject getCall(JNIEnv *env , LinphoneCall *call){
317 void *up=linphone_call_get_user_pointer(call);
320 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
321 jobj=env->NewGlobalRef(jobj);
322 linphone_call_set_user_pointer(call,(void*)jobj);
323 linphone_call_ref(call);
331 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
333 jint result = jvm->AttachCurrentThread(&env,NULL);
336 ms_error("cannot attach VM\n");
339 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
340 env->CallVoidMethod(lcData->listener
343 ,(jcall=lcData->getCall(env,call))
344 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
345 message ? env->NewStringUTF(message) : NULL);
346 if (state==LinphoneCallReleased){
347 linphone_call_set_user_pointer(call,NULL);
348 env->DeleteGlobalRef(jcall);
351 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
353 jint result = jvm->AttachCurrentThread(&env,NULL);
355 ms_error("cannot attach VM\n");
358 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
359 env->CallVoidMethod(lcData->listener
360 ,lcData->callEncryptionChangedId
362 ,lcData->getCall(env,call)
364 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
366 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
368 jint result = jvm->AttachCurrentThread(&env,NULL);
370 ms_error("cannot attach VM\n");
373 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
374 env->CallVoidMethod(lcData->listener
375 ,lcData->notifyPresenceReceivedId
377 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
379 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
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->newSubscriptionRequestId
390 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
391 ,url ? env->NewStringUTF(url) : NULL);
393 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
395 jint result = jvm->AttachCurrentThread(&env,NULL);
397 ms_error("cannot attach VM\n");
400 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
401 env->CallVoidMethod(lcData->listener
402 ,lcData->textReceivedId
404 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
405 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
406 ,message ? env->NewStringUTF(message) : NULL);
408 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
410 jint result = jvm->AttachCurrentThread(&env,NULL);
412 ms_error("cannot attach VM\n");
415 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
416 env->CallVoidMethod(lcData->listener
417 ,lcData->messageReceivedId
419 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
420 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
422 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
424 jint result = jvm->AttachCurrentThread(&env,NULL);
426 ms_error("cannot attach VM\n");
429 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
430 env->CallVoidMethod(lcData->listener
431 ,lcData->ecCalibrationStatusId
433 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
435 ,data ? data : NULL);
436 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
437 //final state, releasing global ref
438 env->DeleteGlobalRef((jobject)data);
442 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
446 jint result = jvm->AttachCurrentThread(&env,NULL);
448 ms_error("cannot attach VM\n");
451 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
452 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
453 callobj = lcData->getCall(env, call);
454 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
455 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
457 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
458 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
463 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
467 ,jstring jfactoryConfig
470 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
471 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
472 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
475 libmsilbc_init(); // requires an fpu
489 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
493 //clear auth info list
494 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
495 //clear existing proxy config
496 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
498 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
499 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
502 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
505 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
506 linphone_core_destroy((LinphoneCore*)lc);
510 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
511 linphone_core_clear_proxy_config((LinphoneCore*)lc);
514 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
518 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
520 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
523 LinphoneProxyConfig *config=0;
524 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
525 return (jlong)config;
528 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
529 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
530 int proxyCount = ms_list_size(proxies);
531 jlongArray jProxies = env->NewLongArray(proxyCount);
532 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
534 for (int i = 0; i < proxyCount; i++ ) {
535 jInternalArray[i] = (unsigned long) (proxies->data);
536 proxies = proxies->next;
539 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
544 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
549 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
550 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
552 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
555 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
556 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
559 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
560 linphone_core_refresh_registers((LinphoneCore*)lc);
563 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
567 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
569 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
572 linphone_core_iterate((LinphoneCore*)lc);
574 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
578 const char* uri = env->GetStringUTFChars(juri, NULL);
579 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
580 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
581 env->ReleaseStringUTFChars(juri, uri);
582 return lcd->getCall(env,lCall);
584 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
588 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
589 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
592 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
596 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
599 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
602 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
604 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
608 return linphone_core_in_call((LinphoneCore*)lc);
610 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
614 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
616 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
621 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
624 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
629 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
632 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
637 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
640 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
644 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
647 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
651 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
653 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
656 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
658 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
661 ,jboolean isReachable) {
662 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
665 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
668 return linphone_core_is_network_reachable((LinphoneCore*)lc);
671 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
675 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
678 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
681 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
684 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
688 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
691 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
695 const char* url = env->GetStringUTFChars(jurl, NULL);
696 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
697 env->ReleaseStringUTFChars(jurl, url);
700 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
704 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
706 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
711 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
713 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
716 linphone_core_stop_dtmf((LinphoneCore*)lc);
719 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
722 linphone_core_get_missed_calls_count((LinphoneCore*)lc);
725 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
728 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
731 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
733 ,jlong lc, jlong log) {
734 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
737 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
740 linphone_core_clear_call_logs((LinphoneCore*)lc);
742 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
745 return linphone_core_is_mic_muted((LinphoneCore*)lc);
747 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
753 const char* mime = env->GetStringUTFChars(jmime, NULL);
754 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
755 env->ReleaseStringUTFChars(jmime, mime);
758 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
761 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
762 int codecsCount = ms_list_size(codecs);
763 jlongArray jCodecs = env->NewLongArray(codecsCount);
764 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
766 for (int i = 0; i < codecsCount; i++ ) {
767 jInternalArray[i] = (unsigned long) (codecs->data);
768 codecs = codecs->next;
771 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
776 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
779 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
780 int codecsCount = ms_list_size(codecs);
781 jlongArray jCodecs = env->NewLongArray(codecsCount);
782 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
784 for (int i = 0; i < codecsCount; i++ ) {
785 jInternalArray[i] = (unsigned long) (codecs->data);
786 codecs = codecs->next;
789 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
794 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
799 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
801 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
805 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
807 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
811 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
813 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
817 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
820 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
824 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
827 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
831 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
833 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
835 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
840 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
842 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
846 ,jstring jalternative_contact
848 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
849 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
850 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
853 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
858 const char* to = env->GetStringUTFChars(jto, NULL);
859 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
860 env->ReleaseStringUTFChars(jto, to);
861 return (long)lResult;
864 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
867 ,jboolean vcap_enabled
868 ,jboolean display_enabled) {
869 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
872 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
875 return linphone_core_video_enabled((LinphoneCore*)lc);
877 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
881 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
882 linphone_core_set_play_file((LinphoneCore*)lc,path);
883 if (path) env->ReleaseStringUTFChars(jpath, path);
885 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
889 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
890 linphone_core_set_ring((LinphoneCore*)lc,path);
891 if (path) env->ReleaseStringUTFChars(jpath, path);
893 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
897 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
899 return env->NewStringUTF(path);
904 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
908 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
909 linphone_core_set_root_ca((LinphoneCore*)lc,path);
910 if (path) env->ReleaseStringUTFChars(jpath, path);
912 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
916 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
919 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
922 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
925 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
929 return linphone_core_start_echo_calibration((LinphoneCore*)lc
930 , LinphoneCoreData::ecCalibrationStatus
931 , data?env->NewGlobalRef(data):NULL);
935 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
939 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
942 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
946 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
949 extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
950 return (long)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
953 extern "C" long Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
954 return (long)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
957 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
961 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
964 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
968 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
971 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
975 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
978 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
982 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
985 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
990 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
995 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
996 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
997 return (jlong) proxy;
1000 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1001 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1003 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1004 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1005 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1006 env->ReleaseStringUTFChars(jidentity, identity);
1008 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1009 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1011 return env->NewStringUTF(identity);
1016 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1017 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1018 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1019 env->ReleaseStringUTFChars(jproxy, proxy);
1022 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1023 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1025 return env->NewStringUTF(proxy);
1030 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1031 const char* params = env->GetStringUTFChars(jparams, NULL);
1032 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1033 env->ReleaseStringUTFChars(jparams, params);
1035 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1036 if (jroute != NULL) {
1037 const char* route = env->GetStringUTFChars(jroute, NULL);
1038 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1039 env->ReleaseStringUTFChars(jroute, route);
1042 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1045 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1046 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1048 return env->NewStringUTF(route);
1054 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1055 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1057 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1058 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1060 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1061 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1063 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1064 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1066 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1067 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1069 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1071 ms_error("cannot normalized null number");
1073 const char* number = env->GetStringUTFChars(jnumber, NULL);
1074 int len = env->GetStringLength(jnumber);
1076 ms_warning("cannot normalize empty number");
1079 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1080 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1081 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1082 env->ReleaseStringUTFChars(jnumber, number);
1083 return normalizedNumber;
1085 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1086 const char* iso = env->GetStringUTFChars(jiso, NULL);
1087 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1088 env->ReleaseStringUTFChars(jiso, iso);
1089 return (jint) prefix;
1091 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1094 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1096 return env->NewStringUTF(domain);
1101 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1102 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1105 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1109 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1110 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1111 env->ReleaseStringUTFChars(jprefix, prefix);
1113 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1117 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1119 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1120 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1125 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1133 const char* username = env->GetStringUTFChars(jusername, NULL);
1134 const char* userid = env->GetStringUTFChars(juserid, NULL);
1135 const char* password = env->GetStringUTFChars(jpassword, NULL);
1136 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1137 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1138 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1140 env->ReleaseStringUTFChars(jusername, username);
1141 env->ReleaseStringUTFChars(juserid, userid);
1142 env->ReleaseStringUTFChars(jpassword, password);
1143 env->ReleaseStringUTFChars(jha1, ha1);
1144 env->ReleaseStringUTFChars(jrealm, realm);
1148 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1151 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1156 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1159 ,jstring jdisplayName) {
1160 const char* uri = env->GetStringUTFChars(juri, NULL);
1161 LinphoneAddress* address = linphone_address_new(uri);
1162 if (jdisplayName && address) {
1163 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1164 linphone_address_set_display_name(address,displayName);
1165 env->ReleaseStringUTFChars(jdisplayName, displayName);
1167 env->ReleaseStringUTFChars(juri, uri);
1169 return (jlong) address;
1171 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1174 linphone_address_destroy((LinphoneAddress*)ptr);
1177 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1180 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1182 return env->NewStringUTF(displayName);
1187 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1190 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1192 return env->NewStringUTF(userName);
1197 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1200 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1202 return env->NewStringUTF(domain);
1208 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1211 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1212 jstring juri =env->NewStringUTF(uri);
1216 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1219 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1220 jstring juri =env->NewStringUTF(uri);
1224 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1227 ,jstring jdisplayName) {
1228 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1229 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1230 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1235 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1238 return (jlong)((LinphoneCallLog*)ptr)->from;
1240 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1243 return (jlong)((LinphoneCallLog*)ptr)->status;
1245 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1248 return (jlong)((LinphoneCallLog*)ptr)->to;
1250 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1253 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1255 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1258 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1261 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1264 return ((LinphoneCallLog*)ptr)->duration;
1268 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1269 return (int)((LinphoneCallStats *)stats_ptr)->type;
1271 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1272 return (int)((LinphoneCallStats *)stats_ptr)->ice_state;
1274 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1275 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1277 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1278 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1280 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1281 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1282 const report_block_t *srb = NULL;
1284 if (!stats || !stats->sent_rtcp)
1286 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1287 if (stats->sent_rtcp->b_cont != NULL)
1288 msgpullup(stats->sent_rtcp, -1);
1289 if (rtcp_is_SR(stats->sent_rtcp))
1290 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1291 else if (rtcp_is_RR(stats->sent_rtcp))
1292 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1295 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1297 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1298 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1299 const report_block_t *rrb = NULL;
1301 if (!stats || !stats->received_rtcp)
1303 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1304 if (stats->received_rtcp->b_cont != NULL)
1305 msgpullup(stats->received_rtcp, -1);
1306 if (rtcp_is_RR(stats->received_rtcp))
1307 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1308 else if (rtcp_is_SR(stats->received_rtcp))
1309 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1312 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1314 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1315 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1316 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1317 const LinphoneCallParams *params;
1318 const PayloadType *pt;
1319 const report_block_t *srb = NULL;
1321 if (!stats || !call || !stats->sent_rtcp)
1323 params = linphone_call_get_current_params(call);
1326 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1327 if (stats->sent_rtcp->b_cont != NULL)
1328 msgpullup(stats->sent_rtcp, -1);
1329 if (rtcp_is_SR(stats->sent_rtcp))
1330 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1331 else if (rtcp_is_RR(stats->sent_rtcp))
1332 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1335 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1336 pt = linphone_call_params_get_used_audio_codec(params);
1338 pt = linphone_call_params_get_used_video_codec(params);
1339 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1341 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1342 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1343 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1344 const LinphoneCallParams *params;
1345 const PayloadType *pt;
1346 const report_block_t *rrb = NULL;
1348 if (!stats || !call || !stats->received_rtcp)
1350 params = linphone_call_get_current_params(call);
1353 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1354 if (stats->received_rtcp->b_cont != NULL)
1355 msgpullup(stats->received_rtcp, -1);
1356 if (rtcp_is_SR(stats->received_rtcp))
1357 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1358 else if (rtcp_is_RR(stats->received_rtcp))
1359 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1362 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1363 pt = linphone_call_params_get_used_audio_codec(params);
1365 pt = linphone_call_params_get_used_video_codec(params);
1366 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1368 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1369 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1371 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1372 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1373 LinphoneCall *call = (LinphoneCall *)call_ptr;
1374 rtp_stats_t rtp_stats;
1376 if (!stats || !call)
1378 memset(&rtp_stats, 0, sizeof(rtp_stats));
1379 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1380 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1381 #ifdef VIDEO_ENABLED
1383 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1385 return (jlong)rtp_stats.outoftime;
1387 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1388 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1392 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1393 PayloadType* pt = (PayloadType*)ptr;
1394 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1395 ,payload_type_get_mime(pt)
1396 ,payload_type_get_rate(pt)
1397 ,payload_type_get_bitrate(pt));
1398 jstring jvalue =env->NewStringUTF(value);
1402 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1403 PayloadType* pt = (PayloadType*)ptr;
1404 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1407 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1408 PayloadType* pt = (PayloadType*)ptr;
1409 return payload_type_get_rate(pt);
1413 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1416 LinphoneCall *call=(LinphoneCall*)ptr;
1417 linphone_call_unref(call);
1420 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1423 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1426 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1428 ,jlong ptr, jstring path) {
1429 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1430 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1433 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1435 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1436 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1439 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1442 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1445 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1448 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1451 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1454 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1456 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1460 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1462 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1465 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1468 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1472 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1474 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1477 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1480 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1483 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1484 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1487 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1490 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1493 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1496 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1501 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1503 ,jstring jFriendUri) {
1504 LinphoneFriend* lResult;
1507 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1508 lResult= linphone_friend_new_with_addr(friendUri);
1509 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1511 lResult = linphone_friend_new();
1513 return (long)lResult;
1515 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1518 ,jlong linphoneAddress) {
1519 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1521 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1524 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1526 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1530 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1532 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1535 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1537 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1541 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1543 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1546 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1548 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1551 return linphone_friend_get_status((LinphoneFriend*)ptr);
1553 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1556 return linphone_friend_edit((LinphoneFriend*)ptr);
1558 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1561 linphone_friend_done((LinphoneFriend*)ptr);
1564 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1567 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1569 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1572 ,jstring jmessage) {
1573 const char* message = env->GetStringUTFChars(jmessage, NULL);
1574 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1575 env->ReleaseStringUTFChars(jmessage, message);
1577 return (jlong) chatMessage;
1579 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1582 jobject ud = env->NewGlobalRef(thiz);
1583 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1585 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1588 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1591 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1594 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1597 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1601 const char* url = env->GetStringUTFChars(jurl, NULL);
1602 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1603 env->ReleaseStringUTFChars(jurl, url);
1605 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1608 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1610 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1613 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1615 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1618 ,jstring jmessage) {
1619 const char* message = env->GetStringUTFChars(jmessage, NULL);
1620 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1621 env->ReleaseStringUTFChars(jmessage, message);
1624 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1626 jint result = jvm->AttachCurrentThread(&env,NULL);
1628 ms_error("cannot attach VM\n");
1632 jobject listener = (jobject) ud;
1633 jclass clazz = (jclass) env->GetObjectClass(listener);
1634 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1636 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1637 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1638 env->CallVoidMethod(
1641 (jobject)linphone_chat_message_get_user_data(msg),
1642 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1644 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1645 env->DeleteGlobalRef(listener);
1648 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1652 ,jobject jlistener) {
1653 jobject listener = env->NewGlobalRef(jlistener);
1654 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1656 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1660 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1661 if (oldWindow != NULL) {
1662 env->DeleteGlobalRef(oldWindow);
1665 obj = env->NewGlobalRef(obj);
1667 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1670 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1674 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1675 if (oldWindow != NULL) {
1676 env->DeleteGlobalRef(oldWindow);
1679 obj = env->NewGlobalRef(obj);
1681 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1684 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1688 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1692 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1693 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1696 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1697 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1700 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1701 const char* server = NULL;
1702 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1703 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1704 if (server) env->ReleaseStringUTFChars(jserver,server);
1707 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1708 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1709 if (ret==NULL) return NULL;
1710 jstring jvalue =env->NewStringUTF(ret);
1714 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1715 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1718 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1719 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1722 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1723 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1726 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1727 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1730 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1731 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1733 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1734 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1737 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1738 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1741 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1744 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1745 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1748 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1749 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1752 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1753 linphone_call_camera_enabled((LinphoneCall *)lc);
1756 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1757 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1758 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1761 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1762 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1765 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1766 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1770 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1772 vsize.width = (int)width;
1773 vsize.height = (int)height;
1774 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1777 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1778 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1779 jintArray arr = env->NewIntArray(2);
1780 int tVsize [2]= {vsize.width,vsize.height};
1781 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1785 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1786 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1789 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1790 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1793 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1794 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1797 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1798 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1801 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1802 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1804 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1805 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1808 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1809 linphone_call_get_duration((LinphoneCall *) ptr);
1812 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1814 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1827 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1828 LinphoneCore *lc = (LinphoneCore *) ptr;
1834 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1837 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1838 ,jlong lc, jboolean enable) {
1839 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1842 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1843 ,jlong ptr, jint db) {
1844 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1847 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1848 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1850 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1851 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1853 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1854 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1856 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1857 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1859 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1860 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1862 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1863 linphone_core_leave_conference((LinphoneCore *) pCore);
1865 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1866 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1868 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1869 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1871 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1872 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1875 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1876 linphone_core_terminate_conference((LinphoneCore *) pCore);
1878 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1879 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1881 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1882 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1884 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1885 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1886 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1887 return lcd->getCall(env,lCall);
1889 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1890 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1893 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1894 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1895 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1896 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1898 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1899 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1902 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1904 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1905 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1906 env->ReleaseStringUTFChars(jFile, cFile);
1908 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1912 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1913 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1914 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1915 env->ReleaseStringUTFChars(jUri, cUri);
1916 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1917 return (jobject) lcdata->getCall(env,call);
1921 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1922 LinphoneCore* lc = (LinphoneCore *) pCore;
1923 const char** devices = linphone_core_get_video_devices(lc);
1924 if (devices == NULL) {
1925 ms_error("No existing video devices\n");
1929 for(i=0; i<=id; i++) {
1930 if (devices[i] == NULL)
1932 ms_message("Existing device %d : %s\n", i, devices[i]);
1934 return linphone_core_set_video_device(lc, devices[i]);
1940 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1941 LinphoneCore* lc = (LinphoneCore *) pCore;
1942 const char** devices = linphone_core_get_video_devices(lc);
1943 if (devices == NULL) {
1944 ms_error("No existing video devices\n");
1947 const char* cam = linphone_core_get_video_device(lc);
1949 ms_error("No current video device\n");
1952 while(devices[i] != NULL) {
1953 if (strcmp(devices[i], cam) == 0)
1958 ms_warning("Returning default (0) device\n");
1962 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1963 LinphoneCall *call = (LinphoneCall *) ptr;
1964 const char* token = linphone_call_get_authentication_token(call);
1965 if (token == NULL) return NULL;
1966 return env->NewStringUTF(token);
1968 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1969 LinphoneCall *call = (LinphoneCall *) ptr;
1970 return linphone_call_get_authentication_token_verified(call);
1972 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1973 LinphoneCall *call = (LinphoneCall *) ptr;
1974 linphone_call_set_authentication_token_verified(call, verified);
1977 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1978 LinphoneCall *call = (LinphoneCall *) ptr;
1979 return linphone_call_get_play_volume(call);
1982 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1983 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1986 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1987 // Implemented directly in msandroid.cpp (sound filters for Android).
1988 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1990 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1991 msandroid_hack_speaker_state(speakerOn);
1993 // End Galaxy S hack functions
1996 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1997 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1999 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2000 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2003 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2004 jstring jHost, jint port, jint mirror, jint delay) {
2005 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2006 if (!tunnel) return;
2007 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2008 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2009 env->ReleaseStringUTFChars(jHost, cHost);
2012 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2013 jstring jHost, jint port, jstring username, jstring password) {
2015 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2016 if (!tunnel) return;
2017 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2018 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2019 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2020 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2021 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2022 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2023 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2027 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2028 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2029 linphone_tunnel_auto_detect(tunnel);
2033 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2034 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2035 linphone_tunnel_clean_servers(tunnel);
2038 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2039 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2040 linphone_tunnel_enable(tunnel, enable);
2044 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2045 const char* cname=env->GetStringUTFChars(name, NULL);
2046 const char* cversion=env->GetStringUTFChars(version, NULL);
2047 linphone_core_set_user_agent(cname,cversion);
2048 env->ReleaseStringUTFChars(name, cname);
2049 env->ReleaseStringUTFChars(version, cversion);
2052 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2053 return linphone_core_tunnel_available();
2056 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2057 LinphoneVideoPolicy vpol;
2058 vpol.automatically_initiate = autoInitiate;
2059 vpol.automatically_accept = autoAccept;
2060 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2063 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2064 ms_set_cpu_count(count);
2067 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2068 jstring jvalue =env->NewStringUTF(linphone_core_get_version());