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

Juan Carlos Castro y Castro asteriskteam at digium.com
Thu Oct 15 14:38:29 CDT 2020


Hello Joshua Colp,

I'd like you to do a code review. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/15064

to review the following change.


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

voicemail: add option 'e' top 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: I6b8a77d33e338a3e52dd65f998d8a07e4d16aa2e

Change-Id: I468fd6e5d042df9fad33231947a7bda3e2def3e9
---
M apps/app_voicemail.c
M main/asterisk.c
2 files changed, 29 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/64/15064/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 0b9904c..67562da 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -135,6 +135,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
@@ -627,7 +631,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 {
@@ -653,7 +658,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[] = {
@@ -6905,6 +6911,8 @@
 		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] = "";
@@ -12310,9 +12318,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);
@@ -12345,6 +12350,15 @@
 		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);
+			ast_log(AST_LOG_WARNING, "Playing greetings as Early Media, deferring answer (EXPERIMENTAL FEATURE)\n");
+		} 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/main/asterisk.c b/main/asterisk.c
index a028611..94d791b 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -307,6 +307,10 @@
                 "This is free software, with components licensed under the GNU General Public\n" \
                 "License version 2 and other licenses; you are welcome to redistribute it under\n" \
                 "certain conditions. Type 'core show license' for details.\n" \
+                "=========================================================================\n" \
+                "Please note that this version of Asterisk no longer receives bug fixes.\n" \
+                "Consult the following URL for Asterisk version support status information:\n" \
+                "https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions\n" \
                 "=========================================================================\n", ast_get_version()) \
 
 static int ast_socket = -1;		/*!< UNIX Socket for allowing remote control */
@@ -4193,6 +4197,12 @@
 	run_startup_commands();
 	ast_sd_notify("READY=1");
 
+	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_RED, 0, "========================================================================="));
+	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_RED, 0, "Please note that this version of Asterisk no longer receives bug fixes."));
+	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_RED, 0, "Consult the following URL for Asterisk version support status information:"));
+	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_RED, 0, "https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions"));
+	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_RED, 0, "========================================================================="));
+
 	ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_BRGREEN, 0, "Asterisk Ready."));
 
 	logger_queue_start();

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

Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: I468fd6e5d042df9fad33231947a7bda3e2def3e9
Gerrit-Change-Number: 15064
Gerrit-PatchSet: 1
Gerrit-Owner: Juan Carlos Castro y Castro <jccyc1965 at gmail.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201015/dcc32578/attachment.html>


More information about the asterisk-code-review mailing list