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;
116 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
118 /*displayStatus(LinphoneCore lc,String message);*/
119 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
121 /*void generalState(LinphoneCore lc,int state); */
122 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
123 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
124 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
126 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
127 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
128 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
129 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
131 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
132 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
133 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
134 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
136 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
137 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
139 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
140 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
142 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
143 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
144 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
145 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
147 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
148 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
150 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
151 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
153 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
154 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
155 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
157 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
158 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
160 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
161 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
163 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
164 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
166 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
167 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
169 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
170 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
172 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
173 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
177 ~LinphoneCoreData() {
179 jvm->AttachCurrentThread(&env,NULL);
180 env->DeleteGlobalRef(core);
181 env->DeleteGlobalRef(listener);
182 if (userdata) env->DeleteGlobalRef(userdata);
183 env->DeleteGlobalRef(listenerClass);
184 env->DeleteGlobalRef(globalStateClass);
185 env->DeleteGlobalRef(registrationStateClass);
186 env->DeleteGlobalRef(callStateClass);
187 env->DeleteGlobalRef(chatMessageStateClass);
188 env->DeleteGlobalRef(proxyClass);
189 env->DeleteGlobalRef(callClass);
190 env->DeleteGlobalRef(chatMessageClass);
191 env->DeleteGlobalRef(chatRoomClass);
192 env->DeleteGlobalRef(friendClass);
199 jclass listenerClass;
200 jmethodID displayStatusId;
201 jmethodID newSubscriptionRequestId;
202 jmethodID notifyPresenceReceivedId;
203 jmethodID textReceivedId;
204 jmethodID messageReceivedId;
206 jclass globalStateClass;
207 jmethodID globalStateId;
208 jmethodID globalStateFromIntId;
210 jclass registrationStateClass;
211 jmethodID registrationStateId;
212 jmethodID registrationStateFromIntId;
214 jclass callStateClass;
215 jmethodID callStateId;
216 jmethodID callStateFromIntId;
218 jclass chatMessageStateClass;
219 jmethodID chatMessageStateFromIntId;
221 jmethodID callEncryptionChangedId;
223 jclass ecCalibratorStatusClass;
224 jmethodID ecCalibrationStatusId;
225 jmethodID ecCalibratorStatusFromIntId;
228 jmethodID proxyCtrId;
233 jclass chatMessageClass;
234 jmethodID chatMessageCtrId;
236 jclass chatRoomClass;
237 jmethodID chatRoomCtrId;
240 jmethodID friendCtrId;
243 jmethodID addressCtrId;
245 LinphoneCoreVTable vTable;
247 static void showInterfaceCb(LinphoneCore *lc) {
250 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
253 static void displayStatusCb(LinphoneCore *lc, const char *message) {
255 jint result = jvm->AttachCurrentThread(&env,NULL);
257 ms_error("cannot attach VM\n");
260 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
261 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
263 static void displayMessageCb(LinphoneCore *lc, const char *message) {
266 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
269 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
271 jint result = jvm->AttachCurrentThread(&env,NULL);
273 ms_error("cannot attach VM\n");
276 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
277 env->CallVoidMethod(lcData->listener
278 ,lcData->globalStateId
280 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
281 message ? env->NewStringUTF(message) : NULL);
283 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
285 jint result = jvm->AttachCurrentThread(&env,NULL);
287 ms_error("cannot attach VM\n");
290 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
291 env->CallVoidMethod(lcData->listener
292 ,lcData->registrationStateId
294 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
295 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
296 message ? env->NewStringUTF(message) : NULL);
298 jobject getCall(JNIEnv *env , LinphoneCall *call){
302 void *up=linphone_call_get_user_pointer(call);
305 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
306 jobj=env->NewGlobalRef(jobj);
307 linphone_call_set_user_pointer(call,(void*)jobj);
308 linphone_call_ref(call);
316 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
318 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
328 ,(jcall=lcData->getCall(env,call))
329 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
330 message ? env->NewStringUTF(message) : NULL);
331 if (state==LinphoneCallReleased){
332 linphone_call_set_user_pointer(call,NULL);
333 env->DeleteGlobalRef(jcall);
336 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
338 jint result = jvm->AttachCurrentThread(&env,NULL);
340 ms_error("cannot attach VM\n");
343 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
344 env->CallVoidMethod(lcData->listener
345 ,lcData->callEncryptionChangedId
347 ,lcData->getCall(env,call)
349 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
351 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
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->notifyPresenceReceivedId
362 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
364 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
366 jint result = jvm->AttachCurrentThread(&env,NULL);
368 ms_error("cannot attach VM\n");
371 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
372 env->CallVoidMethod(lcData->listener
373 ,lcData->newSubscriptionRequestId
375 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
376 ,url ? env->NewStringUTF(url) : NULL);
378 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
380 jint result = jvm->AttachCurrentThread(&env,NULL);
382 ms_error("cannot attach VM\n");
385 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
386 env->CallVoidMethod(lcData->listener
387 ,lcData->textReceivedId
389 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
390 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
391 ,message ? env->NewStringUTF(message) : NULL);
393 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
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->messageReceivedId
404 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
405 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
407 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
409 jint result = jvm->AttachCurrentThread(&env,NULL);
411 ms_error("cannot attach VM\n");
414 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
415 env->CallVoidMethod(lcData->listener
416 ,lcData->ecCalibrationStatusId
418 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
420 ,data ? data : NULL);
421 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
422 //final state, releasing global ref
423 env->DeleteGlobalRef((jobject)data);
430 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
434 ,jstring jfactoryConfig
437 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
438 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
439 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
442 libmsilbc_init(); // requires an fpu
456 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
460 //clear auth info list
461 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
462 //clear existing proxy config
463 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
465 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
466 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
469 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
472 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
473 linphone_core_destroy((LinphoneCore*)lc);
477 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
478 linphone_core_clear_proxy_config((LinphoneCore*)lc);
481 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
485 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
487 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
490 LinphoneProxyConfig *config=0;
491 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
492 return (jlong)config;
495 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
496 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
497 int proxyCount = ms_list_size(proxies);
498 jlongArray jProxies = env->NewLongArray(proxyCount);
499 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
501 for (int i = 0; i < proxyCount; i++ ) {
502 jInternalArray[i] = (unsigned long) (proxies->data);
503 proxies = proxies->next;
506 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
511 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
516 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
517 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
519 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
522 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
523 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
526 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
527 linphone_core_refresh_registers((LinphoneCore*)lc);
530 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
534 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
536 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
539 linphone_core_iterate((LinphoneCore*)lc);
541 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
545 const char* uri = env->GetStringUTFChars(juri, NULL);
546 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
547 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
548 env->ReleaseStringUTFChars(juri, uri);
549 return lcd->getCall(env,lCall);
551 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
555 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
556 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
559 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
563 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
566 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
569 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
571 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
575 return linphone_core_in_call((LinphoneCore*)lc);
577 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
581 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
583 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
588 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
591 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
596 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
599 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
604 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
607 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
611 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
614 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
618 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
620 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
623 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
625 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
628 ,jboolean isReachable) {
629 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
632 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
635 return linphone_core_is_network_reachable((LinphoneCore*)lc);
638 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
642 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
645 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
648 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
651 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
655 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
658 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
662 const char* url = env->GetStringUTFChars(jurl, NULL);
663 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
664 env->ReleaseStringUTFChars(jurl, url);
667 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
671 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
673 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
678 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
680 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
683 linphone_core_stop_dtmf((LinphoneCore*)lc);
686 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
689 linphone_core_get_missed_calls_count((LinphoneCore*)lc);
692 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
695 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
698 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
700 ,jlong lc, jlong log) {
701 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
704 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
707 linphone_core_clear_call_logs((LinphoneCore*)lc);
709 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
712 return linphone_core_is_mic_muted((LinphoneCore*)lc);
714 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
720 const char* mime = env->GetStringUTFChars(jmime, NULL);
721 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
722 env->ReleaseStringUTFChars(jmime, mime);
725 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
728 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
729 int codecsCount = ms_list_size(codecs);
730 jlongArray jCodecs = env->NewLongArray(codecsCount);
731 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
733 for (int i = 0; i < codecsCount; i++ ) {
734 jInternalArray[i] = (unsigned long) (codecs->data);
735 codecs = codecs->next;
738 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
743 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
746 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
747 int codecsCount = ms_list_size(codecs);
748 jlongArray jCodecs = env->NewLongArray(codecsCount);
749 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
751 for (int i = 0; i < codecsCount; i++ ) {
752 jInternalArray[i] = (unsigned long) (codecs->data);
753 codecs = codecs->next;
756 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
761 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
766 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
768 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
772 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
774 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
778 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
780 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
784 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
787 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
791 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
794 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
798 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
800 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
802 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
807 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
809 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
813 ,jstring jalternative_contact
815 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
816 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
817 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
820 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
825 const char* to = env->GetStringUTFChars(jto, NULL);
826 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
827 env->ReleaseStringUTFChars(jto, to);
828 return (long)lResult;
831 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
834 ,jboolean vcap_enabled
835 ,jboolean display_enabled) {
836 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
839 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
842 return linphone_core_video_enabled((LinphoneCore*)lc);
844 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
848 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
849 linphone_core_set_play_file((LinphoneCore*)lc,path);
850 if (path) env->ReleaseStringUTFChars(jpath, path);
852 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
856 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
857 linphone_core_set_ring((LinphoneCore*)lc,path);
858 if (path) env->ReleaseStringUTFChars(jpath, path);
860 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
864 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
866 return env->NewStringUTF(path);
871 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
875 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
876 linphone_core_set_root_ca((LinphoneCore*)lc,path);
877 if (path) env->ReleaseStringUTFChars(jpath, path);
879 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
883 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
886 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
889 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
892 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
896 return linphone_core_start_echo_calibration((LinphoneCore*)lc
897 , LinphoneCoreData::ecCalibrationStatus
898 , data?env->NewGlobalRef(data):NULL);
902 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
906 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
909 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
913 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
916 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
920 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
923 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
927 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
930 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
934 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
937 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
941 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
944 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
949 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
954 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
955 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
956 return (jlong) proxy;
959 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
960 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
962 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
963 const char* identity = env->GetStringUTFChars(jidentity, NULL);
964 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
965 env->ReleaseStringUTFChars(jidentity, identity);
967 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
968 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
970 return env->NewStringUTF(identity);
975 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
976 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
977 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
978 env->ReleaseStringUTFChars(jproxy, proxy);
981 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
982 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
984 return env->NewStringUTF(proxy);
989 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
990 const char* params = env->GetStringUTFChars(jparams, NULL);
991 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
992 env->ReleaseStringUTFChars(jparams, params);
994 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
995 if (jroute != NULL) {
996 const char* route = env->GetStringUTFChars(jroute, NULL);
997 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
998 env->ReleaseStringUTFChars(jroute, route);
1001 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1004 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1005 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1007 return env->NewStringUTF(route);
1013 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1014 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1016 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1017 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1019 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1020 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1022 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1023 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1025 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1026 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1028 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1030 ms_error("cannot normalized null number");
1032 const char* number = env->GetStringUTFChars(jnumber, NULL);
1033 int len = env->GetStringLength(jnumber);
1035 ms_warning("cannot normalize empty number");
1038 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1039 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1040 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1041 env->ReleaseStringUTFChars(jnumber, number);
1042 return normalizedNumber;
1044 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1047 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1049 return env->NewStringUTF(domain);
1054 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1055 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1058 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1062 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1063 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1064 env->ReleaseStringUTFChars(jprefix, prefix);
1066 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1070 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1072 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1073 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1078 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1086 const char* username = env->GetStringUTFChars(jusername, NULL);
1087 const char* password = env->GetStringUTFChars(jpassword, NULL);
1088 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1090 env->ReleaseStringUTFChars(jusername, username);
1091 env->ReleaseStringUTFChars(jpassword, password);
1095 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1098 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1103 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1106 ,jstring jdisplayName) {
1107 const char* uri = env->GetStringUTFChars(juri, NULL);
1108 LinphoneAddress* address = linphone_address_new(uri);
1109 if (jdisplayName && address) {
1110 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1111 linphone_address_set_display_name(address,displayName);
1112 env->ReleaseStringUTFChars(jdisplayName, displayName);
1114 env->ReleaseStringUTFChars(juri, uri);
1116 return (jlong) address;
1118 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1121 linphone_address_destroy((LinphoneAddress*)ptr);
1124 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1127 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1129 return env->NewStringUTF(displayName);
1134 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1137 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1139 return env->NewStringUTF(userName);
1144 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1147 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1149 return env->NewStringUTF(domain);
1155 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1158 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1159 jstring juri =env->NewStringUTF(uri);
1163 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1166 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1167 jstring juri =env->NewStringUTF(uri);
1171 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1174 ,jstring jdisplayName) {
1175 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1176 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1177 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1182 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1185 return (jlong)((LinphoneCallLog*)ptr)->from;
1187 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1190 return (jlong)((LinphoneCallLog*)ptr)->status;
1192 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1195 return (jlong)((LinphoneCallLog*)ptr)->to;
1197 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1200 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1202 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1205 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1208 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1211 return ((LinphoneCallLog*)ptr)->duration;
1215 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1216 PayloadType* pt = (PayloadType*)ptr;
1217 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1218 ,payload_type_get_mime(pt)
1219 ,payload_type_get_rate(pt)
1220 ,payload_type_get_bitrate(pt));
1221 jstring jvalue =env->NewStringUTF(value);
1225 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1226 PayloadType* pt = (PayloadType*)ptr;
1227 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1230 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1231 PayloadType* pt = (PayloadType*)ptr;
1232 return payload_type_get_rate(pt);
1236 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1239 LinphoneCall *call=(LinphoneCall*)ptr;
1240 linphone_call_unref(call);
1243 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1246 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1249 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1251 ,jlong ptr, jstring path) {
1252 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1253 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1256 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1258 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1259 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1262 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1265 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1268 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1271 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1274 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1277 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1279 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1283 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1285 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1288 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1291 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1295 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1297 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1300 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1303 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1306 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1307 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1310 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1313 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1316 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1319 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1324 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1326 ,jstring jFriendUri) {
1327 LinphoneFriend* lResult;
1330 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1331 lResult= linphone_friend_new_with_addr(friendUri);
1332 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1334 lResult = linphone_friend_new();
1336 return (long)lResult;
1338 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1341 ,jlong linphoneAddress) {
1342 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1344 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1347 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1349 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1353 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1355 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1358 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1360 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1364 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1366 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1369 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1371 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1374 return linphone_friend_get_status((LinphoneFriend*)ptr);
1376 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1379 return linphone_friend_edit((LinphoneFriend*)ptr);
1381 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1384 linphone_friend_done((LinphoneFriend*)ptr);
1387 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1390 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1392 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1395 ,jstring jmessage) {
1396 const char* message = env->GetStringUTFChars(jmessage, NULL);
1397 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1398 env->ReleaseStringUTFChars(jmessage, message);
1400 return (jlong) chatMessage;
1402 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1405 jobject ud = env->NewGlobalRef(thiz);
1406 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1408 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1411 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1414 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1417 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1420 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1424 const char* url = env->GetStringUTFChars(jurl, NULL);
1425 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1426 env->ReleaseStringUTFChars(jurl, url);
1428 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1431 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1433 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1436 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1438 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1441 ,jstring jmessage) {
1442 const char* message = env->GetStringUTFChars(jmessage, NULL);
1443 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1444 env->ReleaseStringUTFChars(jmessage, message);
1447 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1449 jint result = jvm->AttachCurrentThread(&env,NULL);
1451 ms_error("cannot attach VM\n");
1455 jobject listener = (jobject) ud;
1456 jclass clazz = (jclass) env->GetObjectClass(listener);
1457 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1459 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1460 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1461 env->CallVoidMethod(
1464 (jobject)linphone_chat_message_get_user_data(msg),
1465 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1467 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1468 env->DeleteGlobalRef(listener);
1471 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1475 ,jobject jlistener) {
1476 jobject listener = env->NewGlobalRef(jlistener);
1477 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1479 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1483 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1484 if (oldWindow != NULL) {
1485 env->DeleteGlobalRef(oldWindow);
1488 obj = env->NewGlobalRef(obj);
1490 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1493 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1497 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1498 if (oldWindow != NULL) {
1499 env->DeleteGlobalRef(oldWindow);
1502 obj = env->NewGlobalRef(obj);
1504 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1507 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1511 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1515 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1516 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1519 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1520 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1523 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1524 const char* server = NULL;
1525 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1526 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1527 if (server) env->ReleaseStringUTFChars(jserver,server);
1530 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1531 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1532 if (ret==NULL) return NULL;
1533 jstring jvalue =env->NewStringUTF(ret);
1537 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1538 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1541 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1542 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1545 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1546 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1549 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1550 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1553 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1554 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1556 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1557 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1560 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1561 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1564 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1565 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1568 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1569 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1572 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1573 linphone_call_camera_enabled((LinphoneCall *)lc);
1576 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1577 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1578 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1581 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1582 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1585 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1586 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1590 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1592 vsize.width = (int)width;
1593 vsize.height = (int)height;
1594 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1597 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1598 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1599 jintArray arr = env->NewIntArray(2);
1600 int tVsize [2]= {vsize.width,vsize.height};
1601 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1605 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1606 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1610 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1613 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1614 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1617 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1618 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1621 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1622 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1624 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1625 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1628 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1629 linphone_call_get_duration((LinphoneCall *) ptr);
1632 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1634 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1647 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1648 LinphoneCore *lc = (LinphoneCore *) ptr;
1654 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1657 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1658 ,jlong lc, jboolean enable) {
1659 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1662 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1663 ,jlong ptr, jint db) {
1664 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1667 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1668 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1670 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1671 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1673 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1674 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1676 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1677 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1679 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1680 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1682 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1683 linphone_core_leave_conference((LinphoneCore *) pCore);
1685 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1686 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1688 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1689 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1691 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1692 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1695 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1696 linphone_core_terminate_conference((LinphoneCore *) pCore);
1698 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1699 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1701 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1702 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1704 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1705 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1706 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1707 return lcd->getCall(env,lCall);
1709 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1710 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1713 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1714 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1715 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1716 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1718 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1719 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1722 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1724 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1725 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1726 env->ReleaseStringUTFChars(jFile, cFile);
1728 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1732 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1733 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1734 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1735 env->ReleaseStringUTFChars(jUri, cUri);
1736 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1737 return (jobject) lcdata->getCall(env,call);
1741 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1742 LinphoneCore* lc = (LinphoneCore *) pCore;
1743 const char** devices = linphone_core_get_video_devices(lc);
1744 if (devices == NULL) {
1745 ms_error("No existing video devices\n");
1749 for(i=0; i<=id; i++) {
1750 if (devices[i] == NULL)
1752 ms_message("Existing device %d : %s\n", i, devices[i]);
1754 return linphone_core_set_video_device(lc, devices[i]);
1760 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1761 LinphoneCore* lc = (LinphoneCore *) pCore;
1762 const char** devices = linphone_core_get_video_devices(lc);
1763 if (devices == NULL) {
1764 ms_error("No existing video devices\n");
1767 const char* cam = linphone_core_get_video_device(lc);
1769 ms_error("No current video device\n");
1772 while(devices[i] != NULL) {
1773 if (strcmp(devices[i], cam) == 0)
1778 ms_warning("Returning default (0) device\n");
1782 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1783 LinphoneCall *call = (LinphoneCall *) ptr;
1784 const char* token = linphone_call_get_authentication_token(call);
1785 if (token == NULL) return NULL;
1786 return env->NewStringUTF(token);
1788 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1789 LinphoneCall *call = (LinphoneCall *) ptr;
1790 return linphone_call_get_authentication_token_verified(call);
1792 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1793 LinphoneCall *call = (LinphoneCall *) ptr;
1794 linphone_call_set_authentication_token_verified(call, verified);
1797 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1798 LinphoneCall *call = (LinphoneCall *) ptr;
1799 return linphone_call_get_play_volume(call);
1802 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1803 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1806 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1807 // Implemented directly in msandroid.cpp (sound filters for Android).
1808 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1810 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1811 msandroid_hack_speaker_state(speakerOn);
1813 // End Galaxy S hack functions
1816 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1817 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1819 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1820 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1823 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1824 jstring jHost, jint port, jint mirror, jint delay) {
1825 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1826 if (!tunnel) return;
1827 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1828 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1829 env->ReleaseStringUTFChars(jHost, cHost);
1832 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1833 jstring jHost, jint port, jstring username, jstring password) {
1835 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1836 if (!tunnel) return;
1837 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1838 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1839 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1840 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1841 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1842 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1843 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1847 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1848 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1849 linphone_tunnel_auto_detect(tunnel);
1853 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1854 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1855 linphone_tunnel_clean_servers(tunnel);
1858 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1859 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1860 linphone_tunnel_enable(tunnel, enable);
1864 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
1865 const char* cname=env->GetStringUTFChars(name, NULL);
1866 const char* cversion=env->GetStringUTFChars(version, NULL);
1867 linphone_core_set_user_agent(cname,cversion);
1868 env->ReleaseStringUTFChars(name, cname);
1869 env->ReleaseStringUTFChars(version, cversion);
1872 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1873 return linphone_core_tunnel_available();
1876 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1877 LinphoneVideoPolicy vpol;
1878 vpol.automatically_initiate = autoInitiate;
1879 vpol.automatically_accept = autoAccept;
1880 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
1883 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
1884 ms_set_cpu_count(count);
1887 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
1888 jstring jvalue =env->NewStringUTF(linphone_core_get_version());