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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 1 15:39:40 CDT 2013


Author: mmichelson
Date: Thu Aug  1 15:39:35 2013
New Revision: 396027

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396027
Log:
Address review feedback and update to deal with bridge renaming.


Modified:
    team/mmichelson/queue_bugbug/apps/app_queue.c
    team/mmichelson/queue_bugbug/include/asterisk/app.h
    team/mmichelson/queue_bugbug/include/asterisk/bridge_basic.h
    team/mmichelson/queue_bugbug/main/bridge.c
    team/mmichelson/queue_bugbug/main/bridge_basic.c
    team/mmichelson/queue_bugbug/main/core_local.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=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/apps/app_queue.c (original)
+++ team/mmichelson/queue_bugbug/apps/app_queue.c Thu Aug  1 15:39:35 2013
@@ -109,11 +109,11 @@
 #include "asterisk/stasis_channels.h"
 #include "asterisk/stasis_message_router.h"
 #include "asterisk/bridge_after.h"
-#include "asterisk/stasis_bridging.h"
+#include "asterisk/stasis_bridges.h"
 #include "asterisk/core_local.h"
 #include "asterisk/mixmonitor.h"
 #include "asterisk/core_unreal.h"
-#include "asterisk/bridging_basic.h"
+#include "asterisk/bridge_basic.h"
 
 /* Define, to debug reference counts on queues, without debugging reference counts on queue members */
 /* #define REF_DEBUG_ONLY_QUEUES */
@@ -1908,7 +1908,7 @@
 		"%s", ast_str_buffer(event_string));
 }
 
-static void queue_publish_multi_channel_snapshot_blob(struct stasis_topic *topic, 
+static void queue_publish_multi_channel_snapshot_blob(struct stasis_topic *topic,
 		struct ast_channel_snapshot *caller_snapshot,
 		struct ast_channel_snapshot *agent_snapshot,
 		struct stasis_message_type *type, struct ast_json *blob)
@@ -5497,12 +5497,12 @@
 
 	if (stasis_subscription_final_message(sub, msg)) {
 		ao2_cleanup(queue_data);
-	} 
+	}
 
 	if (queue_data->dying) {
 		return;
 	}
-	
+
 	if (ast_channel_entered_bridge_type() == stasis_message_type(msg)) {
 		handle_bridge_enter(queue_data, msg);
 	} else if (ast_blind_transfer_type() == stasis_message_type(msg)) {
@@ -5697,7 +5697,7 @@
 		handle_local_optimization_end(queue_data, msg);
 		return;
 	}
-	
+
 	if (ast_channel_hangup_request_type() == stasis_message_type(msg)) {
 		handle_hangup(queue_data, msg);
 	}
@@ -5816,7 +5816,7 @@
 	if (p == escaped + size) {
 		escaped[size - 1] = '\0';
 	}
-	
+
 	pbx_substitute_variables_helper(chan, escaped, output, size - 1);
 }
 
@@ -5857,7 +5857,7 @@
 	} else {
 		snprintf(mixmonargs, sizeof(mixmonargs), "b%s", monitor_options);
 	}
-	
+
 	ast_debug(1, "Arguments being passed to MixMonitor: %s,%s\n", file_with_ext, mixmonargs);
 
 	if (ast_start_mixmonitor(qe->chan, file_with_ext, mixmonargs)) {
@@ -10241,7 +10241,7 @@
 static const struct ast_data_entry queue_data_providers[] = {
 	AST_DATA_ENTRY("asterisk/application/queue/list", &queues_data_provider),
 };
-	
+
 static struct stasis_message_router *agent_router;
 
 static int unload_module(void)

Modified: team/mmichelson/queue_bugbug/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/include/asterisk/app.h?view=diff&rev=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/include/asterisk/app.h (original)
+++ team/mmichelson/queue_bugbug/include/asterisk/app.h Thu Aug  1 15:39:35 2013
@@ -1292,7 +1292,7 @@
 struct stasis_topic *ast_queue_topic_all(void);
 
 /*!
- * \brief Get the \ref stasis topic for queue messages for a particular queue name 
+ * \brief Get the \ref stasis topic for queue messages for a particular queue name
  * \param queuename The name for which to get the topic
  * \retval The topic structure for queue messages for a given name
  * \retval NULL if it failed to be found or allocated

Modified: team/mmichelson/queue_bugbug/include/asterisk/bridge_basic.h
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/include/asterisk/bridge_basic.h?view=diff&rev=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/include/asterisk/bridge_basic.h (original)
+++ team/mmichelson/queue_bugbug/include/asterisk/bridge_basic.h Thu Aug  1 15:39:35 2013
@@ -33,6 +33,7 @@
 extern "C" {
 #endif
 
+#define AST_TRANSFERER_ROLE_NAME "transferer"
 /* ------------------------------------------------------------------- */
 
 /*!
@@ -121,6 +122,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/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/main/bridge.c?view=diff&rev=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/main/bridge.c (original)
+++ team/mmichelson/queue_bugbug/main/bridge.c Thu Aug  1 15:39:35 2013
@@ -70,6 +70,8 @@
 static struct ao2_container *bridges;
 
 static AST_RWLIST_HEAD_STATIC(bridge_technologies, ast_bridge_technology);
+
+static unsigned int optimization_id;
 
 /* Initial starting point for the bridge array of channels */
 #define BRIDGE_ARRAY_START 128
@@ -2377,22 +2379,26 @@
 
 	other = ast_bridge_channel_peer(src_bridge_channel);
 	if (other && other->state == BRIDGE_CHANNEL_STATE_WAIT) {
+		unsigned int id = ast_atomic_fetchadd_int((int *) &optimization_id, +1);
+
 		ast_verb(3, "Move-swap optimizing %s <-- %s.\n",
 			ast_channel_name(dst_bridge_channel->chan),
 			ast_channel_name(other->chan));
 
 		if (pvt && !ast_test_flag(pvt, AST_UNREAL_OPTIMIZE_BEGUN) && pvt->callbacks
 				&& pvt->callbacks->optimization_started) {
-			pvt->callbacks->optimization_started(pvt);
+			pvt->callbacks->optimization_started(pvt, other->chan,
+					dst_bridge_channel->chan == pvt->owner ? AST_UNREAL_OWNER : AST_UNREAL_CHAN,
+					id);
 			ast_set_flag(pvt, AST_UNREAL_OPTIMIZE_BEGUN);
 		}
 		other->swap = dst_bridge_channel->chan;
 		if (!bridge_do_move(dst_bridge, other, 1, 1)) {
 			ast_bridge_channel_leave_bridge(src_bridge_channel, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 			res = -1;
-			if (pvt && pvt->callbacks && pvt->callbacks->optimization_finished) {
-				pvt->callbacks->optimization_finished(pvt);
-			}
+		}
+		if (pvt && pvt->callbacks && pvt->callbacks->optimization_finished) {
+			pvt->callbacks->optimization_finished(pvt, res == 1, id);
 		}
 	}
 	return res;
@@ -2470,6 +2476,7 @@
 		chan_bridge_channel,
 		peer_bridge_channel,
 	};
+	unsigned int id;
 
 	switch (bridges_allow_merge_optimization(chan_bridge, peer_bridge, ARRAY_LEN(kick_me), &merge)) {
 	case MERGE_ALLOWED:
@@ -2493,14 +2500,18 @@
 		ast_channel_name(chan_bridge_channel->chan),
 		ast_channel_name(peer_bridge_channel->chan));
 
+	id = ast_atomic_fetchadd_int((int *) &optimization_id, +1);
+
 	if (pvt && !ast_test_flag(pvt, AST_UNREAL_OPTIMIZE_BEGUN) && pvt->callbacks
 			&& pvt->callbacks->optimization_started) {
-		pvt->callbacks->optimization_started(pvt);
+		pvt->callbacks->optimization_started(pvt, NULL,
+				merge.dest == ast_channel_internal_bridge(pvt->owner) ? AST_UNREAL_OWNER : AST_UNREAL_CHAN,
+				id);
 		ast_set_flag(pvt, AST_UNREAL_OPTIMIZE_BEGUN);
 	}
 	bridge_do_merge(merge.dest, merge.src, kick_me, ARRAY_LEN(kick_me), 1);
 	if (pvt && pvt->callbacks && pvt->callbacks->optimization_finished) {
-		pvt->callbacks->optimization_finished(pvt);
+		pvt->callbacks->optimization_finished(pvt, 1, id);
 	}
 
 	return -1;

Modified: team/mmichelson/queue_bugbug/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/main/bridge_basic.c?view=diff&rev=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/main/bridge_basic.c (original)
+++ team/mmichelson/queue_bugbug/main/bridge_basic.c Thu Aug  1 15:39:35 2013
@@ -50,7 +50,6 @@
 			| AST_BRIDGE_FLAG_SMART)
 
 #define TRANSFER_FLAGS AST_BRIDGE_FLAG_SMART
-#define TRANSFERER_ROLE_NAME "transferer"
 
 struct attended_transfer_properties;
 
@@ -1170,7 +1169,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);
@@ -2257,14 +2256,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,
@@ -2514,11 +2513,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);
 }
 
 /*!
@@ -2919,6 +2918,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/core_local.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/queue_bugbug/main/core_local.c?view=diff&rev=396027&r1=396026&r2=396027
==============================================================================
--- team/mmichelson/queue_bugbug/main/core_local.c (original)
+++ team/mmichelson/queue_bugbug/main/core_local.c Thu Aug  1 15:39:35 2013
@@ -96,6 +96,13 @@
 			<syntax>
 				<channel_snapshot prefix="LocalOne"/>
 				<channel_snapshot prefix="LocalTwo"/>
+				<channel_snapshot prefix="Source"/>
+				<parameter name="DestUniqueId">
+					<para>The unique ID of the bridge into which the local channel is optimizing.</para>
+				</parameter>
+				<parameter name="Id">
+					<para>Identification for the optimization operation.</para>
+				</parameter>
 			</syntax>
 			<see-also>
 				<ref type="managerEvent">LocalOptimizationEnd</ref>
@@ -110,6 +117,13 @@
 			<syntax>
 				<channel_snapshot prefix="LocalOne"/>
 				<channel_snapshot prefix="LocalTwo"/>
+				<parameter name="Success">
+					<para>Indicates whether the local optimization succeeded.</para>
+				</parameter>
+				<parameter name="Id">
+					<para>Identification for the optimization operation. Matches the <replaceable>Id</replaceable>
+					from a previous <literal>LocalOptimizationBegin</literal></para>
+				</parameter>
 			</syntax>
 			<see-also>
 				<ref type="managerEvent">LocalOptimizationBegin</ref>
@@ -343,8 +357,6 @@
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	struct local_pvt *p = (struct local_pvt *)base;
 
-	ast_log(LOG_NOTICE, "Publishing dest of %s\n", dest == AST_UNREAL_OWNER ? "OWNER" : "CHAN");
-
 	json_object = ast_json_pack("{s: i, s: i}",
 			"dest", dest, "id", id);
 
@@ -353,6 +365,9 @@
 	}
 
 	payload = local_channel_optimization_blob(p, json_object);
+	if (!payload) {
+		return;
+	}
 
 	if (source) {
 		RAII_VAR(struct ast_channel_snapshot *, source_snapshot, NULL, ao2_cleanup);
@@ -387,6 +402,9 @@
 	}
 
 	payload = local_channel_optimization_blob(p, json_object);
+	if (!payload) {
+		return;
+	}
 
 	msg = stasis_message_create(ast_local_optimization_end_type(), payload);
 	if (!msg) {
@@ -427,6 +445,9 @@
 		source_snapshot = ast_multi_channel_blob_get_channel(obj, "source");
 		if (source_snapshot) {
 			source_str = ast_manager_build_channel_state_string_prefix(source_snapshot, "Source");
+			if (!source_str) {
+				return NULL;
+			}
 		}
 
 		dest_uniqueid = ast_json_object_get(blob, "dest") == AST_UNREAL_OWNER ?




More information about the asterisk-commits mailing list