[asterisk-commits] dvossel: branch dvossel/hd_confbridge r311609 - in /team/dvossel/hd_confbridg...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 23 12:43:34 CDT 2011
Author: dvossel
Date: Wed Mar 23 12:43:31 2011
New Revision: 311609
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311609
Log:
Adds 'announce_user_count_all' confbridge.conf option
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=311609&r1=311608&r2=311609
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Wed Mar 23 12:43:31 2011
@@ -219,6 +219,7 @@
static struct ao2_container *conference_bridges;
static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename);
+static int play_sound_number(struct conference_bridge *conference_bridge, int say_number);
static int execute_menu_entry(struct conference_bridge *conference_bridge,
struct conference_bridge_user *conference_bridge_user,
struct ast_bridge_channel *bridge_channel,
@@ -477,36 +478,51 @@
* \brief Announce number of users in the conference bridge to the caller
*
* \param conference_bridge Conference bridge to peek at
- * \param conference_bridge_user Caller
- *
+ * \param (OPTIONAL) conference_bridge_user Caller
+ *
+ * \note if caller is NULL, the announcment will be sent to all participants in the conference.
* \return Returns nothing
*/
static void announce_user_count(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
{
+ const char *other_in_party = conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference_bridge->b_profile.sounds);
+ const char *only_one = conf_get_sound(CONF_SOUND_ONLY_ONE, conference_bridge->b_profile.sounds);
+ const char *there_are = conf_get_sound(CONF_SOUND_THERE_ARE, conference_bridge->b_profile.sounds);
+
if (conference_bridge->users == 1) {
/* Awww we are the only person in the conference bridge */
return;
} else if (conference_bridge->users == 2) {
- /* Eep, there is one other person */
- if (ast_stream_and_wait(conference_bridge_user->chan,
- conf_get_sound(CONF_SOUND_ONLY_ONE, conference_bridge_user->b_profile.sounds),
- "")) {
- return;
+ if (conference_bridge_user) {
+ /* Eep, there is one other person */
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ only_one,
+ "")) {
+ return;
+ }
+ } else {
+ play_sound_file(conference_bridge, only_one);
}
} else {
/* Alas multiple others in here */
- if (ast_stream_and_wait(conference_bridge_user->chan,
- conf_get_sound(CONF_SOUND_THERE_ARE, conference_bridge_user->b_profile.sounds),
- "")) {
- return;
- }
- if (ast_say_number(conference_bridge_user->chan, conference_bridge->users - 1, "", conference_bridge_user->chan->language, NULL)) {
- return;
- }
- if (ast_stream_and_wait(conference_bridge_user->chan,
- conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference_bridge_user->b_profile.sounds),
- "")) {
- return;
+ if (conference_bridge_user) {
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ there_are,
+ "")) {
+ return;
+ }
+ if (ast_say_number(conference_bridge_user->chan, conference_bridge->users - 1, "", conference_bridge_user->chan->language, NULL)) {
+ return;
+ }
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ other_in_party,
+ "")) {
+ return;
+ }
+ } else {
+ play_sound_file(conference_bridge, there_are);
+ play_sound_number(conference_bridge, conference_bridge->users - 1);
+ play_sound_file(conference_bridge, other_in_party);
}
}
}
@@ -631,6 +647,12 @@
if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNT)) {
ao2_unlock(conference_bridge);
announce_user_count(conference_bridge, conference_bridge_user);
+ ao2_lock(conference_bridge);
+ }
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNTALL) &&
+ (conference_bridge->users > conference_bridge_user->u_profile.announce_user_count_all_after)) {
+ ao2_unlock(conference_bridge);
+ announce_user_count(conference_bridge, NULL);
ao2_lock(conference_bridge);
}
@@ -873,16 +895,7 @@
ao2_ref(conference_bridge, -1);
}
-/*!
- * \brief Play sound file into conference bridge
- *
- * \param conference_bridge The conference bridge to play sound file into
- * \param filename Sound file to play
- *
- * \retval 0 success
- * \retval -1 failure
- */
-static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename)
+static int play_sound_helper(struct conference_bridge *conference_bridge, const char *filename, int say_number)
{
struct ast_channel *underlying_channel;
@@ -922,7 +935,11 @@
}
/* The channel is all under our control, in goes the prompt */
- ast_stream_and_wait(conference_bridge->playback_chan, filename, "");
+ if (!ast_strlen_zero(filename)) {
+ ast_stream_and_wait(conference_bridge->playback_chan, filename, "");
+ } else {
+ ast_say_number(conference_bridge->playback_chan, say_number, "", conference_bridge->playback_chan->language, NULL);
+ }
ast_debug(1, "Departing underlying channel '%s' from bridge '%p'\n", underlying_channel->name, conference_bridge->bridge);
ast_bridge_depart(conference_bridge->bridge, underlying_channel);
@@ -930,6 +947,34 @@
ast_mutex_unlock(&conference_bridge->playback_lock);
return 0;
+}
+
+/*!
+ * \brief Play sound file into conference bridge
+ *
+ * \param conference_bridge The conference bridge to play sound file into
+ * \param filename Sound file to play
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename)
+{
+ return play_sound_helper(conference_bridge, filename, 0);
+}
+
+/*!
+ * \brief Play number into the conference bridge
+ *
+ * \param conference_bridge The conference bridge to say the number into
+ * \param number to say
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+static int play_sound_number(struct conference_bridge *conference_bridge, int say_number)
+{
+ return play_sound_helper(conference_bridge, NULL, say_number);
}
static void conf_handle_talker_destructor(void *pvt_data)
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=311609&r1=311608&r2=311609
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Wed Mar 23 12:43:31 2011
@@ -167,6 +167,16 @@
u_profile->flags = ast_true(value) ?
u_profile->flags | USER_OPT_QUIET :
u_profile->flags & ~USER_OPT_QUIET;
+ } else if (!strcasecmp(name, "announce_user_count_all")) {
+ if (ast_true(value)) {
+ u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else if (ast_false(value)) {
+ u_profile->flags = u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else if (sscanf(value, "%30u", &u_profile->announce_user_count_all_after) == 1) {
+ u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else {
+ return -1;
+ }
} else if (!strcasecmp(name, "announce_user_count")) {
u_profile->flags = ast_true(value) ?
u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNT :
@@ -478,6 +488,7 @@
ao2_lock(u_profile);
/* set defaults */
u_profile->flags = 0;
+ u_profile->announce_user_count_all_after = 0;
memset(u_profile->pin, 0, sizeof(u_profile->pin));
memset(u_profile->moh_class, 0, sizeof(u_profile->moh_class));
for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
@@ -752,9 +763,6 @@
ast_cli(a->fd,"Quiet: %s\n",
u_profile.flags & USER_OPT_QUIET ?
"enabled" : "disabled");
- ast_cli(a->fd,"Announce User Count: %s\n",
- u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ?
- "enabled" : "disabled");
ast_cli(a->fd,"Wait Marked: %s\n",
u_profile.flags & USER_OPT_WAITMARKED ?
"enabled" : "disabled");
@@ -767,9 +775,6 @@
ast_cli(a->fd,"Denoise: %s\n",
u_profile.flags & USER_OPT_DENOISE ?
"enabled" : "disabled");
- ast_cli(a->fd,"Announce join/leave: %s\n",
- u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE ?
- "enabled" : "disabled");
ast_cli(a->fd,"Talk Detect Events: %s\n",
u_profile.flags & USER_OPT_TALKER_DETECT ?
"enabled" : "disabled");
@@ -779,8 +784,16 @@
ast_cli(a->fd,"PIN: %s\n",
ast_strlen_zero(u_profile.pin) ?
"None" : u_profile.pin);
-
- ast_cli(a->fd,"\n");
+ ast_cli(a->fd,"Announce User Count: %s\n",
+ u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Announce join/leave: %s\n",
+ u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Announce User Count all: %s\n",
+ u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"\n");
return CLI_SUCCESS;
}
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=311609&r1=311608&r2=311609
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Wed Mar 23 12:43:31 2011
@@ -52,6 +52,7 @@
USER_OPT_TALKER_DETECT = (1 << 11), /*!< Sets if start and stop talking events should generated for this user over AMI. */
USER_OPT_DROP_SILENCE = (1 << 12), /*!< Sets if silence should be dropped from the mix or not. */
USER_OPT_DTMF_PASS = (1 << 13), /*!< Sets if dtmf should be passed into the conference or not */
+ USER_OPT_ANNOUNCEUSERCOUNTALL = (1 << 14), /*!< Sets if the number of users should be announced to everyone. */
};
enum bridge_profile_flags {
@@ -114,6 +115,7 @@
char pin[MAX_PIN];
char moh_class[128];
unsigned int flags;
+ unsigned int announce_user_count_all_after;
int delme;
};
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=311609&r1=311608&r2=311609
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Wed Mar 23 12:43:31 2011
@@ -27,6 +27,11 @@
; Off by default
;announce_user_count=yes ; Sets if the number of users should be announced to the
; caller. Off by default.
+;announce_user_count_all=yes ; Sets if the number of users should be announced to
+ ; all the other users in the conference when someone joins.
+ ; This option can be either set to 'yes' or a number.
+ ; When set to a number, the announcement will only occur
+ ; once the user count is above the specified number.
;announce_only_user=yes ; Sets if the only user announcement should be played
; 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
More information about the asterisk-commits
mailing list