[asterisk-commits] dlee: branch dlee/ASTERISK-22451-ari-subscribe r399209 - in /team/dlee/ASTERI...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 16 13:57:58 CDT 2013
Author: dlee
Date: Mon Sep 16 13:57:56 2013
New Revision: 399209
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399209
Log:
Bridge unsubscribe
Modified:
team/dlee/ASTERISK-22451-ari-subscribe/res/ari/resource_applications.c
team/dlee/ASTERISK-22451-ari-subscribe/res/res_stasis.c
team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c
team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.h
Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/ari/resource_applications.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/ari/resource_applications.c?view=diff&rev=399209&r1=399208&r2=399209
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/ari/resource_applications.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/ari/resource_applications.c Mon Sep 16 13:57:56 2013
@@ -112,6 +112,7 @@
case STASIS_ASR_INTERNAL_ERROR:
ast_ari_response_error(response, 500, "Internal Server Error",
"Error processing request");
+ break;
}
}
Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/res_stasis.c?view=diff&rev=399209&r1=399208&r2=399209
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/res_stasis.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/res_stasis.c Mon Sep 16 13:57:56 2013
@@ -860,12 +860,15 @@
}
for (i = 0; res == STASIS_ASR_OK && i < event_sources_count; ++i) {
+ ast_debug(1, "%s: Checking %s\n", app_name,
+ event_source_names[i]);
if (ast_begins_with(event_source_names[i], CHANNEL_SCHEME)) {
event_sources[i].event_source_type =
EVENT_SOURCE_CHANNEL;
event_sources[i].channel = ast_channel_get_by_name(
event_source_names[i] + strlen(CHANNEL_SCHEME));
if (!event_sources[i].channel) {
+ ast_debug(1, " Channel not found\n");
res = STASIS_ASR_EVENT_SOURCE_NOT_FOUND;
}
} else if (ast_begins_with(event_source_names[i], BRIDGE_SCHEME)) {
@@ -874,15 +877,20 @@
event_sources[i].bridge = stasis_app_bridge_find_by_id(
event_source_names[i] + strlen(BRIDGE_SCHEME));
if (!event_sources[i].bridge) {
+ ast_debug(1, " Bridge not found\n");
res = STASIS_ASR_EVENT_SOURCE_NOT_FOUND;
}
} else {
+ ast_debug(1, " Invalid scheme\n");
res = STASIS_ASR_EVENT_SOURCE_BAD_SCHEME;
}
}
for (i = 0; res == STASIS_ASR_OK && i < event_sources_count; ++i) {
int sub_res = -1;
+ ast_debug(1, "%s: Subscribing to %s\n", app_name,
+ event_source_names[i]);
+
switch (event_sources[i].event_source_type) {
case EVENT_SOURCE_CHANNEL:
sub_res = app_subscribe_channel(app, event_sources[i].channel);
@@ -903,6 +911,7 @@
}
if (res == STASIS_ASR_OK && json) {
+ ast_debug(1, "%s: Successful; setting results\n", app_name);
*json = app_to_json(app);
}
@@ -925,7 +934,7 @@
}
enum stasis_app_subscribe_res stasis_app_unsubscribe(const char *app_name,
- const char **event_sources, int event_sources_count,
+ const char **event_source_names, int event_sources_count,
struct ast_json **json)
{
RAII_VAR(struct app *, app, NULL, ao2_cleanup);
@@ -942,22 +951,32 @@
/* Validate the input */
for (i = 0; res == STASIS_ASR_OK && i < event_sources_count; ++i) {
- if (ast_begins_with(event_sources[i], CHANNEL_SCHEME)) {
- const char *channel_id = event_sources[i] +
+ if (ast_begins_with(event_source_names[i], CHANNEL_SCHEME)) {
+ const char *channel_id = event_source_names[i] +
strlen(CHANNEL_SCHEME);
if (!app_is_subscribed_channel_id(app, channel_id)) {
res = STASIS_ASR_EVENT_SOURCE_NOT_FOUND;
}
+ } else if (ast_begins_with(event_source_names[i], BRIDGE_SCHEME)) {
+ const char *bridge_id = event_source_names[i] +
+ strlen(BRIDGE_SCHEME);
+ if (!app_is_subscribed_bridge_id(app, bridge_id)) {
+ res = STASIS_ASR_EVENT_SOURCE_NOT_FOUND;
+ }
} else {
res = STASIS_ASR_EVENT_SOURCE_BAD_SCHEME;
}
}
for (i = 0; res == STASIS_ASR_OK && i < event_sources_count; ++i) {
- if (ast_begins_with(event_sources[i], CHANNEL_SCHEME)) {
- const char *channel_id = event_sources[i] +
+ if (ast_begins_with(event_source_names[i], CHANNEL_SCHEME)) {
+ const char *channel_id = event_source_names[i] +
strlen(CHANNEL_SCHEME);
app_unsubscribe_channel_id(app, channel_id);
+ } else if (ast_begins_with(event_source_names[i], BRIDGE_SCHEME)) {
+ const char *bridge_id = event_source_names[i] +
+ strlen(BRIDGE_SCHEME);
+ app_unsubscribe_bridge_id(app, bridge_id);
}
}
Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c?view=diff&rev=399209&r1=399208&r2=399209
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c Mon Sep 16 13:57:56 2013
@@ -811,5 +811,21 @@
return -1;
}
- return unsubscribe(app, "bridge", bridge->uniqueid);
-}
+ return app_unsubscribe_bridge_id(app, bridge->uniqueid);
+}
+
+int app_unsubscribe_bridge_id(struct app *app, const char *bridge_id)
+{
+ if (!app || !bridge_id) {
+ return -1;
+ }
+
+ return unsubscribe(app, "bridge", bridge_id);
+}
+
+int app_is_subscribed_bridge_id(struct app *app, const char *bridge_id)
+{
+ RAII_VAR(struct app_forwards *, forwards, NULL, ao2_cleanup);
+ forwards = ao2_find(app->forwards, bridge_id, OBJ_SEARCH_KEY);
+ return forwards != NULL;
+}
Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.h?view=diff&rev=399209&r1=399208&r2=399209
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.h (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.h Mon Sep 16 13:57:56 2013
@@ -158,4 +158,8 @@
*/
int app_unsubscribe_bridge(struct app *app, struct ast_bridge *bridge);
+int app_unsubscribe_bridge_id(struct app *app, const char *bridge_id);
+
+int app_is_subscribed_bridge_id(struct app *app, const char *bridge_id);
+
#endif /* _ASTERISK_RES_STASIS_APP_H */
More information about the asterisk-commits
mailing list