[asterisk-commits] kmoore: branch kmoore/stasis-bridging_events r389747 - /team/kmoore/stasis-br...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 24 16:22:25 CDT 2013
Author: kmoore
Date: Fri May 24 16:22:20 2013
New Revision: 389747
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389747
Log:
Add bridges container and accessors
Modified:
team/kmoore/stasis-bridging_events/res/stasis/app.c
team/kmoore/stasis-bridging_events/res/stasis/app.h
Modified: team/kmoore/stasis-bridging_events/res/stasis/app.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging_events/res/stasis/app.c?view=diff&rev=389747&r1=389746&r2=389747
==============================================================================
--- team/kmoore/stasis-bridging_events/res/stasis/app.c (original)
+++ team/kmoore/stasis-bridging_events/res/stasis/app.c Fri May 24 16:22:20 2013
@@ -38,6 +38,12 @@
*/
#define APP_CHANNELS_BUCKETS 7
+/*!
+ * \brief Number of buckets for the bridges container for app instances. Remember
+ * to keep it a prime number!
+ */
+#define APP_BRIDGES_BUCKETS 7
+
struct app {
/*! Callback function for this application. */
stasis_app_cb handler;
@@ -45,6 +51,8 @@
void *data;
/*! List of channel identifiers this app instance is interested in */
struct ao2_container *channels;
+ /*! List of bridge identifiers this app instance owns */
+ struct ao2_container *bridges;
/*! Name of the Stasis application */
char name[];
};
@@ -57,6 +65,8 @@
app->data = NULL;
ao2_cleanup(app->channels);
app->channels = NULL;
+ ao2_cleanup(app->bridges);
+ app->bridges = NULL;
}
struct app *app_create(const char *name, stasis_app_cb handler, void *data)
@@ -84,6 +94,11 @@
return NULL;
}
+ app->bridges = ast_str_container_alloc(APP_BRIDGES_BUCKETS);
+ if (!app->bridges) {
+ return NULL;
+ }
+
ao2_ref(app, +1);
return app;
}
@@ -104,6 +119,22 @@
ast_assert(app != NULL);
ao2_find(app->channels, ast_channel_uniqueid(chan), OBJ_KEY | OBJ_NODATA | OBJ_UNLINK);
+}
+
+int app_add_bridge(struct app *app, const char *uniqueid)
+{
+ ast_assert(uniqueid != NULL);
+ ast_assert(app != NULL);
+
+ return ast_str_container_add(app->bridges, uniqueid) ? -1 : 0;
+}
+
+void app_remove_bridge(struct app* app, const char *uniqueid)
+{
+ ast_assert(uniqueid != NULL);
+ ast_assert(app != NULL);
+
+ ao2_find(app->bridges, uniqueid, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK);
}
/*!
@@ -137,3 +168,10 @@
found = ao2_find(app->channels, uniqueid, OBJ_KEY);
return found != NULL;
}
+
+int app_is_watching_bridge(struct app *app, const char *uniqueid)
+{
+ RAII_VAR(char *, found, NULL, ao2_cleanup);
+ found = ao2_find(app->bridges, uniqueid, OBJ_KEY);
+ return found != NULL;
+}
Modified: team/kmoore/stasis-bridging_events/res/stasis/app.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-bridging_events/res/stasis/app.h?view=diff&rev=389747&r1=389746&r2=389747
==============================================================================
--- team/kmoore/stasis-bridging_events/res/stasis/app.h (original)
+++ team/kmoore/stasis-bridging_events/res/stasis/app.h Fri May 24 16:22:20 2013
@@ -135,4 +135,32 @@
*/
void app_remove_channel(struct app *app, const struct ast_channel *chan);
+/*!
+ * \brief Add a bridge to an application's watch list by uniqueid.
+ *
+ * \param app Application.
+ * \param bridge Bridge to watch.
+ * \return 0 on success.
+ * \return Non-zero on error.
+ */
+int app_add_bridge(struct app *app, const char *uniqueid);
+
+/*!
+ * \brief Remove a bridge from an application's watch list by uniqueid.
+ *
+ * \param app Application.
+ * \param bridge Bridge to remove.
+ */
+void app_remove_bridge(struct app* app, const char *uniqueid);
+
+/*!
+ * \brief Checks if an application is watching a given bridge.
+ *
+ * \param app Application.
+ * \param uniqueid Uniqueid of the bridge to check.
+ * \return True (non-zero) if \a app is watching bridge with given \a uniqueid
+ * \return False (zero) if \a app isn't.
+ */
+int app_is_watching_bridge(struct app *app, const char *uniqueid);
+
#endif /* _ASTERISK_RES_STASIS_APP_H */
More information about the asterisk-commits
mailing list