[asterisk-commits] mjordan: branch 12 r403993 - /branches/12/res/ari/resource_channels.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 17 06:51:57 CST 2013


Author: mjordan
Date: Tue Dec 17 06:51:51 2013
New Revision: 403993

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=403993
Log:
ari/resource_channels: When creating a channel, specify a default format (SLIN)

When creating channels via ARI, the current code fails to provide any default
format capabilities. For non-virtual channels this isn't really a problem -
the channels typically receive their capabilities as a result of the
underlying channel driver configuration. For virtual channels (such as Local
channels), the lack of any format capabilities causes the Asterisk core to
make some 'odd' choices with respect to the translation paths. The issue
reporter had some paths that had 3 hops on each channel leg, causing multiple
transcodings and some really crappy audio/performance.

By specifying a baseline of SLIN, we prevent that from occurring. Note that
this is what AMI does when it performs an Originate, as does res_clioriginate.

Review: https://reviewboard.asterisk.org/r/3068/

(issue ASTERISK-22962)
Reported by: Matt DiMeo

Modified:
    branches/12/res/ari/resource_channels.c

Modified: branches/12/res/ari/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/resource_channels.c?view=diff&rev=403993&r1=403992&r2=403993
==============================================================================
--- branches/12/res/ari/resource_channels.c (original)
+++ branches/12/res/ari/resource_channels.c Tue Dec 17 06:51:51 2013
@@ -735,10 +735,19 @@
 	char *cid_num = NULL;
 	char *cid_name = NULL;
 	int timeout = 30000;
+	RAII_VAR(struct ast_format_cap *, cap,
+		ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK), ast_format_cap_destroy);
+	struct ast_format tmp_fmt;
 
 	char *stuff;
 	struct ast_channel *chan;
 	RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
+
+	if (!cap) {
+		ast_ari_response_alloc_failed(response);
+		return;
+	}
+	ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
 
 	if (ast_strlen_zero(args->endpoint)) {
 		ast_ari_response_error(response, 400, "Bad Request",
@@ -789,13 +798,13 @@
 		}
 
 		/* originate a channel, putting it into an application */
-		if (ast_pbx_outgoing_app(dialtech, NULL, dialdevice, timeout, app, ast_str_buffer(appdata), NULL, 0, cid_num, cid_name, NULL, NULL, &chan)) {
+		if (ast_pbx_outgoing_app(dialtech, cap, dialdevice, timeout, app, ast_str_buffer(appdata), NULL, 0, cid_num, cid_name, NULL, NULL, &chan)) {
 			ast_ari_response_alloc_failed(response);
 			return;
 		}
 	} else if (!ast_strlen_zero(args->extension)) {
 		/* originate a channel, sending it to an extension */
-		if (ast_pbx_outgoing_exten(dialtech, NULL, dialdevice, timeout, S_OR(args->context, "default"), args->extension, args->priority ? args->priority : 1, NULL, 0, cid_num, cid_name, NULL, NULL, &chan, 0)) {
+		if (ast_pbx_outgoing_exten(dialtech, cap, dialdevice, timeout, S_OR(args->context, "default"), args->extension, args->priority ? args->priority : 1, NULL, 0, cid_num, cid_name, NULL, NULL, &chan, 0)) {
 			ast_ari_response_alloc_failed(response);
 			return;
 		}




More information about the asterisk-commits mailing list