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_jni.h"
21 #include "linphonecore_utils.h"
22 #include <ortp/zrtp.h>
25 #include "linphone_tunnel.h"
29 #include "mediastreamer2/mediastream.h"
31 #include "mediastreamer2/msjava.h"
33 #include <cpu-features.h>
36 #include <android/log.h>
37 extern "C" void libmsilbc_init();
39 extern "C" void libmsx264_init();
42 extern "C" void libmsamr_init();
45 extern "C" void libmssilk_init();
48 extern "C" void libmsbcg729_init();
55 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
61 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
62 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
63 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
64 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
65 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
66 default: prio = ANDROID_LOG_DEFAULT; break;
68 vsnprintf(str, sizeof(str) - 1, fmt, args);
69 str[sizeof(str) - 1] = '\0';
70 if (strlen(str) < 512) {
71 __android_log_write(prio, LOG_DOMAIN, str);
74 while ((next = strchr(current, '\n')) != NULL) {
76 __android_log_write(prio, LOG_DOMAIN, current);
79 __android_log_write(prio, LOG_DOMAIN, current);
83 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
84 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
88 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
94 return JNI_VERSION_1_2;
99 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
103 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
105 linphone_core_disable_logs();
110 class LinphoneCoreData {
112 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
114 core = env->NewGlobalRef(lc);
115 listener = env->NewGlobalRef(alistener);
116 userdata = auserdata?env->NewGlobalRef(auserdata):0;
117 memset(&vTable,0,sizeof(vTable));
118 vTable.show = showInterfaceCb;
119 vTable.auth_info_requested = authInfoRequested;
120 vTable.display_status = displayStatusCb;
121 vTable.display_message = displayMessageCb;
122 vTable.display_warning = displayMessageCb;
123 vTable.global_state_changed = globalStateChange;
124 vTable.registration_state_changed = registrationStateChange;
125 vTable.call_state_changed = callStateChange;
126 vTable.call_encryption_changed = callEncryptionChange;
127 vTable.text_received = text_received;
128 vTable.message_received = message_received;
129 vTable.dtmf_received = dtmf_received;
130 vTable.new_subscription_request = new_subscription_request;
131 vTable.notify_presence_recv = notify_presence_recv;
132 vTable.call_stats_updated = callStatsUpdated;
134 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
136 /*displayStatus(LinphoneCore lc,String message);*/
137 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
139 /*void generalState(LinphoneCore lc,int state); */
140 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
141 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
142 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
144 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
145 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
146 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
147 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
149 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
150 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
151 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
152 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
154 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
155 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
157 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
158 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
160 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
161 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
163 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
164 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
165 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
166 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
168 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
169 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
171 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
172 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
174 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
175 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
176 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
177 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
179 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
180 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
182 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
183 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
185 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
186 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
188 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
189 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
191 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
192 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
194 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
195 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
197 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
198 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
199 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
200 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
203 ~LinphoneCoreData() {
205 jvm->AttachCurrentThread(&env,NULL);
206 env->DeleteGlobalRef(core);
207 env->DeleteGlobalRef(listener);
208 if (userdata) env->DeleteGlobalRef(userdata);
209 env->DeleteGlobalRef(listenerClass);
210 env->DeleteGlobalRef(globalStateClass);
211 env->DeleteGlobalRef(registrationStateClass);
212 env->DeleteGlobalRef(callStateClass);
213 env->DeleteGlobalRef(callStatsClass);
214 env->DeleteGlobalRef(chatMessageStateClass);
215 env->DeleteGlobalRef(proxyClass);
216 env->DeleteGlobalRef(callClass);
217 env->DeleteGlobalRef(chatMessageClass);
218 env->DeleteGlobalRef(chatRoomClass);
219 env->DeleteGlobalRef(friendClass);
226 jclass listenerClass;
227 jmethodID displayStatusId;
228 jmethodID newSubscriptionRequestId;
229 jmethodID notifyPresenceReceivedId;
230 jmethodID textReceivedId;
231 jmethodID messageReceivedId;
232 jmethodID dtmfReceivedId;
233 jmethodID callStatsUpdatedId;
235 jclass globalStateClass;
236 jmethodID globalStateId;
237 jmethodID globalStateFromIntId;
239 jclass registrationStateClass;
240 jmethodID registrationStateId;
241 jmethodID registrationStateFromIntId;
243 jclass callStateClass;
244 jmethodID callStateId;
245 jmethodID callStateFromIntId;
247 jclass callStatsClass;
248 jmethodID callStatsId;
249 jmethodID callSetAudioStatsId;
250 jmethodID callSetVideoStatsId;
252 jclass chatMessageStateClass;
253 jmethodID chatMessageStateFromIntId;
255 jmethodID callEncryptionChangedId;
257 jclass ecCalibratorStatusClass;
258 jmethodID ecCalibrationStatusId;
259 jmethodID ecCalibratorStatusFromIntId;
262 jmethodID proxyCtrId;
267 jclass chatMessageClass;
268 jmethodID chatMessageCtrId;
270 jclass chatRoomClass;
271 jmethodID chatRoomCtrId;
274 jmethodID friendCtrId;
277 jmethodID addressCtrId;
279 LinphoneCoreVTable vTable;
281 static void showInterfaceCb(LinphoneCore *lc) {
284 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
287 static void displayStatusCb(LinphoneCore *lc, const char *message) {
289 jint result = jvm->AttachCurrentThread(&env,NULL);
291 ms_error("cannot attach VM\n");
294 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
295 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
297 static void displayMessageCb(LinphoneCore *lc, const char *message) {
300 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
303 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
305 jint result = jvm->AttachCurrentThread(&env,NULL);
307 ms_error("cannot attach VM\n");
310 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
311 env->CallVoidMethod(lcData->listener
312 ,lcData->globalStateId
314 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
315 message ? env->NewStringUTF(message) : NULL);
317 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
319 jint result = jvm->AttachCurrentThread(&env,NULL);
321 ms_error("cannot attach VM\n");
324 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
325 env->CallVoidMethod(lcData->listener
326 ,lcData->registrationStateId
328 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
329 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
330 message ? env->NewStringUTF(message) : NULL);
332 jobject getCall(JNIEnv *env , LinphoneCall *call){
336 void *up=linphone_call_get_user_pointer(call);
339 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
340 jobj=env->NewGlobalRef(jobj);
341 linphone_call_set_user_pointer(call,(void*)jobj);
342 linphone_call_ref(call);
350 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
352 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
362 ,(jcall=lcData->getCall(env,call))
363 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
364 message ? env->NewStringUTF(message) : NULL);
365 if (state==LinphoneCallReleased){
366 linphone_call_set_user_pointer(call,NULL);
367 env->DeleteGlobalRef(jcall);
370 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
372 jint result = jvm->AttachCurrentThread(&env,NULL);
374 ms_error("cannot attach VM\n");
377 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
378 env->CallVoidMethod(lcData->listener
379 ,lcData->callEncryptionChangedId
381 ,lcData->getCall(env,call)
383 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
385 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
387 jint result = jvm->AttachCurrentThread(&env,NULL);
389 ms_error("cannot attach VM\n");
392 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
393 env->CallVoidMethod(lcData->listener
394 ,lcData->notifyPresenceReceivedId
396 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
398 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
400 jint result = jvm->AttachCurrentThread(&env,NULL);
402 ms_error("cannot attach VM\n");
405 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
406 env->CallVoidMethod(lcData->listener
407 ,lcData->newSubscriptionRequestId
409 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
410 ,url ? env->NewStringUTF(url) : NULL);
412 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
414 jint result = jvm->AttachCurrentThread(&env,NULL);
416 ms_error("cannot attach VM\n");
419 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
420 env->CallVoidMethod(lcData->listener
421 ,lcData->dtmfReceivedId
423 ,lcData->getCall(env,call)
426 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
428 jint result = jvm->AttachCurrentThread(&env,NULL);
430 ms_error("cannot attach VM\n");
433 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
434 env->CallVoidMethod(lcData->listener
435 ,lcData->textReceivedId
437 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
438 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
439 ,message ? env->NewStringUTF(message) : NULL);
441 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
443 jint result = jvm->AttachCurrentThread(&env,NULL);
445 ms_error("cannot attach VM\n");
448 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
449 env->CallVoidMethod(lcData->listener
450 ,lcData->messageReceivedId
452 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
453 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
455 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
457 jint result = jvm->AttachCurrentThread(&env,NULL);
459 ms_error("cannot attach VM\n");
462 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
463 env->CallVoidMethod(lcData->listener
464 ,lcData->ecCalibrationStatusId
466 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
468 ,data ? data : NULL);
469 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
470 //final state, releasing global ref
471 env->DeleteGlobalRef((jobject)data);
475 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
479 jint result = jvm->AttachCurrentThread(&env,NULL);
481 ms_error("cannot attach VM\n");
484 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
485 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
486 callobj = lcData->getCall(env, call);
487 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
488 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
490 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
491 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
496 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
500 ,jstring jfactoryConfig
503 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
504 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
505 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
508 libmsilbc_init(); // requires an fpu
522 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
526 //clear auth info list
527 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
528 //clear existing proxy config
529 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
531 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
532 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
535 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
538 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
539 linphone_core_destroy((LinphoneCore*)lc);
543 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
544 linphone_core_clear_proxy_config((LinphoneCore*)lc);
547 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
551 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
553 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
556 LinphoneProxyConfig *config=0;
557 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
558 return (jlong)config;
561 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
562 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
563 int proxyCount = ms_list_size(proxies);
564 jlongArray jProxies = env->NewLongArray(proxyCount);
565 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
567 for (int i = 0; i < proxyCount; i++ ) {
568 jInternalArray[i] = (unsigned long) (proxies->data);
569 proxies = proxies->next;
572 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
577 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
582 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
583 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
585 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
588 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
589 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
592 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
593 linphone_core_refresh_registers((LinphoneCore*)lc);
596 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
600 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
602 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
605 linphone_core_iterate((LinphoneCore*)lc);
607 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
611 const char* uri = env->GetStringUTFChars(juri, NULL);
612 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
613 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
614 env->ReleaseStringUTFChars(juri, uri);
615 return lcd->getCall(env,lCall);
617 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
621 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
622 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
625 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
629 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
632 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
635 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
637 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
641 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
643 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
647 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
649 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
654 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
657 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
662 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
665 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
670 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
673 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
677 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
680 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
684 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
686 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
689 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
691 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
694 ,jboolean isReachable) {
695 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
698 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
701 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
704 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
708 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
711 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
714 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
717 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
721 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
724 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
728 const char* url = env->GetStringUTFChars(jurl, NULL);
729 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
730 env->ReleaseStringUTFChars(jurl, url);
733 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
737 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
739 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
744 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
746 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
749 linphone_core_stop_dtmf((LinphoneCore*)lc);
752 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
755 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
758 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
761 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
764 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
766 ,jlong lc, jlong log) {
767 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
770 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
773 linphone_core_clear_call_logs((LinphoneCore*)lc);
775 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
778 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
780 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
786 const char* mime = env->GetStringUTFChars(jmime, NULL);
787 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
788 env->ReleaseStringUTFChars(jmime, mime);
791 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
794 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
795 int codecsCount = ms_list_size(codecs);
796 jlongArray jCodecs = env->NewLongArray(codecsCount);
797 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
799 for (int i = 0; i < codecsCount; i++ ) {
800 jInternalArray[i] = (unsigned long) (codecs->data);
801 codecs = codecs->next;
804 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
809 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
812 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
813 int codecsCount = ms_list_size(codecs);
814 jlongArray jCodecs = env->NewLongArray(codecsCount);
815 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
817 for (int i = 0; i < codecsCount; i++ ) {
818 jInternalArray[i] = (unsigned long) (codecs->data);
819 codecs = codecs->next;
822 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
827 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
832 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
834 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
838 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
840 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
844 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
846 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
850 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
853 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
857 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
860 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
864 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
866 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
868 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
873 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
875 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
879 ,jstring jalternative_contact
881 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
882 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
883 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
886 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
891 const char* to = env->GetStringUTFChars(jto, NULL);
892 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
893 env->ReleaseStringUTFChars(jto, to);
894 return (jlong)lResult;
897 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
900 ,jboolean vcap_enabled
901 ,jboolean display_enabled) {
902 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
905 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
908 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
910 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
914 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
915 linphone_core_set_play_file((LinphoneCore*)lc,path);
916 if (path) env->ReleaseStringUTFChars(jpath, path);
918 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
922 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
923 linphone_core_set_ring((LinphoneCore*)lc,path);
924 if (path) env->ReleaseStringUTFChars(jpath, path);
926 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
930 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
932 return env->NewStringUTF(path);
937 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
941 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
942 linphone_core_set_root_ca((LinphoneCore*)lc,path);
943 if (path) env->ReleaseStringUTFChars(jpath, path);
945 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
949 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
952 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
955 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
958 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
962 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
963 , LinphoneCoreData::ecCalibrationStatus
964 , data?env->NewGlobalRef(data):NULL);
968 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
972 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
975 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
979 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
982 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
986 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
989 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
993 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
996 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1001 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1006 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1007 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1008 return (jlong) proxy;
1011 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1012 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1014 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1015 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1016 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1017 env->ReleaseStringUTFChars(jidentity, identity);
1019 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1020 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1022 return env->NewStringUTF(identity);
1027 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1028 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1029 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1030 env->ReleaseStringUTFChars(jproxy, proxy);
1033 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1034 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1036 return env->NewStringUTF(proxy);
1041 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1042 const char* params = env->GetStringUTFChars(jparams, NULL);
1043 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1044 env->ReleaseStringUTFChars(jparams, params);
1046 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1047 if (jroute != NULL) {
1048 const char* route = env->GetStringUTFChars(jroute, NULL);
1049 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1050 env->ReleaseStringUTFChars(jroute, route);
1053 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1056 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1057 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1059 return env->NewStringUTF(route);
1065 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1066 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1068 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1069 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1071 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1072 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1074 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1075 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1077 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1078 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1080 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1082 ms_error("cannot normalized null number");
1084 const char* number = env->GetStringUTFChars(jnumber, NULL);
1085 int len = env->GetStringLength(jnumber);
1087 ms_warning("cannot normalize empty number");
1090 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1091 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1092 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1093 env->ReleaseStringUTFChars(jnumber, number);
1094 return normalizedNumber;
1096 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1097 const char* iso = env->GetStringUTFChars(jiso, NULL);
1098 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1099 env->ReleaseStringUTFChars(jiso, iso);
1100 return (jint) prefix;
1102 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1105 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1107 return env->NewStringUTF(domain);
1112 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1113 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1116 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1120 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1121 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1122 env->ReleaseStringUTFChars(jprefix, prefix);
1124 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1128 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1130 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1131 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1136 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1144 const char* username = env->GetStringUTFChars(jusername, NULL);
1145 const char* userid = env->GetStringUTFChars(juserid, NULL);
1146 const char* password = env->GetStringUTFChars(jpassword, NULL);
1147 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1148 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1149 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1151 env->ReleaseStringUTFChars(jusername, username);
1152 env->ReleaseStringUTFChars(juserid, userid);
1153 env->ReleaseStringUTFChars(jpassword, password);
1154 env->ReleaseStringUTFChars(jha1, ha1);
1155 env->ReleaseStringUTFChars(jrealm, realm);
1159 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1162 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1167 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1170 ,jstring jdisplayName) {
1171 const char* uri = env->GetStringUTFChars(juri, NULL);
1172 LinphoneAddress* address = linphone_address_new(uri);
1173 if (jdisplayName && address) {
1174 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1175 linphone_address_set_display_name(address,displayName);
1176 env->ReleaseStringUTFChars(jdisplayName, displayName);
1178 env->ReleaseStringUTFChars(juri, uri);
1180 return (jlong) address;
1182 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1185 linphone_address_destroy((LinphoneAddress*)ptr);
1188 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1191 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1193 return env->NewStringUTF(displayName);
1198 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1201 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1203 return env->NewStringUTF(userName);
1208 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1211 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1213 return env->NewStringUTF(domain);
1219 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1222 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1223 jstring juri =env->NewStringUTF(uri);
1227 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1230 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1231 jstring juri =env->NewStringUTF(uri);
1235 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1238 ,jstring jdisplayName) {
1239 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1240 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1241 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1246 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1249 return (jlong)((LinphoneCallLog*)ptr)->from;
1251 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1254 return (jint)((LinphoneCallLog*)ptr)->status;
1256 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1259 return (jlong)((LinphoneCallLog*)ptr)->to;
1261 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1264 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1266 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1269 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1272 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1275 return (jint)((LinphoneCallLog*)ptr)->duration;
1279 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1280 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1282 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1283 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1285 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1286 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1288 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1289 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1291 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1292 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1293 const report_block_t *srb = NULL;
1295 if (!stats || !stats->sent_rtcp)
1297 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1298 if (stats->sent_rtcp->b_cont != NULL)
1299 msgpullup(stats->sent_rtcp, -1);
1300 if (rtcp_is_SR(stats->sent_rtcp))
1301 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1302 else if (rtcp_is_RR(stats->sent_rtcp))
1303 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1306 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1308 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1309 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1310 const report_block_t *rrb = NULL;
1312 if (!stats || !stats->received_rtcp)
1314 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1315 if (stats->received_rtcp->b_cont != NULL)
1316 msgpullup(stats->received_rtcp, -1);
1317 if (rtcp_is_RR(stats->received_rtcp))
1318 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1319 else if (rtcp_is_SR(stats->received_rtcp))
1320 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1323 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1325 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1326 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1327 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1328 const LinphoneCallParams *params;
1329 const PayloadType *pt;
1330 const report_block_t *srb = NULL;
1332 if (!stats || !call || !stats->sent_rtcp)
1334 params = linphone_call_get_current_params(call);
1337 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1338 if (stats->sent_rtcp->b_cont != NULL)
1339 msgpullup(stats->sent_rtcp, -1);
1340 if (rtcp_is_SR(stats->sent_rtcp))
1341 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1342 else if (rtcp_is_RR(stats->sent_rtcp))
1343 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1346 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1347 pt = linphone_call_params_get_used_audio_codec(params);
1349 pt = linphone_call_params_get_used_video_codec(params);
1350 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1352 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1353 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1354 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1355 const LinphoneCallParams *params;
1356 const PayloadType *pt;
1357 const report_block_t *rrb = NULL;
1359 if (!stats || !call || !stats->received_rtcp)
1361 params = linphone_call_get_current_params(call);
1364 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1365 if (stats->received_rtcp->b_cont != NULL)
1366 msgpullup(stats->received_rtcp, -1);
1367 if (rtcp_is_SR(stats->received_rtcp))
1368 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1369 else if (rtcp_is_RR(stats->received_rtcp))
1370 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1373 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1374 pt = linphone_call_params_get_used_audio_codec(params);
1376 pt = linphone_call_params_get_used_video_codec(params);
1377 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1379 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1380 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1382 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1383 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1384 LinphoneCall *call = (LinphoneCall *)call_ptr;
1385 rtp_stats_t rtp_stats;
1387 if (!stats || !call)
1389 memset(&rtp_stats, 0, sizeof(rtp_stats));
1390 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1391 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1392 #ifdef VIDEO_ENABLED
1394 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1396 return (jlong)rtp_stats.outoftime;
1398 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1399 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1403 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1404 PayloadType* pt = (PayloadType*)ptr;
1405 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1406 ,payload_type_get_mime(pt)
1407 ,payload_type_get_rate(pt)
1408 ,payload_type_get_bitrate(pt));
1409 jstring jvalue =env->NewStringUTF(value);
1413 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1414 PayloadType* pt = (PayloadType*)ptr;
1415 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1418 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1419 PayloadType* pt = (PayloadType*)ptr;
1420 return (jint)payload_type_get_rate(pt);
1424 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1427 LinphoneCall *call=(LinphoneCall*)ptr;
1428 linphone_call_unref(call);
1431 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1434 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1437 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1439 ,jlong ptr, jstring path) {
1440 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1441 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1444 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1446 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1447 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1450 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1453 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1456 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1459 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1462 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1465 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1467 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1471 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1473 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1476 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1479 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1483 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1485 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1488 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1491 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1494 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1495 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1498 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1501 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1504 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1507 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1512 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1514 ,jstring jFriendUri) {
1515 LinphoneFriend* lResult;
1518 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1519 lResult= linphone_friend_new_with_addr(friendUri);
1520 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1522 lResult = linphone_friend_new();
1524 return (jlong)lResult;
1526 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1529 ,jlong linphoneAddress) {
1530 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1532 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1535 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1537 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1541 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1543 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1546 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1548 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1552 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1554 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1557 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1559 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1562 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1564 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1567 return linphone_friend_edit((LinphoneFriend*)ptr);
1569 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1572 linphone_friend_done((LinphoneFriend*)ptr);
1574 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1578 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1580 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1583 ,jstring jaddress) {
1584 const char* address = env->GetStringUTFChars(jaddress, NULL);
1585 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1586 env->ReleaseStringUTFChars(jaddress, address);
1590 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1593 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1595 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1598 ,jstring jmessage) {
1599 const char* message = env->GetStringUTFChars(jmessage, NULL);
1600 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1601 env->ReleaseStringUTFChars(jmessage, message);
1603 return (jlong) chatMessage;
1605 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1608 jobject ud = env->NewGlobalRef(thiz);
1609 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1611 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1614 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1617 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1620 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1623 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1627 const char* url = env->GetStringUTFChars(jurl, NULL);
1628 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1629 env->ReleaseStringUTFChars(jurl, url);
1631 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1634 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1636 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1639 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1641 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1644 ,jstring jmessage) {
1645 const char* message = env->GetStringUTFChars(jmessage, NULL);
1646 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1647 env->ReleaseStringUTFChars(jmessage, message);
1650 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1652 jint result = jvm->AttachCurrentThread(&env,NULL);
1654 ms_error("cannot attach VM\n");
1658 jobject listener = (jobject) ud;
1659 jclass clazz = (jclass) env->GetObjectClass(listener);
1660 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1662 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1663 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1664 env->CallVoidMethod(
1667 (jobject)linphone_chat_message_get_user_data(msg),
1668 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1670 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1671 env->DeleteGlobalRef(listener);
1674 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1678 ,jobject jlistener) {
1679 jobject listener = env->NewGlobalRef(jlistener);
1680 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1682 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1686 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1687 if (oldWindow != NULL) {
1688 env->DeleteGlobalRef(oldWindow);
1691 obj = env->NewGlobalRef(obj);
1693 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1696 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1700 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1701 if (oldWindow != NULL) {
1702 env->DeleteGlobalRef(oldWindow);
1705 obj = env->NewGlobalRef(obj);
1707 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1710 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1714 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1718 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1719 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1722 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1723 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1726 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1727 const char* server = NULL;
1728 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1729 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1730 if (server) env->ReleaseStringUTFChars(jserver,server);
1733 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1734 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1735 if (ret==NULL) return NULL;
1736 jstring jvalue =env->NewStringUTF(ret);
1742 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1743 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1746 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1747 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1750 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
1754 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
1757 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1761 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1764 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1765 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1768 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1769 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1772 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1773 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1776 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1777 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1780 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1781 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1783 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1784 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1787 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1788 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1791 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1794 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1795 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1798 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1799 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1802 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1803 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
1806 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1807 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1808 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1811 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1812 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1815 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1816 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1820 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1822 vsize.width = (int)width;
1823 vsize.height = (int)height;
1824 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1827 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1828 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1829 jintArray arr = env->NewIntArray(2);
1830 int tVsize [2]= {vsize.width,vsize.height};
1831 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1835 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1836 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1839 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1840 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1843 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1844 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1847 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1848 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1851 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1852 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1854 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1855 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1858 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1859 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
1862 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1864 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1877 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1878 LinphoneCore *lc = (LinphoneCore *) ptr;
1884 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1887 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1888 ,jlong lc, jboolean enable) {
1889 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1892 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1893 ,jlong ptr, jint db) {
1894 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1897 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1898 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1900 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1901 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
1903 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1904 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1906 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1907 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
1909 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1910 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
1912 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1913 linphone_core_leave_conference((LinphoneCore *) pCore);
1915 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1916 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1918 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1919 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1921 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1922 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1925 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1926 linphone_core_terminate_conference((LinphoneCore *) pCore);
1928 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1929 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
1931 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1932 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1934 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1935 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1936 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1937 return lcd->getCall(env,lCall);
1939 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1940 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1943 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1944 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1945 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1946 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1949 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1950 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1953 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1955 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1956 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1957 env->ReleaseStringUTFChars(jFile, cFile);
1959 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1963 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1964 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1965 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1966 env->ReleaseStringUTFChars(jUri, cUri);
1967 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1968 return (jobject) lcdata->getCall(env,call);
1972 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1973 LinphoneCore* lc = (LinphoneCore *) pCore;
1974 const char** devices = linphone_core_get_video_devices(lc);
1975 if (devices == NULL) {
1976 ms_error("No existing video devices\n");
1980 for(i=0; i<=id; i++) {
1981 if (devices[i] == NULL)
1983 ms_message("Existing device %d : %s\n", i, devices[i]);
1985 return (jint)linphone_core_set_video_device(lc, devices[i]);
1991 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1992 LinphoneCore* lc = (LinphoneCore *) pCore;
1993 const char** devices = linphone_core_get_video_devices(lc);
1994 if (devices == NULL) {
1995 ms_error("No existing video devices\n");
1998 const char* cam = linphone_core_get_video_device(lc);
2000 ms_error("No current video device\n");
2003 while(devices[i] != NULL) {
2004 if (strcmp(devices[i], cam) == 0)
2009 ms_warning("Returning default (0) device\n");
2013 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2014 LinphoneCall *call = (LinphoneCall *) ptr;
2015 const char* token = linphone_call_get_authentication_token(call);
2016 if (token == NULL) return NULL;
2017 return env->NewStringUTF(token);
2019 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2020 LinphoneCall *call = (LinphoneCall *) ptr;
2021 return (jboolean)linphone_call_get_authentication_token_verified(call);
2023 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2024 LinphoneCall *call = (LinphoneCall *) ptr;
2025 linphone_call_set_authentication_token_verified(call, verified);
2028 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2029 LinphoneCall *call = (LinphoneCall *) ptr;
2030 return (jfloat)linphone_call_get_play_volume(call);
2033 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2034 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2037 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2038 // Implemented directly in msandroid.cpp (sound filters for Android).
2039 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
2041 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
2042 msandroid_hack_speaker_state(speakerOn);
2044 // End Galaxy S hack functions
2047 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2048 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2050 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2051 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2054 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2055 jstring jHost, jint port, jint mirror, jint delay) {
2056 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2057 if (!tunnel) return;
2058 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2059 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2060 env->ReleaseStringUTFChars(jHost, cHost);
2063 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2064 jstring jHost, jint port, jstring username, jstring password) {
2066 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2067 if (!tunnel) return;
2068 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2069 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2070 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2071 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2072 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2073 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2074 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2078 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2079 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2080 linphone_tunnel_auto_detect(tunnel);
2084 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2085 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2086 linphone_tunnel_clean_servers(tunnel);
2089 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2090 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2091 linphone_tunnel_enable(tunnel, enable);
2095 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2096 const char* cname=env->GetStringUTFChars(name, NULL);
2097 const char* cversion=env->GetStringUTFChars(version, NULL);
2098 linphone_core_set_user_agent(cname,cversion);
2099 env->ReleaseStringUTFChars(name, cname);
2100 env->ReleaseStringUTFChars(version, cversion);
2103 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2104 return (jboolean)linphone_core_tunnel_available();
2107 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2108 LinphoneVideoPolicy vpol;
2109 vpol.automatically_initiate = autoInitiate;
2110 vpol.automatically_accept = autoAccept;
2111 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2114 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2115 ms_set_cpu_count(count);
2118 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2119 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2122 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2123 linphone_core_set_video_port((LinphoneCore *)lc, port);
2126 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2127 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2130 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2131 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2134 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2135 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2138 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2139 jstring jvalue =env->NewStringUTF(linphone_core_get_version());