[asterisk-commits] jrose: trunk r352134 - in /trunk: ./ configs/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 23 12:34:56 CST 2012


Author: jrose
Date: Mon Jan 23 12:34:47 2012
New Revision: 352134

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=352134
Log:
Add an announcement option to music-on-hold - plays sound when put on hold/between songs

This is a feature patch which allows an 'announcement' option to be specified in
musiconhold.conf which should be set to the name of a sound. If a valid sound is
specified for this option, then it will be played on that music on hold class whenever
a channel bound to that class is put on hold as well as when Asterisk is able to detect
that a song has ended before starting the next song (excludes external players).

(closes ASTERISK-18977)
Reported by: Timo Teräs
Patches:
	asterisk-moh-announcement.diff uploaded by Timo Teräs (license 5409)

Modified:
    trunk/CHANGES
    trunk/configs/musiconhold.conf.sample
    trunk/res/res_musiconhold.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=352134&r1=352133&r2=352134
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Jan 23 12:34:47 2012
@@ -57,6 +57,12 @@
    specification of a list of codecs allowed and disallowed, without the
    requirement to use two different keywords.  For example, to specify all
    codecs except g729 and g723, one need only specify allow=all,!g729,!g723.
+
+Music On Hold Changes
+---------------------
+ * Added 'announcement' option which will play at the start of MOH and between
+   songs in modes of MOH that can detect transitions between songs (eg.
+   files, mp3, etc).
 
 Queue changes
 -------------

Modified: trunk/configs/musiconhold.conf.sample
URL: http://svnview.digium.com/svn/asterisk/trunk/configs/musiconhold.conf.sample?view=diff&rev=352134&r1=352133&r2=352134
==============================================================================
--- trunk/configs/musiconhold.conf.sample (original)
+++ trunk/configs/musiconhold.conf.sample Mon Jan 23 12:34:47 2012
@@ -52,6 +52,11 @@
 ;digit=#        ; If this option is set for a class, then when callers are
 ;               ; listening to music on hold, they can press this digit, and
 ;               ; they will switch to listening to this music class.
+;announcement=queue-thankyou	;If this option is set for a class, then
+;               ; when callers get put on hold, the specified sound will be
+;               ; be played to them. Also, if using modes that Asterisk
+;               ; controls the playlist for (files, mp3, etc), the same
+;               ; sound will also be played between MOH songs.
 ;sort=random    ; Sort the files in random order
 
 ;[native-alphabetical]

Modified: trunk/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=352134&r1=352133&r2=352134
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Mon Jan 23 12:34:47 2012
@@ -158,6 +158,7 @@
 	char name[MAX_MUSICCLASS];
 	struct ast_format origwfmt;
 	struct ast_format mohwfmt;
+	int announcement;
 	int samples;
 	int sample_queue;
 	int pos;
@@ -173,6 +174,7 @@
 #define MOH_SORTALPHA		(1 << 4)
 
 #define MOH_CACHERTCLASSES      (1 << 5)        /*!< Should we use a separate instance of MOH for each user or not */
+#define MOH_ANNOUNCEMENT	(1 << 6)			/*!< Do we play announcement files between songs on this channel? */
 
 /* Custom astobj2 flag */
 #define MOH_NOTDELETED          (1 << 30)       /*!< Find only records that aren't deleted? */
@@ -183,6 +185,7 @@
 	char name[MAX_MUSICCLASS];
 	char dir[256];
 	char args[256];
+	char announcement[256];
 	char mode[80];
 	char digit;
 	/*! A dynamically sized array to hold the list of filenames in "files" mode */
@@ -276,6 +279,7 @@
 	}
 
 	state->save_pos = state->pos;
+	state->announcement = 0;
 
 	state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator");
 }
@@ -289,6 +293,16 @@
 	if (chan->stream) {
 		ast_closestream(chan->stream);
 		chan->stream = NULL;
+	}
+
+	if (ast_test_flag(state->class, MOH_ANNOUNCEMENT) && state->announcement == 0) {
+		state->announcement = 1;
+		if (ast_openstream_full(chan, state->class->announcement, chan->language, 1)) {
+			ast_debug(1, "%s Opened announcement '%s'\n", ast_channel_name(chan), state->class->announcement);
+			return 0;
+		}
+	} else {
+		state->announcement = 0;
 	}
 
 	if (!state->class->total_files) {
@@ -1735,23 +1749,26 @@
 			break;
 		}
 
-		ast_copy_string(class->name, cat, sizeof(class->name));	
+		ast_copy_string(class->name, cat, sizeof(class->name));
 		for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
-			if (!strcasecmp(var->name, "mode"))
-				ast_copy_string(class->mode, var->value, sizeof(class->mode)); 
-			else if (!strcasecmp(var->name, "directory"))
+			if (!strcasecmp(var->name, "mode")) {
+				ast_copy_string(class->mode, var->value, sizeof(class->mode));
+			} else if (!strcasecmp(var->name, "directory")) {
 				ast_copy_string(class->dir, var->value, sizeof(class->dir));
-			else if (!strcasecmp(var->name, "application"))
+			} else if (!strcasecmp(var->name, "application")) {
 				ast_copy_string(class->args, var->value, sizeof(class->args));
-			else if (!strcasecmp(var->name, "digit") && (isdigit(*var->value) || strchr("*#", *var->value)))
+			} else if (!strcasecmp(var->name, "announcement")) {
+				ast_copy_string(class->announcement, var->value, sizeof(class->announcement));
+				ast_set_flag(class, MOH_ANNOUNCEMENT);
+			} else if (!strcasecmp(var->name, "digit") && (isdigit(*var->value) || strchr("*#", *var->value))) {
 				class->digit = *var->value;
-			else if (!strcasecmp(var->name, "random"))
+			} else if (!strcasecmp(var->name, "random")) {
 				ast_set2_flag(class, ast_true(var->value), MOH_RANDOMIZE);
-			else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "random"))
+			} else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "random")) {
 				ast_set_flag(class, MOH_RANDOMIZE);
-			else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) 
+			} else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) {
 				ast_set_flag(class, MOH_SORTALPHA);
-			else if (!strcasecmp(var->name, "format")) {
+			} else if (!strcasecmp(var->name, "format")) {
 				ast_getformatbyname(var->value, &class->format);
 				if (!class->format.id) {
 					ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);




More information about the asterisk-commits mailing list