diff options
author | Jonathan Rose <jrose@digium.com> | 2012-01-23 18:34:47 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2012-01-23 18:34:47 +0000 |
commit | de09749470ceb17af6c6646115d447e0e54c75ee (patch) | |
tree | e3a49ec2e023df24a16dc2c9a71e327188f0302f | |
parent | a1bef6041dba6e0e6fd54766493e2006711a31d0 (diff) |
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)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@352134 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | configs/musiconhold.conf.sample | 5 | ||||
-rw-r--r-- | res/res_musiconhold.c | 37 |
3 files changed, 38 insertions, 10 deletions
@@ -58,6 +58,12 @@ Codec changes 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 ------------- * Added queue options autopausebusy and autopauseunavail for automatically diff --git a/configs/musiconhold.conf.sample b/configs/musiconhold.conf.sample index 9147588f1..1211c8a6d 100644 --- a/configs/musiconhold.conf.sample +++ b/configs/musiconhold.conf.sample @@ -52,6 +52,11 @@ directory=moh ;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] diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 0b04c9d39..7ef43ea23 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -158,6 +158,7 @@ struct moh_files_state { 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 @@ struct moh_files_state { #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 @@ struct mohclass { 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 @@ static void moh_files_release(struct ast_channel *chan, void *data) } state->save_pos = state->pos; + state->announcement = 0; state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator"); } @@ -291,6 +295,16 @@ static int ast_moh_files_next(struct ast_channel *chan) 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) { ast_log(LOG_WARNING, "No files available for class '%s'\n", state->class->name); return -1; @@ -1735,23 +1749,26 @@ static int load_moh_classes(int reload) 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); |