[asterisk-commits] rmudgett: trunk r402428 - in /trunk: ./ apps/ apps/confbridge/ apps/confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Nov 1 22:24:50 CDT 2013


Author: rmudgett
Date: Fri Nov  1 22:24:47 2013
New Revision: 402428

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402428
Log:
confbridge: Separate user muting from system muting overrides.

The system overrides the user muting requests when MOH is playing or a
waitmarked user is waiting for a marked user to join.  System muting
overrides interfere with what the user may wish the muting to be when the
system override ends.

* User muting requests are now independent of the system muting overrides.
The effective muting is now the logical or of the user request and system
override.

* Added a Muted flag to the CLI "confbridge list <conference>" command.

* Added a Muted header to the AMI ConfbridgeList action ConfbridgeList
event.

(closes issue AST-1102)
Reported by: John Bigelow

Review: https://reviewboard.asterisk.org/r/2960/
........

Merged revisions 402425 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 402427 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/apps/app_confbridge.c
    trunk/apps/confbridge/conf_state.c
    trunk/apps/confbridge/conf_state_inactive.c
    trunk/apps/confbridge/conf_state_multi.c
    trunk/apps/confbridge/conf_state_multi_marked.c
    trunk/apps/confbridge/conf_state_single.c
    trunk/apps/confbridge/conf_state_single_marked.c
    trunk/apps/confbridge/include/confbridge.h

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Fri Nov  1 22:24:47 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402367,402387,402398,402416
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402367,402387,402398,402416,402427

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Fri Nov  1 22:24:47 2013
@@ -967,6 +967,32 @@
 	return 0;
 }
 
+void conf_update_user_mute(struct confbridge_user *user)
+{
+	int mute_user;
+	int mute_system;
+	int mute_effective;
+
+	/* User level mute request. */
+	mute_user = user->muted;
+
+	/* System level mute request. */
+	mute_system = user->playing_moh
+		/*
+		 * Do not allow waitmarked users to talk to anyone unless there
+		 * is a marked user present.
+		 */
+		|| (!user->conference->markedusers
+			&& ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED));
+
+	mute_effective = mute_user || mute_system;
+
+	ast_debug(1, "User %s is %s: user:%d system:%d.\n",
+		ast_channel_name(user->chan), mute_effective ? "muted" : "unmuted",
+		mute_user, mute_system);
+	user->features.mute = mute_effective;
+}
+
 void conf_moh_stop(struct confbridge_user *user)
 {
 	user->playing_moh = 0;
@@ -1112,9 +1138,7 @@
 	if (ast_test_flag(&first_user->u_profile, USER_OPT_MUSICONHOLD)) {
 		conf_moh_stop(first_user);
 	}
-	if (!ast_test_flag(&first_user->u_profile, USER_OPT_STARTMUTED)) {
-		first_user->features.mute = 0;
-	}
+	conf_update_user_mute(first_user);
 }
 
 void conf_ended(struct confbridge_conference *conference)
@@ -1638,7 +1662,8 @@
 
 	/* If the caller should be joined already muted, make it so */
 	if (ast_test_flag(&user.u_profile, USER_OPT_STARTMUTED)) {
-		user.features.mute = 1;
+		/* Set user level mute request. */
+		user.muted = 1;
 	}
 
 	if (ast_test_flag(&user.u_profile, USER_OPT_DROP_SILENCE)) {
@@ -1756,17 +1781,28 @@
 	struct confbridge_user *user,
 	struct ast_channel *chan)
 {
-	/* Mute or unmute yourself, note we only allow manipulation if they aren't waiting for a marked user or if marked users exist */
-	if (!ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED) || conference->markedusers) {
-		user->features.mute = (!user->features.mute ? 1 : 0);
-		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(chan), user->features.mute ? "muted" : "unmuted", user->b_profile.name, ast_channel_name(chan));
-		if (user->features.mute) {
-			send_mute_event(chan, conference);
-		} else {
-			send_unmute_event(chan, conference);
-		}
-	}
-	return ast_stream_and_wait(chan, (user->features.mute ?
+	int mute;
+
+	/* Toggle user level mute request. */
+	mute = !user->muted;
+	user->muted = mute;
+
+	conf_update_user_mute(user);
+	ast_test_suite_event_notify("CONF_MUTE",
+		"Message: participant %s %s\r\n"
+		"Conference: %s\r\n"
+		"Channel: %s",
+		ast_channel_name(chan),
+		mute ? "muted" : "unmuted",
+		user->b_profile.name,
+		ast_channel_name(chan));
+	if (mute) {
+		send_mute_event(chan, conference);
+	} else {
+		send_unmute_event(chan, conference);
+	}
+
+	return ast_stream_and_wait(chan, (mute ?
 		conf_get_sound(CONF_SOUND_MUTED, user->b_profile.sounds) :
 		conf_get_sound(CONF_SOUND_UNMUTED, user->b_profile.sounds)),
 		"");
@@ -1776,21 +1812,26 @@
 {
 	struct confbridge_user *cur_user = NULL;
 	const char *sound_to_play;
+	int mute;
 
 	ao2_lock(conference);
 
-	/* If already muted, then unmute */
-	conference->muted = conference->muted ? 0 : 1;
-	sound_to_play = conf_get_sound((conference->muted ? CONF_SOUND_PARTICIPANTS_MUTED : CONF_SOUND_PARTICIPANTS_UNMUTED),
-		user->b_profile.sounds);
+	/* Toggle bridge level mute request. */
+	mute = !conference->muted;
+	conference->muted = mute;
 
 	AST_LIST_TRAVERSE(&conference->active_list, cur_user, list) {
 		if (!ast_test_flag(&cur_user->u_profile, USER_OPT_ADMIN)) {
-			cur_user->features.mute = conference->muted;
+			/* Set user level to bridge level mute request. */
+			cur_user->muted = mute;
+			conf_update_user_mute(cur_user);
 		}
 	}
 
 	ao2_unlock(conference);
+
+	sound_to_play = conf_get_sound((mute ? CONF_SOUND_PARTICIPANTS_MUTED : CONF_SOUND_PARTICIPANTS_UNMUTED),
+		user->b_profile.sounds);
 
 	/* The host needs to hear it seperately, as they don't get the audio from play_sound_helper */
 	ast_stream_and_wait(user->chan, sound_to_play, "");
@@ -2211,7 +2252,7 @@
 
 static void handle_cli_confbridge_list_item(struct ast_cli_args *a, struct confbridge_user *user, int waiting)
 {
-	char flag_str[5 + 1];/* Max flags + terminator */
+	char flag_str[6 + 1];/* Max flags + terminator */
 	int pos = 0;
 
 	/* Build flags column string. */
@@ -2227,18 +2268,22 @@
 	if (ast_test_flag(&user->u_profile, USER_OPT_ENDMARKED)) {
 		flag_str[pos++] = 'E';
 	}
+	if (user->muted) {
+		flag_str[pos++] = 'm';
+	}
 	if (waiting) {
 		flag_str[pos++] = 'w';
 	}
 	flag_str[pos] = '\0';
 
-	ast_cli(a->fd, "%-29s ", ast_channel_name(user->chan));
-	ast_cli(a->fd, "%-5s ", flag_str);
-	ast_cli(a->fd, "%-17s", user->u_profile.name);
-	ast_cli(a->fd, "%-17s", user->b_profile.name);
-	ast_cli(a->fd, "%-17s", user->menu_name);
-	ast_cli(a->fd, "%-17s", S_COR(ast_channel_caller(user->chan)->id.number.valid, ast_channel_caller(user->chan)->id.number.str, "<unknown>"));
-	ast_cli(a->fd, "\n");
+	ast_cli(a->fd, "%-30s %-6s %-16s %-16s %-16s %s\n",
+		ast_channel_name(user->chan),
+		flag_str,
+		user->u_profile.name,
+		user->b_profile.name,
+		user->menu_name,
+		S_COR(ast_channel_caller(user->chan)->id.number.valid,
+			ast_channel_caller(user->chan)->id.number.str, "<unknown>"));
 }
 
 static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -2260,6 +2305,7 @@
 			"         M - The user is a marked user\n"
 			"         W - The user must wait for a marked user to join\n"
 			"         E - The user will be kicked after the last marked user leaves the conference\n"
+			"         m - The user is muted\n"
 			"         w - The user is waiting for a marked user to join\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -2291,8 +2337,8 @@
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
 		}
-		ast_cli(a->fd, "Channel                       Flags User Profile     Bridge Profile   Menu             CallerID\n");
-		ast_cli(a->fd, "============================= ===== ================ ================ ================ ================\n");
+		ast_cli(a->fd, "Channel                        Flags  User Profile     Bridge Profile   Menu             CallerID\n");
+		ast_cli(a->fd, "============================== ====== ================ ================ ================ ================\n");
 		ao2_lock(conference);
 		AST_LIST_TRAVERSE(&conference->active_list, user, list) {
 			handle_cli_confbridge_list_item(a, user, 0);
@@ -2356,14 +2402,23 @@
 		}
 	}
 	if (user) {
-		user->features.mute = mute;
-		ast_channel_lock(user->chan);
-		if (user->features.mute) {
+		/* Set user level mute request. */
+		user->muted = mute ? 1 : 0;
+
+		conf_update_user_mute(user);
+		ast_test_suite_event_notify("CONF_MUTE",
+			"Message: participant %s %s\r\n"
+			"Conference: %s\r\n"
+			"Channel: %s",
+			ast_channel_name(user->chan),
+			mute ? "muted" : "unmuted",
+			conference->b_profile.name,
+			ast_channel_name(user->chan));
+		if (mute) {
 			send_mute_event(user->chan, conference);
 		} else {
 			send_unmute_event(user->chan, conference);
 		}
-		ast_channel_unlock(user->chan);
 	} else {
 		res = -2;;
 	}
@@ -2622,6 +2677,7 @@
 		"WaitMarked: %s\r\n"
 		"EndMarked: %s\r\n"
 		"Waiting: %s\r\n"
+		"Muted: %s\r\n"
 		"\r\n",
 		id_text,
 		conference->name,
@@ -2632,7 +2688,8 @@
 		ast_test_flag(&user->u_profile, USER_OPT_MARKEDUSER) ? "Yes" : "No",
 		ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED) ? "Yes" : "No",
 		ast_test_flag(&user->u_profile, USER_OPT_ENDMARKED) ? "Yes" : "No",
-		waiting ? "Yes" : "No");
+		waiting ? "Yes" : "No",
+		user->muted ? "Yes" : "No");
 }
 
 static int action_confbridgelist(struct mansession *s, const struct message *m)
@@ -3065,11 +3122,11 @@
 {
 	struct confbridge_user *only_user = AST_LIST_FIRST(&conference->active_list);
 
-	/* Turn on MOH/mute if the single participant is set up for it */
+	/* Turn on MOH if the single participant is set up for it */
 	if (ast_test_flag(&only_user->u_profile, USER_OPT_MUSICONHOLD)) {
-		only_user->features.mute = 1;
 		conf_moh_start(only_user);
 	}
+	conf_update_user_mute(only_user);
 }
 
 void conf_remove_user_waiting(struct confbridge_conference *conference, struct confbridge_user *user)

Modified: trunk/apps/confbridge/conf_state.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state.c (original)
+++ trunk/apps/confbridge/conf_state.c Fri Nov  1 22:24:47 2013
@@ -57,12 +57,11 @@
  */
 static void conf_mute_moh_inactive_waitmarked(struct confbridge_user *user)
 {
-	/* Be sure we are muted so we can't talk to anybody else waiting */
-	user->features.mute = 1;
 	/* Start music on hold if needed */
 	if (ast_test_flag(&user->u_profile, USER_OPT_MUSICONHOLD)) {
 		conf_moh_start(user);
 	}
+	conf_update_user_mute(user);
 }
 
 void conf_default_join_waitmarked(struct confbridge_user *user)

Modified: trunk/apps/confbridge/conf_state_inactive.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state_inactive.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state_inactive.c (original)
+++ trunk/apps/confbridge/conf_state_inactive.c Fri Nov  1 22:24:47 2013
@@ -61,7 +61,7 @@
 static void join_marked(struct confbridge_user *user)
 {
 	conf_add_user_marked(user->conference, user);
-	conf_handle_second_active(user->conference);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI_MARKED);
 }

Modified: trunk/apps/confbridge/conf_state_multi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state_multi.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state_multi.c (original)
+++ trunk/apps/confbridge/conf_state_multi.c Fri Nov  1 22:24:47 2013
@@ -54,11 +54,13 @@
 static void join_unmarked(struct confbridge_user *user)
 {
 	conf_add_user_active(user->conference, user);
+	conf_update_user_mute(user);
 }
 
 static void join_marked(struct confbridge_user *user)
 {
 	conf_add_user_marked(user->conference, user);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI_MARKED);
 }

Modified: trunk/apps/confbridge/conf_state_multi_marked.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state_multi_marked.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state_multi_marked.c (original)
+++ trunk/apps/confbridge/conf_state_multi_marked.c Fri Nov  1 22:24:47 2013
@@ -60,11 +60,13 @@
 static void join_active(struct confbridge_user *user)
 {
 	conf_add_user_active(user->conference, user);
+	conf_update_user_mute(user);
 }
 
 static void join_marked(struct confbridge_user *user)
 {
 	conf_add_user_marked(user->conference, user);
+	conf_update_user_mute(user);
 }
 
 static void leave_active(struct confbridge_user *user)
@@ -95,8 +97,8 @@
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->active_list, user_iter, list) {
 			/* Kick ENDMARKED user_iters */
 			if (ast_test_flag(&user_iter->u_profile, USER_OPT_ENDMARKED)) {
-				if (ast_test_flag(&user_iter->u_profile, USER_OPT_WAITMARKED) &&
-						  !ast_test_flag(&user_iter->u_profile, USER_OPT_MARKEDUSER)) {
+				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);
@@ -104,17 +106,18 @@
 				}
 				user_iter->kicked = 1;
 				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)) {
+			} else 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++;
-				/* Handle muting/moh of user_iter if necessary */
+
+				/* Handle moh of user_iter if necessary */
 				if (ast_test_flag(&user_iter->u_profile, USER_OPT_MUSICONHOLD)) {
-					user_iter->features.mute = 1;
 					conf_moh_start(user_iter);
 				}
+				conf_update_user_mute(user_iter);
 			}
 		}
 		AST_LIST_TRAVERSE_SAFE_END;
@@ -170,7 +173,7 @@
 		conf_handle_first_marked_common(user);
 	}
 
-	/* Move all waiting users to active, stopping MOH and umuting if necessary */
+	/* Move all waiting users to active, stopping MOH and unmuting if necessary */
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&user->conference->waiting_list, user_iter, list) {
 		AST_LIST_REMOVE_CURRENT(list);
 		user->conference->waitingusers--;
@@ -179,10 +182,7 @@
 		if (user_iter->playing_moh) {
 			conf_moh_stop(user_iter);
 		}
-		/* only unmute them if they are not supposed to start muted */
-		if (!ast_test_flag(&user_iter->u_profile, USER_OPT_STARTMUTED)) {
-			user_iter->features.mute = 0;
-		}
+		conf_update_user_mute(user_iter);
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 }

Modified: trunk/apps/confbridge/conf_state_single.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state_single.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state_single.c (original)
+++ trunk/apps/confbridge/conf_state_single.c Fri Nov  1 22:24:47 2013
@@ -55,6 +55,7 @@
 {
 	conf_add_user_active(user->conference, user);
 	conf_handle_second_active(user->conference);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI);
 }
@@ -63,6 +64,7 @@
 {
 	conf_add_user_marked(user->conference, user);
 	conf_handle_second_active(user->conference);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI_MARKED);
 }

Modified: trunk/apps/confbridge/conf_state_single_marked.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_state_single_marked.c?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/conf_state_single_marked.c (original)
+++ trunk/apps/confbridge/conf_state_single_marked.c Fri Nov  1 22:24:47 2013
@@ -54,6 +54,7 @@
 {
 	conf_add_user_active(user->conference, user);
 	conf_handle_second_active(user->conference);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI_MARKED);
 }
@@ -62,6 +63,7 @@
 {
 	conf_add_user_marked(user->conference, user);
 	conf_handle_second_active(user->conference);
+	conf_update_user_mute(user);
 
 	conf_change_state(user, CONF_STATE_MULTI_MARKED);
 }

Modified: trunk/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/include/confbridge.h?view=diff&rev=402428&r1=402427&r2=402428
==============================================================================
--- trunk/apps/confbridge/include/confbridge.h (original)
+++ trunk/apps/confbridge/include/confbridge.h Fri Nov  1 22:24:47 2013
@@ -242,6 +242,7 @@
 	struct ast_bridge_features features;         /*!< Bridge features structure */
 	struct ast_bridge_tech_optimizations tech_args; /*!< Bridge technology optimizations for talk detection */
 	unsigned int suspended_moh;                  /*!< Count of active suspended MOH actions. */
+	unsigned int muted:1;                        /*!< Has the user requested to be muted? */
 	unsigned int kicked:1;                       /*!< User has been kicked from the conference */
 	unsigned int playing_moh:1;                  /*!< MOH is currently being played to the user */
 	AST_LIST_HEAD_NOLOCK(, post_join_action) post_join_list; /*!< List of sounds to play after joining */;
@@ -385,6 +386,15 @@
 void conf_ended(struct confbridge_conference *conference);
 
 /*!
+ * \brief Update the actual mute status of the user and set it on the bridge.
+ *
+ * \param user User to update the mute status.
+ *
+ * \return Nothing
+ */
+void conf_update_user_mute(struct confbridge_user *user);
+
+/*!
  * \brief Stop MOH for the conference user.
  *
  * \param user Conference user to stop MOH on.




More information about the asterisk-commits mailing list