[svn-commits] qwell: branch qwell/http-channels-post r390506 - in /team/qwell/http-channels...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 5 11:33:07 CDT 2013


Author: qwell
Date: Wed Jun  5 11:33:06 2013
New Revision: 390506

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390506
Log:
Commit progress.

Modified:
    team/qwell/http-channels-post/res/res_stasis_http_channels.c
    team/qwell/http-channels-post/res/stasis_http/resource_channels.c
    team/qwell/http-channels-post/res/stasis_http/resource_channels.h
    team/qwell/http-channels-post/rest-api/api-docs/channels.json

Modified: team/qwell/http-channels-post/res/res_stasis_http_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/res_stasis_http_channels.c?view=diff&rev=390506&r1=390505&r2=390506
==============================================================================
--- team/qwell/http-channels-post/res/res_stasis_http_channels.c (original)
+++ team/qwell/http-channels-post/res/res_stasis_http_channels.c Wed Jun  5 11:33:06 2013
@@ -83,6 +83,12 @@
 		if (strcmp(i->name, "context") == 0) {
 			args.context = (i->value);
 		} else
+		if (strcmp(i->name, "app") == 0) {
+			args.app = (i->value);
+		} else
+		if (strcmp(i->name, "appArgs") == 0) {
+			args.app_args = (i->value);
+		} else
 		{}
 	}
 	stasis_http_originate(headers, &args, response);

Modified: team/qwell/http-channels-post/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/stasis_http/resource_channels.c?view=diff&rev=390506&r1=390505&r2=390506
==============================================================================
--- team/qwell/http-channels-post/res/stasis_http/resource_channels.c (original)
+++ team/qwell/http-channels-post/res/stasis_http/resource_channels.c Wed Jun  5 11:33:06 2013
@@ -33,6 +33,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/file.h"
+#include "asterisk/pbx.h"
 #include "asterisk/stasis_app.h"
 #include "asterisk/stasis_app_playback.h"
 #include "asterisk/stasis_channels.h"
@@ -314,10 +315,49 @@
 			   struct ast_originate_args *args,
 			   struct stasis_http_response *response)
 {
+	char *dialtech = "Local";
+	char dialdevice[AST_CHANNEL_NAME];
+
+	int timeout = 30000;
+	int reason;
+
+	struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+	struct ast_format tmp_fmt;
+
+	const char *app = "Stasis";
+	RAII_VAR(struct ast_str *, appdata, ast_str_create(64), ast_free);
+
+	if (!appdata) {
+		stasis_http_response_alloc_failed(response);
+		return;
+	}
+
+	ast_str_set(&appdata, 0, "%s", args->app);
+	if (!ast_strlen_zero(args->app_args)) {
+		ast_str_append(&appdata, 0, ",%s", args->app_args);
+	}
+
+	ast_format_cap_add(cap, ast_format_set(&tmp_fmt, AST_FORMAT_SLINEAR, 0));
+
 	if (args->endpoint) {
-		ast_log(LOG_DEBUG, "Dialing specific endpoint %s\n", args->endpoint);
-	}
-
-	ast_log(LOG_DEBUG, "Dialing %s@%s\n", args->extension, args->context);
-	/* ast_pbx_outgoing_app - originates a channel, putting it into an application */
-}
+		char *tmp = ast_strdupa(args->endpoint);
+		char *stuff;
+
+		if ((stuff = strchr(tmp, '/'))) {
+			*stuff++ = '\0';
+			dialtech = tmp;
+			ast_copy_string(dialdevice, stuff, sizeof(dialdevice));
+	        }
+	} else {
+		snprintf(dialdevice, sizeof(dialdevice), "%s@%s", args->extension, args->context);
+	}
+
+	ast_log(LOG_DEBUG, "Dialing %s/%s\n", dialtech, dialdevice);
+
+	/* originate a channel, putting it into an application */
+	ast_pbx_outgoing_app(dialtech, cap, dialdevice, timeout, app, ast_str_buffer(appdata), &reason, 0, NULL, NULL, NULL, NULL, NULL);
+
+	ast_format_cap_destroy(cap);
+
+	stasis_http_response_no_content(response);
+}

Modified: team/qwell/http-channels-post/res/stasis_http/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/res/stasis_http/resource_channels.h?view=diff&rev=390506&r1=390505&r2=390506
==============================================================================
--- team/qwell/http-channels-post/res/stasis_http/resource_channels.h (original)
+++ team/qwell/http-channels-post/res/stasis_http/resource_channels.h Wed Jun  5 11:33:06 2013
@@ -58,6 +58,10 @@
 	const char *extension;
 	/*! \brief When routing via dialplan, the context use. If omitted, uses 'default' */
 	const char *context;
+	/*! \brief Application name to pass to the Stasis application. */
+	const char *app;
+	/*! \brief Application arguments to pass to the Stasis application. */
+	const char *app_args;
 };
 /*!
  * \brief Create a new channel (originate).

Modified: team/qwell/http-channels-post/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/team/qwell/http-channels-post/rest-api/api-docs/channels.json?view=diff&rev=390506&r1=390505&r2=390506
==============================================================================
--- team/qwell/http-channels-post/rest-api/api-docs/channels.json (original)
+++ team/qwell/http-channels-post/rest-api/api-docs/channels.json Wed Jun  5 11:33:06 2013
@@ -21,7 +21,7 @@
 					"httpMethod": "POST",
 					"summary": "Create a new channel (originate).",
 					"nickname": "originate",
-					"responseClass": "Originated",
+					"responseClass": "void",
 					"parameters": [
 						{
 							"name": "endpoint",
@@ -42,6 +42,22 @@
 						{
 							"name": "context",
 							"description": "When routing via dialplan, the context use. If omitted, uses 'default'",
+							"paramType": "query",
+							"required": false,
+							"allowMultiple": false,
+							"dataType": "string"
+						},
+						{
+							"name": "app",
+							"description": "Application name to pass to the Stasis application.",
+							"paramType": "query",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						},
+						{
+							"name": "appArgs",
+							"description": "Application arguments to pass to the Stasis application.",
 							"paramType": "query",
 							"required": false,
 							"allowMultiple": false,




More information about the svn-commits mailing list