[svn-commits] file: branch file/bridge_unreal r410304 - in /team/file/bridge_unreal: apps/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Mar 8 13:32:38 CST 2014


Author: file
Date: Sat Mar  8 13:32:22 2014
New Revision: 410304

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410304
Log:
Remove optimization messages.

I'm going CRAZY with this!

Modified:
    team/file/bridge_unreal/apps/app_queue.c
    team/file/bridge_unreal/include/asterisk/core_local.h
    team/file/bridge_unreal/include/asterisk/core_unreal.h
    team/file/bridge_unreal/main/cel.c
    team/file/bridge_unreal/main/core_local.c

Modified: team/file/bridge_unreal/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/apps/app_queue.c?view=diff&rev=410304&r1=410303&r2=410304
==============================================================================
--- team/file/bridge_unreal/apps/app_queue.c (original)
+++ team/file/bridge_unreal/apps/app_queue.c Sat Mar  8 13:32:22 2014
@@ -5700,122 +5700,6 @@
 
 /*!
  * \internal
- * \brief Handler for the beginning of a local channel optimization
- *
- * This method gathers data relevant to the local channel optimization and stores
- * it to be used once the local optimization completes.
- *
- * \param userdata Data pertaining to the particular call in the queue.
- * \param sub The stasis subscription on which the message occurred.
- * \param topic The topic for this event.
- * \param msg The stasis message for the local optimization begin event
- */
-static void handle_local_optimization_begin(void *userdata, struct stasis_subscription *sub,
-		struct stasis_message *msg)
-{
-	struct queue_stasis_data *queue_data = userdata;
-	struct ast_multi_channel_blob *optimization_blob = stasis_message_data(msg);
-	struct ast_channel_snapshot *local_one = ast_multi_channel_blob_get_channel(optimization_blob, "1");
-	struct ast_channel_snapshot *local_two = ast_multi_channel_blob_get_channel(optimization_blob, "2");
-	struct ast_channel_snapshot *source = ast_multi_channel_blob_get_channel(optimization_blob, "source");
-	struct local_optimization *optimization;
-	unsigned int id;
-	SCOPED_AO2LOCK(lock, queue_data);
-
-	if (queue_data->dying) {
-		return;
-	}
-
-	if (!strcmp(local_one->uniqueid, queue_data->member_uniqueid)) {
-		optimization = &queue_data->member_optimize;
-	} else if (!strcmp(local_two->uniqueid, queue_data->caller_uniqueid)) {
-		optimization = &queue_data->caller_optimize;
-	} else {
-		return;
-	}
-
-	/* We only allow move-swap optimizations, so there had BETTER be a source */
-	ast_assert(source != NULL);
-
-	optimization->source_chan_uniqueid = ast_strdup(source->uniqueid);
-	if (!optimization->source_chan_uniqueid) {
-		ast_log(LOG_ERROR, "Unable to track local channel optimization for channel %s. Expect further errors\n", local_one->name);
-		return;
-	}
-	id = ast_json_integer_get(ast_json_object_get(ast_multi_channel_blob_get_json(optimization_blob), "id"));
-
-	optimization->id = id;
-	optimization->in_progress = 1;
-}
-
-/*!
- * \internal
- * \brief Handler for the end of a local channel optimization
- *
- * This method takes the data gathered during the local channel optimization begin
- * event and applies it to the queue stasis data appropriately. This generally involves
- * updating the caller or member unique ID with the channel that is taking the place of
- * the previous caller or member.
- *
- * \param userdata Data pertaining to the particular call in the queue.
- * \param sub The stasis subscription on which the message occurred.
- * \param topic The topic for this event.
- * \param msg The stasis message for the local optimization end event
- */
-static void handle_local_optimization_end(void *userdata, struct stasis_subscription *sub,
-		struct stasis_message *msg)
-{
-	struct queue_stasis_data *queue_data = userdata;
-	struct ast_multi_channel_blob *optimization_blob = stasis_message_data(msg);
-	struct ast_channel_snapshot *local_one = ast_multi_channel_blob_get_channel(optimization_blob, "1");
-	struct ast_channel_snapshot *local_two = ast_multi_channel_blob_get_channel(optimization_blob, "2");
-	struct local_optimization *optimization;
-	int is_caller;
-	unsigned int id;
-	SCOPED_AO2LOCK(lock, queue_data);
-
-	if (queue_data->dying) {
-		return;
-	}
-
-	if (!strcmp(local_one->uniqueid, queue_data->member_uniqueid)) {
-		optimization = &queue_data->member_optimize;
-		is_caller = 0;
-	} else if (!strcmp(local_two->uniqueid, queue_data->caller_uniqueid)) {
-		optimization = &queue_data->caller_optimize;
-		is_caller = 1;
-	} else {
-		return;
-	}
-
-	id = ast_json_integer_get(ast_json_object_get(ast_multi_channel_blob_get_json(optimization_blob), "id"));
-
-	if (!optimization->in_progress) {
-		ast_log(LOG_WARNING, "Told of a local optimization end when we had no previous begin\n");
-		return;
-	}
-
-	if (id != optimization->id) {
-		ast_log(LOG_WARNING, "Local optimization end event ID does not match begin (%u != %u)\n",
-				id, optimization->id);
-		return;
-	}
-
-	if (is_caller) {
-		ast_debug(3, "Local optimization: Changing queue caller uniqueid from %s to %s\n",
-				queue_data->caller_uniqueid, optimization->source_chan_uniqueid);
-		ast_string_field_set(queue_data, caller_uniqueid, optimization->source_chan_uniqueid);
-	} else {
-		ast_debug(3, "Local optimization: Changing queue member uniqueid from %s to %s\n",
-				queue_data->member_uniqueid, optimization->source_chan_uniqueid);
-		ast_string_field_set(queue_data, member_uniqueid, optimization->source_chan_uniqueid);
-	}
-
-	optimization->in_progress = 0;
-}
-
-/*!
- * \internal
  * \brief Handler for hangup stasis event
  *
  * This is how we determine that the caller or member has hung up and the call
@@ -5948,10 +5832,6 @@
 	}
 
 	ao2_ref(queue_data, +1);
-	stasis_message_router_add(queue_data->channel_router, ast_local_optimization_begin_type(),
-			handle_local_optimization_begin, queue_data);
-	stasis_message_router_add(queue_data->channel_router, ast_local_optimization_end_type(),
-			handle_local_optimization_end, queue_data);
 	stasis_message_router_add(queue_data->channel_router, ast_channel_hangup_request_type(),
 			handle_hangup, queue_data);
 	stasis_message_router_set_default(queue_data->channel_router,

Modified: team/file/bridge_unreal/include/asterisk/core_local.h
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/include/asterisk/core_local.h?view=diff&rev=410304&r1=410303&r2=410304
==============================================================================
--- team/file/bridge_unreal/include/asterisk/core_local.h (original)
+++ team/file/bridge_unreal/include/asterisk/core_local.h Sat Mar  8 13:32:22 2014
@@ -106,30 +106,6 @@
  */
 struct stasis_message_type *ast_local_bridge_type(void);
 
-/*!
- * \brief Message type for when a local channel optimization begins
- * \since 12.0.0
- *
- * \note Payloads for the \ref ast_local_optimization_begin_type are a
- * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
- * are "1" and "2", reflecting the two halves.
- *
- * \retval A \ref stasis message type
- */
-struct stasis_message_type *ast_local_optimization_begin_type(void);
-
-/*!
- * \brief Message type for when a local channel optimization completes
- * \since 12.0.0
- *
- * \note Payloads for the \ref ast_local_optimization_end_type are a
- * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
- * are "1" and "2", reflecting the two halves.
- *
- * \retval A \ref stasis message type
- */
-struct stasis_message_type *ast_local_optimization_end_type(void);
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/file/bridge_unreal/include/asterisk/core_unreal.h
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/include/asterisk/core_unreal.h?view=diff&rev=410304&r1=410303&r2=410304
==============================================================================
--- team/file/bridge_unreal/include/asterisk/core_unreal.h (original)
+++ team/file/bridge_unreal/include/asterisk/core_unreal.h Sat Mar  8 13:32:22 2014
@@ -52,36 +52,6 @@
 };
 
 /*!
- * \brief Callbacks that can be provided by concrete implementations of the unreal
- * channel driver that will be called when events occur in the unreal layer
- */
-struct ast_unreal_pvt_callbacks {
-	/*!
-	 * \brief Called when an optimization attempt has started
-	 * \note p is locked when this callback is called
-	 * \param p The \ref ast_unreal_pvt object
-	 * \param source The channel that is optimizing into an unreal_pvt channel's bridge.
-	 * If NULL, the optimization is being accomplished via a bridge merge.
-	 * \param dest Indicator of which channel's bridge in the unreal_pvt will survive the
-	 * optimization
-	 * \param id Unique identifier for this optimization operation.
-	 */
-	void (* const optimization_started)(struct ast_unreal_pvt *p, struct ast_channel *source,
-			enum ast_unreal_channel_indicator dest, unsigned int id);
-
-	/*!
-	 * \brief Called when an optimization attempt completed successfully
-	 * \note p is locked when this callback is called
-	 * \param p The \ref ast_unreal_pvt object
-	 * \param success Non-zero if the optimization succeeded, zero if the optimization
-	 * met with fatal and permanent error
-	 * \param id Unique identifier for this optimization. Same as the one from the optimization_started
-	 * call
-	 */
-	void (* const optimization_finished)(struct ast_unreal_pvt *p, int success, unsigned int id);
-};
-
-/*!
  * \brief The base pvt structure for local channel derivatives.
  *
  * The unreal pvt has two ast_chan objects - the "owner" and the "next channel", the outbound channel
@@ -89,7 +59,6 @@
  * ast_chan owner -> ast_unreal_pvt -> ast_chan chan
  */
 struct ast_unreal_pvt {
-	struct ast_unreal_pvt_callbacks *callbacks; /*!< Event callbacks */
 	struct ast_channel *owner;                  /*!< Master Channel - ;1 side */
 	struct ast_channel *chan;                   /*!< Outbound channel - ;2 side */
 	struct ast_channel *bridged_owner;			/*!< Master Channel - Bridged */
@@ -106,7 +75,6 @@
 #define AST_UNREAL_CARETAKER_THREAD (1 << 0) /*!< The ;2 side launched a PBX, was pushed into a bridge, or was masqueraded into an application. */
 #define AST_UNREAL_NO_OPTIMIZATION  (1 << 1) /*!< Do not optimize out the unreal channels */
 #define AST_UNREAL_MOH_INTERCEPT    (1 << 2) /*!< Intercept and act on hold/unhold control frames */
-#define AST_UNREAL_OPTIMIZE_BEGUN   (1 << 3) /*!< Indicates that an optimization attempt has been started */
 
 /*!
  * \brief Send an unreal pvt in with no locks held and get all locks

Modified: team/file/bridge_unreal/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/main/cel.c?view=diff&rev=410304&r1=410303&r2=410304
==============================================================================
--- team/file/bridge_unreal/main/cel.c (original)
+++ team/file/bridge_unreal/main/cel.c Sat Mar  8 13:32:22 2014
@@ -1437,28 +1437,6 @@
 	ast_json_unref(extra);
 }
 
-static void cel_local_cb(
-	void *data, struct stasis_subscription *sub,
-	struct stasis_message *message)
-{
-	struct ast_multi_channel_blob *obj = stasis_message_data(message);
-	struct ast_channel_snapshot *localone = ast_multi_channel_blob_get_channel(obj, "1");
-	struct ast_channel_snapshot *localtwo = ast_multi_channel_blob_get_channel(obj, "2");
-	struct ast_json *extra;
-
-	if (!localone || !localtwo) {
-		return;
-	}
-
-	extra = ast_json_pack("{s: s}", "local_two", localtwo->name);
-	if (!extra) {
-		return;
-	}
-
-	cel_report_event(localone, AST_CEL_LOCAL_OPTIMIZE, NULL, extra, NULL);
-	ast_json_unref(extra);
-}
-
 static void destroy_routes(void)
 {
 	stasis_message_router_unsubscribe_and_join(cel_state_router);
@@ -1604,11 +1582,6 @@
 		cel_pickup_cb,
 		NULL);
 
-	ret |= stasis_message_router_add(cel_state_router,
-		ast_local_optimization_end_type(),
-		cel_local_cb,
-		NULL);
-
 	if (ret) {
 		ast_log(AST_LOG_ERROR, "Failed to register for Stasis messages\n");
 	}

Modified: team/file/bridge_unreal/main/core_local.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/main/core_local.c?view=diff&rev=410304&r1=410303&r2=410304
==============================================================================
--- team/file/bridge_unreal/main/core_local.c (original)
+++ team/file/bridge_unreal/main/core_local.c Sat Mar  8 13:32:22 2014
@@ -141,9 +141,6 @@
 static int local_call(struct ast_channel *ast, const char *dest, int timeout);
 static int local_hangup(struct ast_channel *ast);
 static int local_devicestate(const char *data);
-static void local_optimization_started_cb(struct ast_unreal_pvt *base, struct ast_channel *source,
-		enum ast_unreal_channel_indicator dest, unsigned int id);
-static void local_optimization_finished_cb(struct ast_unreal_pvt *base, int success, unsigned int id);
 
 static struct ast_manager_event_blob *local_message_to_ami(struct stasis_message *msg);
 
@@ -153,19 +150,7 @@
 STASIS_MESSAGE_TYPE_DEFN(ast_local_bridge_type,
 	.to_ami = local_message_to_ami,
 	);
-STASIS_MESSAGE_TYPE_DEFN(ast_local_optimization_begin_type,
-	.to_ami = local_message_to_ami,
-	);
-STASIS_MESSAGE_TYPE_DEFN(ast_local_optimization_end_type,
-	.to_ami = local_message_to_ami,
-	);
 /*! @} */
-
-/*! \brief Callbacks from the unreal core when channel optimization occurs */
-struct ast_unreal_pvt_callbacks local_unreal_callbacks = {
-	.optimization_started = local_optimization_started_cb,
-	.optimization_finished = local_optimization_finished_cb,
-};
 
 /* PBX interface structure for channel registration */
 static struct ast_channel_tech local_tech = {
@@ -321,99 +306,6 @@
 	return res;
 }
 
-static struct ast_multi_channel_blob *local_channel_optimization_blob(struct local_pvt *p,
-		struct ast_json *json_object)
-{
-	struct ast_multi_channel_blob *payload;
-	RAII_VAR(struct ast_channel_snapshot *, local_one_snapshot, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_channel_snapshot *, local_two_snapshot, NULL, ao2_cleanup);
-
-	local_one_snapshot = ast_channel_snapshot_create(p->base.owner);
-	if (!local_one_snapshot) {
-		return NULL;
-	}
-
-	local_two_snapshot = ast_channel_snapshot_create(p->base.chan);
-	if (!local_two_snapshot) {
-		return NULL;
-	}
-
-	payload = ast_multi_channel_blob_create(json_object);
-	if (!payload) {
-		return NULL;
-	}
-	ast_multi_channel_blob_add_channel(payload, "1", local_one_snapshot);
-	ast_multi_channel_blob_add_channel(payload, "2", local_two_snapshot);
-
-	return payload;
-}
-
-/*! \brief Callback for \ref ast_unreal_pvt_callbacks \ref optimization_started_cb */
-static void local_optimization_started_cb(struct ast_unreal_pvt *base, struct ast_channel *source,
-		enum ast_unreal_channel_indicator dest, unsigned int id)
-{
-	RAII_VAR(struct ast_json *, json_object, ast_json_null(), ast_json_unref);
-	RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct local_pvt *p = (struct local_pvt *)base;
-
-	json_object = ast_json_pack("{s: i, s: i}",
-			"dest", dest, "id", id);
-
-	if (!json_object) {
-		return;
-	}
-
-	payload = local_channel_optimization_blob(p, json_object);
-	if (!payload) {
-		return;
-	}
-
-	if (source) {
-		RAII_VAR(struct ast_channel_snapshot *, source_snapshot, NULL, ao2_cleanup);
-		source_snapshot = ast_channel_snapshot_create(source);
-		if (!source_snapshot) {
-			return;
-		}
-
-		ast_multi_channel_blob_add_channel(payload, "source", source_snapshot);
-	}
-
-	msg = stasis_message_create(ast_local_optimization_begin_type(), payload);
-	if (!msg) {
-		return;
-	}
-
-	stasis_publish(ast_channel_topic(p->base.owner), msg);
-}
-
-/*! \brief Callback for \ref ast_unreal_pvt_callbacks \ref optimization_finished_cb */
-static void local_optimization_finished_cb(struct ast_unreal_pvt *base, int success, unsigned int id)
-{
-	RAII_VAR(struct ast_json *, json_object, ast_json_null(), ast_json_unref);
-	RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct local_pvt *p = (struct local_pvt *)base;
-
-	json_object = ast_json_pack("{s: i, s: i}", "success", success, "id", id);
-
-	if (!json_object) {
-		return;
-	}
-
-	payload = local_channel_optimization_blob(p, json_object);
-	if (!payload) {
-		return;
-	}
-
-	msg = stasis_message_create(ast_local_optimization_end_type(), payload);
-	if (!msg) {
-		return;
-	}
-
-	stasis_publish(ast_channel_topic(p->base.owner), msg);
-}
-
 static struct ast_manager_event_blob *local_message_to_ami(struct stasis_message *message)
 {
 	struct ast_multi_channel_blob *obj = stasis_message_data(message);
@@ -438,33 +330,7 @@
 		return NULL;
 	}
 
-	if (stasis_message_type(message) == ast_local_optimization_begin_type()) {
-		struct ast_channel_snapshot *source_snapshot;
-		RAII_VAR(struct ast_str *, source_str, NULL, ast_free);
-		const char *dest_uniqueid;
-
-		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 ?
-				local_snapshot_one->uniqueid : local_snapshot_two->uniqueid;
-
-		event = "LocalOptimizationBegin";
-		if (source_str) {
-			ast_str_append(&event_buffer, 0, "%s", ast_str_buffer(source_str));
-		}
-		ast_str_append(&event_buffer, 0, "DestUniqueId: %s\r\n", dest_uniqueid);
-		ast_str_append(&event_buffer, 0, "Id: %u\r\n", (unsigned int) ast_json_integer_get(ast_json_object_get(blob, "id")));
-	} else if (stasis_message_type(message) == ast_local_optimization_end_type()) {
-		event = "LocalOptimizationEnd";
-		ast_str_append(&event_buffer, 0, "Success: %s\r\n", ast_json_integer_get(ast_json_object_get(blob, "success")) ? "Yes" : "No");
-		ast_str_append(&event_buffer, 0, "Id: %u\r\n", (unsigned int) ast_json_integer_get(ast_json_object_get(blob, "id")));
-	} else if (stasis_message_type(message) == ast_local_bridge_type()) {
+	if (stasis_message_type(message) == ast_local_bridge_type()) {
 		event = "LocalBridge";
 		ast_str_append(&event_buffer, 0, "Context: %s\r\n", ast_json_string_get(ast_json_object_get(blob, "context")));
 		ast_str_append(&event_buffer, 0, "Exten: %s\r\n", ast_json_string_get(ast_json_object_get(blob, "exten")));
@@ -824,7 +690,6 @@
 	if (!pvt) {
 		return NULL;
 	}
-	pvt->base.callbacks = &local_unreal_callbacks;
 
 	parse = ast_strdupa(data);
 
@@ -1010,22 +875,11 @@
 
 	ast_format_cap_destroy(local_tech.capabilities);
 
-	STASIS_MESSAGE_TYPE_CLEANUP(ast_local_optimization_begin_type);
-	STASIS_MESSAGE_TYPE_CLEANUP(ast_local_optimization_end_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_local_bridge_type);
 }
 
 int ast_local_init(void)
 {
-
-	if (STASIS_MESSAGE_TYPE_INIT(ast_local_optimization_begin_type)) {
-		return -1;
-	}
-
-	if (STASIS_MESSAGE_TYPE_INIT(ast_local_optimization_end_type)) {
-		return -1;
-	}
-
 	if (STASIS_MESSAGE_TYPE_INIT(ast_local_bridge_type)) {
 		return -1;
 	}




More information about the svn-commits mailing list