]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Confbridge: Add a user timeout option 30/1630/3
authorMark Michelson <mmichelson@digium.com>
Fri, 13 Nov 2015 20:03:35 +0000 (14:03 -0600)
committerMark Michelson <mmichelson@digium.com>
Mon, 16 Nov 2015 20:12:50 +0000 (14:12 -0600)
This option adds the ability to specify a timeout, in seconds, for a
participant in a ConfBridge. When the user's timeout has been reached,
the user is ejected from the conference with the CONFBRIDGE_RESULT
channel variable set to "TIMEOUT".

The rationale for this change is that there have been times where we
have seen channels get "stuck" in ConfBridge because a network issue
results in a SIP BYE not being received by Asterisk. While these
channels can be hung up manually via CLI/AMI/ARI, adding some sort of
automatic cleanup of the channels is a nice feature to have.

ASTERISK-25549 #close
Reported by Mark Michelson

Change-Id: I2996b6c5e16a3dda27595f8352abad0bda9c2d98

CHANGES
apps/app_confbridge.c
apps/confbridge/conf_config_parser.c
apps/confbridge/include/confbridge.h
configs/samples/confbridge.conf.sample

diff --git a/CHANGES b/CHANGES
index 99632a7e957438f52355fd880c1d908247fba259..7314549702decd9e0fc16366f12f9294a41c1519 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 --- Functionality changes from Asterisk 13.1.0-cert3 to Asterisk 13.1-cert4 --
 ------------------------------------------------------------------------------
 
+ConfBridge
+------------------
+ * A new "timeout" user profile option has been added. This configures the number
+   of seconds that a participant may stay in the ConfBridge after joining. When
+   the time expires, the user is ejected from the conference and CONFBRIDGE_RESULT
+   is set to "TIMEOUT" on the channel.
+
 AMI
 ------------------
  * Added the Linkedid header to the common channel headers listed for each
index e4dd68330e7d72a0df64c17fde04001d3cb1704d..75ccb327181bc6ac1bc8ec4bfc7b2cd227f180ec 100644 (file)
@@ -118,6 +118,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                        <value name="KICKED">The channel was kicked from the conference.</value>
                                        <value name="ENDMARKED">The channel left the conference as a result of the last marked user leaving.</value>
                                        <value name="DTMF">The channel pressed a DTMF sequence to exit the conference.</value>
+                                       <value name="TIMEOUT">The channel reached its configured timeout.</value>
                                </variable>
                        </variablelist>
                </description>
@@ -1496,6 +1497,13 @@ static int conf_get_pin(struct ast_channel *chan, struct confbridge_user *user)
        return -1;
 }
 
+static int user_timeout(struct ast_bridge_channel *bridge_channel, void *ignore)
+{
+       ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END, 0);
+       pbx_builtin_setvar_helper(bridge_channel->chan, "CONFBRIDGE_RESULT", "TIMEOUT");
+       return -1;
+}
+
 static int conf_rec_name(struct confbridge_user *user, const char *conf_name)
 {
        char destdir[PATH_MAX];
@@ -1730,6 +1738,16 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
                ast_autoservice_stop(chan);
        }
 
+       if (user.u_profile.timeout) {
+               ast_bridge_interval_hook(&user.features,
+                       0,
+                       user.u_profile.timeout * 1000,
+                       user_timeout,
+                       NULL,
+                       NULL,
+                       AST_BRIDGE_HOOK_REMOVE_ON_PULL);
+       }
+
        /* See if we need to automatically set this user as a video source or not */
        handle_video_on_join(conference, user.chan, ast_test_flag(&user.u_profile, USER_OPT_MARKEDUSER));
 
index af5dfcea9d94b5e55424e97f61667942150cef4a..fef0220fb564aeb4d6f5aca5576e394bc4969913 100644 (file)
@@ -227,6 +227,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                <configOption name="template">
                                        <synopsis>When using the CONFBRIDGE dialplan function, use a user profile as a template for creating a new temporary profile</synopsis>
                                </configOption>
+                               <configOption name="timeout">
+                                       <synopsis>Kick the user out of the conference after this many seconds. 0 means there is no timeout for the user.</synopsis>
+                               </configOption>
                        </configObject>
                        <configObject name="bridge_profile">
                                <synopsis>A named profile to apply to specific bridges.</synopsis>
@@ -2083,6 +2086,7 @@ int conf_load_config(void)
        aco_option_register(&cfg_info, "dsp_silence_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_SILENCE_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, silence_threshold));
        aco_option_register(&cfg_info, "dsp_talking_threshold", ACO_EXACT, user_types, __stringify(DEFAULT_TALKING_THRESHOLD), OPT_UINT_T, 0, FLDSET(struct user_profile, talking_threshold));
        aco_option_register(&cfg_info, "jitterbuffer", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_JITTERBUFFER);
+       aco_option_register(&cfg_info, "timeout", ACO_EXACT, user_types, "0", OPT_UINT_T, 0, FLDSET(struct user_profile, timeout));
        /* This option should only be used with the CONFBRIDGE dialplan function */
        aco_option_register_custom(&cfg_info, "template", ACO_EXACT, user_types, NULL, user_template_handler, 0);
 
index 6f8439a9c9a2abaf5a9bc7aae5b20813e97dbd9f..8d2dffb1cd904c9b4a0e097835b6e08e4bb9d94d 100644 (file)
@@ -140,6 +140,8 @@ struct user_profile {
        unsigned int talking_threshold;
        /*! The time in ms of silence before a user is considered to be silent by the dsp. */
        unsigned int silence_threshold;
+       /*! The time in ms the user may stay in the confbridge */
+       unsigned int timeout;
 };
 
 enum conf_sounds {
index 860f1cb876e69d4cbd306d74d2b3619ea2352ed0..0419001eb8c3ad6a1cabc198cf6c321a91a1d878 100644 (file)
@@ -137,6 +137,12 @@ type=user
                        ; This option is off by default.
 ;announcement=</path/to/file> ; Play a sound file to the user when they join the conference.
 
+;timeout=3600 ; When set non-zero, this specifies the number of seconds that the participant
+              ; may stay in the conference before being automatically ejected. When the user
+              ; is ejected from the conference, the user's channel will have the CONFBRIDGE_RESULT
+              ; variable set to "TIMEOUT". A value of 0 indicates that there is no timeout.
+              ; Default: 0
+
 ; --- ConfBridge Bridge Profile Options ---
 [default_bridge]
 type=bridge