[svn-commits] dvossel: branch dvossel/hd_confbridge r311744 - in /team/dvossel/hd_confbridg...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 28 15:01:47 CDT 2011


Author: dvossel
Date: Mon Mar 28 15:01:42 2011
New Revision: 311744

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311744
Log:
Adds the ability to chain multiple menu actions together for a single sequence

For example:
*=reset_listening_volume, reset_talking_volume
will reset both volume settings.

And prompts can be chained together as well.

*=playback_and_continue(prompt2),playback_and_continue(prompt2),playback_and_continue(prompt3)

Prompt1, prompt2, and prompt3 will get played together until a
DTMF sequence is entered.


Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
    team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
    team/dvossel/hd_confbridge/configs/confbridge.conf.sample

Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=311744&r1=311743&r2=311744
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Mon Mar 28 15:01:42 2011
@@ -1374,7 +1374,8 @@
 	struct ast_bridge_channel *bridge_channel,
 	struct conf_menu *menu,
 	const char *playback_file,
-	const char *cur_dtmf)
+	const char *cur_dtmf,
+	int *stop_prompts)
 {
 	int i;
 	int digit;
@@ -1395,6 +1396,10 @@
 		return -1;
 	}
 	ast_stopstream(bridge_channel->chan);
+
+	/* If we get here, then DTMF has been entered, This means no
+	 * additional prompts should be played for this menu entry */
+	*stop_prompts = 1;
 
 	/* If a digit was pressed during the payback, update
 	 * the dtmf string and look for a new menu entry in the
@@ -1478,6 +1483,7 @@
 	struct conf_menu_action *menu_action;
 	struct conference_bridge_user *last_participant = NULL;
 	int isadmin = ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN);
+	int stop_prompts = 0;
 	int res = 0;
 
 	AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) {
@@ -1488,9 +1494,10 @@
 				bridge_channel->chan);
 			break;
 		case MENU_ACTION_PLAYBACK:
-			res |= action_playback(bridge_channel, menu_action->data.playback_file);
+			if (!(stop_prompts)) {
+				res |= action_playback(bridge_channel, menu_action->data.playback_file);
+			}
 			break;
-
 		case MENU_ACTION_RESET_LISTENING:
 			ast_audiohook_volume_set(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_WRITE, 0);
 			break;
@@ -1514,12 +1521,15 @@
 				AST_AUDIOHOOK_DIRECTION_READ, -1);
 			break;
 		case MENU_ACTION_PLAYBACK_AND_CONTINUE:
-			res |= action_playback_and_continue(conference_bridge,
-				conference_bridge_user,
-				bridge_channel,
-				menu,
-				menu_action->data.playback_file,
-				menu_entry->dtmf);
+			if (!(stop_prompts)) {
+				res |= action_playback_and_continue(conference_bridge,
+					conference_bridge_user,
+					bridge_channel,
+					menu,
+					menu_action->data.playback_file,
+					menu_entry->dtmf,
+					&stop_prompts);
+			}
 			break;
 		case MENU_ACTION_DIALPLAN_EXEC:
 			res |= action_dialplan_exec(bridge_channel, menu_action);
@@ -1558,6 +1568,8 @@
 			ao2_lock(conference_bridge);
 			ast_bridge_remove(conference_bridge->bridge, bridge_channel->chan);
 			ao2_unlock(conference_bridge);
+			break;
+		case MENU_ACTION_NOOP:
 			break;
 		}
 	}

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=311744&r1=311743&r2=311744
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Mon Mar 28 15:01:42 2011
@@ -545,6 +545,7 @@
 	menu_action->id = id;
 
 	switch (id) {
+	case MENU_ACTION_NOOP:
 	case MENU_ACTION_TOGGLE_MUTE:
 	case MENU_ACTION_INCREASE_LISTENING:
 	case MENU_ACTION_DECREASE_LISTENING:
@@ -601,59 +602,66 @@
 	return 0;
 }
 
-static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action)
+static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names)
 {
 	struct conf_menu_entry *menu_entry = ast_calloc(1, sizeof(*menu_entry));
 	int res = 0;
-	unsigned int action_len = strlen(action);
+	char *tmp_action_names = ast_strdupa(action_names);
+	char *action = NULL;
 	char *action_args;
 	char *tmp;
 
 	if (!(menu_entry)) {
 		return -1;
 	}
-	ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
-	if (!strcasecmp(action, "toggle_mute")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
-	} else if (!strcasecmp(action, "increase_listening_volume")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL);
-	} else if (!strcasecmp(action, "decrease_listening_volume")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL);
-	} else if (!strcasecmp(action, "increase_talking_volume")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL);
-	} else if (!strcasecmp(action, "reset_listening_volume")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL);
-	} else if (!strcasecmp(action, "reset_talking_volume")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL);
-	} else if (!strcasecmp(action, "decrease_talking_volume")) {
-		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_kick_last")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
-	} else if (!strcasecmp(action, "leave_conference")) {
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
-	} else if (!strncasecmp(action, "dialplan_exec", 13)) {
-		action_args = ast_strdupa(action);
-		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
-			*tmp = '\0';
-			action_args++;
-		}
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
-	} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue", 21)) {
-		action_args = ast_strdupa(action);
-		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
-			*tmp = '\0';
-			action_args++;
-		}
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
-	} else if (action_len >= 8 && !strncasecmp(action, "playback", 8)) {
-		action_args = ast_strdupa(action);
-		if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
-			*tmp = '\0';
-			action_args++;
-		}
-		res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args);
+
+	while ((action = strsep(&tmp_action_names, ","))) {
+		unsigned int action_len = strlen(action);
+		ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
+		if (!strcasecmp(action, "toggle_mute")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
+		} else if (!strcasecmp(action, "no_op")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL);
+		} else if (!strcasecmp(action, "increase_listening_volume")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL);
+		} else if (!strcasecmp(action, "decrease_listening_volume")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL);
+		} else if (!strcasecmp(action, "increase_talking_volume")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL);
+		} else if (!strcasecmp(action, "reset_listening_volume")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL);
+		} else if (!strcasecmp(action, "reset_talking_volume")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL);
+		} else if (!strcasecmp(action, "decrease_talking_volume")) {
+			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_kick_last")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
+		} else if (!strcasecmp(action, "leave_conference")) {
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
+		} else if (!strncasecmp(action, "dialplan_exec", 13)) {
+			action_args = ast_strdupa(action);
+			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+				*tmp = '\0';
+				action_args++;
+			}
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
+		} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue", 21)) {
+			action_args = ast_strdupa(action);
+			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+				*tmp = '\0';
+				action_args++;
+			}
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
+		} else if (action_len >= 8 && !strncasecmp(action, "playback", 8)) {
+			action_args = ast_strdupa(action);
+			if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+				*tmp = '\0';
+				action_args++;
+			}
+			res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args);
+		}
 	}
 
 	/* if adding any of the actions failed, bail */
@@ -1059,6 +1067,9 @@
 			case MENU_ACTION_TOGGLE_MUTE:
 				ast_cli(a->fd, "toggle_mute");
 				break;
+			case MENU_ACTION_NOOP:
+				ast_cli(a->fd, "no_op");
+				break;
 			case MENU_ACTION_INCREASE_LISTENING:
 				ast_cli(a->fd, "increase_listening_volume");
 				break;

Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=311744&r1=311743&r2=311744
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Mon Mar 28 15:01:42 2011
@@ -76,6 +76,7 @@
 	MENU_ACTION_ADMIN_TOGGLE_LOCK,
 	MENU_ACTION_ADMIN_KICK_LAST,
 	MENU_ACTION_LEAVE,
+	MENU_ACTION_NOOP,
 };
 
 /*! The conference menu action contains both
@@ -85,7 +86,7 @@
 struct conf_menu_action {
 	enum conf_menu_action_id id;
 	union {
-		char playback_file[256];
+		char playback_file[512];
 		struct {
 			char context[AST_MAX_CONTEXT];
 			char exten[AST_MAX_EXTENSION];

Modified: team/dvossel/hd_confbridge/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/configs/confbridge.conf.sample?view=diff&rev=311744&r1=311743&r2=311744
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Mon Mar 28 15:01:42 2011
@@ -206,17 +206,26 @@
 ; Below is a list of menu actions that can be assigned
 ; to a DTMF sequence.
 ;
+; A single DTMF sequence can have multiple actions associated with it. This is
+; accomplished by stringing the actions together.
+: Example:  Two playback files are played back one after the other after '*' is pressed.
+; *=playback_and_continue(tt-weasels),playback_and_continue(tt-monkeys)
+;
 ; playback(<name of playback prompt>)  ; Playback will play back a prompt to a channel
                                        ; and then immediately return to the conference.
+                                       ; This prompt can not be interupted by DTMF.
 ; playback_and_continue(<name of playback prompt>) ; playback_and_continue will
                                        ; play back a prompt while continuing to
                                        ; collect the dtmf sequence.  This is useful
                                        ; when using a menu prompt that describes all
-                                       ; the menu options.
+                                       ; the menu options.  Note however that any DTMF
+                                       ; during this action will terminate the prompts
+                                       ; playback.
 ; toggle_mute      ; Toggle turning on and off mute.  Mute will make the user silent
                    ; to everyone else, but the user will still be able to listen in.
                    ; continue to collect the dtmf sequence.
-
+; no_op ; This action does nothing (No Operation). Its only real purpose exists for
+        ; being able to reserve a sequence in the config as a menu exit sequence.
 ; decrease_listening_volume ; Decreases the channel's listening volume.
 ; increase_listening_volume ; Increases the channel's listening volume.
 ; reset_listening_volume    ; Reset channel's listening volume to default level.
@@ -248,6 +257,7 @@
 *4=decrease_listening_volume
 *6=increase_listening_volume
 *7=decrease_talking_volume
+*8=no_op
 *9=increase_talking_volume
 
 [sample_admin_menu]
@@ -259,4 +269,5 @@
 *4=decrease_listening_volume
 *6=increase_listening_volume
 *7=decrease_talking_volume
+*8=no_op
 *9=increase_talking_volume




More information about the svn-commits mailing list