diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b25523df1..353eaa1b6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -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); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d0ecc11a3..99ae480fc 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -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); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 5ebf57892..85bd10259 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -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; diff --git a/coreapi/private.h b/coreapi/private.h index e9165a501..e6ed960bc 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -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;