aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk/ASTERISK-18977.patch
blob: fffce032cd706bf1fd2321e0c97150b6a85d4bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- a/res/res_musiconhold.c.orig
+++ b/res/res_musiconhold.c
@@ -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)
 
 /* 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[80];
 	char mode[80];
 	char digit;
 	/*! A dynamically sized array to hold the list of filenames in "files" mode */
@@ -278,6 +281,7 @@
 	}
 
 	state->save_pos = state->pos;
+	state->announcement = 0;
 
 	state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator");
 }
@@ -293,6 +297,16 @@
 		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", chan->name, 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;
@@ -1731,7 +1745,10 @@
 				ast_copy_string(class->dir, var->value, sizeof(class->dir));
 			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"))
 				ast_set2_flag(class, ast_true(var->value), MOH_RANDOMIZE);