[asterisk-commits] mmichelson: branch group/bridge_construction r386401 - in /team/group/bridge_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 23 17:56:56 CDT 2013
Author: mmichelson
Date: Tue Apr 23 17:56:53 2013
New Revision: 386401
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386401
Log:
Add a function to get the channels belonging to a bridge.
Modified:
team/group/bridge_construction/include/asterisk/bridging.h
team/group/bridge_construction/main/bridging.c
Modified: team/group/bridge_construction/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/bridging.h?view=diff&rev=386401&r1=386400&r2=386401
==============================================================================
--- team/group/bridge_construction/include/asterisk/bridging.h (original)
+++ team/group/bridge_construction/include/asterisk/bridging.h Tue Apr 23 17:56:53 2013
@@ -1316,6 +1316,15 @@
*/
void ast_after_bridge_goto_discard(struct ast_channel *chan);
+/*!
+ * \brief Get a container of all channels in the bridge
+ *
+ * \param bridge The bridge
+ * \retval NULL Failed to create container
+ * \retval non-NULL Container of channels in the bridge
+ */
+struct ao2_container *ast_bridge_peers(struct ast_bridge *bridge);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=386401&r1=386400&r2=386401
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Tue Apr 23 17:56:53 2013
@@ -4189,6 +4189,42 @@
ast_bridge_unlock(bridge);
}
+static int channel_hash(const void *obj, int flags)
+{
+ const struct ast_channel *chan = obj;
+ const char *chan_name = flags & OBJ_KEY ? obj : ast_channel_name(chan);
+
+ return ast_str_hash(chan_name);
+}
+
+static int channel_cmp(void *obj, void *arg, int flags)
+{
+ struct ast_channel *chan1 = obj;
+ struct ast_channel *chan2 = arg;
+ const char *chan2_name = flags & OBJ_KEY ? arg : ast_channel_name(chan2);
+
+ return strcmp(ast_channel_name(chan1), chan2_name) ? 0 : CMP_MATCH;
+}
+
+struct ao2_container *ast_bridge_peers(struct ast_bridge *bridge)
+{
+ struct ao2_container *channels;
+ struct ast_bridge_channel *iter;
+
+ channels = ao2_container_alloc(13, channel_hash, channel_cmp);
+ if (!channels) {
+ return NULL;
+ }
+
+ ast_bridge_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
+ ao2_link(channels, iter->chan);
+ }
+ ast_bridge_unlock(bridge);
+
+ return channels;
+}
+
/*!
* \internal
* \brief Service the bridge manager request.
More information about the asterisk-commits
mailing list