[Asterisk-code-review] features: Add no answer option to Bridge. (asterisk[16])
Friendly Automation
asteriskteam at digium.com
Mon Sep 26 11:28:54 CDT 2022
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19331 )
Change subject: features: Add no answer option to Bridge.
......................................................................
features: Add no answer option to Bridge.
Adds the n "no answer" option to the Bridge application
so that answer supervision can not automatically
be provided when Bridge is executed.
Additionally, a mechanism (dialplan variable)
is added to prevent bridge targets (typically the
target of a masquerade) from answering the channel
when they enter the bridge.
ASTERISK-30223 #close
Change-Id: I76f73fcd8e403bcd18f2abb40c658f537ac1ba6d
---
A doc/CHANGES-staging/features_bridge_noanswer.txt
M main/features.c
2 files changed, 55 insertions(+), 5 deletions(-)
Approvals:
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/doc/CHANGES-staging/features_bridge_noanswer.txt b/doc/CHANGES-staging/features_bridge_noanswer.txt
new file mode 100644
index 0000000..7399ad1
--- /dev/null
+++ b/doc/CHANGES-staging/features_bridge_noanswer.txt
@@ -0,0 +1,5 @@
+Subject: features
+
+The Bridge application now has the n "no answer" option
+that can be used to prevent the channel from being
+automatically answered prior to bridging.
diff --git a/main/features.c b/main/features.c
index 1da4557..befe12d 100644
--- a/main/features.c
+++ b/main/features.c
@@ -163,6 +163,12 @@
</variable>
</variablelist>
</option>
+ <option name="n">
+ <para>Do not answer the channel automatically before bridging.</para>
+ <para>Additionally, to prevent a bridged channel (the target of the Bridge application)
+ from answering, the <literal>BRIDGE_NOANSWER</literal> variable can be set to inhibit
+ answering.</para>
+ </option>
<option name="S(x)">
<para>Hang up the call after <replaceable>x</replaceable> seconds *after* the called party has answered the call.</para>
</option>
@@ -524,7 +530,7 @@
}
static int pre_bridge_setup(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config,
- struct ast_bridge_features *chan_features, struct ast_bridge_features *peer_features)
+ struct ast_bridge_features *chan_features, struct ast_bridge_features *peer_features, int noanswer)
{
int res;
@@ -548,8 +554,15 @@
set_config_flags(chan, config);
/* Answer if need be */
- if (ast_channel_state(chan) != AST_STATE_UP) {
- if (ast_raw_answer(chan)) {
+
+ res = 0;
+
+ if (noanswer) {
+ ast_debug(1, "Skipping answer on %s due to no answer directive\n", ast_channel_name(chan));
+ } else if (ast_channel_state(chan) != AST_STATE_UP) {
+ ast_debug(1, "Answering channel for bridge: %s\n", ast_channel_name(chan));
+ res = ast_raw_answer(chan);
+ if (res != 0) {
return -1;
}
}
@@ -621,6 +634,9 @@
struct ast_bridge_features chan_features;
struct ast_bridge_features *peer_features;
+ const char *value;
+ int noanswer;
+
/* Setup features. */
res = ast_bridge_features_init(&chan_features);
peer_features = ast_bridge_features_new();
@@ -631,7 +647,12 @@
return -1;
}
- if (pre_bridge_setup(chan, peer, config, &chan_features, peer_features)) {
+ ast_channel_lock(chan);
+ value = pbx_builtin_getvar_helper(chan, "BRIDGE_NOANSWER");
+ noanswer = !ast_strlen_zero(value) ? 1 : 0;
+ ast_channel_unlock(chan);
+
+ if (pre_bridge_setup(chan, peer, config, &chan_features, peer_features, noanswer)) {
ast_bridge_features_destroy(peer_features);
ast_bridge_features_cleanup(&chan_features);
bridge_failed_peer_goto(chan, peer);
@@ -840,6 +861,7 @@
OPT_CALLER_PARK = (1 << 10),
OPT_CALLEE_KILL = (1 << 11),
OPT_CALLEE_GO_ON = (1 << 12),
+ OPT_NOANSWER = (1 << 13),
};
enum {
@@ -858,6 +880,7 @@
AST_APP_OPTION('k', OPT_CALLEE_PARK),
AST_APP_OPTION('K', OPT_CALLER_PARK),
AST_APP_OPTION_ARG('L', OPT_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT),
+ AST_APP_OPTION('n', OPT_NOANSWER),
AST_APP_OPTION_ARG('S', OPT_DURATION_STOP, OPT_ARG_DURATION_STOP),
AST_APP_OPTION('t', OPT_CALLEE_TRANSFER),
AST_APP_OPTION('T', OPT_CALLER_TRANSFER),
@@ -1004,6 +1027,7 @@
struct ast_bridge_features *peer_features;
struct ast_bridge *bridge;
struct ast_features_xfer_config *xfer_cfg;
+ int noanswer;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(dest_chan);
@@ -1058,6 +1082,7 @@
ast_set_flag(&(bconfig.features_callee), AST_FEATURE_PARKCALL);
if (ast_test_flag(&opts, OPT_CALLER_PARK))
ast_set_flag(&(bconfig.features_caller), AST_FEATURE_PARKCALL);
+ noanswer = ast_test_flag(&opts, OPT_NOANSWER);
/* Setup after bridge goto location. */
if (ast_test_flag(&opts, OPT_CALLEE_GO_ON)) {
@@ -1088,7 +1113,7 @@
goto done;
}
- if (pre_bridge_setup(chan, current_dest_chan, &bconfig, &chan_features, peer_features)) {
+ if (pre_bridge_setup(chan, current_dest_chan, &bconfig, &chan_features, peer_features, noanswer)) {
ast_bridge_features_destroy(peer_features);
ast_bridge_features_cleanup(&chan_features);
goto done;
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19331
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I76f73fcd8e403bcd18f2abb40c658f537ac1ba6d
Gerrit-Change-Number: 19331
Gerrit-PatchSet: 4
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220926/9cedabcf/attachment-0001.html>
More information about the asterisk-code-review
mailing list