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/LinphoneAddress;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 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->addressClass,lcData->addressCtrId,(jlong)msg->from)
406 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
408 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
410 jint result = jvm->AttachCurrentThread(&env,NULL);
412 ms_error("cannot attach VM\n");
415 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
416 env->CallVoidMethod(lcData->listener
417 ,lcData->ecCalibrationStatusId
419 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
421 ,data ? data : NULL);
422 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
423 //final state, releasing global ref
424 env->DeleteGlobalRef((jobject)data);
431 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
435 ,jstring jfactoryConfig
438 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
439 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
440 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
443 libmsilbc_init(); // requires an fpu
457 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
461 //clear auth info list
462 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
463 //clear existing proxy config
464 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
466 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
467 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
470 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
473 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
474 linphone_core_destroy((LinphoneCore*)lc);
478 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
479 linphone_core_clear_proxy_config((LinphoneCore*)lc);
482 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
486 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
488 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
491 LinphoneProxyConfig *config=0;
492 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
493 return (jlong)config;
496 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
497 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
498 int proxyCount = ms_list_size(proxies);
499 jlongArray jProxies = env->NewLongArray(proxyCount);
500 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
502 for (int i = 0; i < proxyCount; i++ ) {
503 jInternalArray[i] = (unsigned long) (proxies->data);
504 proxies = proxies->next;
507 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
512 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
517 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
518 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
520 return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
523 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
524 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
527 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
528 linphone_core_refresh_registers((LinphoneCore*)lc);
531 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
535 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
537 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
540 linphone_core_iterate((LinphoneCore*)lc);
542 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
546 const char* uri = env->GetStringUTFChars(juri, NULL);
547 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
548 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
549 env->ReleaseStringUTFChars(juri, uri);
550 return lcd->getCall(env,lCall);
552 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
556 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
557 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
560 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
564 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
567 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
570 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
572 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
576 return linphone_core_in_call((LinphoneCore*)lc);
578 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
582 return linphone_core_inc_invite_pending((LinphoneCore*)lc);
584 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
589 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
592 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
597 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
600 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
605 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
608 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
612 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
615 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
619 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
621 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
624 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
626 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
629 ,jboolean isReachable) {
630 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
633 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
636 return linphone_core_is_network_reachable((LinphoneCore*)lc);
639 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
643 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
646 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
649 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
652 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
656 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
659 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
663 const char* url = env->GetStringUTFChars(jurl, NULL);
664 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
665 env->ReleaseStringUTFChars(jurl, url);
668 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
672 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
674 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
679 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
681 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
684 linphone_core_stop_dtmf((LinphoneCore*)lc);
687 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
690 linphone_core_get_missed_calls_count((LinphoneCore*)lc);
693 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
696 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
699 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
701 ,jlong lc, jlong log) {
702 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
705 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
708 linphone_core_clear_call_logs((LinphoneCore*)lc);
710 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
713 return linphone_core_is_mic_muted((LinphoneCore*)lc);
715 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
721 const char* mime = env->GetStringUTFChars(jmime, NULL);
722 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
723 env->ReleaseStringUTFChars(jmime, mime);
726 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
729 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
730 int codecsCount = ms_list_size(codecs);
731 jlongArray jCodecs = env->NewLongArray(codecsCount);
732 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
734 for (int i = 0; i < codecsCount; i++ ) {
735 jInternalArray[i] = (unsigned long) (codecs->data);
736 codecs = codecs->next;
739 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
744 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
747 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
748 int codecsCount = ms_list_size(codecs);
749 jlongArray jCodecs = env->NewLongArray(codecsCount);
750 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
752 for (int i = 0; i < codecsCount; i++ ) {
753 jInternalArray[i] = (unsigned long) (codecs->data);
754 codecs = codecs->next;
757 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
762 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
767 return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
769 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
773 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
775 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
779 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
781 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
785 return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
788 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
792 return linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
795 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
799 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
801 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
803 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
808 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
810 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
814 ,jstring jalternative_contact
816 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
817 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
818 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
821 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
826 const char* to = env->GetStringUTFChars(jto, NULL);
827 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
828 env->ReleaseStringUTFChars(jto, to);
829 return (long)lResult;
832 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
835 ,jboolean vcap_enabled
836 ,jboolean display_enabled) {
837 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
840 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
843 return linphone_core_video_enabled((LinphoneCore*)lc);
845 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
849 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
850 linphone_core_set_play_file((LinphoneCore*)lc,path);
851 if (path) env->ReleaseStringUTFChars(jpath, path);
853 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
857 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
858 linphone_core_set_ring((LinphoneCore*)lc,path);
859 if (path) env->ReleaseStringUTFChars(jpath, path);
861 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
865 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
867 return env->NewStringUTF(path);
872 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
876 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
877 linphone_core_set_root_ca((LinphoneCore*)lc,path);
878 if (path) env->ReleaseStringUTFChars(jpath, path);
880 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
884 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
887 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
890 return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
893 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
897 return linphone_core_start_echo_calibration((LinphoneCore*)lc
898 , LinphoneCoreData::ecCalibrationStatus
899 , data?env->NewGlobalRef(data):NULL);
903 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
907 return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
910 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
914 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
917 extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
921 return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
924 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
928 return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
931 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
935 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
938 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
942 return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
945 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
950 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
955 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
956 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
957 return (jlong) proxy;
960 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
961 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
963 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
964 const char* identity = env->GetStringUTFChars(jidentity, NULL);
965 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
966 env->ReleaseStringUTFChars(jidentity, identity);
968 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
969 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
971 return env->NewStringUTF(identity);
976 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
977 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
978 int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
979 env->ReleaseStringUTFChars(jproxy, proxy);
982 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
983 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
985 return env->NewStringUTF(proxy);
990 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
991 const char* params = env->GetStringUTFChars(jparams, NULL);
992 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
993 env->ReleaseStringUTFChars(jparams, params);
995 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
996 if (jroute != NULL) {
997 const char* route = env->GetStringUTFChars(jroute, NULL);
998 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
999 env->ReleaseStringUTFChars(jroute, route);
1002 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1005 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1006 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1008 return env->NewStringUTF(route);
1014 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1015 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1017 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1018 return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1020 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1021 return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1023 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1024 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1026 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1027 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1029 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1031 ms_error("cannot normalized null number");
1033 const char* number = env->GetStringUTFChars(jnumber, NULL);
1034 int len = env->GetStringLength(jnumber);
1036 ms_warning("cannot normalize empty number");
1039 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1040 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1041 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1042 env->ReleaseStringUTFChars(jnumber, number);
1043 return normalizedNumber;
1045 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1048 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1050 return env->NewStringUTF(domain);
1055 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1056 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1059 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1063 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1064 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1065 env->ReleaseStringUTFChars(jprefix, prefix);
1067 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1071 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1073 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1074 return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1079 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1087 const char* username = env->GetStringUTFChars(jusername, NULL);
1088 const char* password = env->GetStringUTFChars(jpassword, NULL);
1089 jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
1091 env->ReleaseStringUTFChars(jusername, username);
1092 env->ReleaseStringUTFChars(jpassword, password);
1096 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1099 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1104 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1107 ,jstring jdisplayName) {
1108 const char* uri = env->GetStringUTFChars(juri, NULL);
1109 LinphoneAddress* address = linphone_address_new(uri);
1110 if (jdisplayName && address) {
1111 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1112 linphone_address_set_display_name(address,displayName);
1113 env->ReleaseStringUTFChars(jdisplayName, displayName);
1115 env->ReleaseStringUTFChars(juri, uri);
1117 return (jlong) address;
1119 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1122 linphone_address_destroy((LinphoneAddress*)ptr);
1125 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1128 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1130 return env->NewStringUTF(displayName);
1135 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1138 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1140 return env->NewStringUTF(userName);
1145 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1148 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1150 return env->NewStringUTF(domain);
1156 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1159 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1160 jstring juri =env->NewStringUTF(uri);
1164 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1167 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1168 jstring juri =env->NewStringUTF(uri);
1172 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1175 ,jstring jdisplayName) {
1176 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1177 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1178 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1183 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1186 return (jlong)((LinphoneCallLog*)ptr)->from;
1188 extern "C" int Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1191 return (jlong)((LinphoneCallLog*)ptr)->status;
1193 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1196 return (jlong)((LinphoneCallLog*)ptr)->to;
1198 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1201 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1203 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1206 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1209 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1212 return ((LinphoneCallLog*)ptr)->duration;
1216 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1217 PayloadType* pt = (PayloadType*)ptr;
1218 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1219 ,payload_type_get_mime(pt)
1220 ,payload_type_get_rate(pt)
1221 ,payload_type_get_bitrate(pt));
1222 jstring jvalue =env->NewStringUTF(value);
1226 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1227 PayloadType* pt = (PayloadType*)ptr;
1228 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1231 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1232 PayloadType* pt = (PayloadType*)ptr;
1233 return payload_type_get_rate(pt);
1237 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1240 LinphoneCall *call=(LinphoneCall*)ptr;
1241 linphone_call_unref(call);
1244 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1247 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1250 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1252 ,jlong ptr, jstring path) {
1253 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1254 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1257 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1259 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1260 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1263 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1266 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1269 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1272 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1275 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1278 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1280 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1284 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1286 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1289 return linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1292 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1296 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1298 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1301 return linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1304 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1307 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1308 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1311 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1314 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1317 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1320 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1325 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1327 ,jstring jFriendUri) {
1328 LinphoneFriend* lResult;
1331 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1332 lResult= linphone_friend_new_with_addr(friendUri);
1333 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1335 lResult = linphone_friend_new();
1337 return (long)lResult;
1339 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1342 ,jlong linphoneAddress) {
1343 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1345 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1348 return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
1350 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1354 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1356 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1359 return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1361 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1365 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1367 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1370 return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1372 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1375 return linphone_friend_get_status((LinphoneFriend*)ptr);
1377 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1380 return linphone_friend_edit((LinphoneFriend*)ptr);
1382 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1385 linphone_friend_done((LinphoneFriend*)ptr);
1388 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1391 return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1393 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1396 ,jstring jmessage) {
1397 const char* message = env->GetStringUTFChars(jmessage, NULL);
1398 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1399 env->ReleaseStringUTFChars(jmessage, message);
1401 return (jlong) chatMessage;
1403 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1406 jobject ud = env->NewGlobalRef(thiz);
1407 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1409 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1412 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1415 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1418 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1421 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1425 const char* url = env->GetStringUTFChars(jurl, NULL);
1426 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1427 env->ReleaseStringUTFChars(jurl, url);
1429 extern "C" long Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1432 return (long) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1434 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1437 ,jstring jmessage) {
1438 const char* message = env->GetStringUTFChars(jmessage, NULL);
1439 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1440 env->ReleaseStringUTFChars(jmessage, message);
1443 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1445 jint result = jvm->AttachCurrentThread(&env,NULL);
1447 ms_error("cannot attach VM\n");
1451 jobject listener = (jobject) ud;
1452 jclass clazz = (jclass) env->GetObjectClass(listener);
1453 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1455 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1456 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1457 env->CallVoidMethod(
1460 (jobject)linphone_chat_message_get_user_data(msg),
1461 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1463 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1464 env->DeleteGlobalRef(listener);
1467 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1471 ,jobject jlistener) {
1472 jobject listener = env->NewGlobalRef(jlistener);
1473 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1475 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1479 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1480 if (oldWindow != NULL) {
1481 env->DeleteGlobalRef(oldWindow);
1484 obj = env->NewGlobalRef(obj);
1486 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1489 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1493 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1494 if (oldWindow != NULL) {
1495 env->DeleteGlobalRef(oldWindow);
1498 obj = env->NewGlobalRef(obj);
1500 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1503 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1507 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1511 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
1512 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1515 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1516 return linphone_core_get_firewall_policy((LinphoneCore*)lc);
1519 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1520 const char* server = NULL;
1521 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1522 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1523 if (server) env->ReleaseStringUTFChars(jserver,server);
1526 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1527 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1528 if (ret==NULL) return NULL;
1529 jstring jvalue =env->NewStringUTF(ret);
1533 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1534 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1537 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1538 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1541 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1542 return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1545 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1546 return linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1549 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1550 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1552 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1553 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1556 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1557 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1560 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1561 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1564 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1565 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1568 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1569 linphone_call_camera_enabled((LinphoneCall *)lc);
1572 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1573 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1574 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1577 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1578 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1581 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1582 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1586 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1588 vsize.width = (int)width;
1589 vsize.height = (int)height;
1590 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1593 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1594 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1595 jintArray arr = env->NewIntArray(2);
1596 int tVsize [2]= {vsize.width,vsize.height};
1597 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1601 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1602 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1605 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1606 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1609 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1610 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1613 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1614 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1617 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1618 return (int) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1620 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1621 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1624 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1625 linphone_call_get_duration((LinphoneCall *) ptr);
1628 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1630 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1643 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1644 LinphoneCore *lc = (LinphoneCore *) ptr;
1650 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1653 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1654 ,jlong lc, jboolean enable) {
1655 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1658 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1659 ,jlong ptr, jint db) {
1660 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1663 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1664 return linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1666 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1667 return linphone_core_pause_all_calls((LinphoneCore *) pCore);
1669 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1670 return linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1672 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1673 return linphone_core_is_in_conference((LinphoneCore *) pCore);
1675 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1676 return 0 == linphone_core_enter_conference((LinphoneCore *) pCore);
1678 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1679 linphone_core_leave_conference((LinphoneCore *) pCore);
1681 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1682 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1684 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1685 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1687 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1688 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1691 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1692 linphone_core_terminate_conference((LinphoneCore *) pCore);
1694 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1695 return linphone_core_get_conference_size((LinphoneCore *) pCore);
1697 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1698 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1700 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1701 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1702 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1703 return lcd->getCall(env,lCall);
1705 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1706 return ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
1709 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
1710 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
1711 linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
1712 env->ReleaseStringUTFChars(jReferTo, cReferTo);
1714 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
1715 linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
1718 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
1720 const char* cFile=env->GetStringUTFChars(jFile, NULL);
1721 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
1722 env->ReleaseStringUTFChars(jFile, cFile);
1724 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
1728 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
1729 const char* cUri=env->GetStringUTFChars(jUri, NULL);
1730 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
1731 env->ReleaseStringUTFChars(jUri, cUri);
1732 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1733 return (jobject) lcdata->getCall(env,call);
1737 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
1738 LinphoneCore* lc = (LinphoneCore *) pCore;
1739 const char** devices = linphone_core_get_video_devices(lc);
1740 if (devices == NULL) {
1741 ms_error("No existing video devices\n");
1745 for(i=0; i<=id; i++) {
1746 if (devices[i] == NULL)
1748 ms_message("Existing device %d : %s\n", i, devices[i]);
1750 return linphone_core_set_video_device(lc, devices[i]);
1756 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
1757 LinphoneCore* lc = (LinphoneCore *) pCore;
1758 const char** devices = linphone_core_get_video_devices(lc);
1759 if (devices == NULL) {
1760 ms_error("No existing video devices\n");
1763 const char* cam = linphone_core_get_video_device(lc);
1765 ms_error("No current video device\n");
1768 while(devices[i] != NULL) {
1769 if (strcmp(devices[i], cam) == 0)
1774 ms_warning("Returning default (0) device\n");
1778 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
1779 LinphoneCall *call = (LinphoneCall *) ptr;
1780 const char* token = linphone_call_get_authentication_token(call);
1781 if (token == NULL) return NULL;
1782 return env->NewStringUTF(token);
1784 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
1785 LinphoneCall *call = (LinphoneCall *) ptr;
1786 return linphone_call_get_authentication_token_verified(call);
1788 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
1789 LinphoneCall *call = (LinphoneCall *) ptr;
1790 linphone_call_set_authentication_token_verified(call, verified);
1793 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
1794 LinphoneCall *call = (LinphoneCall *) ptr;
1795 return linphone_call_get_play_volume(call);
1798 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
1799 return linphone_core_sound_resources_locked((LinphoneCore *) ptr);
1802 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
1803 // Implemented directly in msandroid.cpp (sound filters for Android).
1804 extern "C" void msandroid_hack_speaker_state(bool speakerOn);
1806 extern "C" void Java_org_linphone_LinphoneManager_hackSpeakerState(JNIEnv* env,jobject thiz,jboolean speakerOn){
1807 msandroid_hack_speaker_state(speakerOn);
1809 // End Galaxy S hack functions
1812 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1813 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
1815 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
1816 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
1819 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
1820 jstring jHost, jint port, jint mirror, jint delay) {
1821 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1822 if (!tunnel) return;
1823 const char* cHost=env->GetStringUTFChars(jHost, NULL);
1824 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
1825 env->ReleaseStringUTFChars(jHost, cHost);
1828 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
1829 jstring jHost, jint port, jstring username, jstring password) {
1831 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
1832 if (!tunnel) return;
1833 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
1834 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
1835 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
1836 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
1837 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
1838 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
1839 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
1843 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
1844 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1845 linphone_tunnel_auto_detect(tunnel);
1849 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
1850 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1851 linphone_tunnel_clean_servers(tunnel);
1854 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
1855 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
1856 linphone_tunnel_enable(tunnel, enable);
1860 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
1861 const char* cname=env->GetStringUTFChars(name, NULL);
1862 const char* cversion=env->GetStringUTFChars(version, NULL);
1863 linphone_core_set_user_agent(cname,cversion);
1864 env->ReleaseStringUTFChars(name, cname);
1865 env->ReleaseStringUTFChars(version, cversion);
1868 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
1869 return linphone_core_tunnel_available();
1872 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
1873 LinphoneVideoPolicy vpol;
1874 vpol.automatically_initiate = autoInitiate;
1875 vpol.automatically_accept = autoAccept;
1876 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
1879 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
1880 ms_set_cpu_count(count);
1883 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
1884 jstring jvalue =env->NewStringUTF(linphone_core_get_version());