[asterisk-commits] mmichelson: branch mmichelson/atxfer_features r390467 - in /team/mmichelson/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 4 20:07:48 CDT 2013


Author: mmichelson
Date: Tue Jun  4 20:07:47 2013
New Revision: 390467

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390467
Log:
Add tentative personality change functions to the basic bridge.


Modified:
    team/mmichelson/atxfer_features/include/asterisk/bridging_basic.h
    team/mmichelson/atxfer_features/main/bridging_basic.c

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging_basic.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_basic.h?view=diff&rev=390467&r1=390466&r2=390467
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_basic.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_basic.h Tue Jun  4 20:07:47 2013
@@ -98,6 +98,9 @@
 /*! Initialize the basic bridge class for use by the system. */
 void ast_bridging_init_basic(void);
 
+void ast_bridge_basic_change_personality_atxfer(struct ast_bridge *bridge);
+void ast_bridge_basic_change_personality_normal(struct ast_bridge *bridge);
+
 /* ------------------------------------------------------------------- */
 
 #if defined(__cplusplus) || defined(c_plusplus)

Modified: team/mmichelson/atxfer_features/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging_basic.c?view=diff&rev=390467&r1=390466&r2=390467
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jun  4 20:07:47 2013
@@ -141,7 +141,12 @@
 
 static int bridge_personality_atxfer_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 {
-	/* STUB */
+	/* XXX STUB */
+
+	/* This push function will check the role of the bridge channel being added
+	 * to determine if it is a transferer. If it is, then the transferer gets
+	 * a special set of DTMF hooks. Isn't he/she special?!
+	 */
 	return 0;
 }
 
@@ -191,3 +196,62 @@
 	ast_bridge_basic_v_table.name = "basic";
 	ast_bridge_basic_v_table.push = bridge_basic_push;
 }
+
+static int remove_hook(void *obj, void *arg, int flags)
+{
+	struct ast_bridge_hook *hook = obj;
+
+	if (hook->remove_on_personality_change) {
+		return CMP_MATCH;
+	}
+
+	return 0;
+}
+
+/* XXX This seems like something that should be handled in the core since otherwise
+ * this has to be done in every bridge subclass that implements personalities
+ */
+static void remove_hooks_on_personality_change(struct ast_bridge *bridge)
+{
+	struct ast_bridge_channel *iter;
+	int flags = OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE;
+
+	AST_LIST_TRAVERSE(&bridge->channels, iter, entry) {
+		SCOPED_LOCK(lock, iter, ast_bridge_channel_lock, ast_bridge_channel_unlock);
+
+		ao2_callback(iter->features->dtmf_hooks, flags, remove_hook, NULL);
+		ao2_callback(iter->features->hangup_hooks, flags, remove_hook, NULL);
+		ao2_callback(iter->features->join_hooks, flags, remove_hook, NULL);
+		ao2_callback(iter->features->leave_hooks, flags, remove_hook, NULL);
+		/* XXX Come back for interval hooks.
+		 *
+		 * Since it's a heap instead of an ao2_conatainer, I'll need to pop
+		 * each element off the heap, inspect it and then either discard the hook
+		 * or put it in a local heap. Once finished, I can set the interval hooks
+		 * to point to the local heap and destroy the old one.
+		 *
+		 * Also need to check lock order to see if wrlocking the heap will clash
+		 * with the already-held bridge and bridge channel locks
+		 */
+	}
+}
+
+void ast_bridge_basic_change_personality_atxfer(struct ast_bridge *bridge)
+{
+	SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
+
+	ast_assert(bridge->v_table == &ast_bridge_base_v_table);
+
+	bridge->personality = &bridge_atxfer_personality;
+	remove_hooks_on_personality_change(bridge);
+}
+
+void ast_bridge_basic_change_personality_normal(struct ast_bridge *bridge)
+{
+	SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
+
+	ast_assert(bridge->v_table == &ast_bridge_base_v_table);
+
+	bridge->personality = &bridge_normal_personality;
+	remove_hooks_on_personality_change(bridge);
+}




More information about the asterisk-commits mailing list