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" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
953 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
956 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
960 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
963 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
967 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
970 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
974 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
977 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
982 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
987 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
988 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
989 return (jlong) proxy;
992 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
993 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
995 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
996 const char* identity = env->GetStringUTFChars(jidentity, NULL);
997 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
998 env->ReleaseStringUTFChars(jidentity, identity);
1000 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1001 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1003 return env->NewStringUTF(identity);
1008 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1009 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1010 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1011 env->ReleaseStringUTFChars(jproxy, proxy);
1014 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1015 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1017 return env->NewStringUTF(proxy);
1022 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1023 const char* params = env->GetStringUTFChars(jparams, NULL);
1024 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1025 env->ReleaseStringUTFChars(jparams, params);
1027 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1028 if (jroute != NULL) {
1029 const char* route = env->GetStringUTFChars(jroute, NULL);
1030 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1031 env->ReleaseStringUTFChars(jroute, route);
1034 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1037 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1038 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1040 return env->NewStringUTF(route);
1046 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1047 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1049 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1050 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1052 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1053 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1055 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1056 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1058 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1059 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1061 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1063 ms_error("cannot normalized null number");
1065 const char* number = env->GetStringUTFChars(jnumber, NULL);
1066 int len = env->GetStringLength(jnumber);
1068 ms_warning("cannot normalize empty number");
1071 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1072 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1073 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1074 env->ReleaseStringUTFChars(jnumber, number);
1075 return normalizedNumber;
1077 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1080 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1082 return env->NewStringUTF(domain);
1087 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1088 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1091 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1095 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1096 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1097 env->ReleaseStringUTFChars(jprefix, prefix);
1099 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1103 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1105 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1106 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1111 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1119 const char* username = env->GetStringUTFChars(jusername, NULL);
1120 const char* password = env->GetStringUTFChars(jpassword, NULL);
1121 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1123 env->ReleaseStringUTFChars(jusername, username);
1124 env->ReleaseStringUTFChars(jpassword, password);
1128 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1131 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1136 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1139 ,jstring jdisplayName) {
1140 const char* uri = env->GetStringUTFChars(juri, NULL);
1141 LinphoneAddress* address = linphone_address_new(uri);
1142 if (jdisplayName && address) {
1143 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1144 linphone_address_set_display_name(address,displayName);
1145 env->ReleaseStringUTFChars(jdisplayName, displayName);
1147 env->ReleaseStringUTFChars(juri, uri);
1149 return (jlong) address;
1151 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1154 linphone_address_destroy((LinphoneAddress*)ptr);
1157 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1160 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1162 return env->NewStringUTF(displayName);
1167 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1170 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1172 return env->NewStringUTF(userName);
1177 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1180 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1182 return env->NewStringUTF(domain);
1188 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1191 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1192 jstring juri =env->NewStringUTF(uri);
1196 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1199 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1200 jstring juri =env->NewStringUTF(uri);
1204 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1207 ,jstring jdisplayName) {
1208 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1209 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1210 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1215 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1218 return (jlong)((LinphoneCallLog*)ptr)->from;
1220 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1223 return (jlong)((LinphoneCallLog*)ptr)->status;
1225 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1228 return (jlong)((LinphoneCallLog*)ptr)->to;
1230 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1233 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1235 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1238 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1241 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1244 return ((LinphoneCallLog*)ptr)->duration;
1248 extern "C" int Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1249 return (int)((LinphoneCallStats *)stats_ptr)->type;
1251 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1252 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1253 const report_block_t *srb = NULL;
1255 if (!stats->sent_rtcp)
1257 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1258 if (stats->sent_rtcp->b_cont != NULL)
1259 msgpullup(stats->sent_rtcp, -1);
1260 if (rtcp_is_SR(stats->sent_rtcp))
1261 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1262 else if (rtcp_is_RR(stats->sent_rtcp))
1263 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1266 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1268 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1269 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1270 const report_block_t *rrb = NULL;
1272 if (!stats->received_rtcp)
1274 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1275 if (stats->received_rtcp->b_cont != NULL)
1276 msgpullup(stats->received_rtcp, -1);
1277 if (rtcp_is_RR(stats->received_rtcp))
1278 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1279 else if (rtcp_is_SR(stats->received_rtcp))
1280 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1283 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1285 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1286 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1287 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1288 const LinphoneCallParams *params = linphone_call_get_current_params(call);
1289 const PayloadType *pt;
1290 const report_block_t *srb = NULL;
1292 if (!stats->sent_rtcp)
1294 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1295 if (stats->sent_rtcp->b_cont != NULL)
1296 msgpullup(stats->sent_rtcp, -1);
1297 if (rtcp_is_SR(stats->sent_rtcp))
1298 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1299 else if (rtcp_is_RR(stats->sent_rtcp))
1300 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1303 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1304 pt = linphone_call_params_get_used_audio_codec(params);
1306 pt = linphone_call_params_get_used_video_codec(params);
1307 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1309 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1310 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1311 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1312 const LinphoneCallParams *params = linphone_call_get_current_params(call);
1313 const PayloadType *pt;
1314 const report_block_t *rrb = NULL;
1316 if (!stats->received_rtcp)
1318 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1319 if (stats->received_rtcp->b_cont != NULL)
1320 msgpullup(stats->received_rtcp, -1);
1321 if (rtcp_is_SR(stats->received_rtcp))
1322 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1323 else if (rtcp_is_RR(stats->received_rtcp))
1324 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1327 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1328 pt = linphone_call_params_get_used_audio_codec(params);
1330 pt = linphone_call_params_get_used_video_codec(params);
1331 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1333 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1334 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1336 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1337 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1338 LinphoneCall *call = (LinphoneCall *)call_ptr;
1339 rtp_stats_t rtp_stats;
1341 memset(&rtp_stats, 0, sizeof(rtp_stats));
1342 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1343 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1344 #ifdef VIDEO_ENABLED
1346 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1348 return (jlong)rtp_stats.outoftime;
1350 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1351 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1355 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1356 PayloadType* pt = (PayloadType*)ptr;
1357 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1358 ,payload_type_get_mime(pt)
1359 ,payload_type_get_rate(pt)
1360 ,payload_type_get_bitrate(pt));
1361 jstring jvalue =env->NewStringUTF(value);
1365 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1366 PayloadType* pt = (PayloadType*)ptr;
1367 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1370 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1371 PayloadType* pt = (PayloadType*)ptr;
1372 return payload_type_get_rate(pt);
1376 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1379 LinphoneCall *call=(LinphoneCall*)ptr;
1380 linphone_call_unref(call);
1383 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1386 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1389 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1391 ,jlong ptr, jstring path) {
1392 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1393 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1396 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1398 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1399 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1402 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1405 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1408 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1411 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1414 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1417 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1419 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1423 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1425 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1428 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1431 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1435 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1437 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1440 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1443 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1446 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1447 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1450 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1453 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1456 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1459 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1464 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1466 ,jstring jFriendUri) {
1467 LinphoneFriend* lResult;
1470 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1471 lResult= linphone_friend_new_with_addr(friendUri);
1472 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1474 lResult = linphone_friend_new();
1476 return (long)lResult;
1478 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1481 ,jlong linphoneAddress) {
1482 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1484 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1487 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1489 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1493 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1495 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1498 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1500 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1504 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1506 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1509 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1511 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1514 return linphone_friend_get_status((LinphoneFriend*)ptr);
1516 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1519 return linphone_friend_edit((LinphoneFriend*)ptr);
1521 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1524 linphone_friend_done((LinphoneFriend*)ptr);
1527 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1530 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1532 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1535 ,jstring jmessage) {
1536 const char* message = env->GetStringUTFChars(jmessage, NULL);
1537 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1538 env->ReleaseStringUTFChars(jmessage, message);
1540 return (jlong) chatMessage;
1542 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1545 jobject ud = env->NewGlobalRef(thiz);
1546 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1548 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1551 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1554 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1557 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1560 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1564 const char* url = env->GetStringUTFChars(jurl, NULL);
1565 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1566 env->ReleaseStringUTFChars(jurl, url);
1568 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1571 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1573 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1576 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1578 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1581 ,jstring jmessage) {
1582 const char* message = env->GetStringUTFChars(jmessage, NULL);
1583 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1584 env->ReleaseStringUTFChars(jmessage, message);
1587 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1589 jint result = jvm->AttachCurrentThread(&env,NULL);
1591 ms_error("cannot attach VM\n");
1595 jobject listener = (jobject) ud;
1596 jclass clazz = (jclass) env->GetObjectClass(listener);
1597 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1599 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1600 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1601 env->CallVoidMethod(
1604 (jobject)linphone_chat_message_get_user_data(msg),
1605 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1607 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1608 env->DeleteGlobalRef(listener);
1611 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1615 ,jobject jlistener) {
1616 jobject listener = env->NewGlobalRef(jlistener);
1617 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1619 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1623 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1624 if (oldWindow != NULL) {
1625 env->DeleteGlobalRef(oldWindow);
1628 obj = env->NewGlobalRef(obj);
1630 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1633 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1637 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1638 if (oldWindow != NULL) {
1639 env->DeleteGlobalRef(oldWindow);
1642 obj = env->NewGlobalRef(obj);
1644 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1647 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1651 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1655 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1656 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1659 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1660 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1663 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1664 const char* server = NULL;
1665 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1666 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1667 if (server) env->ReleaseStringUTFChars(jserver,server);
1670 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1671 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1672 if (ret==NULL) return NULL;
1673 jstring jvalue =env->NewStringUTF(ret);
1677 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1678 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1681 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1682 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1685 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1686 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1689 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1690 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1693 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1694 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1696 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1697 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1700 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1701 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1704 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1707 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1708 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1711 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1712 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1715 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1716 linphone_call_camera_enabled((LinphoneCall *)lc);
1719 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1720 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1721 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1724 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1725 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1728 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1729 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1733 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1735 vsize.width = (int)width;
1736 vsize.height = (int)height;
1737 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1740 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1741 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1742 jintArray arr = env->NewIntArray(2);
1743 int tVsize [2]= {vsize.width,vsize.height};
1744 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1748 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1749 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1752 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1753 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1756 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1757 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1760 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1761 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1764 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1765 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1767 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1768 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1771 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1772 linphone_call_get_duration((LinphoneCall *) ptr);
1775 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1777 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1790 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1791 LinphoneCore *lc = (LinphoneCore *) ptr;
1797 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1800 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1801 ,jlong lc, jboolean enable) {
1802 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1805 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1806 ,jlong ptr, jint db) {
1807 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1810 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1811 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1813 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1814 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1816 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1817 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1819 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1820 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1822 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1823 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1825 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1826 linphone_core_leave_conference((LinphoneCore *) pCore);
1828 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1829 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1831 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1832 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1834 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1835 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1838 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1839 linphone_core_terminate_conference((LinphoneCore *) pCore);
1841 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1842 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1844 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1845 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1847 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1848 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1849 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1850 return lcd->getCall(env,lCall);
1852 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1853 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1856 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1857 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1858 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1859 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1861 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1862 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1865 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1867 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1868 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1869 env->ReleaseStringUTFChars(jFile, cFile);
1871 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1875 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1876 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1877 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1878 env->ReleaseStringUTFChars(jUri, cUri);
1879 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1880 return (jobject) lcdata->getCall(env,call);
1884 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1885 LinphoneCore* lc = (LinphoneCore *) pCore;
1886 const char** devices = linphone_core_get_video_devices(lc);
1887 if (devices == NULL) {
1888 ms_error("No existing video devices\n");
1892 for(i=0; i<=id; i++) {
1893 if (devices[i] == NULL)
1895 ms_message("Existing device %d : %s\n", i, devices[i]);
1897 return linphone_core_set_video_device(lc, devices[i]);
1903 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1904 LinphoneCore* lc = (LinphoneCore *) pCore;
1905 const char** devices = linphone_core_get_video_devices(lc);
1906 if (devices == NULL) {
1907 ms_error("No existing video devices\n");
1910 const char* cam = linphone_core_get_video_device(lc);
1912 ms_error("No current video device\n");
1915 while(devices[i] != NULL) {
1916 if (strcmp(devices[i], cam) == 0)
1921 ms_warning("Returning default (0) device\n");
1925 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1926 LinphoneCall *call = (LinphoneCall *) ptr;
1927 const char* token = linphone_call_get_authentication_token(call);
1928 if (token == NULL) return NULL;
1929 return env->NewStringUTF(token);
1931 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1932 LinphoneCall *call = (LinphoneCall *) ptr;
1933 return linphone_call_get_authentication_token_verified(call);
1935 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1936 LinphoneCall *call = (LinphoneCall *) ptr;
1937 linphone_call_set_authentication_token_verified(call, verified);
1940 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1941 LinphoneCall *call = (LinphoneCall *) ptr;
1942 return linphone_call_get_play_volume(call);
1945 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1946 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1949 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1950 // Implemented directly in msandroid.cpp (sound filters for Android).
1951 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1953 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1954 msandroid_hack_speaker_state(speakerOn);
1956 // End Galaxy S hack functions
1959 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1960 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1962 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1963 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1966 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1967 jstring jHost, jint port, jint mirror, jint delay) {
1968 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1969 if (!tunnel) return;
1970 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1971 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1972 env->ReleaseStringUTFChars(jHost, cHost);
1975 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1976 jstring jHost, jint port, jstring username, jstring password) {
1978 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1979 if (!tunnel) return;
1980 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1981 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1982 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1983 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1984 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1985 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1986 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1990 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1991 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1992 linphone_tunnel_auto_detect(tunnel);
1996 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1997 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1998 linphone_tunnel_clean_servers(tunnel);
2001 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2002 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2003 linphone_tunnel_enable(tunnel, enable);
2007 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2008 const char* cname=env->GetStringUTFChars(name, NULL);
2009 const char* cversion=env->GetStringUTFChars(version, NULL);
2010 linphone_core_set_user_agent(cname,cversion);
2011 env->ReleaseStringUTFChars(name, cname);
2012 env->ReleaseStringUTFChars(version, cversion);
2015 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2016 return linphone_core_tunnel_available();
2019 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2020 LinphoneVideoPolicy vpol;
2021 vpol.automatically_initiate = autoInitiate;
2022 vpol.automatically_accept = autoAccept;
2023 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2026 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2027 ms_set_cpu_count(count);
2030 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2031 jstring jvalue =env->NewStringUTF(linphone_core_get_version());