]> sjero.net Git - linphone/commitdiff
add linphone_core_enable_keep_alive
authorJehan Monnier <jehan.monnier@linphone.org>
Mon, 24 Jan 2011 15:38:29 +0000 (16:38 +0100)
committerJehan Monnier <jehan.monnier@linphone.org>
Mon, 24 Jan 2011 15:38:29 +0000 (16:38 +0100)
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
coreapi/sal.h
coreapi/sal_eXosip2.c
java/common/org/linphone/core/LinphoneCore.java

index ef145c2fd35af1d304afcc5129104ed87b810f73..7252a5490d4b6a3f0bd384554060e3353f545576 100644 (file)
@@ -4037,4 +4037,19 @@ const char *linphone_error_to_string(LinphoneReason err){
        }
        return "unknown error";
 }
-
+/**
+ * enable signaling keep alive
+ */
+void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) {
+       if (enable > 0) {
+               sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
+       } else {
+               sal_set_keepalive_period(lc->sal,0);
+       }
+}
+/**
+ * Is signaling keep alive
+ */
+bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc) {
+       return sal_get_keepalive_period(lc->sal) > 0;
+}
index 0b9823f3c0eeeafb15deb97bbbf11ef3800203a8..6ad65d8d470b0def4ef2d3fbd9243710c007a82b 100644 (file)
@@ -919,6 +919,14 @@ void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value);
  */
 bool_t linphone_core_is_network_reachabled(LinphoneCore* lc);
 
+/**
+ *  enable signaling keep alive. small udp packet sent periodically to keep udp NAT association
+ */
+void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable);
+/**
+ * Is signaling keep alive
+ */
+bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc);
 
 void *linphone_core_get_user_data(LinphoneCore *lc);
 
index fbd8f01eab4f534d297958f7be18d312b7f46a13..93ea0012e47f1ed681db748861a97ecde156fdee 100644 (file)
@@ -614,8 +614,19 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
                return NULL;
        }
 }
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableKeepAlive(JNIEnv*  env
+                                                                                                                               ,jobject  thiz
+                                                                                                                               ,jlong lc
+                                                                                                                               ,jboolean enable) {
+       linphone_core_enable_keep_alive((LinphoneCore*)lc,enable);
 
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isKeepAliveEnabled(JNIEnv*  env
+                                                                                                                               ,jobject  thiz
+                                                                                                                               ,jlong lc) {
+       return linphone_core_keep_alive_enabled((LinphoneCore*)lc);
 
+}
 //ProxyConfig
 
 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
index 359d81883a3ea9f56132c13c8ca67eb44cbaf554..3434b54c27dce30f7cc92cf5fdacb6f695e20cdd 100644 (file)
@@ -249,6 +249,11 @@ ortp_socket_t sal_get_socket(Sal *ctx);
 void sal_set_user_agent(Sal *ctx, const char *user_agent);
 /*keepalive period in ms*/
 void sal_set_keepalive_period(Sal *ctx,unsigned int value);
+/**
+ * returns keepalive period in ms
+ * 0 desactiaved
+ * */
+unsigned int sal_get_keepalive_period(Sal *ctx);
 void sal_use_session_timers(Sal *ctx, int expires);
 void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec);
 int sal_iterate(Sal *sal);
index 4203cb85e900990dc139309991277a7430f33275..f4bc032805aec84b0ac4e72133cfab9deecf6436 100644 (file)
@@ -1982,6 +1982,9 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value) {
        ctx->keepalive_period=value;
        eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value);
 }
+unsigned int sal_get_keepalive_period(Sal *ctx) {
+       return ctx->keepalive_period;
+}
 
 const char * sal_address_get_port(const SalAddress *addr) {
        const osip_from_t *u=(const osip_from_t*)addr;
index 3e33bdce6ea6cab1b05a77d4449807b647f2da44..e0e0d4ba8da0508bc16dbbb3395e9fa003c536d0 100644 (file)
@@ -488,5 +488,13 @@ public interface LinphoneCore {
        public VideoSize getPreferredVideoSize();
        
        public PayloadType[] listVideoCodecs();
-
+       /**
+        * enable signaling keep alive. small udp packet sent periodically to keep udp NAT association
+        */
+       void enableKeepAlive(boolean enable);
+       /**
+        * get keep elive mode
+        * @return true if enable
+        */
+       boolean isKeepAliveEnabled();
 }