[asterisk-commits] dvossel: branch dvossel/hd_confbridge r310589 - in /team/dvossel/hd_confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 14 11:15:51 CDT 2011


Author: dvossel
Date: Mon Mar 14 11:15:49 2011
New Revision: 310589

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310589
Log:
Ability to record and announce user names on join and leave

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=310589&r1=310588&r2=310589
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Mon Mar 14 11:15:49 2011
@@ -49,6 +49,7 @@
 #include "asterisk/audiohook.h"
 #include "asterisk/astobj2.h"
 #include "confbridge/include/confbridge.h"
+#include "asterisk/paths.h"
 
 /*** DOCUMENTATION
         <application name="ConfBridge" language="en_US">
@@ -547,7 +548,6 @@
 	return 0;
 }
 
-
 static int conf_get_pin(struct ast_channel *chan, const char *pin)
 {
 	char pin_guess[MAX_PIN] = { 0, };
@@ -575,6 +575,39 @@
 		}
 	}
 	return -1;
+}
+
+static int conf_rec_name(struct conference_bridge_user *user, const char *conf_name)
+{
+	char destdir[PATH_MAX];
+	int res;
+	int duration = 20;
+
+	snprintf(destdir, sizeof(destdir), "%s/confbridge", ast_config_AST_SPOOL_DIR);
+
+	if (ast_mkdir(destdir, 0777) != 0) {
+		ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno));
+		return -1;
+	}
+	snprintf(user->name_rec_location, sizeof(user->name_rec_location),
+		 "%s/confbridge-name-%s-%s", destdir,
+		 conf_name, user->chan->uniqueid);
+
+	res = ast_play_and_record(user->chan,
+		"vm-rec-name",
+		user->name_rec_location,
+		10,
+		"sln",
+		&duration,
+		ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE),
+		0,
+		NULL);
+
+	if (res == -1) {
+		user->name_rec_location[0] = '\0';
+		return -1;
+	}
+	return 0;
 }
 
 /*! \brief The ConfBridge application */
@@ -625,6 +658,11 @@
 		}
 	}
 
+	/* See if we need them to record a intro name */
+	if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_ANNOUNCE_JOIN_LEAVE)) {
+		conf_rec_name(&conference_bridge_user, args.conf_name);
+	}
+
 	/* Always initialize the features structure, we are in most cases always going to need it. */
 	ast_bridge_features_init(&conference_bridge_user.features);
 	/* menu name */
@@ -672,6 +710,14 @@
 	}
 	ast_channel_unlock(chan);
 
+	/* if this user has a intro, play it before entering */
+	if (!ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+		ast_autoservice_start(chan);
+		play_sound_file(conference_bridge, conference_bridge_user.name_rec_location);
+		play_sound_file(conference_bridge, "conf-hasjoin");
+		ast_autoservice_stop(chan);
+	}
+
 	/* If there is 1 or more people already in the conference then play our join sound unless overridden */
 	if (!ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_QUIET) && !ast_strlen_zero(join_sound) && conference_bridge->users >= 2) {
 		ast_autoservice_start(chan);
@@ -682,6 +728,14 @@
 	/* Join our conference bridge for real */
 	ast_bridge_join(conference_bridge->bridge, chan, NULL, &conference_bridge_user.features);
 
+	/* if this user has a intro, play it when leaving */
+	if (!ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+		ast_autoservice_start(chan);
+		play_sound_file(conference_bridge, conference_bridge_user.name_rec_location);
+		play_sound_file(conference_bridge, "conf-hasleft");
+		ast_autoservice_stop(chan);
+	}
+
 	/* If there is 1 or more people (not including us) already in the conference then play our leave sound unless overridden */
 	if (!ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_QUIET) && !ast_strlen_zero(leave_sound) && conference_bridge->users >= 2) {
 		ast_autoservice_start(chan);
@@ -707,6 +761,10 @@
 	}
 	if (volume_adjustments[1]) {
 		ast_audiohook_volume_set(chan, AST_AUDIOHOOK_DIRECTION_WRITE, volume_adjustments[1]);
+	}
+
+	if (!ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+		ast_filedelete(conference_bridge_user.name_rec_location, NULL);
 	}
 
 	return res;

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=310589&r1=310588&r2=310589
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Mon Mar 14 11:15:49 2011
@@ -220,6 +220,10 @@
 			u_profile->flags = ast_true(var->value) ?
 				u_profile->flags | USER_OPT_WAITMARKED :
 				u_profile->flags & ~USER_OPT_WAITMARKED;
+		} else if (!strcasecmp(var->name, "announce_join_leave")) {
+			u_profile->flags = ast_true(var->value) ?
+				u_profile->flags | USER_OPT_ANNOUNCE_JOIN_LEAVE :
+				u_profile->flags & ~USER_OPT_ANNOUNCE_JOIN_LEAVE;
 		} else if (!strcasecmp(var->name, "pin")) {
 			ast_copy_string(u_profile->pin, var->value, sizeof(u_profile->pin));
 		} else if (!strcasecmp(var->name, "denoise")) {
@@ -470,6 +474,9 @@
 	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,"PIN:                 %s\n",
 		ast_strlen_zero(u_profile.pin) ?
 		"None" : u_profile.pin);

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=310589&r1=310588&r2=310589
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Mon Mar 14 11:15:49 2011
@@ -41,6 +41,7 @@
 	USER_OPT_ANNOUNCEUSERCOUNT = (1 << 6), /*!< Set if the number of users should be announced to the caller */
 	USER_OPT_WAITMARKED =   (1 << 7), /*!< Set if the conference must wait for a marked user before starting */
 	USER_OPT_DENOISE =      (1 << 8), /*!< Sets if denoise filter should be used on audio before mixing. */
+	USER_OPT_ANNOUNCE_JOIN_LEAVE = (1 << 9), /*!< Sets if the user's name should be recorded and announced on join and leave. */
 };
 
 enum conf_menu_action_id {
@@ -131,6 +132,7 @@
 	struct bridge_profile b_profile;             /*!< The Bridge Configuration Profile */
 	struct user_profile u_profile;               /*!< The User Configuration Profile */
 	char menu_name[64];                          /*!< The name of the DTMF menu assigned to this user */
+	char name_rec_location[PATH_MAX];            /*!< Location of the User's name recorded file if it exists */
 	struct ast_channel *chan;                    /*!< Asterisk channel participating */
 	char *opt_args[OPTION_ARRAY_SIZE];           /*!< Arguments to options passed when application was called */
 	struct ast_bridge_features features;         /*!< Bridge features structure */

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=310589&r1=310588&r2=310589
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Mon Mar 14 11:15:49 2011
@@ -30,8 +30,10 @@
              ; codec_speex to be built and installed.
 ;pin=1234  ; Sets if this user must enter a PIN number before entering
            ; the conference.  The PIN will be prompted for.
-
-
+;announce_join_leave=yes ; When enabled, this option will prompt the user for a
+                         ; name when entering the conference.  After the name is
+                         ; recorded, it will be played as the user enters and exists
+                         ; the conference. This option is off by default.
 
 ; --- ConfBridge Bridge Profile Options ---
 [default_bridge]




More information about the asterisk-commits mailing list