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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 11 09:52:53 CDT 2013


Author: mmichelson
Date: Thu Jul 11 09:52:51 2013
New Revision: 394077

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394077
Log:
Address some of the feedback from Richard in his review.

This mostly handles the easy items. The next bit of work will
be a bit more complex as it involves changing the scheme by which
personalities are allocated.


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

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=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_features.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_features.h Thu Jul 11 09:52:51 2013
@@ -184,7 +184,7 @@
 	/*! The hook is removed when the channel is pulled from the bridge. */
 	AST_BRIDGE_HOOK_REMOVE_ON_PULL = (1 << 0),
 	/*! The hook is removed when the bridge's personality changes. */
-	AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE,
+	AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE = (1 << 1),
 };
 
 /* BUGBUG Need to be able to selectively remove DTMF, hangup, and interval hooks. */
@@ -200,8 +200,6 @@
 	void *hook_pvt;
 	/*! Flags determining when hooks should be removed from a bridge channel */
 	struct ast_flags remove_flags;
-	/*! 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/include/asterisk/bridging_internal.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/include/asterisk/bridging_internal.h?view=diff&rev=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/include/asterisk/bridging_internal.h (original)
+++ team/mmichelson/atxfer_features/include/asterisk/bridging_internal.h Thu Jul 11 09:52:51 2013
@@ -33,6 +33,7 @@
 struct ast_bridge_channel;
 
 /*!
+ * \internal
  * \brief Move a bridge channel from one bridge to another.
  * \since 12.0.0
  *
@@ -49,6 +50,7 @@
 		int attempt_recovery);
 
 /*!
+ * \internal
  * \brief Do the merge of two bridges.
  * \since 12.0.0
  *

Modified: team/mmichelson/atxfer_features/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/bridging.c?view=diff&rev=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging.c (original)
+++ team/mmichelson/atxfer_features/main/bridging.c Thu Jul 11 09:52:51 2013
@@ -463,18 +463,6 @@
 	}
 }
 
-/*!
- * \internal
- * \brief Helper function to find a bridge channel given a channel.
- *
- * \param bridge What to search
- * \param chan What to search for.
- *
- * \note On entry, bridge is already locked.
- *
- * \retval bridge_channel if channel is in the bridge.
- * \retval NULL if not in bridge.
- */
 struct ast_bridge_channel *find_bridge_channel(struct ast_bridge *bridge, struct ast_channel *chan)
 {
 	struct ast_bridge_channel *bridge_channel;
@@ -3973,23 +3961,6 @@
 	ao2_ref(old_bridge, -1);
 }
 
-/*!
- * \internal
- * \brief Do the merge of two bridges.
- * \since 12.0.0
- *
- * \param dst_bridge Destination bridge of merge.
- * \param src_bridge Source bridge of merge.
- * \param kick_me Array of channels to kick from the bridges.
- * \param num_kick Number of channels in the kick_me array.
- *
- * \return Nothing
- *
- * \note The two bridges are assumed already locked.
- *
- * This moves the channels in src_bridge into the bridge pointed
- * to by dst_bridge.
- */
 void bridge_merge_do(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_bridge_channel **kick_me, unsigned int num_kick)
 {
 	struct ast_bridge_channel *bridge_channel;

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=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/main/bridging_basic.c (original)
+++ team/mmichelson/atxfer_features/main/bridging_basic.c Thu Jul 11 09:52:51 2013
@@ -45,8 +45,8 @@
 #include "asterisk/dial.h"
 #include "asterisk/stasis_bridging.h"
 
-#define NORMAL_FLAGS	AST_BRIDGE_FLAG_DISSOLVE_HANGUP | AST_BRIDGE_FLAG_DISSOLVE_EMPTY \
-			| AST_BRIDGE_FLAG_SMART
+#define NORMAL_FLAGS	(AST_BRIDGE_FLAG_DISSOLVE_HANGUP | AST_BRIDGE_FLAG_DISSOLVE_EMPTY \
+			| AST_BRIDGE_FLAG_SMART)
 
 #define TRANSFER_FLAGS AST_BRIDGE_FLAG_SMART
 #define TRANSFERER_ROLE_NAME "transferer"
@@ -132,8 +132,6 @@
  * \brief The basis for basic bridge personalities
  */
 struct bridge_basic_personality {
-	/*! The name of this personality */
-	const char *name;
 	/*! The v_table to use for this personality */
 	struct ast_bridge_methods *v_table;
 	/*! User data for this personality */
@@ -195,8 +193,6 @@
 static void bridge_basic_destroy(struct ast_bridge *self)
 {
 	struct bridge_basic_personality *personality = self->personality;
-
-	ast_assert(personality != NULL);
 
 	ao2_cleanup(personality);
 
@@ -783,8 +779,20 @@
  * \brief Collection of data related to an attended transfer attempt
  */
 struct attended_transfer_properties {
-	/*! This lock protects the stimulus queue and is used in tandem with cond */
-	ast_mutex_t lock;
+	AST_DECLARE_STRING_FIELDS (
+		/*! Extension of transfer target */
+		AST_STRING_FIELD(exten);
+		/*! Context of transfer target */
+		AST_STRING_FIELD(context);
+		/*! Sound to play on failure */
+		AST_STRING_FIELD(failsound);
+		/*! Sound to play when transfer completes */
+		AST_STRING_FIELD(xfersound);
+		/*! The channel technology of the transferer channel */
+		AST_STRING_FIELD(transferer_type);
+		/*! The transferer channel address */
+		AST_STRING_FIELD(transferer_addr);
+	);
 	/*! Condition used to synchronize when stimuli are reported to the monitor thread */
 	ast_cond_t cond;
 	/*! The bridge where the transferee resides. This bridge is also the bridge that
@@ -823,18 +831,6 @@
 	int retry_attempts;
 	/*! Framehook ID for outbounc call to transfer target or recall target */
 	int target_framehook_id;
-	/*! Extension of transfer target */
-	char exten[AST_MAX_EXTENSION];
-	/*! Context of transfer target */
-	char context[AST_MAX_CONTEXT];
-	/*! Sound to play on failure */
-	char failsound[PATH_MAX];
-	/*! Sound to play when transfer completes */
-	char xfersound[PATH_MAX];
-	/*! The channel technology of the transferer channel */
-	char transferer_type[AST_CHANNEL_NAME];
-	/*! The transferer channel address */
-	char transferer_addr[AST_CHANNEL_NAME];
 	/*! Dial structure used when recalling transferer channel */
 	struct ast_dial *dial;
 	/*! The bridging features the transferer has available */
@@ -849,12 +845,12 @@
 
 	ao2_cleanup(props->target_bridge);
 	ao2_cleanup(props->transferee_bridge);
-	/* Use ao2_cleanup() instead of ast_channel_unref() for channels since they may be NULL */
-	ao2_cleanup(props->transferer);
-	ao2_cleanup(props->transfer_target);
-	ao2_cleanup(props->recall_target);
+	/* Use ast_channel_cleanup() instead of ast_channel_unref() for channels since they may be NULL */
+	ast_channel_cleanup(props->transferer);
+	ast_channel_cleanup(props->transfer_target);
+	ast_channel_cleanup(props->recall_target);
+	ast_string_field_free_memory(props);
 	ast_cond_destroy(&props->cond);
-	ast_mutex_destroy(&props->lock);
 }
 
 /*!
@@ -909,11 +905,10 @@
 	struct ast_flags *transferer_features;
 
 	props = ao2_alloc(sizeof(*props), attended_transfer_properties_destructor);
-	if (!props) {
+	if (!props || ast_string_field_init(props, 64)) {
 		return NULL;
 	}
 
-	ast_mutex_init(&props->lock);
 	ast_cond_init(&props->cond, NULL);
 
 	props->target_framehook_id = -1;
@@ -934,9 +929,9 @@
 	props->atxfercallbackretries = xfer_cfg->atxfercallbackretries;
 	props->atxfernoanswertimeout = xfer_cfg->atxfernoanswertimeout;
 	props->atxferloopdelay = xfer_cfg->atxferloopdelay;
-	ast_copy_string(props->context, get_transfer_context(transferer, context), sizeof(props->context));
-	ast_copy_string(props->failsound, xfer_cfg->xferfailsound, sizeof(props->failsound));
-	ast_copy_string(props->xfersound, xfer_cfg->xfersound, sizeof(props->xfersound));
+	ast_string_field_set(props, context, get_transfer_context(transferer, context));
+	ast_string_field_set(props, failsound, xfer_cfg->xferfailsound);
+	ast_string_field_set(props, xfersound, xfer_cfg->xfersound);
 
 	tech = ast_strdupa(ast_channel_name(props->transferer));
 	addr = strchr(tech, '/');
@@ -950,8 +945,8 @@
 	if (serial) {
 		*serial = '\0';
 	}
-	ast_copy_string(props->transferer_type, tech, sizeof(props->transferer_type));
-	ast_copy_string(props->transferer_addr, addr, sizeof(props->transferer_addr));
+	ast_string_field_set(props, transferer_type, tech);
+	ast_string_field_set(props, transferer_addr, addr);
 
 	ast_channel_unlock(props->transferer);
 
@@ -966,7 +961,7 @@
 static void clear_stimulus_queue(struct attended_transfer_properties *props)
 {
 	struct stimulus_list *list;
-	SCOPED_MUTEX(lock, &props->lock);
+	SCOPED_MUTEX(lock, ao2_object_get_lockaddr(props));
 
 	while ((list = AST_LIST_REMOVE_HEAD(&props->stimulus_queue, next))) {
 		ast_free(list);
@@ -1014,10 +1009,10 @@
 	}
 
 	list->stimulus = stimulus;
-	ast_mutex_lock(&props->lock);
+	ao2_lock(props);
 	AST_LIST_INSERT_TAIL(&props->stimulus_queue, list, next);
 	ast_cond_signal(&props->cond);
-	ast_mutex_unlock(&props->lock);
+	ao2_unlock(props);
 }
 
 /*!
@@ -1251,14 +1246,15 @@
  * \brief Flags that indicate properties of attended transfer states
  */
 enum attended_transfer_state_flags {
-	/*! This state has a time limit associated with it */
-	TRANSFER_STATE_FLAG_TIMED = (7 << 0),
 	/*! This state requires that the timer be reset when entering the state */
 	TRANSFER_STATE_FLAG_TIMER_RESET = (1 << 0),
 	/*! This state's timer uses atxferloopdelay */
 	TRANSFER_STATE_FLAG_TIMER_LOOP_DELAY = (1 << 1),
 	/*! This state's timer uses atxfernoanswertimeout */
 	TRANSFER_STATE_FLAG_ATXFER_NO_ANSWER = (1 << 2),
+	/*! This state has a time limit associated with it */
+	TRANSFER_STATE_FLAG_TIMED = (TRANSFER_STATE_FLAG_TIMER_RESET |
+			TRANSFER_STATE_FLAG_TIMER_LOOP_DELAY | TRANSFER_STATE_FLAG_ATXFER_NO_ANSWER),
 	/*! This state does not transition to any other states */
 	TRANSFER_STATE_FLAG_TERMINAL = (1 << 3),
 };
@@ -1314,7 +1310,7 @@
 /*!
  * \brief Properties of an attended transfer state
  */
-static struct attended_transfer_state_properties {
+struct attended_transfer_state_properties {
 	/*! The name of the state. Used for debugging */
 	const char *state_name;
 	/*! Function used to enter a state */
@@ -1329,7 +1325,9 @@
 			enum attended_transfer_stimulus stimulus);
 	/*! Flags associated with this state */
 	enum attended_transfer_state_flags flags;
-} state_properties [] = {
+};
+
+static const struct attended_transfer_state_properties state_properties[] = {
 	[TRANSFER_CALLING_TARGET] = {
 		.state_name = "Calling Target",
 		.enter = calling_target_enter,
@@ -2198,7 +2196,7 @@
 static enum attended_transfer_stimulus wait_for_stimulus(struct attended_transfer_properties *props)
 {
 	RAII_VAR(struct stimulus_list *, list, NULL, ast_free_ptr);
-	SCOPED_MUTEX(lock, &props->lock);
+	SCOPED_MUTEX(lock, ao2_object_get_lockaddr(props));
 
 	while (!(list = AST_LIST_REMOVE_HEAD(&props->stimulus_queue, next))) {
 		if (!(state_properties[props->state].flags & TRANSFER_STATE_FLAG_TIMED)) {
@@ -2437,6 +2435,7 @@
 	struct ast_bridge_features_attended_transfer *attended_transfer = hook_pvt;
 	struct attended_transfer_properties *props;
 	char destination[AST_MAX_EXTENSION + AST_MAX_CONTEXT + 1];
+	char exten[AST_MAX_EXTENSION] = "";
 	pthread_t thread;
 
 	if (bridge->inhibit_merge) {
@@ -2462,12 +2461,14 @@
 	props->transferee_bridge = ast_bridge_channel_merge_inhibit(bridge_channel, +1);
 
 	/* Grab the extension to transfer to */
-	if (grab_transfer(bridge_channel->chan, props->exten, sizeof(props->exten), props->context)) {
+	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), props->context)) {
 		ast_log(LOG_WARNING, "Unable to acquire target extension for attended transfer\n");
 		ast_bridge_channel_write_unhold(bridge_channel);
 		attended_transfer_properties_shutdown(props);
 		return 0;
 	}
+
+	ast_string_field_set(props, exten, exten);
 
 	/* Fill the variable with the extension and context we want to call */
 	snprintf(destination, sizeof(destination), "%s@%s", props->exten, props->context);
@@ -2621,7 +2622,6 @@
 	if (!normal) {
 		return NULL;
 	}
-	normal->name = personality_normal_v_table.name;
 	normal->v_table = &personality_normal_v_table;
 
 	return normal;
@@ -2645,7 +2645,6 @@
 	if (!atxfer) {
 		return NULL;
 	}
-	atxfer->name = personality_atxfer_v_table.name;
 	atxfer->v_table = &personality_atxfer_v_table;
 	ao2_ref(props, +1);
 	atxfer->pvt = props;

Modified: team/mmichelson/atxfer_features/main/features_config.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/features_config.c?view=diff&rev=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/main/features_config.c (original)
+++ team/mmichelson/atxfer_features/main/features_config.c Thu Jul 11 09:52:51 2013
@@ -107,7 +107,7 @@
 					</description>
 				</configOption>
 				<configOption name="atxferswap" default="*4">
-					<synopsis>Digits to dial to change who the transferrer is currently bridged to during an attended transfer</synopsis>
+					<synopsis>Digits to dial to toggle who the transferrer is currently bridged to during an attended transfer</synopsis>
 					<description>
 						<para>This option is only available to the transferrer during an attended
 						transfer operation. Pressing this DTMF sequence will result in the transferrer swapping

Modified: team/mmichelson/atxfer_features/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/atxfer_features/main/stasis_bridging.c?view=diff&rev=394077&r1=394076&r2=394077
==============================================================================
--- team/mmichelson/atxfer_features/main/stasis_bridging.c (original)
+++ team/mmichelson/atxfer_features/main/stasis_bridging.c Thu Jul 11 09:52:51 2013
@@ -844,6 +844,7 @@
 		ast_str_append(&variable_data, 0, "DestType: Threeway\r\n");
 		ast_str_append(&variable_data, 0, "DestBridgeUniqueid: %s\r\n", transfer_msg->dest.threeway.bridge_snapshot->uniqueid);
 		ast_str_append(&variable_data, 0, "DestTransfererChannel: %s\r\n", transfer_msg->dest.threeway.channel_snapshot->name);
+		break;
 	case AST_ATTENDED_TRANSFER_DEST_FAIL:
 		ast_str_append(&variable_data, 0, "DestType: Fail\r\n");
 		break;




More information about the asterisk-commits mailing list