[Asterisk-code-review] app_confbridge: Add end_marked_any option. (asterisk[19])

N A asteriskteam at digium.com
Wed Sep 7 07:58:43 CDT 2022


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


Change subject: app_confbridge: Add end_marked_any option.
......................................................................

app_confbridge: Add end_marked_any option.

Adds the end_marked_any option, which can be used
to kick a user from a conference if any marked user
leaves.

ASTERISK-30211 #close

Change-Id: I9e8da7ccb892e522546c0f2b5476d172e022c2f5
---
M apps/app_confbridge.c
M apps/confbridge/conf_config_parser.c
M apps/confbridge/conf_state_multi_marked.c
M apps/confbridge/include/confbridge.h
M configs/samples/confbridge.conf.sample
A doc/CHANGES-staging/app_confbridge_marked_any.txt
6 files changed, 62 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/96/19096/1

diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index ea206bf..dd683d3 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -4022,6 +4022,7 @@
 		"MarkedUser: %s\r\n"
 		"WaitMarked: %s\r\n"
 		"EndMarked: %s\r\n"
+		"EndMarkedAny: %s\r\n"
 		"Waiting: %s\r\n"
 		"Muted: %s\r\n"
 		"Talking: %s\r\n"
@@ -4034,6 +4035,7 @@
 		AST_YESNO(ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER)),
 		AST_YESNO(ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED)),
 		AST_YESNO(ast_test_flag(&user->u_profile, USER_OPT_ENDMARKED)),
+		AST_YESNO(ast_test_flag(&user->u_profile, USER_OPT_ENDMARKEDANY)),
 		AST_YESNO(waiting),
 		AST_YESNO(user->muted),
 		AST_YESNO(user->talking),
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
index d04bcf9..aceb356 100644
--- a/apps/confbridge/conf_config_parser.c
+++ b/apps/confbridge/conf_config_parser.c
@@ -120,6 +120,9 @@
 				<configOption name="end_marked">
 					<synopsis>Kick the user from the conference when the last marked user leaves</synopsis>
 				</configOption>
+				<configOption name="end_marked_any">
+					<synopsis>Kick the user from the conference when any marked user leaves</synopsis>
+				</configOption>
 				<configOption name="talk_detection_events">
 					<synopsis>Set whether or not notifications of when a user begins and ends talking should be sent out as events over AMI</synopsis>
 				</configOption>
@@ -1581,9 +1584,12 @@
 	ast_cli(a->fd,"Wait Marked:             %s\n",
 		u_profile.flags & USER_OPT_WAITMARKED ?
 		"enabled" : "disabled");
-	ast_cli(a->fd,"END Marked:              %s\n",
+	ast_cli(a->fd,"END Marked (All):        %s\n",
 		u_profile.flags & USER_OPT_ENDMARKED ?
 		"enabled" : "disabled");
+	ast_cli(a->fd,"END Marked (Any):        %s\n",
+		u_profile.flags & USER_OPT_ENDMARKEDANY ?
+		"enabled" : "disabled");
 	ast_cli(a->fd,"Drop_silence:            %s\n",
 		u_profile.flags & USER_OPT_DROP_SILENCE ?
 		"enabled" : "disabled");
@@ -2407,6 +2413,7 @@
 	aco_option_register(&cfg_info, "announce_only_user", ACO_EXACT, user_types, "yes", OPT_BOOLFLAG_T, 0, FLDSET(struct user_profile, flags), USER_OPT_NOONLYPERSON);
 	aco_option_register(&cfg_info, "wait_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_WAITMARKED);
 	aco_option_register(&cfg_info, "end_marked", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKED);
+	aco_option_register(&cfg_info, "end_marked_any", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ENDMARKEDANY);
 	aco_option_register(&cfg_info, "talk_detection_events", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_TALKER_DETECT);
 	aco_option_register(&cfg_info, "dtmf_passthrough", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_DTMF_PASS);
 	aco_option_register(&cfg_info, "announce_join_leave", ACO_EXACT, user_types, "no", OPT_BOOLFLAG_T, 1, FLDSET(struct user_profile, flags), USER_OPT_ANNOUNCE_JOIN_LEAVE);
diff --git a/apps/confbridge/conf_state_multi_marked.c b/apps/confbridge/conf_state_multi_marked.c
index 3932edc..ef3c4b3 100644
--- a/apps/confbridge/conf_state_multi_marked.c
+++ b/apps/confbridge/conf_state_multi_marked.c
@@ -82,37 +82,39 @@
 
 	conf_remove_user_marked(user->conference, user);
 
-	if (user->conference->markedusers == 0) {
-		AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->active_list, user_iter, list) {
-			/* Kick ENDMARKED cbu_iters */
-			if (ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKED) && !user_iter->kicked) {
-				if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED)
-					&& !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
-					AST_LIST_REMOVE_CURRENT(list);
-					user_iter->conference->activeusers--;
-					AST_LIST_INSERT_TAIL(&user_iter->conference->waiting_list, user_iter, list);
-					user_iter->conference->waitingusers++;
-				}
-				user_iter->kicked = 1;
-				pbx_builtin_setvar_helper(user_iter->chan, "CONFBRIDGE_RESULT", "ENDMARKED");
-				ast_bridge_remove(user_iter->conference->bridge, user_iter->chan);
-			} else if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED)
-				&& !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
-				need_prompt = 1;
-
+	/* If all marked users have left, or we're set to kick if any marked user leaves, then boot everyone */
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->active_list, user_iter, list) {
+		if (user->conference->markedusers > 0 && !ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKEDANY)) {
+			continue;
+		}
+		/* Kick ENDMARKED cbu_iters */
+		if ((ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKED) || ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKEDANY)) && !user_iter->kicked) {
+			if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED)
+				&& (!ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER) || ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKEDANY))) {
 				AST_LIST_REMOVE_CURRENT(list);
 				user_iter->conference->activeusers--;
 				AST_LIST_INSERT_TAIL(&user_iter->conference->waiting_list, user_iter, list);
 				user_iter->conference->waitingusers++;
-			} else {
-				/* User is neither wait_marked nor end_marked; however, they
-				 * should still hear the prompt.
-				 */
-				need_prompt = 1;
 			}
+			user_iter->kicked = 1;
+			pbx_builtin_setvar_helper(user_iter->chan, "CONFBRIDGE_RESULT", "ENDMARKED");
+			ast_bridge_remove(user_iter->conference->bridge, user_iter->chan);
+		} else if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED)
+			&& !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
+			need_prompt = 1;
+
+			AST_LIST_REMOVE_CURRENT(list);
+			user_iter->conference->activeusers--;
+			AST_LIST_INSERT_TAIL(&user_iter->conference->waiting_list, user_iter, list);
+			user_iter->conference->waitingusers++;
+		} else {
+			/* User is neither wait_marked nor end_marked nor end_marked_any; however, they
+			 * should still hear the prompt.
+			 */
+			need_prompt = 1;
 		}
-		AST_LIST_TRAVERSE_SAFE_END;
 	}
+	AST_LIST_TRAVERSE_SAFE_END;
 
 	switch (user->conference->activeusers) {
 	case 0:
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
index f90f185..a6fdbb4 100644
--- a/apps/confbridge/include/confbridge.h
+++ b/apps/confbridge/include/confbridge.h
@@ -71,6 +71,7 @@
 	USER_OPT_TEXT_MESSAGING = (1 << 19), /*!< Send text messages to the user */
 	USER_OPT_ANSWER_CHANNEL = (1 << 20), /*!< Sets if the channel should be answered if currently unanswered */
 	USER_OPT_HEAR_OWN_JOIN_SOUND  = (1 << 21), /*!< Set if the caller should hear the join sound */
+	USER_OPT_ENDMARKEDANY = (1 << 22), /*!< Set if the user should be kicked after any marked user exits */
 };
 
 enum bridge_profile_flags {
diff --git a/configs/samples/confbridge.conf.sample b/configs/samples/confbridge.conf.sample
index ed4c72b..f582323 100644
--- a/configs/samples/confbridge.conf.sample
+++ b/configs/samples/confbridge.conf.sample
@@ -58,8 +58,11 @@
                           ; when a channel enters a empty conference.  On by default.
 ;wait_marked=yes   ; Sets if the user must wait for a marked user to enter before
                    ; joining the conference. Off by default.
-;end_marked=yes ; This option will kick every user with this option set in their
-                ; user profile after the last Marked user exists the conference.
+;end_marked=yes ; This option will kick every non-marked user with this option set in their
+                ; user profile after the last marked user exits the conference.
+;end_marked_any=no ; This option will kick every user with this option set in
+                   ; their user profile after any marked user exits the conference.
+                   ; Additionally, note that unlike end_marked, this includes marked users.
 
 ;dsp_drop_silence=yes  ; This option drops what Asterisk detects as silence from
                        ; entering into the bridge.  Enabling this option will drastically
diff --git a/doc/CHANGES-staging/app_confbridge_marked_any.txt b/doc/CHANGES-staging/app_confbridge_marked_any.txt
new file mode 100644
index 0000000..cbc1bbf
--- /dev/null
+++ b/doc/CHANGES-staging/app_confbridge_marked_any.txt
@@ -0,0 +1,5 @@
+Subject: app_confbridge
+
+Adds the end_marked_any option which can be used
+to kick users from a conference after any
+marked user leaves (including marked users).

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

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I9e8da7ccb892e522546c0f2b5476d172e022c2f5
Gerrit-Change-Number: 19096
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/20220907/3df4ad30/attachment-0001.html>


More information about the asterisk-code-review mailing list