[asterisk-commits] mjordan: trunk r345560 - in /trunk: ./ apps/ apps/confbridge/ apps/confbridge...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 17 12:09:19 CST 2011


Author: mjordan
Date: Thu Nov 17 12:09:13 2011
New Revision: 345560

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=345560
Log:
Add admin toggle mute all and participant count menu options to app_confbridge

This patch adds two new menu features to app_confbridge, admin_toggle_menu_
participants and participant_count.  The admin action will globally mute /
unmute all non-admin participants on a converence, while the participant
count simply exposes the existing participant count function to the
conference bridge menu.

This also adds configuration options to change the sound played when the
conference is globally muted / unmuted, as well as the necessary config
hooks to place these functions in the DTMF menus.

(closes issue ASTERISK-18204)
Reported by: Kevin Reeves
Tested by: Matt Jordan
Patches:
  app_confbridge.c.patch.txt, conf_config_parser.c.patch.txt, 
  confbridge.h.patch.txt uploaded by Kevin Reeves (license 6281)

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


Added:
    trunk/contrib/realtime/mysql/sipfriends.sql
      - copied unchanged from r343280, team/mjordan/AST_18204/contrib/realtime/mysql/sipfriends.sql
Modified:
    trunk/CHANGES
    trunk/apps/app_confbridge.c
    trunk/apps/confbridge/conf_config_parser.c
    trunk/apps/confbridge/include/confbridge.h
    trunk/configs/confbridge.conf.sample

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=345560&r1=345559&r2=345560
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Nov 17 12:09:13 2011
@@ -11,6 +11,15 @@
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 10 to Asterisk 11 --------------------
 ------------------------------------------------------------------------------
+
+ConfBridge
+-------------------
+ * Added menu action admin_toggle_mute_participants.  This will mute / unmute
+   all non-admin participants on a conference.  The confbridge configuration file
+   also allows for the default sounds played to all conference users when this
+   occurs to be overriden using sound_participants_unmuted and sound_participants_muted.
+ * Added menu action participant_count.  This will playback the number of current
+   participants in a conference.
 
 SIP Changes
 -----------

Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=345560&r1=345559&r2=345560
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Thu Nov 17 12:09:13 2011
@@ -340,6 +340,10 @@
 		return S_OR(custom_sounds->join, "confbridge-join");
 	case CONF_SOUND_LEAVE:
 		return S_OR(custom_sounds->leave, "confbridge-leave");
+	case CONF_SOUND_PARTICIPANTS_MUTED:
+		return S_OR(custom_sounds->participantsmuted, "conf-now-muted");
+	case CONF_SOUND_PARTICIPANTS_UNMUTED:
+		return S_OR(custom_sounds->participantsunmuted, "conf-now-unmuted");
 	}
 
 	return "";
@@ -1548,6 +1552,37 @@
 		"");
 }
 
+static int action_toggle_mute_participants(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
+{
+	struct conference_bridge_user *participant = NULL;
+	const char *sound_to_play;
+
+	ao2_lock(conference_bridge);
+
+	/* If already muted, then unmute */
+	conference_bridge->muted = conference_bridge->muted ? 0 : 1;
+	sound_to_play = conf_get_sound((conference_bridge->muted ? CONF_SOUND_PARTICIPANTS_MUTED : CONF_SOUND_PARTICIPANTS_UNMUTED),
+		conference_bridge_user->b_profile.sounds);
+
+	AST_LIST_TRAVERSE(&conference_bridge->users_list, participant, list) {
+		if (!ast_test_flag(&participant->u_profile, USER_OPT_ADMIN)) {
+			participant->features.mute = conference_bridge->muted;
+		}
+	}
+
+	ao2_unlock(conference_bridge);
+
+	/* The host needs to hear it seperately, as they don't get the audio from play_sound_helper */
+	ast_stream_and_wait(conference_bridge_user->chan, sound_to_play, "");
+
+	/* Announce to the group that all participants are muted */
+	ast_autoservice_start(conference_bridge_user->chan);
+	play_sound_helper(conference_bridge, sound_to_play, 0);
+	ast_autoservice_stop(conference_bridge_user->chan);
+
+	return 0;
+}
+
 static int action_playback(struct ast_bridge_channel *bridge_channel, const char *playback_file)
 {
 	char *file_copy = ast_strdupa(playback_file);
@@ -1726,6 +1761,15 @@
 			res |= action_toggle_mute(conference_bridge,
 				conference_bridge_user,
 				bridge_channel->chan);
+			break;
+		case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
+			if (!isadmin) {
+				break;
+			}
+			action_toggle_mute_participants(conference_bridge, conference_bridge_user);
+			break;
+		case MENU_ACTION_PARTICIPANT_COUNT:
+			announce_user_count(conference_bridge, conference_bridge_user);
 			break;
 		case MENU_ACTION_PLAYBACK:
 			if (!stop_prompts) {
@@ -1944,14 +1988,15 @@
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
 		}
-		ast_cli(a->fd, "Channel                       User Profile     Bridge Profile   Menu\n");
-		ast_cli(a->fd, "============================= ================ ================ ================\n");
+		ast_cli(a->fd, "Channel                       User Profile     Bridge Profile   Menu             CallerID\n");
+		ast_cli(a->fd, "============================= ================ ================ ================ ================\n");
 		ao2_lock(bridge);
 		AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
 			ast_cli(a->fd, "%-29s ", participant->chan->name);
 			ast_cli(a->fd, "%-17s", participant->u_profile.name);
 			ast_cli(a->fd, "%-17s", participant->b_profile.name);
 			ast_cli(a->fd, "%-17s", participant->menu_name);
+			ast_cli(a->fd, "%-17s", S_COR(participant->chan->caller.id.number.valid, participant->chan->caller.id.number.str, "<unknown>"));
 			ast_cli(a->fd, "\n");
 		}
 		ao2_unlock(bridge);

Modified: trunk/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/conf_config_parser.c?view=diff&rev=345560&r1=345559&r2=345560
==============================================================================
--- trunk/apps/confbridge/conf_config_parser.c (original)
+++ trunk/apps/confbridge/conf_config_parser.c Thu Nov 17 12:09:13 2011
@@ -253,6 +253,10 @@
 		ast_string_field_set(sounds, join, sound_file);
 	} else if (!strcasecmp(sound_name, "sound_leave")) {
 		ast_string_field_set(sounds, leave, sound_file);
+	} else if (!strcasecmp(sound_name, "sound_participants_muted")) {
+		ast_string_field_set(sounds, participantsmuted, sound_file);
+	} else if (!strcasecmp(sound_name, "sound_participants_unmuted")) {
+		ast_string_field_set(sounds, participantsunmuted, sound_file);
 	} else {
 		return -1;
 	}
@@ -315,7 +319,7 @@
 		}
 		/* Using a bridge profile as a template is a little complicated due to the sounds. Since the sounds
 		 * structure of a dynamic profile will need to be altered, a completely new sounds structure must be
-		 * create instead of simply holding a reference to the one built by the config file. */
+		 * created instead of simply holding a reference to the one built by the config file. */
 		ast_string_field_set(sounds, onlyperson, tmp->sounds->onlyperson);
 		ast_string_field_set(sounds, hasjoin, tmp->sounds->hasjoin);
 		ast_string_field_set(sounds, hasleft, tmp->sounds->hasleft);
@@ -332,6 +336,8 @@
 		ast_string_field_set(sounds, unlockednow, tmp->sounds->unlockednow);
 		ast_string_field_set(sounds, lockednow, tmp->sounds->lockednow);
 		ast_string_field_set(sounds, errormenu, tmp->sounds->errormenu);
+		ast_string_field_set(sounds, participantsmuted, tmp->sounds->participantsmuted);
+		ast_string_field_set(sounds, participantsunmuted, tmp->sounds->participantsunmuted);
 
 		ao2_ref(tmp->sounds, -1); /* sounds struct copied over to it from the template by reference only. */
 		ao2_ref(oldsounds,-1);    /* original sounds struct we don't need anymore */
@@ -540,6 +546,8 @@
 	case MENU_ACTION_RESET_LISTENING:
 	case MENU_ACTION_RESET_TALKING:
 	case MENU_ACTION_ADMIN_TOGGLE_LOCK:
+	case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
+	case MENU_ACTION_PARTICIPANT_COUNT:
 	case MENU_ACTION_ADMIN_KICK_LAST:
 	case MENU_ACTION_LEAVE:
 	case MENU_ACTION_SET_SINGLE_VIDEO_SRC:
@@ -655,6 +663,10 @@
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL);
 		} else if (!strcasecmp(action, "admin_toggle_conference_lock")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_LOCK, NULL);
+		} else if (!strcasecmp(action, "admin_toggle_mute_participants")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS, NULL);
+		} else if (!strcasecmp(action, "participant_count")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PARTICIPANT_COUNT, NULL);
 		} else if (!strcasecmp(action, "admin_kick_last")) {
 			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
 		} else if (!strcasecmp(action, "leave_conference")) {
@@ -1025,6 +1037,8 @@
 	ast_cli(a->fd,"sound_unlocked_now:   %s\n", conf_get_sound(CONF_SOUND_UNLOCKED_NOW, b_profile.sounds));
 	ast_cli(a->fd,"sound_lockednow:      %s\n", conf_get_sound(CONF_SOUND_LOCKED_NOW, b_profile.sounds));
 	ast_cli(a->fd,"sound_error_menu:     %s\n", conf_get_sound(CONF_SOUND_ERROR_MENU, b_profile.sounds));
+	ast_cli(a->fd,"sound_participants_muted:     %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_MUTED, b_profile.sounds));
+	ast_cli(a->fd,"sound_participants_unmuted:     %s\n", conf_get_sound(CONF_SOUND_PARTICIPANTS_UNMUTED, b_profile.sounds));
 	ast_cli(a->fd,"\n");
 
 	conf_bridge_profile_destroy(&b_profile);
@@ -1160,6 +1174,12 @@
 			case MENU_ACTION_ADMIN_TOGGLE_LOCK:
 				ast_cli(a->fd, "admin_toggle_conference_lock");
 				break;
+			case MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS:
+				ast_cli(a->fd, "admin_toggle_mute_participants");
+				break;
+			case MENU_ACTION_PARTICIPANT_COUNT:
+				ast_cli(a->fd, "participant_count");
+				break;
 			case MENU_ACTION_ADMIN_KICK_LAST:
 				ast_cli(a->fd, "admin_kick_last");
 				break;
@@ -1360,8 +1380,9 @@
 				conf_bridge_profile_copy(result, &b_data->b_profile);
 				return result;
 			}
-		}
-		ast_channel_unlock(chan);
+		} else {
+			ast_channel_unlock(chan);
+		}
 	}
 	if (ast_strlen_zero(bridge_profile_name)) {
 		bridge_profile_name = DEFAULT_BRIDGE_PROFILE;

Modified: trunk/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/confbridge/include/confbridge.h?view=diff&rev=345560&r1=345559&r2=345560
==============================================================================
--- trunk/apps/confbridge/include/confbridge.h (original)
+++ trunk/apps/confbridge/include/confbridge.h Thu Nov 17 12:09:13 2011
@@ -83,6 +83,8 @@
 	MENU_ACTION_NOOP,
 	MENU_ACTION_SET_SINGLE_VIDEO_SRC,
 	MENU_ACTION_RELEASE_SINGLE_VIDEO_SRC,
+	MENU_ACTION_PARTICIPANT_COUNT,
+	MENU_ACTION_ADMIN_TOGGLE_MUTE_PARTICIPANTS,
 };
 
 /*! The conference menu action contains both
@@ -156,6 +158,8 @@
 	CONF_SOUND_ERROR_MENU,
 	CONF_SOUND_JOIN,
 	CONF_SOUND_LEAVE,
+	CONF_SOUND_PARTICIPANTS_MUTED,
+	CONF_SOUND_PARTICIPANTS_UNMUTED,
 };
 
 struct bridge_profile_sounds {
@@ -180,6 +184,8 @@
 		AST_STRING_FIELD(errormenu);
 		AST_STRING_FIELD(leave);
 		AST_STRING_FIELD(join);
+		AST_STRING_FIELD(participantsmuted);
+		AST_STRING_FIELD(participantsunmuted);
 	);
 };
 
@@ -202,6 +208,7 @@
 	unsigned int users;                                               /*!< Number of users present */
 	unsigned int markedusers;                                         /*!< Number of marked users present */
 	unsigned int locked:1;                                            /*!< Is this conference bridge locked? */
+	unsigned int muted:1;                                            /*!< Is this conference bridge muted? */
 	struct ast_channel *playback_chan;                                /*!< Channel used for playback into the conference bridge */
 	struct ast_channel *record_chan;                                  /*!< Channel used for recording the conference */
 	pthread_t record_thread;                                          /*!< The thread the recording chan lives in */

Modified: trunk/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/confbridge.conf.sample?view=diff&rev=345560&r1=345559&r2=345560
==============================================================================
--- trunk/configs/confbridge.conf.sample (original)
+++ trunk/configs/confbridge.conf.sample Thu Nov 17 12:09:13 2011
@@ -306,6 +306,15 @@
                               ; to whatever operation the video_mode option is set to
                               ; upon release of the video src.
 
+; admin_toggle_mute_participants ; This action allows an administrator to toggle the mute
+                                 ; state for all non-admins within a conference.  All
+                                 ; admin users are unaffected by this option.  Note that all
+                                 ; users, regardless of their admin status, are notified
+                                 ; that the conference is muted.
+
+; participant_count        ; This action plays back the number of participants currently
+                           ; in a conference
+
 [sample_user_menu]
 type=menu
 *=playback_and_continue(conf-usermenu)




More information about the asterisk-commits mailing list