]> sjero.net Git - linphone/commitdiff
Add in call timeout
authorYann Diorcet <yann.diorcet@belledonne-communications.com>
Wed, 31 Oct 2012 09:52:43 +0000 (10:52 +0100)
committerYann Diorcet <yann.diorcet@belledonne-communications.com>
Wed, 31 Oct 2012 09:52:43 +0000 (10:52 +0100)
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
coreapi/private.h

index b25523df19db0fccd1a4a1d5fcdda5c6fce3694c..353eaa1b6dbb076ca51046efe3489afbb1edcf17 100644 (file)
@@ -591,6 +591,9 @@ static void sip_config_read(LinphoneCore *lc)
        tmp=lp_config_get_int(lc->config,"sip","inc_timeout",30);
        linphone_core_set_inc_timeout(lc,tmp);
 
+       tmp=lp_config_get_int(lc->config,"sip","in_call_timeout",0);
+       linphone_core_set_in_call_timeout(lc,tmp);
+
        /* get proxies config */
        for(i=0;; i++){
                LinphoneProxyConfig *cfg=linphone_proxy_config_new_from_config_file(lc->config,i);
@@ -1979,6 +1982,7 @@ void linphone_core_iterate(LinphoneCore *lc){
        calls= lc->calls;
        while(calls!= NULL){
                call = (LinphoneCall *)calls->data;
+               elapsed = curtime-call->start_time;
                 /* get immediately a reference to next one in case the one
                 we are going to examine is destroy and removed during
                 linphone_core_start_invite() */
@@ -1995,7 +1999,6 @@ void linphone_core_iterate(LinphoneCore *lc){
                        linphone_core_start_invite(lc,call);
                }
                if (call->state==LinphoneCallIncomingReceived){
-                       elapsed=curtime-call->start_time;
                        ms_message("incoming call ringing for %i seconds",elapsed);
                        if (elapsed>lc->sip_conf.inc_timeout){
                                ms_message("incoming call timeout (%i)",lc->sip_conf.inc_timeout);
@@ -2004,6 +2007,12 @@ void linphone_core_iterate(LinphoneCore *lc){
                                linphone_core_terminate_call(lc,call);
                        }
                }
+               if (lc->sip_conf.in_call_timeout > 0 && elapsed>lc->sip_conf.in_call_timeout) {
+                       ms_message("in call timeout (%i)",lc->sip_conf.in_call_timeout);
+                       call->log->status=LinphoneCallMissed;
+                       call->reason=LinphoneReasonNotAnswered;
+                       linphone_core_terminate_call(lc,call);
+               }
        }
                
        if (linphone_core_video_preview_enabled(lc)){
@@ -3208,6 +3217,26 @@ int linphone_core_get_inc_timeout(LinphoneCore *lc){
        return lc->sip_conf.inc_timeout;
 }
 
+/**
+ * Set the in call timeout in seconds.
+ *
+ * @ingroup call_control
+ * After this timeout period, the call is automatically hangup.
+**/
+void linphone_core_set_in_call_timeout(LinphoneCore *lc, int seconds){
+       lc->sip_conf.in_call_timeout=seconds;
+}
+
+/**
+ * Returns the in call timeout
+ *
+ * @ingroup call_control
+ * See linphone_core_set_in_call_timeout() for details.
+**/
+int linphone_core_get_in_call_timeout(LinphoneCore *lc){
+       return lc->sip_conf.in_call_timeout;
+}
+
 void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,
                                                                                                        const char *contact,
                                                                                                        LinphoneOnlineStatus presence_mode)
@@ -4604,6 +4633,7 @@ void sip_config_uninit(LinphoneCore *lc)
        lp_config_set_int(lc->config,"sip","guess_hostname",config->guess_hostname);
        lp_config_set_string(lc->config,"sip","contact",config->contact);
        lp_config_set_int(lc->config,"sip","inc_timeout",config->inc_timeout);
+       lp_config_set_int(lc->config,"sip","in_call_timeout",config->in_call_timeout);
        lp_config_set_int(lc->config,"sip","use_info",config->use_info);
        lp_config_set_int(lc->config,"sip","use_rfc2833",config->use_rfc2833);
        lp_config_set_int(lc->config,"sip","use_ipv6",config->ipv6_enabled);
index d0ecc11a360713e7a41ecd40c1bfc75dd85c1744..99ae480fcc4393446e447b64357bbd2a85823d90 100644 (file)
@@ -1164,6 +1164,10 @@ void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds);
 
 int linphone_core_get_inc_timeout(LinphoneCore *lc);
 
+void linphone_core_set_in_call_timeout(LinphoneCore *lc, int seconds);
+
+int linphone_core_get_in_call_timeout(LinphoneCore *lc);
+
 void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
 
 const char * linphone_core_get_stun_server(const LinphoneCore *lc);
index 5ebf578925441dab517cc81bcee115d93425cfc6..85bd102595b2d5c5b004199c10bc623e00f003d9 100644 (file)
@@ -2137,6 +2137,10 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setIncomingTimeout(JNIEn
        linphone_core_set_inc_timeout((LinphoneCore *)lc, timeout);
 }
 
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setInCallTimeout(JNIEnv *env, jobject thiz, jlong lc, jint timeout) {
+       linphone_core_set_in_call_timeout((LinphoneCore *)lc, timeout);
+}
+
 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv*  env,jobject  thiz,jlong ptr) {
        jstring jvalue =env->NewStringUTF(linphone_core_get_version());
        return jvalue;
index e9165a501404e3f5dd4acb1dd994e010d52108f3..e6ed960bcd2bfba1e2456029460aaf7e7e9cd100 100644 (file)
@@ -382,6 +382,7 @@ typedef struct sip_config
        MSList *proxies;
        MSList *deleted_proxies;
        int inc_timeout;        /*timeout after an un-answered incoming call is rejected*/
+       int in_call_timeout;    /*timeout after a call is hangup */
        unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/
        LCSipTransports transports;
        bool_t use_info;