[Asterisk-code-review] app_originate: Add ability to set codecs (asterisk[master])
N A
asteriskteam at digium.com
Wed Aug 4 19:31:02 CDT 2021
N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/16232 )
Change subject: app_originate: Add ability to set codecs
......................................................................
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.
ASTERISK-29543
Change-Id: I96a1aeb83d54b635b7a51e1b4680f03791622883
---
M apps/app_originate.c
A doc/CHANGES-staging/app_originate_codecs.txt
2 files changed, 25 insertions(+), 15 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/16232/1
diff --git a/apps/app_originate.c b/apps/app_originate.c
index 2af46e3..1741fe5 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -95,6 +95,10 @@
<argument name="argN" />
</argument>
</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">
<para>The caller ID number to use for the called channel. Default is
the current channel's Caller ID number.</para>
@@ -141,7 +145,8 @@
OPT_ASYNC = (1 << 2),
OPT_CALLER_NUM = (1 << 3),
OPT_CALLER_NAME = (1 << 4),
- OPT_VARIABLES = (1 << 5),
+ OPT_CODECS = (1 << 5),
+ OPT_VARIABLES = (1 << 6),
};
enum {
@@ -149,6 +154,7 @@
OPT_ARG_PREDIAL_CALLER,
OPT_ARG_CALLER_NUM,
OPT_ARG_CALLER_NAME,
+ OPT_ARG_CODECS,
OPT_ARG_VARIABLES,
/* note: this entry _MUST_ be the last one in the enum */
OPT_ARG_ARRAY_SIZE,
@@ -158,6 +164,7 @@
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_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('n', OPT_CALLER_NAME, OPT_ARG_CALLER_NAME),
AST_APP_OPTION_ARG('v', OPT_VARIABLES, OPT_ARG_VARIABLES),
@@ -186,22 +193,15 @@
int outgoing_status = 0;
unsigned int timeout = 30;
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);
- if (!cap_slin) {
+ if (!capabilities) {
goto return_cleanup;
}
- ast_format_cap_append(cap_slin, 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);
+ ast_format_cap_append(capabilities, ast_format_slin, 0);
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "Originate() requires arguments\n");
@@ -257,6 +257,12 @@
goto return_cleanup;
}
+ if (ast_test_flag64(&opts, OPT_CODECS)) {
+ if (!ast_strlen_zero(opt_args[OPT_ARG_CODECS])) {
+ ast_format_cap_update_by_allow_disallow(capabilities, opt_args[OPT_ARG_CODECS], 1);
+ }
+ }
+
if (ast_test_flag64(&opts, OPT_CALLER_NUM)) {
if (!ast_strlen_zero(opt_args[OPT_ARG_CALLER_NUM])) {
cnum = opt_args[OPT_ARG_CALLER_NUM];
@@ -318,7 +324,7 @@
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
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,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
cid_num, cid_name, vars, NULL, NULL, 0, NULL,
@@ -329,7 +335,7 @@
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
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,
ast_test_flag64(&opts, OPT_ASYNC) ? AST_OUTGOING_NO_WAIT : AST_OUTGOING_WAIT,
cid_num, cid_name, vars, NULL, NULL, NULL,
@@ -380,7 +386,7 @@
if (vars) {
ast_variables_destroy(vars);
}
- ao2_cleanup(cap_slin);
+ ao2_cleanup(capabilities);
ast_autoservice_stop(chan);
return continue_in_dialplan ? 0 : -1;
diff --git a/doc/CHANGES-staging/app_originate_codecs.txt b/doc/CHANGES-staging/app_originate_codecs.txt
new file mode 100644
index 0000000..d6321a7
--- /dev/null
+++ b/doc/CHANGES-staging/app_originate_codecs.txt
@@ -0,0 +1,4 @@
+Subject: app_originate
+
+Codecs can now be specified for dialplan-originated
+calls, as with call files and the manager action.
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16232
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I96a1aeb83d54b635b7a51e1b4680f03791622883
Gerrit-Change-Number: 16232
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210804/4b087581/attachment-0001.html>
More information about the asterisk-code-review
mailing list