summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlle Johansson <oej@edvina.net>2008-05-14 12:32:57 +0000
committerOlle Johansson <oej@edvina.net>2008-05-14 12:32:57 +0000
commit29b1d7356730d4a419d0f66828ef9078f1db3119 (patch)
tree33fa7c9bc63426c37001a6a915951427181aa96e
parente4c544cd5ab371cd6a87bf0c22f7c8e8a981ea85 (diff)
Add support for codec settings in originate via call file and manager.
This is to enable video and text in originated calls. Development sponsored by Omnitor AB, Sweden. (http://www.omnitor.se) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116229 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--CHANGES1
-rw-r--r--channels/chan_sip.c3
-rw-r--r--main/manager.c18
-rw-r--r--pbx/pbx_spool.c8
-rw-r--r--sample.call3
5 files changed, 25 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index c1964cfea..45d1a2457 100644
--- a/CHANGES
+++ b/CHANGES
@@ -166,6 +166,7 @@ AMI - The manager (TCP/TLS/HTTP)
* Originate now requires the Originate privilege and, if you want to call out
to a subshell, it requires the System privilege, as well. This was done to
enhance manager security.
+ * Originate now accepts codec settings with "Codecs: alaw, ulaw, h264"
* New command: Atxfer. See doc/manager_1_1.txt for more details or
manager show command Atxfer from the CLI
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index cc6b5ab26..71a5744ad 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -11976,7 +11976,8 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req)
struct ast_frame f;
const char *content_type = get_header(req, "Content-Type");
- if (strcmp(content_type, "text/plain")) { /* No text/plain attachment */
+ if (strncmp(content_type, "text/plain", strlen("text/plain"))) {
+ //if (strcmp(content_type, "text/plain")) { /* No text/plain attachment */
transmit_response(p, "415 Unsupported Media Type", req);
if (!p->owner)
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
diff --git a/main/manager.c b/main/manager.c
index 665b3e1fb..2df5e8164 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2106,11 +2106,12 @@ static int action_command(struct mansession *s, const struct message *m)
return 0;
}
-/* helper function for originate */
+/*! \brief helper function for originate */
struct fast_originate_helper {
char tech[AST_MAX_EXTENSION];
char data[AST_MAX_EXTENSION];
int timeout;
+ int format; /*!< Codecs used for a call */
char app[AST_MAX_APP];
char appdata[AST_MAX_EXTENSION];
char cid_name[AST_MAX_EXTENSION];
@@ -2132,12 +2133,12 @@ static void *fast_originate(void *data)
char requested_channel[AST_CHANNEL_NAME];
if (!ast_strlen_zero(in->app)) {
- res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1,
+ res = ast_pbx_outgoing_app(in->tech, in->format, in->data, in->timeout, in->app, in->appdata, &reason, 1,
S_OR(in->cid_num, NULL),
S_OR(in->cid_name, NULL),
in->vars, in->account, &chan);
} else {
- res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
+ res = ast_pbx_outgoing_exten(in->tech, in->format, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1,
S_OR(in->cid_num, NULL),
S_OR(in->cid_name, NULL),
in->vars, in->account, &chan);
@@ -2198,6 +2199,7 @@ static int action_originate(struct mansession *s, const struct message *m)
const char *appdata = astman_get_header(m, "Data");
const char *async = astman_get_header(m, "Async");
const char *id = astman_get_header(m, "ActionID");
+ const char *codecs = astman_get_header(m, "Codecs");
struct ast_variable *vars = astman_get_variables(m);
char *tech, *data;
char *l = NULL, *n = NULL;
@@ -2207,6 +2209,7 @@ static int action_originate(struct mansession *s, const struct message *m)
int reason = 0;
char tmp[256];
char tmp2[256];
+ int format = AST_FORMAT_SLINEAR;
pthread_t th;
if (!name) {
@@ -2242,6 +2245,10 @@ static int action_originate(struct mansession *s, const struct message *m)
if (ast_strlen_zero(l))
l = NULL;
}
+ if (!ast_strlen_zero(codecs)) {
+ format = 0;
+ ast_parse_allow_disallow(NULL, &format, codecs, 1);
+ }
if (ast_true(async)) {
struct fast_originate_helper *fast = ast_calloc(1, sizeof(*fast));
if (!fast) {
@@ -2261,6 +2268,7 @@ static int action_originate(struct mansession *s, const struct message *m)
ast_copy_string(fast->context, context, sizeof(fast->context));
ast_copy_string(fast->exten, exten, sizeof(fast->exten));
ast_copy_string(fast->account, account, sizeof(fast->account));
+ fast->format = format;
fast->timeout = to;
fast->priority = pi;
if (ast_pthread_create_detached(&th, NULL, fast_originate, fast)) {
@@ -2285,10 +2293,10 @@ static int action_originate(struct mansession *s, const struct message *m)
astman_send_error(s, m, "Originate with certain 'Application' arguments requires the additional System privilege, which you do not have.");
return 0;
}
- res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
+ res = ast_pbx_outgoing_app(tech, format, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
} else {
if (exten && context && pi)
- res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
+ res = ast_pbx_outgoing_exten(tech, format, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
else {
astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
return 0;
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index b297e9a02..793ccde55 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -66,6 +66,7 @@ struct outgoing {
int retrytime; /*!< How long to wait between retries (in seconds) */
int waittime; /*!< How long to wait for an answer */
long callingpid; /*!< PID which is currently calling */
+ int format; /*!< Formats (codecs) for this call */
char tech[256]; /*!< Which channel driver to use for outgoing call */
char dest[256]; /*!< Which device/line to use for outgoing call */
@@ -94,6 +95,7 @@ static void init_outgoing(struct outgoing *o)
o->priority = 1;
o->retrytime = 300;
o->waittime = 45;
+ o->format = AST_FORMAT_SLINEAR;
ast_set_flag(&o->options, SPOOL_FLAG_ALWAYS_DELETE);
}
@@ -165,6 +167,8 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
ast_log(LOG_WARNING, "Invalid max retries at line %d of %s\n", lineno, fn);
o->maxretries = 0;
}
+ } else if (!strcasecmp(buf, "codecs")) {
+ ast_parse_allow_disallow(NULL, &o->format, c, 1);
} else if (!strcasecmp(buf, "context")) {
ast_copy_string(o->context, c, sizeof(o->context));
} else if (!strcasecmp(buf, "extension")) {
@@ -310,10 +314,10 @@ static void *attempt_thread(void *data)
int res, reason;
if (!ast_strlen_zero(o->app)) {
ast_verb(3, "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
- res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
+ res = ast_pbx_outgoing_app(o->tech, o->format, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
} else {
ast_verb(3, "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
- res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
+ res = ast_pbx_outgoing_exten(o->tech, o->format, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
}
if (res) {
ast_log(LOG_NOTICE, "Call failed to go through, reason (%d) %s\n", reason, ast_channel_reason2str(reason));
diff --git a/sample.call b/sample.call
index 6549d7914..f00001692 100644
--- a/sample.call
+++ b/sample.call
@@ -14,6 +14,9 @@
#
Channel: Zap/1
#
+# You can specify codecs for the call
+Codecs: alaw, speex, h264
+#
# You may also specify a wait time (default is 45 seconds) for how long to
# wait for the channel to be answered, a retry time (default is 5 mins)
# for how soon to retry this call, and a maximum number of retries (default