[Asterisk-code-review] voicemail: add option 'e' to play greetings as early media (asterisk[16])

George Joseph asteriskteam at digium.com
Tue Dec 1 11:23:26 CST 2020


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15112 )

Change subject: voicemail: add option 'e' to play greetings as early media
......................................................................

voicemail: add option 'e' to play greetings as early media

When using this option, answering the channel is deferred until
all prompts/greetings have been played and the caller is about
to leave their message.

ASTERISK-29118 #close

Change-Id: I41b9f0428783c0bd697c8c994f906d1e75ce9ddb
---
M apps/app_voicemail.c
A doc/CHANGES-staging/voicemail_early_media.txt
2 files changed, 25 insertions(+), 5 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 940ca67..cbeeb4f 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -168,6 +168,10 @@
 						<para>Accept digits for a new extension in context <replaceable>c</replaceable>,
 						if played during the greeting. Context defaults to the current context.</para>
 					</option>
+					<option name="e">
+						<para>Play greetings as early media -- only answer the channel just
+						before accepting the voice message.</para>
+					</option>
 					<option name="g">
 						<argument name="#" required="true" />
 						<para>Use the specified amount of gain when recording the voicemail
@@ -660,7 +664,8 @@
 	OPT_AUTOPLAY =         (1 << 6),
 	OPT_DTMFEXIT =         (1 << 7),
 	OPT_MESSAGE_Urgent =   (1 << 8),
-	OPT_MESSAGE_PRIORITY = (1 << 9)
+	OPT_MESSAGE_PRIORITY = (1 << 9),
+	OPT_EARLYM_GREETING =  (1 << 10)
 };
 
 enum vm_option_args {
@@ -686,7 +691,8 @@
 	AST_APP_OPTION('p', OPT_PREPEND_MAILBOX),
 	AST_APP_OPTION_ARG('a', OPT_AUTOPLAY, OPT_ARG_PLAYFOLDER),
 	AST_APP_OPTION('U', OPT_MESSAGE_Urgent),
-	AST_APP_OPTION('P', OPT_MESSAGE_PRIORITY)
+	AST_APP_OPTION('P', OPT_MESSAGE_PRIORITY),
+	AST_APP_OPTION('e', OPT_EARLYM_GREETING)
 });
 
 static const char * const mailbox_folders[] = {
@@ -6959,6 +6965,9 @@
 		return -1;
 	}
 	/* The meat of recording the message...  All the announcements and beeps have been played*/
+	if (ast_channel_state(chan) != AST_STATE_UP) {
+		ast_answer(chan);
+	}
 	ast_copy_string(fmt, vmfmts, sizeof(fmt));
 	if (!ast_strlen_zero(fmt)) {
 		char msg_id[MSG_ID_LEN] = "";
@@ -12364,9 +12373,6 @@
 
 	memset(&leave_options, 0, sizeof(leave_options));
 
-	if (ast_channel_state(chan) != AST_STATE_UP)
-		ast_answer(chan);
-
 	if (!ast_strlen_zero(data)) {
 		tmp = ast_strdupa(data);
 		AST_STANDARD_APP_ARGS(args, tmp);
@@ -12399,6 +12405,14 @@
 		args.argv0 = ast_strdupa(temp);
 	}
 
+	if (ast_channel_state(chan) != AST_STATE_UP) {
+		if (ast_test_flag(&flags, OPT_EARLYM_GREETING)) {
+			ast_indicate(chan, AST_CONTROL_PROGRESS);
+		} else {
+			ast_answer(chan);
+		}
+	}
+
 	res = leave_voicemail(chan, args.argv0, &leave_options);
 	if (res == 't') {
 		ast_play_and_wait(chan, "vm-goodbye");
diff --git a/doc/CHANGES-staging/voicemail_early_media.txt b/doc/CHANGES-staging/voicemail_early_media.txt
new file mode 100644
index 0000000..6dd79be
--- /dev/null
+++ b/doc/CHANGES-staging/voicemail_early_media.txt
@@ -0,0 +1,6 @@
+Subject: app_voicemail
+
+The VoiceMail application can now be configured to send greetings and
+instructions via early media and only answering the channel when it is
+time for the caller to record their message. This behavior can be
+activated by passing the new 'e' option to VoiceMail.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15112
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I41b9f0428783c0bd697c8c994f906d1e75ce9ddb
Gerrit-Change-Number: 15112
Gerrit-PatchSet: 7
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201201/5b9cbae8/attachment-0001.html>


More information about the asterisk-code-review mailing list