summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2016-06-05 17:37:52 +0200
committerAlfred E. Heggestad <aeh@db.org>2016-06-05 17:37:52 +0200
commit23beca80ead983d7500a9b63b1e420b9185d4b1c (patch)
treef8b729b21dc7e05d34261bddc2ffc051af02bc24
parent439c2f9cb452c20155d7080930e79bee978b9983 (diff)
config: add "call_local_timeout" config option
the config option is used for incoming calls, if the call is not answered after X seconds. The default value is 120 seconds. If the value is set to 0 the timeout timer is not enabled.
-rw-r--r--include/baresip.h7
-rw-r--r--src/call.c10
-rw-r--r--src/config.c21
3 files changed, 34 insertions, 4 deletions
diff --git a/include/baresip.h b/include/baresip.h
index 68cf423..d60b0a5 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -150,6 +150,11 @@ struct config_sip {
char cert[256]; /**< SIP Certificate */
};
+/** Call config */
+struct config_call {
+ uint32_t local_timeout; /**< Incoming call timeout [sec] 0=off */
+};
+
/** Audio */
struct config_audio {
char src_mod[16]; /**< Audio source module */
@@ -210,6 +215,8 @@ struct config {
struct config_sip sip;
+ struct config_call call;
+
struct config_audio audio;
#ifdef USE_VIDEO
diff --git a/src/call.c b/src/call.c
index dda9f3a..913ea25 100644
--- a/src/call.c
+++ b/src/call.c
@@ -24,7 +24,6 @@
/** Call constants */
enum {
PTIME = 20, /**< Packet time for audio */
- LOCAL_TIMEOUT = 120, /**< Incoming call timeout in [seconds] */
};
@@ -78,6 +77,7 @@ struct call {
void *arg; /**< Handler argument */
struct config_avt config_avt;
+ struct config_call config_call;
};
@@ -219,7 +219,7 @@ static void invite_timeout(void *arg)
struct call *call = arg;
info("%s: Local timeout after %u seconds\n",
- call->peer_uri, LOCAL_TIMEOUT);
+ call->peer_uri, call->config_call.local_timeout);
call_event_handler(call, CALL_EVENT_CLOSED, "Local timeout");
}
@@ -460,6 +460,7 @@ int call_alloc(struct call **callp, const struct config *cfg, struct list *lst,
MAGIC_INIT(call);
call->config_avt = cfg->avt;
+ call->config_call = cfg->call;
tmr_init(&call->tmr_inv);
@@ -1311,7 +1312,10 @@ int call_accept(struct call *call, struct sipsess_sock *sess_sock,
set_state(call, STATE_INCOMING);
/* New call */
- tmr_start(&call->tmr_inv, LOCAL_TIMEOUT*1000, invite_timeout, call);
+ if (call->config_call.local_timeout) {
+ tmr_start(&call->tmr_inv, call->config_call.local_timeout*1000,
+ invite_timeout, call);
+ }
if (!call->acc->mnat)
call_event_handler(call, CALL_EVENT_INCOMING, call->peer_uri);
diff --git a/src/config.c b/src/config.c
index 3995e64..6789aaf 100644
--- a/src/config.c
+++ b/src/config.c
@@ -27,6 +27,11 @@ static struct config core_config = {
""
},
+ /** Call config */
+ {
+ 120
+ },
+
/** Audio */
{
"","",
@@ -141,6 +146,10 @@ int config_parse_conf(struct config *cfg, const struct conf *conf)
(void)conf_get_str(conf, "sip_certificate", cfg->sip.cert,
sizeof(cfg->sip.cert));
+ /* Call */
+ (void)conf_get_u32(conf, "call_local_timeout",
+ &cfg->call.local_timeout);
+
/* Audio */
(void)conf_get_csv(conf, "audio_player",
cfg->audio.play_mod,
@@ -235,6 +244,9 @@ int config_print(struct re_printf *pf, const struct config *cfg)
"sip_listen\t\t%s\n"
"sip_certificate\t%s\n"
"\n"
+ "# Call\n"
+ "call_local_timeout\t%u\n"
+ "\n"
"# Audio\n"
"audio_player\t\t%s,%s\n"
"audio_source\t\t%s,%s\n"
@@ -276,6 +288,8 @@ int config_print(struct re_printf *pf, const struct config *cfg)
cfg->sip.trans_bsize, cfg->sip.local, cfg->sip.cert,
+ cfg->call.local_timeout,
+
cfg->audio.play_mod, cfg->audio.play_dev,
cfg->audio.src_mod, cfg->audio.src_dev,
cfg->audio.alert_mod, cfg->audio.alert_dev,
@@ -389,7 +403,11 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"sip_trans_bsize\t\t128\n"
"#sip_listen\t\t0.0.0.0:5060\n"
"#sip_certificate\tcert.pem\n"
- "\n# Audio\n"
+ "\n"
+ "# Call\n"
+ "call_local_timeout\t%u\n"
+ "\n"
+ "# Audio\n"
"audio_player\t\t%s\n"
"audio_source\t\t%s\n"
"audio_alert\t\t%s\n"
@@ -401,6 +419,7 @@ static int core_config_template(struct re_printf *pf, const struct config *cfg)
"#auplay_channels\t\t0\n"
,
poll_method_name(poll_method_best()),
+ cfg->call.local_timeout,
default_audio_device(),
default_audio_device(),
default_audio_device(),