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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 4 19:02:21 CDT 2013


Author: mmichelson
Date: Tue Jun  4 19:02:19 2013
New Revision: 390465

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390465
Log:
Add bridge "personality" and start using it in the basic bridge.

This will be used to allow for the strategy of the bridge to change
when attended transfers are performed. Depending on the current
personality, the DTMF hooks and roles associated with the bridge
differ.

This first commit simply makes the necessary core changes and preserves
compatibility with previous operation.


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

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging.h?view=diff&rev=390465&r1=390464&r2=390465
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging.h Tue Jun  4 19:02:19 2013
@@ -394,6 +394,8 @@
 struct ast_bridge {
 	/*! Bridge virtual method table. */
 	const struct ast_bridge_methods *v_table;
+	/*! "Personality" currently exhibited by bridge subclass */
+	void *personality;
 	/*! Immutable bridge UUID. */
 	char uniqueid[AST_UUID_STR_LEN];
 	/*! Bridge technology that is handling the bridge */

Modified: team/mmichelson/atxfer_features/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_features.h?view=diff&rev=390465&r1=390464&r2=390465
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_features.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_features.h Tue Jun  4 19:02:19 2013
@@ -193,6 +193,8 @@
 	void *hook_pvt;
 	/*! TRUE if the hook is removed when the channel is pulled from the bridge. */
 	unsigned int remove_on_pull:1;
+	/*! TRUE if the hook is removed when the bridge's personality changes */
+	unsigned int remove_on_personality_change:1;
 	/*! Extra hook parameters. */
 	union {
 		/*! Extra parameters for a DTMF feature hook. */

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=390465&r1=390464&r2=390465
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Tue Jun  4 19:02:19 2013
@@ -109,6 +109,11 @@
 	return 0;
 }
 
+struct bridge_basic_personality {
+	const char *name;
+	ast_bridge_push_channel_fn push;
+};
+
 /*!
  * \internal
  * \brief ast_bridge basic push method.
@@ -124,21 +129,49 @@
  * \retval 0 on success
  * \retval -1 on failure
  */
-static int bridge_basic_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+static int bridge_personality_normal_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 {
 	if (ast_bridge_hangup_hook(bridge_channel->features, basic_hangup_hook, NULL, NULL, 1)
 		|| ast_bridge_channel_setup_features(bridge_channel)) {
 		return -1;
 	}
 
+	return 0;
+}
+
+static int bridge_personality_atxfer_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+{
+	/* STUB */
+	return 0;
+}
+
+static int bridge_basic_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+{
+	struct bridge_basic_personality *personality = self->personality;
+
+	ast_assert(personality != NULL);
+
+	if (personality->push(self, bridge_channel, swap)) {
+		return -1;
+	}
 	return ast_bridge_base_v_table.push(self, bridge_channel, swap);
 }
 
 struct ast_bridge_methods ast_bridge_basic_v_table;
 
+static struct bridge_basic_personality bridge_normal_personality = {
+	.name = "normal",
+	.push = bridge_personality_normal_push,
+};
+
+static struct bridge_basic_personality __attribute__((unused)) bridge_atxfer_personality = {
+	.name = "atxfer",
+	.push = bridge_personality_atxfer_push,
+};
+
 struct ast_bridge *ast_bridge_basic_new(void)
 {
-	void *bridge;
+	struct ast_bridge *bridge;
 
 	bridge = ast_bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_basic_v_table);
 	bridge = ast_bridge_base_init(bridge,
@@ -146,6 +179,7 @@
 			| AST_BRIDGE_CAPABILITY_MULTIMIX,
 		AST_BRIDGE_FLAG_DISSOLVE_HANGUP | AST_BRIDGE_FLAG_DISSOLVE_EMPTY
 			| AST_BRIDGE_FLAG_SMART);
+	bridge->personality = &bridge_normal_personality;
 	bridge = ast_bridge_register(bridge);
 	return bridge;
 }




More information about the asterisk-commits mailing list