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
This commit is contained in:
Joshua C. Colp
2020-10-12 07:30:52 -03:00
committed by George Joseph
parent b91fb3c396
commit eda3679c1c
2 changed files with 25 additions and 5 deletions

View File

@@ -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
@@ -577,7 +581,8 @@ enum vm_option_flags {
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 {
@@ -603,7 +608,8 @@ AST_APP_OPTIONS(vm_app_options, {
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[] = {
@@ -6854,6 +6860,9 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
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] = "";
@@ -12259,9 +12268,6 @@ static int vm_exec(struct ast_channel *chan, const char *data)
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);
@@ -12294,6 +12300,14 @@ static int vm_exec(struct ast_channel *chan, const char *data)
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");