[asterisk-commits] qwell: branch qwell/ari_channel_dial r392262 - /team/qwell/ari_channel_dial/r...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 19 10:58:22 CDT 2013
Author: qwell
Date: Wed Jun 19 10:58:19 2013
New Revision: 392262
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392262
Log:
Commit progress. This is quite wrong, but it's a starting point.
Modified:
team/qwell/ari_channel_dial/res/stasis_http/resource_channels.c
Modified: team/qwell/ari_channel_dial/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/ari_channel_dial/res/stasis_http/resource_channels.c?view=diff&rev=392262&r1=392261&r2=392262
==============================================================================
--- team/qwell/ari_channel_dial/res/stasis_http/resource_channels.c (original)
+++ team/qwell/ari_channel_dial/res/stasis_http/resource_channels.c Wed Jun 19 10:58:19 2013
@@ -34,6 +34,8 @@
#include "asterisk/file.h"
#include "asterisk/pbx.h"
+#include "asterisk/dial.h"
+#include "asterisk/bridging.h"
#include "asterisk/callerid.h"
#include "asterisk/stasis_app.h"
#include "asterisk/stasis_app_playback.h"
@@ -78,9 +80,49 @@
return control;
}
+static void dial_cb(struct ast_dial *dial)
+{
+ RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
+
+ struct ast_channel *new_chan;
+ struct ast_bridge *bridge;
+
+ if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED || !(control = ast_dial_get_user_data(dial)) || !(new_chan = ast_dial_answered_steal(dial))) {
+ return;
+ }
+
+ ast_dial_join(dial);
+ ast_dial_destroy(dial);
+
+ bridge = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE_HANGUP);
+
+ ast_bridge_impart(bridge, new_chan, NULL, NULL, 1);
+ stasis_app_control_add_channel_to_bridge(control, bridge);
+}
+
void stasis_http_dial(struct ast_variable *headers, struct ast_dial_args *args, struct stasis_http_response *response)
{
- ast_log(LOG_ERROR, "TODO: stasis_http_dial\n");
+ RAII_VAR(struct ast_channel *, existing_chan, NULL, ao2_cleanup);
+ struct stasis_app_control *control;
+ struct ast_dial *dial;
+ char *tech, *resource;
+
+ control = find_control(response, args->channel_id);
+ if (control == NULL) {
+ return;
+ }
+
+ tech = ast_strdupa(args->endpoint);
+ resource = strchr(tech, '/');
+ *resource++ = '\0';
+
+ dial = ast_dial_create();
+ ast_dial_append(dial, tech, resource);
+ ast_dial_set_user_data(dial, control);
+ ast_dial_set_state_callback(dial, &dial_cb);
+ ast_dial_run(dial, NULL, 1);
+
+ stasis_http_response_no_content(response);
}
void stasis_http_continue_in_dialplan(
More information about the asterisk-commits
mailing list