[asterisk-commits] dlee: branch dlee/ASTERISK-22036 r396810 - in /team/dlee/ASTERISK-22036: incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 15 15:34:44 CDT 2013
Author: dlee
Date: Thu Aug 15 15:34:42 2013
New Revision: 396810
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396810
Log:
Passes test
Modified:
team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h
team/dlee/ASTERISK-22036/res/ari/resource_bridges.c
team/dlee/ASTERISK-22036/res/stasis/control.c
Modified: team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h?view=diff&rev=396810&r1=396809&r2=396810
==============================================================================
--- team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h (original)
+++ team/dlee/ASTERISK-22036/include/asterisk/stasis_app.h Thu Aug 15 15:34:42 2013
@@ -339,8 +339,10 @@
*
* \param control Control whose channel should be added to the bridge
* \param bridge Pointer to the bridge
- */
-void stasis_app_control_add_channel_to_bridge(
+ * \return non-zero on failure
+ * \return zero on success
+ */
+int stasis_app_control_add_channel_to_bridge(
struct stasis_app_control *control, struct ast_bridge *bridge);
/*!
@@ -348,8 +350,10 @@
*
* \param control Control whose channel should be removed from the bridge
* \param bridge Pointer to the bridge
- */
-void stasis_app_control_remove_channel_from_bridge(
+ * \return non-zero on failure
+ * \return zero on success
+ */
+int stasis_app_control_remove_channel_from_bridge(
struct stasis_app_control *control, struct ast_bridge *bridge);
/*!
Modified: team/dlee/ASTERISK-22036/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/res/ari/resource_bridges.c?view=diff&rev=396810&r1=396809&r2=396810
==============================================================================
--- team/dlee/ASTERISK-22036/res/ari/resource_bridges.c (original)
+++ team/dlee/ASTERISK-22036/res/ari/resource_bridges.c Thu Aug 15 15:34:42 2013
@@ -99,14 +99,17 @@
control = stasis_app_control_find_by_channel_id(channel_id);
if (control == NULL) {
/* Distinguish between 400 and 422 errors */
- RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
- chan = ast_channel_get_by_name(channel_id);
- if (chan == NULL) {
+ RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL,
+ ao2_cleanup);
+ snapshot = ast_channel_snapshot_get_latest(channel_id);
+ if (snapshot == NULL) {
+ ast_log(LOG_DEBUG, "Couldn't find '%s'\n", channel_id);
ast_ari_response_error(response, 400, "Bad Request",
"Channel not found");
return NULL;
}
+ ast_log(LOG_DEBUG, "Found non-stasis '%s'\n", channel_id);
ast_ari_response_error(response, 422, "Unprocessable Entity",
"Channel not in Stasis application");
return NULL;
@@ -153,6 +156,7 @@
list->controls[list->count] =
find_channel_control(response, channels[i]);
if (!list->controls[list->count]) {
+ /* response filled in by find_channel_control() */
return NULL;
}
++list->count;
@@ -174,7 +178,7 @@
size_t i;
if (!bridge) {
- /* Response filled in by find_bridge */
+ /* Response filled in by find_bridge() */
return;
}
@@ -208,7 +212,7 @@
size_t i;
if (!bridge) {
- /* Response filled in by find_bridge */
+ /* Response filled in by find_bridge() */
return;
}
@@ -221,6 +225,8 @@
/* Make sure all of the channels are in this bridge */
for (i = 0; i < list->count; ++i) {
if (stasis_app_get_bridge(list->controls[i]) != bridge) {
+ ast_log(LOG_WARNING, "Channel %s not in bridge %s\n",
+ args->channel[i], args->bridge_id);
ast_ari_response_error(response, 422,
"Unprocessable Entity",
"Channel not in this bridge");
Modified: team/dlee/ASTERISK-22036/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22036/res/stasis/control.c?view=diff&rev=396810&r1=396809&r2=396810
==============================================================================
--- team/dlee/ASTERISK-22036/res/stasis/control.c (original)
+++ team/dlee/ASTERISK-22036/res/stasis/control.c Thu Aug 15 15:34:42 2013
@@ -510,6 +510,9 @@
ast_bridge_after_cb_reason_string(reason));
}
+static int OK = 0;
+static int FAIL = -1;
+
static void *app_control_add_channel_to_bridge(
struct stasis_app_control *control,
struct ast_channel *chan, void *data)
@@ -542,7 +545,7 @@
bridge_after_cb_failed, control);
if (res != 0) {
ast_log(LOG_ERROR, "Error setting after-bridge callback\n");
- return NULL;
+ return &FAIL;
}
{
@@ -569,22 +572,24 @@
ast_log(LOG_ERROR, "Error adding channel to bridge\n");
ast_channel_pbx_set(chan, control->pbx);
control->pbx = NULL;
- return NULL;
+ return &FAIL;
}
ast_assert(stasis_app_get_bridge(control) == NULL);
control->bridge = bridge;
}
- return NULL;
-}
-
-void stasis_app_control_add_channel_to_bridge(
+ return &OK;
+}
+
+int stasis_app_control_add_channel_to_bridge(
struct stasis_app_control *control, struct ast_bridge *bridge)
{
+ int *res;
ast_debug(3, "%s: Sending channel add_to_bridge command\n",
stasis_app_control_get_channel_id(control));
- stasis_app_send_command_async(control,
+ res = stasis_app_send_command(control,
app_control_add_channel_to_bridge, bridge);
+ return *res;
}
static void *app_control_remove_channel_from_bridge(
@@ -594,7 +599,7 @@
struct ast_bridge *bridge = data;
if (!control) {
- return NULL;
+ return &FAIL;
}
/* We should only depart from our own bridge */
@@ -606,20 +611,22 @@
ast_log(LOG_WARNING, "%s: Not in bridge %s; not removing\n",
stasis_app_control_get_channel_id(control),
bridge->uniqueid);
- return NULL;
+ return &FAIL;
}
ast_bridge_depart(chan);
- return NULL;
-}
-
-void stasis_app_control_remove_channel_from_bridge(
+ return &OK;
+}
+
+int stasis_app_control_remove_channel_from_bridge(
struct stasis_app_control *control, struct ast_bridge *bridge)
{
+ int *res;
ast_debug(3, "%s: Sending channel remove_from_bridge command\n",
stasis_app_control_get_channel_id(control));
- stasis_app_send_command_async(control,
+ res = stasis_app_send_command(control,
app_control_remove_channel_from_bridge, bridge);
+ return *res;
}
const char *stasis_app_control_get_channel_id(
More information about the asterisk-commits
mailing list