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.
21 #include "linphonecore_jni.h"
23 #include "linphonecore_utils.h"
24 #include <ortp/zrtp.h>
27 #include "linphone_tunnel.h"
31 #include "mediastreamer2/mediastream.h"
33 #include "mediastreamer2/msjava.h"
35 #include <cpu-features.h>
38 #include <android/log.h>
39 extern "C" void libmsilbc_init();
41 extern "C" void libmsx264_init();
44 extern "C" void libmsamr_init();
47 extern "C" void libmssilk_init();
50 extern "C" void libmsbcg729_init();
55 static const char* LogDomain = "Linphone";
58 void linphone_android_log_handler(int prio, const char *fmt, va_list args) {
63 vsnprintf(str, sizeof(str) - 1, fmt, args);
64 str[sizeof(str) - 1] = '\0';
65 if (strlen(str) < 512) {
66 __android_log_write(prio, LogDomain, str);
69 while ((next = strchr(current, '\n')) != NULL) {
71 __android_log_write(prio, LogDomain, current);
74 __android_log_write(prio, LogDomain, current);
78 static void linphone_android_ortp_log_handler(OrtpLogLevel lev, const char *fmt, va_list args) {
81 case ORTP_DEBUG: prio = ANDROID_LOG_DEBUG; break;
82 case ORTP_MESSAGE: prio = ANDROID_LOG_INFO; break;
83 case ORTP_WARNING: prio = ANDROID_LOG_WARN; break;
84 case ORTP_ERROR: prio = ANDROID_LOG_ERROR; break;
85 case ORTP_FATAL: prio = ANDROID_LOG_FATAL; break;
86 default: prio = ANDROID_LOG_DEFAULT; break;
88 linphone_android_log_handler(prio, fmt, args);
91 int dumbMethodForAllowingUsageOfCpuFeaturesFromStaticLibMediastream() {
92 return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0);
96 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved)
102 return JNI_VERSION_1_2;
107 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env
110 ,jstring jdebugTag) {
112 LogDomain = env->GetStringUTFChars(jdebugTag, NULL);
113 linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler);
115 linphone_core_disable_logs();
120 class LinphoneCoreData {
122 LinphoneCoreData(JNIEnv* env, jobject lc,jobject alistener, jobject auserdata) {
124 core = env->NewGlobalRef(lc);
125 listener = env->NewGlobalRef(alistener);
126 userdata = auserdata?env->NewGlobalRef(auserdata):0;
127 memset(&vTable,0,sizeof(vTable));
128 vTable.show = showInterfaceCb;
129 vTable.auth_info_requested = authInfoRequested;
130 vTable.display_status = displayStatusCb;
131 vTable.display_message = displayMessageCb;
132 vTable.display_warning = displayMessageCb;
133 vTable.global_state_changed = globalStateChange;
134 vTable.registration_state_changed = registrationStateChange;
135 vTable.call_state_changed = callStateChange;
136 vTable.call_encryption_changed = callEncryptionChange;
137 vTable.text_received = text_received;
138 vTable.message_received = message_received;
139 vTable.dtmf_received = dtmf_received;
140 vTable.new_subscription_request = new_subscription_request;
141 vTable.notify_presence_recv = notify_presence_recv;
142 vTable.call_stats_updated = callStatsUpdated;
144 listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
146 /*displayStatus(LinphoneCore lc,String message);*/
147 displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
149 /*void generalState(LinphoneCore lc,int state); */
150 globalStateId = env->GetMethodID(listenerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
151 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
152 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
154 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
155 registrationStateId = env->GetMethodID(listenerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
156 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
157 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
159 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
160 callStateId = env->GetMethodID(listenerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
161 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
162 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
164 /*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
165 callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
167 chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
168 chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
170 /*callEncryption(LinphoneCore lc, LinphoneCall call, boolean encrypted,String auth_token);*/
171 callEncryptionChangedId=env->GetMethodID(listenerClass,"callEncryptionChanged","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;ZLjava/lang/String;)V");
173 /*void ecCalibrationStatus(LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);*/
174 ecCalibrationStatusId = env->GetMethodID(listenerClass,"ecCalibrationStatus","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;ILjava/lang/Object;)V");
175 ecCalibratorStatusClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$EcCalibratorStatus"));
176 ecCalibratorStatusFromIntId = env->GetStaticMethodID(ecCalibratorStatusClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$EcCalibratorStatus;");
178 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
179 newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
181 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
182 notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
184 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
185 textReceivedId = env->GetMethodID(listenerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
186 messageReceivedId = env->GetMethodID(listenerClass,"messageReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneChatMessage;)V");
187 dtmfReceivedId = env->GetMethodID(listenerClass,"dtmfReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;I)V");
189 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
190 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
192 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
193 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
195 chatMessageClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessageImpl"));
196 if (chatMessageClass) chatMessageCtrId = env->GetMethodID(chatMessageClass,"<init>", "(J)V");
198 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
199 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
201 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
202 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
204 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
205 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
207 callStatsClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallStatsImpl"));
208 callStatsId = env->GetMethodID(callStatsClass, "<init>", "(JJ)V");
209 callSetAudioStatsId = env->GetMethodID(callClass, "setAudioStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
210 callSetVideoStatsId = env->GetMethodID(callClass, "setVideoStats", "(Lorg/linphone/core/LinphoneCallStats;)V");
213 ~LinphoneCoreData() {
215 jvm->AttachCurrentThread(&env,NULL);
216 env->DeleteGlobalRef(core);
217 env->DeleteGlobalRef(listener);
218 if (userdata) env->DeleteGlobalRef(userdata);
219 env->DeleteGlobalRef(listenerClass);
220 env->DeleteGlobalRef(globalStateClass);
221 env->DeleteGlobalRef(registrationStateClass);
222 env->DeleteGlobalRef(callStateClass);
223 env->DeleteGlobalRef(callStatsClass);
224 env->DeleteGlobalRef(chatMessageStateClass);
225 env->DeleteGlobalRef(proxyClass);
226 env->DeleteGlobalRef(callClass);
227 env->DeleteGlobalRef(chatMessageClass);
228 env->DeleteGlobalRef(chatRoomClass);
229 env->DeleteGlobalRef(friendClass);
236 jclass listenerClass;
237 jmethodID displayStatusId;
238 jmethodID newSubscriptionRequestId;
239 jmethodID notifyPresenceReceivedId;
240 jmethodID textReceivedId;
241 jmethodID messageReceivedId;
242 jmethodID dtmfReceivedId;
243 jmethodID callStatsUpdatedId;
245 jclass globalStateClass;
246 jmethodID globalStateId;
247 jmethodID globalStateFromIntId;
249 jclass registrationStateClass;
250 jmethodID registrationStateId;
251 jmethodID registrationStateFromIntId;
253 jclass callStateClass;
254 jmethodID callStateId;
255 jmethodID callStateFromIntId;
257 jclass callStatsClass;
258 jmethodID callStatsId;
259 jmethodID callSetAudioStatsId;
260 jmethodID callSetVideoStatsId;
262 jclass chatMessageStateClass;
263 jmethodID chatMessageStateFromIntId;
265 jmethodID callEncryptionChangedId;
267 jclass ecCalibratorStatusClass;
268 jmethodID ecCalibrationStatusId;
269 jmethodID ecCalibratorStatusFromIntId;
272 jmethodID proxyCtrId;
277 jclass chatMessageClass;
278 jmethodID chatMessageCtrId;
280 jclass chatRoomClass;
281 jmethodID chatRoomCtrId;
284 jmethodID friendCtrId;
287 jmethodID addressCtrId;
289 LinphoneCoreVTable vTable;
291 static void showInterfaceCb(LinphoneCore *lc) {
294 static void byeReceivedCb(LinphoneCore *lc, const char *from) {
297 static void displayStatusCb(LinphoneCore *lc, const char *message) {
299 jint result = jvm->AttachCurrentThread(&env,NULL);
301 ms_error("cannot attach VM\n");
304 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
305 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL);
307 static void displayMessageCb(LinphoneCore *lc, const char *message) {
310 static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
313 static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
315 jint result = jvm->AttachCurrentThread(&env,NULL);
317 ms_error("cannot attach VM\n");
320 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
321 env->CallVoidMethod(lcData->listener
322 ,lcData->globalStateId
324 ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
325 message ? env->NewStringUTF(message) : NULL);
327 static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
329 jint result = jvm->AttachCurrentThread(&env,NULL);
331 ms_error("cannot attach VM\n");
334 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
335 env->CallVoidMethod(lcData->listener
336 ,lcData->registrationStateId
338 ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
339 ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
340 message ? env->NewStringUTF(message) : NULL);
342 jobject getCall(JNIEnv *env , LinphoneCall *call){
346 void *up=linphone_call_get_user_pointer(call);
349 jobj=env->NewObject(callClass,callCtrId,(jlong)call);
350 jobj=env->NewGlobalRef(jobj);
351 linphone_call_set_user_pointer(call,(void*)jobj);
352 linphone_call_ref(call);
360 static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
362 jint result = jvm->AttachCurrentThread(&env,NULL);
365 ms_error("cannot attach VM\n");
368 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
369 env->CallVoidMethod(lcData->listener
372 ,(jcall=lcData->getCall(env,call))
373 ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
374 message ? env->NewStringUTF(message) : NULL);
375 if (state==LinphoneCallReleased){
376 linphone_call_set_user_pointer(call,NULL);
377 env->DeleteGlobalRef(jcall);
380 static void callEncryptionChange(LinphoneCore *lc, LinphoneCall* call, bool_t encrypted,const char* authentication_token) {
382 jint result = jvm->AttachCurrentThread(&env,NULL);
384 ms_error("cannot attach VM\n");
387 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
388 env->CallVoidMethod(lcData->listener
389 ,lcData->callEncryptionChangedId
391 ,lcData->getCall(env,call)
393 ,authentication_token ? env->NewStringUTF(authentication_token) : NULL);
395 static void notify_presence_recv (LinphoneCore *lc, LinphoneFriend *my_friend) {
397 jint result = jvm->AttachCurrentThread(&env,NULL);
399 ms_error("cannot attach VM\n");
402 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
403 env->CallVoidMethod(lcData->listener
404 ,lcData->notifyPresenceReceivedId
406 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
408 static void new_subscription_request (LinphoneCore *lc, LinphoneFriend *my_friend, const char* url) {
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->newSubscriptionRequestId
419 ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
420 ,url ? env->NewStringUTF(url) : NULL);
422 static void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
424 jint result = jvm->AttachCurrentThread(&env,NULL);
426 ms_error("cannot attach VM\n");
429 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
430 env->CallVoidMethod(lcData->listener
431 ,lcData->dtmfReceivedId
433 ,lcData->getCall(env,call)
436 static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
438 jint result = jvm->AttachCurrentThread(&env,NULL);
440 ms_error("cannot attach VM\n");
443 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
444 env->CallVoidMethod(lcData->listener
445 ,lcData->textReceivedId
447 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
448 ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
449 ,message ? env->NewStringUTF(message) : NULL);
451 static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) {
453 jint result = jvm->AttachCurrentThread(&env,NULL);
455 ms_error("cannot attach VM\n");
458 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
459 env->CallVoidMethod(lcData->listener
460 ,lcData->messageReceivedId
462 ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
463 ,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
465 static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
467 jint result = jvm->AttachCurrentThread(&env,NULL);
469 ms_error("cannot attach VM\n");
472 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
473 env->CallVoidMethod(lcData->listener
474 ,lcData->ecCalibrationStatusId
476 ,env->CallStaticObjectMethod(lcData->ecCalibratorStatusClass,lcData->ecCalibratorStatusFromIntId,(jint)status)
478 ,data ? data : NULL);
479 if (data != NULL &&status !=LinphoneEcCalibratorInProgress ) {
480 //final state, releasing global ref
481 env->DeleteGlobalRef((jobject)data);
485 static void callStatsUpdated(LinphoneCore *lc, LinphoneCall* call, const LinphoneCallStats *stats) {
489 jint result = jvm->AttachCurrentThread(&env,NULL);
491 ms_error("cannot attach VM\n");
494 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
495 statsobj = env->NewObject(lcData->callStatsClass, lcData->callStatsId, (jlong)call, (jlong)stats);
496 callobj = lcData->getCall(env, call);
497 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
498 env->CallVoidMethod(callobj, lcData->callSetAudioStatsId, statsobj);
500 env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
501 env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
506 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
510 ,jstring jfactoryConfig
513 const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
514 const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
515 LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
518 libmsilbc_init(); // requires an fpu
532 jlong nativePtr = (jlong)linphone_core_new( &ldata->vTable
536 //clear auth info list
537 linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
538 //clear existing proxy config
539 linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
541 if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
542 if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
548 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
549 linphone_core_destroy((LinphoneCore*)lc);
553 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) {
554 const char* displayname = env->GetStringUTFChars(jdisplayname, NULL);
555 const char* username = env->GetStringUTFChars(jusername, NULL);
557 LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc);
558 if (parsed != NULL) {
559 linphone_address_set_display_name(parsed, displayname);
560 linphone_address_set_username(parsed, username);
561 char *contact = linphone_address_as_string(parsed);
562 linphone_core_set_primary_contact((LinphoneCore*)lc, contact);
565 env->ReleaseStringUTFChars(jdisplayname, displayname);
566 env->ReleaseStringUTFChars(jusername, username);
569 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
570 linphone_core_clear_proxy_config((LinphoneCore*)lc);
573 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig( JNIEnv* env
577 linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
579 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv* env
582 LinphoneProxyConfig *config=0;
583 linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
584 return (jlong)config;
587 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
588 const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
589 int proxyCount = ms_list_size(proxies);
590 jlongArray jProxies = env->NewLongArray(proxyCount);
591 jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
593 for (int i = 0; i < proxyCount; i++ ) {
594 jInternalArray[i] = (unsigned long) (proxies->data);
595 proxies = proxies->next;
598 env->ReleaseLongArrayElements(jProxies, jInternalArray, 0);
603 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig( JNIEnv* env
608 LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
609 linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
611 return (jint)linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
614 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
615 linphone_core_clear_all_auth_info((LinphoneCore*)lc);
618 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) {
619 linphone_core_refresh_registers((LinphoneCore*)lc);
622 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env
626 linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
628 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate( JNIEnv* env
631 linphone_core_iterate((LinphoneCore*)lc);
633 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite( JNIEnv* env
637 const char* uri = env->GetStringUTFChars(juri, NULL);
638 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
639 LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
640 env->ReleaseStringUTFChars(juri, uri);
641 return lcd->getCall(env,lCall);
643 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv* env
647 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
648 return lcd->getCall(env, linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to));
651 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall( JNIEnv* env
655 linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
658 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress( JNIEnv* env
661 return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
663 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall( JNIEnv* env
667 return (jboolean)linphone_core_in_call((LinphoneCore*)lc);
669 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending( JNIEnv* env
673 return (jboolean)linphone_core_inc_invite_pending((LinphoneCore*)lc);
675 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall( JNIEnv* env
680 linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
683 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallWithParams(JNIEnv *env,
688 linphone_core_accept_call_with_params((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
691 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCallUpdate(JNIEnv *env,
696 linphone_core_accept_call_update((LinphoneCore*)lc,(LinphoneCall*)call, (LinphoneCallParams*)params);
699 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_deferCallUpdate(JNIEnv *env,
703 linphone_core_defer_call_update((LinphoneCore*)lc,(LinphoneCall*)call);
706 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog( JNIEnv* env
710 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
712 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs( JNIEnv* env
715 return (jint)ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
717 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable( JNIEnv* env
720 ,jboolean isReachable) {
721 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
724 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env
727 return (jboolean)linphone_core_is_network_reachable((LinphoneCore*)lc);
730 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMicrophoneGain(JNIEnv* env
734 linphone_core_set_mic_gain_db((LinphoneCore*)lc,gain);
737 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env
741 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
744 extern "C" jfloat Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain( JNIEnv* env
747 return (jfloat)linphone_core_get_playback_gain_db((LinphoneCore*)lc);
750 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic( JNIEnv* env
754 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
757 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* env
761 const char* url = env->GetStringUTFChars(jurl, NULL);
762 jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
763 env->ReleaseStringUTFChars(jurl, url);
766 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env
770 linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
772 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf( JNIEnv* env
777 linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
779 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf( JNIEnv* env
782 linphone_core_stop_dtmf((LinphoneCore*)lc);
785 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMissedCallsCount(JNIEnv* env
788 return (jint)linphone_core_get_missed_calls_count((LinphoneCore*)lc);
791 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JNIEnv* env
794 linphone_core_reset_missed_calls_count((LinphoneCore*)lc);
797 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env
799 ,jlong lc, jlong log) {
800 linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log);
803 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env
806 linphone_core_clear_call_logs((LinphoneCore*)lc);
808 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv* env
811 return (jboolean)linphone_core_is_mic_muted((LinphoneCore*)lc);
813 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* env
819 const char* mime = env->GetStringUTFChars(jmime, NULL);
820 jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels);
821 env->ReleaseStringUTFChars(jmime, mime);
824 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTypes(JNIEnv* env
827 const MSList* codecs = linphone_core_get_video_codecs((LinphoneCore*)lc);
828 int codecsCount = ms_list_size(codecs);
829 jlongArray jCodecs = env->NewLongArray(codecsCount);
830 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
832 for (int i = 0; i < codecsCount; i++ ) {
833 jInternalArray[i] = (unsigned long) (codecs->data);
834 codecs = codecs->next;
837 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
842 extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listAudioPayloadTypes(JNIEnv* env
845 const MSList* codecs = linphone_core_get_audio_codecs((LinphoneCore*)lc);
846 int codecsCount = ms_list_size(codecs);
847 jlongArray jCodecs = env->NewLongArray(codecsCount);
848 jlong *jInternalArray = env->GetLongArrayElements(jCodecs, NULL);
850 for (int i = 0; i < codecsCount; i++ ) {
851 jInternalArray[i] = (unsigned long) (codecs->data);
852 codecs = codecs->next;
855 env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
860 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv* env
865 return (jint)linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
867 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv* env
871 linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
873 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoLimiter(JNIEnv* env
877 linphone_core_enable_echo_limiter((LinphoneCore*)lc,enable);
879 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv* env
883 return (jboolean)linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
886 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoLimiterEnabled(JNIEnv* env
890 return (jboolean)linphone_core_echo_limiter_enabled((LinphoneCore*)lc);
893 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv* env
897 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
899 return lcdata->getCall(env,linphone_core_get_current_call((LinphoneCore*)lc));
901 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env
906 linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
908 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* env
912 ,jstring jalternative_contact
914 const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
915 linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
916 if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
919 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv* env
924 const char* to = env->GetStringUTFChars(jto, NULL);
925 LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
926 env->ReleaseStringUTFChars(jto, to);
927 return (jlong)lResult;
930 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv* env
933 ,jboolean vcap_enabled
934 ,jboolean display_enabled) {
935 linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
938 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv* env
941 return (jboolean)linphone_core_video_enabled((LinphoneCore*)lc);
943 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env
947 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
948 linphone_core_set_play_file((LinphoneCore*)lc,path);
949 if (path) env->ReleaseStringUTFChars(jpath, path);
951 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env
955 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
956 linphone_core_set_ring((LinphoneCore*)lc,path);
957 if (path) env->ReleaseStringUTFChars(jpath, path);
959 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env
963 const char* path = linphone_core_get_ring((LinphoneCore*)lc);
965 return env->NewStringUTF(path);
970 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env
974 const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
975 linphone_core_set_root_ca((LinphoneCore*)lc,path);
976 if (path) env->ReleaseStringUTFChars(jpath, path);
978 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv* env
982 linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
985 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv* env
988 return (jboolean)linphone_core_keep_alive_enabled((LinphoneCore*)lc);
991 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNIEnv* env
995 return (jint)linphone_core_start_echo_calibration((LinphoneCore*)lc
996 , LinphoneCoreData::ecCalibrationStatus
997 , data?env->NewGlobalRef(data):NULL);
1001 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
1005 return (jint)linphone_core_get_media_encryption((LinphoneCore*)lc);
1008 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
1012 linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1015 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
1017 ,jlong lc, jint menc
1019 return (jboolean)linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
1022 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMediaEncryptionMandatory(JNIEnv* env
1026 return (jboolean)linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
1029 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
1034 linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
1039 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv* env,jobject thiz) {
1040 LinphoneProxyConfig* proxy = linphone_proxy_config_new();
1041 return (jlong) proxy;
1044 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv* env,jobject thiz,jlong ptr) {
1045 linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
1047 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
1048 const char* identity = env->GetStringUTFChars(jidentity, NULL);
1049 linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
1050 env->ReleaseStringUTFChars(jidentity, identity);
1052 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1053 const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
1055 return env->NewStringUTF(identity);
1060 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
1061 const char* proxy = env->GetStringUTFChars(jproxy, NULL);
1062 jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
1063 env->ReleaseStringUTFChars(jproxy, proxy);
1066 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1067 const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
1069 return env->NewStringUTF(proxy);
1074 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) {
1075 const char* params = env->GetStringUTFChars(jparams, NULL);
1076 linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params);
1077 env->ReleaseStringUTFChars(jparams, params);
1079 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
1080 if (jroute != NULL) {
1081 const char* route = env->GetStringUTFChars(jroute, NULL);
1082 jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
1083 env->ReleaseStringUTFChars(jroute, route);
1086 return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
1089 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1090 const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
1092 return env->NewStringUTF(route);
1098 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
1099 linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
1101 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1102 return (jboolean)linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
1104 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1105 return (jboolean)linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
1107 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1108 linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
1110 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1111 linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
1113 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
1115 ms_error("cannot normalized null number");
1117 const char* number = env->GetStringUTFChars(jnumber, NULL);
1118 int len = env->GetStringLength(jnumber);
1120 ms_warning("cannot normalize empty number");
1123 char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
1124 linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
1125 jstring normalizedNumber = env->NewStringUTF(targetBuff);
1126 env->ReleaseStringUTFChars(jnumber, number);
1127 return normalizedNumber;
1129 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) {
1130 const char* iso = env->GetStringUTFChars(jiso, NULL);
1131 int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso);
1132 env->ReleaseStringUTFChars(jiso, iso);
1133 return (jint) prefix;
1135 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
1138 const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
1140 return env->NewStringUTF(domain);
1145 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
1146 linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
1149 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
1153 const char* prefix = env->GetStringUTFChars(jprefix, NULL);
1154 linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
1155 env->ReleaseStringUTFChars(jprefix, prefix);
1157 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
1161 linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
1163 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
1164 return (jboolean)linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
1169 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
1177 const char* username = env->GetStringUTFChars(jusername, NULL);
1178 const char* userid = env->GetStringUTFChars(juserid, NULL);
1179 const char* password = env->GetStringUTFChars(jpassword, NULL);
1180 const char* ha1 = env->GetStringUTFChars(jha1, NULL);
1181 const char* realm = env->GetStringUTFChars(jrealm, NULL);
1182 jlong auth = (jlong)linphone_auth_info_new(username,userid,password,ha1,realm);
1184 env->ReleaseStringUTFChars(jusername, username);
1185 env->ReleaseStringUTFChars(juserid, userid);
1186 env->ReleaseStringUTFChars(jpassword, password);
1187 env->ReleaseStringUTFChars(jha1, ha1);
1188 env->ReleaseStringUTFChars(jrealm, realm);
1192 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
1195 linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
1200 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv* env
1203 ,jstring jdisplayName) {
1204 const char* uri = env->GetStringUTFChars(juri, NULL);
1205 LinphoneAddress* address = linphone_address_new(uri);
1206 if (jdisplayName && address) {
1207 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
1208 linphone_address_set_display_name(address,displayName);
1209 env->ReleaseStringUTFChars(jdisplayName, displayName);
1211 env->ReleaseStringUTFChars(juri, uri);
1213 return (jlong) address;
1215 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv* env
1218 linphone_address_destroy((LinphoneAddress*)ptr);
1221 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv* env
1224 const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
1226 return env->NewStringUTF(displayName);
1231 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv* env
1234 const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
1236 return env->NewStringUTF(userName);
1241 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv* env
1244 const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
1246 return env->NewStringUTF(domain);
1252 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv* env
1255 char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
1256 jstring juri =env->NewStringUTF(uri);
1260 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv* env
1263 char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
1264 jstring juri =env->NewStringUTF(uri);
1268 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv* env
1271 ,jstring jdisplayName) {
1272 const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
1273 linphone_address_set_display_name((LinphoneAddress*)address,displayName);
1274 if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
1279 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv* env
1282 return (jlong)((LinphoneCallLog*)ptr)->from;
1284 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getStatus(JNIEnv* env
1287 return (jint)((LinphoneCallLog*)ptr)->status;
1289 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv* env
1292 return (jlong)((LinphoneCallLog*)ptr)->to;
1294 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv* env
1297 return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1299 extern "C" jstring Java_org_linphone_core_LinphoneCallLogImpl_getStartDate(JNIEnv* env
1302 jstring jvalue =env->NewStringUTF(((LinphoneCallLog*)ptr)->start_date);
1305 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTimestamp(JNIEnv* env
1308 return static_cast<long> (((LinphoneCallLog*)ptr)->start_date_time);
1310 extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEnv* env
1313 return (jint)((LinphoneCallLog*)ptr)->duration;
1317 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1318 return (jint)((LinphoneCallStats *)stats_ptr)->type;
1320 extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getIceState(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1321 return (jint)((LinphoneCallStats *)stats_ptr)->ice_state;
1323 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1324 return (jfloat)((LinphoneCallStats *)stats_ptr)->download_bandwidth;
1326 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1327 return (jfloat)((LinphoneCallStats *)stats_ptr)->upload_bandwidth;
1329 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1330 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1331 const report_block_t *srb = NULL;
1333 if (!stats || !stats->sent_rtcp)
1335 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1336 if (stats->sent_rtcp->b_cont != NULL)
1337 msgpullup(stats->sent_rtcp, -1);
1338 if (rtcp_is_SR(stats->sent_rtcp))
1339 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1340 else if (rtcp_is_RR(stats->sent_rtcp))
1341 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1344 return (jfloat)(100.0 * report_block_get_fraction_lost(srb) / 256.0);
1346 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverLossRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1347 const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1348 const report_block_t *rrb = NULL;
1350 if (!stats || !stats->received_rtcp)
1352 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1353 if (stats->received_rtcp->b_cont != NULL)
1354 msgpullup(stats->received_rtcp, -1);
1355 if (rtcp_is_RR(stats->received_rtcp))
1356 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1357 else if (rtcp_is_SR(stats->received_rtcp))
1358 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1361 return (jfloat)(100.0 * report_block_get_fraction_lost(rrb) / 256.0);
1363 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getSenderInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1364 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1365 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1366 const LinphoneCallParams *params;
1367 const PayloadType *pt;
1368 const report_block_t *srb = NULL;
1370 if (!stats || !call || !stats->sent_rtcp)
1372 params = linphone_call_get_current_params(call);
1375 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1376 if (stats->sent_rtcp->b_cont != NULL)
1377 msgpullup(stats->sent_rtcp, -1);
1378 if (rtcp_is_SR(stats->sent_rtcp))
1379 srb = rtcp_SR_get_report_block(stats->sent_rtcp, 0);
1380 else if (rtcp_is_RR(stats->sent_rtcp))
1381 srb = rtcp_RR_get_report_block(stats->sent_rtcp, 0);
1384 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1385 pt = linphone_call_params_get_used_audio_codec(params);
1387 pt = linphone_call_params_get_used_video_codec(params);
1388 if (!pt || (pt->clock_rate == 0))
1390 return (jfloat)((float)report_block_get_interarrival_jitter(srb) / (float)pt->clock_rate);
1392 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getReceiverInterarrivalJitter(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1393 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1394 const LinphoneCall *call = (LinphoneCall *)call_ptr;
1395 const LinphoneCallParams *params;
1396 const PayloadType *pt;
1397 const report_block_t *rrb = NULL;
1399 if (!stats || !call || !stats->received_rtcp)
1401 params = linphone_call_get_current_params(call);
1404 /* Perform msgpullup() to prevent crashes in rtcp_is_SR() or rtcp_is_RR() if the RTCP packet is composed of several mblk_t structure */
1405 if (stats->received_rtcp->b_cont != NULL)
1406 msgpullup(stats->received_rtcp, -1);
1407 if (rtcp_is_SR(stats->received_rtcp))
1408 rrb = rtcp_SR_get_report_block(stats->received_rtcp, 0);
1409 else if (rtcp_is_RR(stats->received_rtcp))
1410 rrb = rtcp_RR_get_report_block(stats->received_rtcp, 0);
1413 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1414 pt = linphone_call_params_get_used_audio_codec(params);
1416 pt = linphone_call_params_get_used_video_codec(params);
1417 if (!pt || (pt->clock_rate == 0))
1419 return (jfloat)((float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate);
1421 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getRoundTripDelay(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1422 return (jfloat)((LinphoneCallStats *)stats_ptr)->round_trip_delay;
1424 extern "C" jlong Java_org_linphone_core_LinphoneCallStatsImpl_getLatePacketsCumulativeNumber(JNIEnv *env, jobject thiz, jlong stats_ptr, jlong call_ptr) {
1425 LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
1426 LinphoneCall *call = (LinphoneCall *)call_ptr;
1427 rtp_stats_t rtp_stats;
1429 if (!stats || !call)
1431 memset(&rtp_stats, 0, sizeof(rtp_stats));
1432 if (stats->type == LINPHONE_CALL_STATS_AUDIO)
1433 audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats);
1434 #ifdef VIDEO_ENABLED
1436 video_stream_get_local_rtp_stats(call->videostream, &rtp_stats);
1438 return (jlong)rtp_stats.outoftime;
1440 extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSize(JNIEnv *env, jobject thiz, jlong stats_ptr) {
1441 return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
1445 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv* env,jobject thiz,jlong ptr) {
1446 PayloadType* pt = (PayloadType*)ptr;
1447 char* value = ms_strdup_printf("[%s] clock [%i], bitrate [%i]"
1448 ,payload_type_get_mime(pt)
1449 ,payload_type_get_rate(pt)
1450 ,payload_type_get_bitrate(pt));
1451 jstring jvalue =env->NewStringUTF(value);
1455 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_getMime(JNIEnv* env,jobject thiz,jlong ptr) {
1456 PayloadType* pt = (PayloadType*)ptr;
1457 jstring jvalue =env->NewStringUTF(payload_type_get_mime(pt));
1460 extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobject thiz, jlong ptr) {
1461 PayloadType* pt = (PayloadType*)ptr;
1462 return (jint)payload_type_get_rate(pt);
1466 extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
1469 LinphoneCall *call=(LinphoneCall*)ptr;
1470 linphone_call_unref(call);
1473 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* env
1476 return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
1479 extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env
1481 ,jlong ptr, jstring path) {
1482 const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL;
1483 linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath);
1486 extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env
1488 ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) {
1489 linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy);
1492 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env
1495 return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
1498 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress( JNIEnv* env
1501 return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
1504 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getRemoteUserAgent(JNIEnv *env, jobject thiz, jlong ptr) {
1505 LinphoneCall *call = (LinphoneCall *)ptr;
1506 jstring jvalue = env->NewStringUTF(linphone_call_get_remote_user_agent(call));
1510 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
1513 return (jint)linphone_call_get_state((LinphoneCall*)ptr);
1515 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
1519 linphone_call_enable_echo_cancellation((LinphoneCall*)ptr,value);
1521 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoCancellationEnabled( JNIEnv* env
1524 return (jboolean)linphone_call_echo_cancellation_enabled((LinphoneCall*)ptr);
1527 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoLimiter( JNIEnv* env
1531 linphone_call_enable_echo_limiter((LinphoneCall*)ptr,value);
1533 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isEchoLimiterEnabled( JNIEnv* env
1536 return (jboolean)linphone_call_echo_limiter_enabled((LinphoneCall*)ptr);
1539 extern "C" jobject Java_org_linphone_core_LinphoneCallImpl_getReplacedCall( JNIEnv* env
1542 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data(linphone_call_get_core((LinphoneCall*)ptr));
1543 return lcd->getCall(env,linphone_call_get_replaced_call((LinphoneCall*)ptr));
1546 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getCurrentQuality( JNIEnv* env
1549 return (jfloat)linphone_call_get_current_quality((LinphoneCall*)ptr);
1552 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNIEnv* env
1555 return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
1560 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv* env
1562 ,jstring jFriendUri) {
1563 LinphoneFriend* lResult;
1566 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
1567 lResult= linphone_friend_new_with_addr(friendUri);
1568 env->ReleaseStringUTFChars(jFriendUri, friendUri);
1570 lResult = linphone_friend_new();
1572 return (jlong)lResult;
1574 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv* env
1577 ,jlong linphoneAddress) {
1578 linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
1580 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv* env
1583 return (jlong)linphone_friend_get_address((LinphoneFriend*)ptr);
1585 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv* env
1589 linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
1591 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv* env
1594 return (jint)linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
1596 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv* env
1600 linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
1602 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv* env
1605 return (jboolean)linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
1607 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv* env
1610 return (jint)linphone_friend_get_status((LinphoneFriend*)ptr);
1612 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv* env
1615 return linphone_friend_edit((LinphoneFriend*)ptr);
1617 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv* env
1620 linphone_friend_done((LinphoneFriend*)ptr);
1622 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFriend(JNIEnv* env
1626 linphone_core_remove_friend((LinphoneCore*)ptr, (LinphoneFriend*)lf);
1628 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIEnv* env
1631 ,jstring jaddress) {
1632 const char* address = env->GetStringUTFChars(jaddress, NULL);
1633 LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address);
1634 env->ReleaseStringUTFChars(jaddress, address);
1638 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
1641 return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
1643 extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
1646 ,jstring jmessage) {
1647 const char* message = env->GetStringUTFChars(jmessage, NULL);
1648 LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
1649 env->ReleaseStringUTFChars(jmessage, message);
1651 return (jlong) chatMessage;
1653 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
1656 jobject ud = env->NewGlobalRef(thiz);
1657 linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
1659 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getMessage(JNIEnv* env
1662 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_message((LinphoneChatMessage*)ptr));
1665 extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env
1668 jstring jvalue =env->NewStringUTF(linphone_chat_message_get_external_body_url((LinphoneChatMessage*)ptr));
1671 extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUrl(JNIEnv* env
1675 const char* url = env->GetStringUTFChars(jurl, NULL);
1676 linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url);
1677 env->ReleaseStringUTFChars(jurl, url);
1679 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env
1682 return (jlong) linphone_chat_message_get_from((LinphoneChatMessage*)ptr);
1684 extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getPeerAddress(JNIEnv* env
1687 return (jlong) linphone_chat_message_get_peer_address((LinphoneChatMessage*)ptr);
1689 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* env
1692 ,jstring jmessage) {
1693 const char* message = env->GetStringUTFChars(jmessage, NULL);
1694 linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message);
1695 env->ReleaseStringUTFChars(jmessage, message);
1698 static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
1700 jint result = jvm->AttachCurrentThread(&env,NULL);
1702 ms_error("cannot attach VM\n");
1706 jobject listener = (jobject) ud;
1707 jclass clazz = (jclass) env->GetObjectClass(listener);
1708 jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
1710 LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
1711 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
1712 env->CallVoidMethod(
1715 (jobject)linphone_chat_message_get_user_data(msg),
1716 env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
1718 if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
1719 env->DeleteGlobalRef(listener);
1722 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
1726 ,jobject jlistener) {
1727 jobject listener = env->NewGlobalRef(jlistener);
1728 linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
1730 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
1734 jobject oldWindow = (jobject) linphone_core_get_native_video_window_id((LinphoneCore*)lc);
1735 if (oldWindow != NULL) {
1736 env->DeleteGlobalRef(oldWindow);
1739 obj = env->NewGlobalRef(obj);
1741 linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
1744 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreviewWindowId(JNIEnv* env
1748 jobject oldWindow = (jobject) linphone_core_get_native_preview_window_id((LinphoneCore*)lc);
1749 if (oldWindow != NULL) {
1750 env->DeleteGlobalRef(oldWindow);
1753 obj = env->NewGlobalRef(obj);
1755 linphone_core_set_native_preview_window_id((LinphoneCore*)lc,(unsigned long)obj);
1758 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv* env
1762 linphone_core_set_device_rotation((LinphoneCore*)lc,rotation);
1766 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, jint enum_value){
1767 linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
1770 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
1771 return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
1774 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
1775 const char* server = NULL;
1776 if (jserver) server=env->GetStringUTFChars(jserver, NULL);
1777 linphone_core_set_stun_server((LinphoneCore*)lc,server);
1778 if (server) env->ReleaseStringUTFChars(jserver,server);
1781 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1782 const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1783 if (ret==NULL) return NULL;
1784 jstring jvalue =env->NewStringUTF(ret);
1790 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableLowBandwidth(JNIEnv *env, jobject thiz, jlong cp, jboolean enable) {
1791 linphone_call_params_enable_low_bandwidth((LinphoneCallParams *)cp, enable);
1794 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedAudioCodec(JNIEnv *env, jobject thiz, jlong cp) {
1795 return (jlong)linphone_call_params_get_used_audio_codec((LinphoneCallParams *)cp);
1798 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_getUsedVideoCodec(JNIEnv *env, jobject thiz, jlong cp) {
1799 return (jlong)linphone_call_params_get_used_video_codec((LinphoneCallParams *)cp);
1802 extern "C" jint Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
1806 return (jint)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
1809 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
1813 linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
1816 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){
1817 linphone_call_params_set_audio_bandwidth_limit((LinphoneCallParams*)lcp, bw);
1820 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1821 linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1824 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1825 return (jboolean)linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1828 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenceMode(JNIEnv *env, jobject thiz, jlong lcp){
1829 return (jboolean)linphone_call_params_local_conference_mode((LinphoneCallParams*)lcp);
1832 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){
1833 return linphone_call_params_destroy((LinphoneCallParams*)lc);
1835 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1836 return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1839 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteParams(JNIEnv *env, jobject thiz, jlong lc){
1840 if (linphone_call_get_remote_params((LinphoneCall*)lc) == NULL) {
1843 return (jlong) linphone_call_params_copy(linphone_call_get_remote_params((LinphoneCall*)lc));
1846 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParamsCopy(JNIEnv *env, jobject thiz, jlong lc){
1847 return (jlong) linphone_call_params_copy(linphone_call_get_current_params((LinphoneCall*)lc));
1850 extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableCamera(JNIEnv *env, jobject thiz, jlong lc, jboolean b){
1851 linphone_call_enable_camera((LinphoneCall *)lc, (bool_t) b);
1854 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_cameraEnabled(JNIEnv *env, jobject thiz, jlong lc){
1855 return (jboolean)linphone_call_camera_enabled((LinphoneCall *)lc);
1858 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1859 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
1860 return lcd->getCall(env,linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params));
1863 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1864 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1867 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1868 return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (const LinphoneCallParams *)params);
1871 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1873 vsize.width = (int)width;
1874 vsize.height = (int)height;
1875 linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1878 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1879 MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1880 jintArray arr = env->NewIntArray(2);
1881 int tVsize [2]= {vsize.width,vsize.height};
1882 env->SetIntArrayRegion(arr, 0, 2, tVsize);
1886 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1887 linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1890 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1891 linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1894 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseSipInfoForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
1895 linphone_core_set_use_info_for_dtmf((LinphoneCore *)lc, (bool) use);
1898 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUseRfc2833ForDtmfs(JNIEnv *env, jobject thiz, jlong lc, jboolean use){
1899 linphone_core_set_use_rfc2833_for_dtmf((LinphoneCore *)lc, (bool) use);
1902 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1903 linphone_core_set_download_ptime((LinphoneCore *)lc, (int) ptime);
1906 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadPtime(JNIEnv *env, jobject thiz, jlong lc, jint ptime){
1907 linphone_core_set_upload_ptime((LinphoneCore *)lc, (int) ptime);
1910 extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_getState(JNIEnv* env,jobject thiz,jlong ptr) {
1911 return (jint) linphone_proxy_config_get_state((const LinphoneProxyConfig *) ptr);
1913 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setExpires(JNIEnv* env,jobject thiz,jlong ptr,jint delay) {
1914 linphone_proxy_config_expires((LinphoneProxyConfig *) ptr, (int) delay);
1917 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getDuration(JNIEnv* env,jobject thiz,jlong ptr) {
1918 return (jint)linphone_call_get_duration((LinphoneCall *) ptr);
1921 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getSignalingTransportPort(JNIEnv* env,jobject thiz,jlong ptr, jint code) {
1923 linphone_core_get_sip_transports((LinphoneCore *) ptr, &tr);
1936 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setSignalingTransportPorts(JNIEnv* env,jobject thiz,jlong ptr,jint udp, jint tcp, jint tls) {
1937 LinphoneCore *lc = (LinphoneCore *) ptr;
1943 linphone_core_set_sip_transports(lc, &tr); // tr will be copied
1946 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableIpv6(JNIEnv* env,jobject thiz
1947 ,jlong lc, jboolean enable) {
1948 linphone_core_enable_ipv6((LinphoneCore*)lc,enable);
1951 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_adjustSoftwareVolume(JNIEnv* env,jobject thiz
1952 ,jlong ptr, jint db) {
1953 linphone_core_set_playback_gain_db((LinphoneCore *) ptr, db);
1956 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1957 return (jint)linphone_core_pause_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1959 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_pauseAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1960 return (jint)linphone_core_pause_all_calls((LinphoneCore *) pCore);
1962 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_resumeCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1963 return (jint)linphone_core_resume_call((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1965 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInConference(JNIEnv *env,jobject thiz,jlong pCore) {
1966 return (jboolean)linphone_core_is_in_conference((LinphoneCore *) pCore);
1968 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_enterConference(JNIEnv *env,jobject thiz,jlong pCore) {
1969 return (jboolean)(0 == linphone_core_enter_conference((LinphoneCore *) pCore));
1971 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_leaveConference(JNIEnv *env,jobject thiz,jlong pCore) {
1972 linphone_core_leave_conference((LinphoneCore *) pCore);
1974 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAllToConference(JNIEnv *env,jobject thiz,jlong pCore) {
1975 linphone_core_add_all_to_conference((LinphoneCore *) pCore);
1977 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addToConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1978 linphone_core_add_to_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1980 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeFromConference(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall) {
1981 linphone_core_remove_from_conference((LinphoneCore *) pCore, (LinphoneCall *) pCall);
1984 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateConference(JNIEnv *env,jobject thiz,jlong pCore) {
1985 linphone_core_terminate_conference((LinphoneCore *) pCore);
1987 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv *env,jobject thiz,jlong pCore) {
1988 return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore);
1990 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateAllCalls(JNIEnv *env,jobject thiz,jlong pCore) {
1991 linphone_core_terminate_all_calls((LinphoneCore *) pCore);
1993 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getCall(JNIEnv *env,jobject thiz,jlong pCore,jint position) {
1994 LinphoneCoreData *lcd=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
1995 LinphoneCall* lCall = (LinphoneCall*) ms_list_nth_data(linphone_core_get_calls((LinphoneCore *) pCore),position);
1996 return lcd->getCall(env,lCall);
1998 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,jobject thiz,jlong pCore) {
1999 return (jint)ms_list_size(linphone_core_get_calls((LinphoneCore *) pCore));
2002 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) {
2003 const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL);
2004 jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo);
2005 env->ReleaseStringUTFChars(jReferTo, cReferTo);
2008 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) {
2009 return (jint)linphone_core_transfer_call_to_another((LinphoneCore *) pCore, (LinphoneCall *) pCall, (LinphoneCall *) pDestCall);
2012 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) {
2014 const char* cFile=env->GetStringUTFChars(jFile, NULL);
2015 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile);
2016 env->ReleaseStringUTFChars(jFile, cFile);
2018 linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL);
2022 extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) {
2023 const char* cUri=env->GetStringUTFChars(jUri, NULL);
2024 LinphoneCall *call= (LinphoneCall *) linphone_core_find_call_from_uri((LinphoneCore *) pCore,cUri);
2025 env->ReleaseStringUTFChars(jUri, cUri);
2026 LinphoneCoreData *lcdata=(LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)pCore);
2027 return (jobject) lcdata->getCall(env,call);
2031 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_setVideoDevice(JNIEnv *env,jobject thiz,jlong pCore,jint id) {
2032 LinphoneCore* lc = (LinphoneCore *) pCore;
2033 const char** devices = linphone_core_get_video_devices(lc);
2034 if (devices == NULL) {
2035 ms_error("No existing video devices\n");
2039 for(i=0; i<=id; i++) {
2040 if (devices[i] == NULL)
2042 ms_message("Existing device %d : %s\n", i, devices[i]);
2044 return (jint)linphone_core_set_video_device(lc, devices[i]);
2050 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getVideoDevice(JNIEnv *env,jobject thiz,jlong pCore) {
2051 LinphoneCore* lc = (LinphoneCore *) pCore;
2052 const char** devices = linphone_core_get_video_devices(lc);
2053 if (devices == NULL) {
2054 ms_error("No existing video devices\n");
2057 const char* cam = linphone_core_get_video_device(lc);
2059 ms_error("No current video device\n");
2062 while(devices[i] != NULL) {
2063 if (strcmp(devices[i], cam) == 0)
2068 ms_warning("Returning default (0) device\n");
2072 extern "C" jstring Java_org_linphone_core_LinphoneCallImpl_getAuthenticationToken(JNIEnv* env,jobject thiz,jlong ptr) {
2073 LinphoneCall *call = (LinphoneCall *) ptr;
2074 const char* token = linphone_call_get_authentication_token(call);
2075 if (token == NULL) return NULL;
2076 return env->NewStringUTF(token);
2078 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr) {
2079 LinphoneCall *call = (LinphoneCall *) ptr;
2080 return (jboolean)linphone_call_get_authentication_token_verified(call);
2082 extern "C" void Java_org_linphone_core_LinphoneCallImpl_setAuthenticationTokenVerified(JNIEnv* env,jobject thiz,jlong ptr,jboolean verified) {
2083 LinphoneCall *call = (LinphoneCall *) ptr;
2084 linphone_call_set_authentication_token_verified(call, verified);
2087 extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getPlayVolume(JNIEnv* env, jobject thiz, jlong ptr) {
2088 LinphoneCall *call = (LinphoneCall *) ptr;
2089 return (jfloat)linphone_call_get_play_volume(call);
2092 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_soundResourcesLocked(JNIEnv* env,jobject thiz,jlong ptr){
2093 return (jboolean)linphone_core_sound_resources_locked((LinphoneCore *) ptr);
2096 // Needed by Galaxy S (can't switch to/from speaker while playing and still keep mic working)
2097 // Implemented directly in msandroid.cpp (sound filters for Android).
2098 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_forceSpeakerState(JNIEnv *env, jobject thiz, jlong ptr, jboolean speakerOn) {
2099 LinphoneCore *lc = (LinphoneCore *)ptr;
2100 LinphoneCall *call = linphone_core_get_current_call(lc);
2101 if (call && call->audiostream && call->audiostream->soundread) {
2102 bool_t on = speakerOn;
2103 ms_filter_call_method(call->audiostream->soundread, MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE, &on);
2106 // End Galaxy S hack functions
2109 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
2110 return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
2112 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
2113 linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
2116 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore,
2117 jstring jHost, jint port, jint mirror, jint delay) {
2118 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2119 if (!tunnel) return;
2120 const char* cHost=env->GetStringUTFChars(jHost, NULL);
2121 linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay);
2122 env->ReleaseStringUTFChars(jHost, cHost);
2125 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore,
2126 jstring jHost, jint port, jstring username, jstring password) {
2128 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel;
2129 if (!tunnel) return;
2130 const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL;
2131 const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL;
2132 const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL;
2133 linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword);
2134 if (cHost) env->ReleaseStringUTFChars(jHost, cHost);
2135 if (cUsername) env->ReleaseStringUTFChars(username, cUsername);
2136 if (cPassword) env->ReleaseStringUTFChars(password, cPassword);
2140 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) {
2141 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2142 linphone_tunnel_auto_detect(tunnel);
2146 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) {
2147 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2148 linphone_tunnel_clean_servers(tunnel);
2151 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) {
2152 LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return;
2153 linphone_tunnel_enable(tunnel, enable);
2157 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){
2158 const char* cname=env->GetStringUTFChars(name, NULL);
2159 const char* cversion=env->GetStringUTFChars(version, NULL);
2160 linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion);
2161 env->ReleaseStringUTFChars(name, cname);
2162 env->ReleaseStringUTFChars(version, cversion);
2165 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){
2166 return (jboolean)linphone_core_tunnel_available();
2169 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *env, jobject thiz, jlong lc, jboolean autoInitiate, jboolean autoAccept){
2170 LinphoneVideoPolicy vpol;
2171 vpol.automatically_initiate = autoInitiate;
2172 vpol.automatically_accept = autoAccept;
2173 linphone_core_set_video_policy((LinphoneCore *)lc, &vpol);
2176 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) {
2177 const char *cpath = env->GetStringUTFChars(path, NULL);
2178 linphone_core_set_static_picture((LinphoneCore *)lc, cpath);
2179 env->ReleaseStringUTFChars(path, cpath);
2182 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) {
2183 ms_set_cpu_count(count);
2186 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2187 linphone_core_set_audio_port((LinphoneCore *)lc, port);
2190 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPort(JNIEnv *env, jobject thiz, jlong lc, jint port) {
2191 linphone_core_set_video_port((LinphoneCore *)lc, port);
2194 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAudioPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2195 linphone_core_set_audio_port_range((LinphoneCore *)lc, min_port, max_port);
2198 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPortRange(JNIEnv *env, jobject thiz, jlong lc, jint min_port, jint max_port) {
2199 linphone_core_set_video_port_range((LinphoneCore *)lc, min_port, max_port);
2202 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2203 linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
2206 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
2207 linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout);
2210 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) {
2211 jstring jvalue =env->NewStringUTF(linphone_core_get_version());