[Asterisk-code-review] app_confbridge: New option to prevent answer supervision (asterisk[16])

N A asteriskteam at digium.com
Thu May 20 10:24:30 CDT 2021


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15918 )


Change subject: app_confbridge: New option to prevent answer supervision
......................................................................

app_confbridge: New option to prevent answer supervision

A new user option, answer_channel, adds the capability to
prevent answering the channel if it hasn't already been
answered yet.

ASTERISK-29440

Change-Id: I26642729d0345f178c7b8045506605c8402de54b
---
M apps/app_confbridge.c
M apps/confbridge/conf_config_parser.c
M apps/confbridge/include/confbridge.h
M configs/samples/confbridge.conf.sample
A doc/CHANGES-staging/app_confbridge_answer.txt
5 files changed, 25 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/18/15918/1

diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 457870a..44d513c 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -2535,10 +2535,6 @@
 		AST_APP_ARG(menu_profile_name);
 	);
 
-	if (ast_channel_state(chan) != AST_STATE_UP) {
-		ast_answer(chan);
-	}
-
 	if (ast_bridge_features_init(&user.features)) {
 		pbx_builtin_setvar_helper(chan, "CONFBRIDGE_RESULT", "FAILED");
 		res = -1;
@@ -2588,6 +2584,11 @@
 		goto confbridge_cleanup;
 	}
 
+	/* If channel hasn't been answered already, answer it, unless we're explicitly not supposed to */
+	if ((ast_channel_state(chan) != AST_STATE_UP) && !(ast_test_flag(&user.u_profile, USER_OPT_NOANSWER))) {
+		ast_answer(chan);
+	}
+
 	quiet = ast_test_flag(&user.u_profile, USER_OPT_QUIET);
 
 	/* ask for a PIN immediately after finding user profile.  This has to be
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index 656acc6..841d06a 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -247,6 +247,9 @@
 					participants in the conference bridge. If disabled then no text
 					messages are sent to the user.</para></description>
 				</configOption>
+				<configOption name="answer_channel" default="yes">
+					<synopsis>Sets if a user's channel should be answered if currently unanswered.</synopsis>
+				</configOption>
 			</configObject>
 			<configObject name="bridge_profile">
 				<synopsis>A named profile to apply to specific bridges.</synopsis>
@@ -1609,9 +1612,12 @@
 	ast_cli(a->fd,"Announce User Count all: %s\n",
 		u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ?
 		"enabled" : "disabled");
-        ast_cli(a->fd,"Text Messaging:          %s\n",
-                u_profile.flags & USER_OPT_TEXT_MESSAGING ?
-                "enabled" : "disabled");
+	ast_cli(a->fd,"Text Messaging:          %s\n",
+			u_profile.flags & USER_OPT_TEXT_MESSAGING ?
+			"enabled" : "disabled");
+	ast_cli(a->fd,"Answer Channel:          %s\n",
+			u_profile.flags & USER_OPT_NOANSWER ?
+			"true" : "false");
 	ast_cli(a->fd, "\n");
 
 	return CLI_SUCCESS;
@@ -2410,6 +2416,8 @@
 	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));
 	aco_option_register(&cfg_info, "text_messaging", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TEXT_MESSAGING);
+	/* Negative logic. Defaults to "yes" and evaluates with ast_false(). If !ast_false(), USER_OPT_NOANSWER is cleared */
+	aco_option_register(&cfg_info, "answer_channel", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 0, FLDSET(struct user_profile, flags), USER_OPT_NOANSWER);
 
 	/* 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);
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index f413359..4b8690a 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -69,6 +69,7 @@
 	USER_OPT_SEND_EVENTS = (1 << 17), /*!< Send text message events to users */
 	USER_OPT_ECHO_EVENTS = (1 << 18), /*!< Send events only to the admin(s) */
 	USER_OPT_TEXT_MESSAGING = (1 << 19), /*!< Send text messages to the user */
+	USER_OPT_NOANSWER = (1 << 20), /*!< Sets if the channel should be answered if currently unanswered */
 };
 
 enum bridge_profile_flags {
diff --git a/configs/samples/confbridge.conf.sample b/configs/samples/confbridge.conf.sample
index 7749c93..eecbb65 100644
--- a/configs/samples/confbridge.conf.sample
+++ b/configs/samples/confbridge.conf.sample
@@ -165,6 +165,8 @@
 ;text_messaging=yes ; When set to yes text messages will be sent to this user. Text messages
                     ; may occur as a result of events or can be received from other participants.
                     ; When set to no text messages will not be sent to this user.
+;answer_channel=yes   ; Sets if the channel should be answered if it hasn't been already.
+                          ; On by default.
 
 ; --- ConfBridge Bridge Profile Options ---
 [default_bridge]
diff --git a/doc/CHANGES-staging/app_confbridge_answer.txt b/doc/CHANGES-staging/app_confbridge_answer.txt
new file mode 100644
index 0000000..b975f48
--- /dev/null
+++ b/doc/CHANGES-staging/app_confbridge_answer.txt
@@ -0,0 +1,6 @@
+Subject: app_confbridge answer supervision control
+
+app_confbridge now provides a user option to prevent
+answer supervision if the channel hasn't been
+answered yet. To use it, set a user profile's
+answer_channel option to no.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15918
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I26642729d0345f178c7b8045506605c8402de54b
Gerrit-Change-Number: 15918
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210520/d2e6e6a2/attachment-0001.html>


More information about the asterisk-code-review mailing list