[asterisk-commits] mmichelson: branch mmichelson/queue_bugbug r395187 - in /team/mmichelson/queu...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 23 13:50:01 CDT 2013


Author: mmichelson
Date: Tue Jul 23 13:49:59 2013
New Revision: 395187

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395187
Log:
Add functionality that needed attended transfer work to be merged.

* If a transfer ends in a threeway call, then don't log a transfer. The agent and caller are still talking.
* If we detect a hangup from a channel with the transferer role, then wait for the ensuing transfer message.
* Modify how we set flags on basic bridges. We need to be able to switch personalities and keep the flags we had previously set.


Modified:
    team/mmichelson/queue_bugbug/apps/app_queue.c
    team/mmichelson/queue_bugbug/include/asterisk/bridging_basic.h
    team/mmichelson/queue_bugbug/include/asterisk/features.h
    team/mmichelson/queue_bugbug/main/bridging_basic.c
    team/mmichelson/queue_bugbug/main/features.c

Modified: team/mmichelson/queue_bugbug/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/apps/app_queue.c?view=diff&rev=395187&r1=395186&r2=395187
==============================================================================
--- team/mmichelson/queue_bugbug/apps/app_queue.c (original)
+++ team/mmichelson/queue_bugbug/apps/app_queue.c Tue Jul 23 13:49:59 2013
@@ -113,6 +113,7 @@
 #include "asterisk/core_local.h"
 #include "asterisk/mixmonitor.h"
 #include "asterisk/core_unreal.h"
+#include "asterisk/bridging_basic.h"
 
 /* Define, to debug reference counts on queues, without debugging reference counts on queue members */
 /* #define REF_DEBUG_ONLY_QUEUES */
@@ -5315,10 +5316,8 @@
 		RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
 
 		ast_log(LOG_NOTICE, "Getting a transfer event...\n");
-		/* BUGBUG Once atxfer_features is merged, we need to also return when
-		 * atxfer_msg->dest == AST_ATTENDED_TRANSFER_THREEWAY
-		 */
-		if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL) {
+		if (atxfer_msg->result == AST_BRIDGE_TRANSFER_FAIL ||
+				atxfer_msg->dest_type == AST_ATTENDED_TRANSFER_DEST_THREEWAY) {
 			return;
 		}
 
@@ -5440,6 +5439,7 @@
 	struct ast_channel_blob *channel_blob = stasis_message_data(msg);
 	RAII_VAR(struct ast_channel_snapshot *, caller, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_channel_snapshot *, agent, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_channel *, chan, NULL, ao2_cleanup);
 	enum agent_complete_reason reason;
 
 	ao2_lock(queue_data);
@@ -5449,6 +5449,15 @@
 	} else if (!strcmp(channel_blob->snapshot->uniqueid, queue_data->agent_uniqueid)) {
 		reason = AGENT;
 	} else {
+		ao2_unlock(queue_data);
+		return;
+	}
+
+	chan = ast_channel_get_by_name(channel_blob->snapshot->name);
+	if (chan && ast_channel_has_role(chan, AST_TRANSFERER_ROLE_NAME)) {
+		/* Channel that is hanging up is doing it as part of a transfer.
+		 * We'll get a transfer event later
+		 */
 		ao2_unlock(queue_data);
 		return;
 	}

Modified: team/mmichelson/queue_bugbug/include/asterisk/bridging_basic.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/include/asterisk/bridging_basic.h?view=diff&rev=395187&r1=395186&r2=395187
==============================================================================
--- team/mmichelson/queue_bugbug/include/asterisk/bridging_basic.h (original)
+++ team/mmichelson/queue_bugbug/include/asterisk/bridging_basic.h Tue Jul 23 13:49:59 2013
@@ -32,6 +32,8 @@
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
+
+#define AST_TRANSFERER_ROLE_NAME "transferer"
 
 /* ------------------------------------------------------------------- */
 
@@ -95,6 +97,17 @@
  */
 struct ast_bridge *ast_bridge_basic_new(void);
 
+/*!
+ * \brief Set feature flags on a basic bridge
+ *
+ * Using this function instead of setting flags directly will
+ * ensure that after operations such as an attended transfer,
+ * the bridge will maintain the flags that were set on it.
+ *
+ * \params Flags to set on the bridge. These are added to the flags already set.
+ */
+void ast_bridge_basic_set_flags(struct ast_bridge *bridge, unsigned int flags);
+
 /*! Initialize the basic bridge class for use by the system. */
 void ast_bridging_init_basic(void);
 

Modified: team/mmichelson/queue_bugbug/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/include/asterisk/features.h?view=diff&rev=395187&r1=395186&r2=395187
==============================================================================
--- team/mmichelson/queue_bugbug/include/asterisk/features.h (original)
+++ team/mmichelson/queue_bugbug/include/asterisk/features.h Tue Jul 23 13:49:59 2013
@@ -168,6 +168,18 @@
 /*! \brief Bridge a call, optionally allowing redirection */
 int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct ast_bridge_config *config);
 
+/*!
+ * \brief Bridge a call, and add additional flags to the bridge
+ *
+ * This does the same thing as \ref ast_bridge_call, except that once the bridge
+ * is created, the provided flags are set on the bridge. The provided flags are
+ * added to the bridge's flags; they will not clear any flags already set.
+ *
+ * \param chan The calling channel
+ * \param peer The called channel
+ * \param config Bridge configuration for the channels
+ * \param flags Additional flags to set on the created bridge
+ */
 int ast_bridge_call_with_flags(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, unsigned int flags);
 
 /*!

Modified: team/mmichelson/queue_bugbug/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/main/bridging_basic.c?view=diff&rev=395187&r1=395186&r2=395187
==============================================================================
--- team/mmichelson/queue_bugbug/main/bridging_basic.c (original)
+++ team/mmichelson/queue_bugbug/main/bridging_basic.c Tue Jul 23 13:49:59 2013
@@ -49,7 +49,6 @@
 			| AST_BRIDGE_FLAG_SMART)
 
 #define TRANSFER_FLAGS AST_BRIDGE_FLAG_SMART
-#define TRANSFERER_ROLE_NAME "transferer"
 
 struct attended_transfer_properties;
 
@@ -1035,7 +1034,7 @@
 	}
 
 	if (props->transferer) {
-		ast_channel_remove_bridge_role(props->transferer, TRANSFERER_ROLE_NAME);
+		ast_channel_remove_bridge_role(props->transferer, AST_TRANSFERER_ROLE_NAME);
 	}
 
 	clear_stimulus_queue(props);
@@ -2122,14 +2121,14 @@
 	const char *swap_dtmf;
 	struct bridge_basic_personality *personality = self->personality;
 
-	if (!ast_channel_has_role(bridge_channel->chan, TRANSFERER_ROLE_NAME)) {
+	if (!ast_channel_has_role(bridge_channel->chan, AST_TRANSFERER_ROLE_NAME)) {
 		return 0;
 	}
 
-	abort_dtmf = ast_channel_get_role_option(bridge_channel->chan, TRANSFERER_ROLE_NAME, "abort");
-	complete_dtmf = ast_channel_get_role_option(bridge_channel->chan, TRANSFERER_ROLE_NAME, "complete");
-	threeway_dtmf = ast_channel_get_role_option(bridge_channel->chan, TRANSFERER_ROLE_NAME, "threeway");
-	swap_dtmf = ast_channel_get_role_option(bridge_channel->chan, TRANSFERER_ROLE_NAME, "swap");
+	abort_dtmf = ast_channel_get_role_option(bridge_channel->chan, AST_TRANSFERER_ROLE_NAME, "abort");
+	complete_dtmf = ast_channel_get_role_option(bridge_channel->chan, AST_TRANSFERER_ROLE_NAME, "complete");
+	threeway_dtmf = ast_channel_get_role_option(bridge_channel->chan, AST_TRANSFERER_ROLE_NAME, "threeway");
+	swap_dtmf = ast_channel_get_role_option(bridge_channel->chan, AST_TRANSFERER_ROLE_NAME, "swap");
 
 	if (!ast_strlen_zero(abort_dtmf) && ast_bridge_dtmf_hook(bridge_channel->features,
 			abort_dtmf, atxfer_abort, personality->details[personality->current].pvt, NULL,
@@ -2379,11 +2378,11 @@
 		atxfer_swap = ast_strdupa(xfer_cfg->atxferswap);
 	}
 
-	return ast_channel_add_bridge_role(chan, TRANSFERER_ROLE_NAME) ||
-		ast_channel_set_bridge_role_option(chan, TRANSFERER_ROLE_NAME, "abort", atxfer_abort) ||
-		ast_channel_set_bridge_role_option(chan, TRANSFERER_ROLE_NAME, "complete", atxfer_complete) ||
-		ast_channel_set_bridge_role_option(chan, TRANSFERER_ROLE_NAME, "threeway", atxfer_threeway) ||
-		ast_channel_set_bridge_role_option(chan, TRANSFERER_ROLE_NAME, "swap", atxfer_swap);
+	return ast_channel_add_bridge_role(chan, AST_TRANSFERER_ROLE_NAME) ||
+		ast_channel_set_bridge_role_option(chan, AST_TRANSFERER_ROLE_NAME, "abort", atxfer_abort) ||
+		ast_channel_set_bridge_role_option(chan, AST_TRANSFERER_ROLE_NAME, "complete", atxfer_complete) ||
+		ast_channel_set_bridge_role_option(chan, AST_TRANSFERER_ROLE_NAME, "threeway", atxfer_threeway) ||
+		ast_channel_set_bridge_role_option(chan, AST_TRANSFERER_ROLE_NAME, "swap", atxfer_swap);
 }
 
 /*!
@@ -2772,6 +2771,15 @@
 	return bridge;
 }
 
+void ast_bridge_basic_set_flags(struct ast_bridge *bridge, unsigned int flags)
+{
+	SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
+	struct bridge_basic_personality *personality = bridge->personality;
+
+	personality->details[personality->current].bridge_flags |= flags;
+	ast_set_flag(&bridge->feature_flags, flags);
+}
+
 void ast_bridging_init_basic(void)
 {
 	/* Setup bridge basic subclass v_table. */

Modified: team/mmichelson/queue_bugbug/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/main/features.c?view=diff&rev=395187&r1=395186&r2=395187
==============================================================================
--- team/mmichelson/queue_bugbug/main/features.c (original)
+++ team/mmichelson/queue_bugbug/main/features.c Tue Jul 23 13:49:59 2013
@@ -3698,7 +3698,7 @@
 		return -1;
 	}
 
-	ast_set_flag(&bridge->feature_flags, flags);
+	ast_bridge_basic_set_flags(bridge, flags);
 
 	/* Put peer into the bridge */
 	if (ast_bridge_impart(bridge, peer, NULL, peer_features, 1)) {




More information about the asterisk-commits mailing list