Skip to content
Snippets Groups Projects
Commit a099f13a authored by Naveen Albert's avatar Naveen Albert Committed by George Joseph
Browse files

app_originate: Add ability to set codecs

A list of codecs to use for dialplan-originated calls can
now be specified in Originate, similar to the ability
in call files and the manager action.

Additionally, we now default to just using the slin codec
for originated calls, rather than all the slin* codecs up
through slin192, which has been known to cause issues
and inconsistencies from AMI and call file behavior.

ASTERISK-29543

Change-Id: I96a1aeb83d54b635b7a51e1b4680f03791622883
parent 137bd7fe
No related branches found
No related tags found
3 merge requests!138Merge branch asterisk-20.3.0 into devel properly,!123Merge asterisk '20.3.0' into devel,!118Draft: manager: AOC-S support for AOCMessage
...@@ -95,6 +95,10 @@ static const char app_originate[] = "Originate"; ...@@ -95,6 +95,10 @@ static const char app_originate[] = "Originate";
<argument name="argN" /> <argument name="argN" />
</argument> </argument>
</option> </option>
<option name="C">
<para>Comma-separated list of codecs to use for this call.
Default is <literal>slin</literal>.</para>
</option>
<option name="c"> <option name="c">
<para>The caller ID number to use for the called channel. Default is <para>The caller ID number to use for the called channel. Default is
the current channel's Caller ID number.</para> the current channel's Caller ID number.</para>
...@@ -114,7 +118,7 @@ static const char app_originate[] = "Originate"; ...@@ -114,7 +118,7 @@ static const char app_originate[] = "Originate";
</parameter> </parameter>
</syntax> </syntax>
<description> <description>
<para>This application originates an outbound call and connects it to a specified extension or application. This application will block until the outgoing call fails or gets answered. At that point, this application will exit with the status variable set and dialplan processing will continue.</para> <para>This application originates an outbound call and connects it to a specified extension or application. This application will block until the outgoing call fails or gets answered, unless the async option is used. At that point, this application will exit with the status variable set and dialplan processing will continue.</para>
<para>This application sets the following channel variable before exiting:</para> <para>This application sets the following channel variable before exiting:</para>
<variablelist> <variablelist>
<variable name="ORIGINATE_STATUS"> <variable name="ORIGINATE_STATUS">
...@@ -141,7 +145,8 @@ enum { ...@@ -141,7 +145,8 @@ enum {
OPT_ASYNC = (1 << 2), OPT_ASYNC = (1 << 2),
OPT_CALLER_NUM = (1 << 3), OPT_CALLER_NUM = (1 << 3),
OPT_CALLER_NAME = (1 << 4), OPT_CALLER_NAME = (1 << 4),
OPT_VARIABLES = (1 << 5), OPT_CODECS = (1 << 5),
OPT_VARIABLES = (1 << 6),
}; };
enum { enum {
...@@ -149,6 +154,7 @@ enum { ...@@ -149,6 +154,7 @@ enum {
OPT_ARG_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER,
OPT_ARG_CALLER_NUM, OPT_ARG_CALLER_NUM,
OPT_ARG_CALLER_NAME, OPT_ARG_CALLER_NAME,
OPT_ARG_CODECS,
OPT_ARG_VARIABLES, OPT_ARG_VARIABLES,
/* note: this entry _MUST_ be the last one in the enum */ /* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE, OPT_ARG_ARRAY_SIZE,
...@@ -158,6 +164,7 @@ AST_APP_OPTIONS(originate_exec_options, BEGIN_OPTIONS ...@@ -158,6 +164,7 @@ AST_APP_OPTIONS(originate_exec_options, BEGIN_OPTIONS
AST_APP_OPTION('a', OPT_ASYNC), AST_APP_OPTION('a', OPT_ASYNC),
AST_APP_OPTION_ARG('b', OPT_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE), AST_APP_OPTION_ARG('b', OPT_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE),
AST_APP_OPTION_ARG('B', OPT_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER), AST_APP_OPTION_ARG('B', OPT_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER),
AST_APP_OPTION_ARG('C', OPT_CODECS, OPT_ARG_CODECS),
AST_APP_OPTION_ARG('c', OPT_CALLER_NUM, OPT_ARG_CALLER_NUM), AST_APP_OPTION_ARG('c', OPT_CALLER_NUM, OPT_ARG_CALLER_NUM),
AST_APP_OPTION_ARG('n', OPT_CALLER_NAME, OPT_ARG_CALLER_NAME), AST_APP_OPTION_ARG('n', OPT_CALLER_NAME, OPT_ARG_CALLER_NAME),
AST_APP_OPTION_ARG('v', OPT_VARIABLES, OPT_ARG_VARIABLES), AST_APP_OPTION_ARG('v', OPT_VARIABLES, OPT_ARG_VARIABLES),
...@@ -178,7 +185,7 @@ static int originate_exec(struct ast_channel *chan, const char *data) ...@@ -178,7 +185,7 @@ static int originate_exec(struct ast_channel *chan, const char *data)
char *opt_args[OPT_ARG_ARRAY_SIZE]; char *opt_args[OPT_ARG_ARRAY_SIZE];
char *predial_callee = NULL; char *predial_callee = NULL;
char *parse, *cnum = NULL, *cname = NULL; char *parse, *cnum = NULL, *cname = NULL;
struct ast_variable *vars = NULL; struct ast_variable *vars = NULL;
char *chantech, *chandata; char *chantech, *chandata;
int res = -1; int res = -1;
...@@ -186,22 +193,15 @@ static int originate_exec(struct ast_channel *chan, const char *data) ...@@ -186,22 +193,15 @@ static int originate_exec(struct ast_channel *chan, const char *data)
int outgoing_status = 0; int outgoing_status = 0;
unsigned int timeout = 30; unsigned int timeout = 30;
static const char default_exten[] = "s"; static const char default_exten[] = "s";
struct ast_format_cap *cap_slin = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); struct ast_format_cap *capabilities;
capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
ast_autoservice_start(chan); ast_autoservice_start(chan);
if (!cap_slin) { if (!capabilities) {
goto return_cleanup; goto return_cleanup;
} }
ast_format_cap_append(cap_slin, ast_format_slin, 0); ast_format_cap_append(capabilities, ast_format_slin, 0);
ast_format_cap_append(cap_slin, ast_format_slin12, 0);
ast_format_cap_append(cap_slin, ast_format_slin16, 0);
ast_format_cap_append(cap_slin, ast_format_slin24, 0);
ast_format_cap_append(cap_slin, ast_format_slin32, 0);
ast_format_cap_append(cap_slin, ast_format_slin44, 0);
ast_format_cap_append(cap_slin, ast_format_slin48, 0);
ast_format_cap_append(cap_slin, ast_format_slin96, 0);
ast_format_cap_append(cap_slin, ast_format_slin192, 0);
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Originate() requires arguments\n"); ast_log(LOG_ERROR, "Originate() requires arguments\n");
...@@ -257,6 +257,13 @@ static int originate_exec(struct ast_channel *chan, const char *data) ...@@ -257,6 +257,13 @@ static int originate_exec(struct ast_channel *chan, const char *data)
goto return_cleanup; goto return_cleanup;
} }
if (ast_test_flag64(&opts, OPT_CODECS)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CODECS])) {
ast_format_cap_remove_by_type(capabilities, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_update_by_allow_disallow(capabilities, opt_args[OPT_ARG_CODECS], 1);
}
}
if (ast_test_flag64(&opts, OPT_CALLER_NUM)) { if (ast_test_flag64(&opts, OPT_CALLER_NUM)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CALLER_NUM])) { if (!ast_strlen_zero(opt_args[OPT_ARG_CALLER_NUM])) {
cnum = opt_args[OPT_ARG_CALLER_NUM]; cnum = opt_args[OPT_ARG_CALLER_NUM];
...@@ -318,7 +325,7 @@ static int originate_exec(struct ast_channel *chan, const char *data) ...@@ -318,7 +325,7 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n", ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
chantech, chandata, args.arg1, exten, priority); chantech, chandata, args.arg1, exten, priority);
res = ast_pbx_outgoing_exten_predial(chantech, cap_slin, chandata, res = ast_pbx_outgoing_exten_predial(chantech, capabilities, chandata,
timeout * 1000, args.arg1, exten, priority, &outgoing_status, timeout * 1000, args.arg1, exten, priority, &outgoing_status,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT, ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
cid_num, cid_name, vars, NULL, NULL, 0, NULL, cid_num, cid_name, vars, NULL, NULL, 0, NULL,
...@@ -329,7 +336,7 @@ static int originate_exec(struct ast_channel *chan, const char *data) ...@@ -329,7 +336,7 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n", ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
chantech, chandata, args.arg1, S_OR(args.arg2, "")); chantech, chandata, args.arg1, S_OR(args.arg2, ""));
res = ast_pbx_outgoing_app_predial(chantech, cap_slin, chandata, res = ast_pbx_outgoing_app_predial(chantech, capabilities, chandata,
timeout * 1000, args.arg1, args.arg2, &outgoing_status, timeout * 1000, args.arg1, args.arg2, &outgoing_status,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT, ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
cid_num, cid_name, vars, NULL, NULL, NULL, cid_num, cid_name, vars, NULL, NULL, NULL,
...@@ -380,7 +387,7 @@ return_cleanup: ...@@ -380,7 +387,7 @@ return_cleanup:
if (vars) { if (vars) {
ast_variables_destroy(vars); ast_variables_destroy(vars);
} }
ao2_cleanup(cap_slin); ao2_cleanup(capabilities);
ast_autoservice_stop(chan); ast_autoservice_stop(chan);
return continue_in_dialplan ? 0 : -1; return continue_in_dialplan ? 0 : -1;
......
Subject: app_originate
Codecs can now be specified for dialplan-originated
calls, as with call files and the manager action.
By default, only the slin codec is now used, instead
of all the slin* codecs.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment