[asterisk-commits] file: branch file/bridge_unreal r410303 - in /team/file/bridge_unreal: includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 8 12:55:40 CST 2014


Author: file
Date: Sat Mar  8 12:55:35 2014
New Revision: 410303

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410303
Log:
Remove old unreal optimization code.

Modified:
    team/file/bridge_unreal/include/asterisk/bridge.h
    team/file/bridge_unreal/main/bridge.c
    team/file/bridge_unreal/main/core_unreal.c

Modified: team/file/bridge_unreal/include/asterisk/bridge.h
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/include/asterisk/bridge.h?view=diff&rev=410303&r1=410302&r2=410303
==============================================================================
--- team/file/bridge_unreal/include/asterisk/bridge.h (original)
+++ team/file/bridge_unreal/include/asterisk/bridge.h Sat Mar  8 12:55:35 2014
@@ -740,24 +740,6 @@
  */
 int ast_bridge_unsuspend(struct ast_bridge *bridge, struct ast_channel *chan);
 
-struct ast_unreal_pvt;
-
-/*!
- * \brief Check and optimize out the unreal channels between bridges.
- * \since 12.0.0
- *
- * \param chan Unreal channel writing a frame into the channel driver.
- * \param peer Other unreal channel in the pair.
- * \param pvt Private data provided by an implementation of the unreal driver that
- * contains the callbacks that should be called when optimization begins/ends
- *
- * \note It is assumed that chan is already locked.
- *
- * \retval 0 if unreal channels were not optimized out.
- * \retval non-zero if unreal channels were optimized out.
- */
-int ast_bridge_unreal_optimize_out(struct ast_channel *chan, struct ast_channel *peer, struct ast_unreal_pvt *pvt);
-
 /*!
  * \brief Tells, if optimization is allowed, how the optimization would be performed
  */

Modified: team/file/bridge_unreal/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/main/bridge.c?view=diff&rev=410303&r1=410302&r2=410303
==============================================================================
--- team/file/bridge_unreal/main/bridge.c (original)
+++ team/file/bridge_unreal/main/bridge.c Sat Mar  8 12:55:35 2014
@@ -114,8 +114,6 @@
 
 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
 
@@ -2323,107 +2321,6 @@
 
 /*!
  * \internal
- * \brief Lock the unreal channel stack for chan and prequalify it.
- * \since 12.0.0
- *
- * \param chan Unreal channel writing a frame into the channel driver.
- *
- * \note It is assumed that chan is already locked.
- *
- * \retval bridge on success with bridge and bridge_channel locked.
- * \retval NULL if cannot do optimization now.
- */
-static struct ast_bridge *optimize_lock_chan_stack(struct ast_channel *chan)
-{
-	struct ast_bridge *bridge;
-	struct ast_bridge_channel *bridge_channel;
-
-	if (!AST_LIST_EMPTY(ast_channel_readq(chan))) {
-		return NULL;
-	}
-	if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF)) {
-		return NULL;
-	}
-	if (ast_channel_has_audio_frame_or_monitor(chan)) {
-		/* Channel has an active monitor, audiohook, or framehook. */
-		return NULL;
-	}
-	bridge_channel = ast_channel_internal_bridge_channel(chan);
-	if (!bridge_channel || ast_bridge_channel_trylock(bridge_channel)) {
-		return NULL;
-	}
-	bridge = bridge_channel->bridge;
-	if (bridge_channel->activity != BRIDGE_CHANNEL_THREAD_SIMPLE
-		|| bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT
-		|| ast_bridge_trylock(bridge)) {
-		ast_bridge_channel_unlock(bridge_channel);
-		return NULL;
-	}
-	if (!bridge_channel_internal_allows_optimization(bridge_channel) ||
-			!bridge_allows_optimization(bridge)) {
-		ast_bridge_unlock(bridge);
-		ast_bridge_channel_unlock(bridge_channel);
-		return NULL;
-	}
-	return bridge;
-}
-
-/*!
- * \internal
- * \brief Lock the unreal channel stack for peer and prequalify it.
- * \since 12.0.0
- *
- * \param peer Other unreal channel in the pair.
- *
- * \retval bridge on success with bridge, bridge_channel, and peer locked.
- * \retval NULL if cannot do optimization now.
- */
-static struct ast_bridge *optimize_lock_peer_stack(struct ast_channel *peer)
-{
-	struct ast_bridge *bridge;
-	struct ast_bridge_channel *bridge_channel;
-
-	if (ast_channel_trylock(peer)) {
-		return NULL;
-	}
-	if (!AST_LIST_EMPTY(ast_channel_readq(peer))) {
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	if (ast_test_flag(ast_channel_flags(peer), AST_FLAG_EMULATE_DTMF)) {
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	if (ast_channel_has_audio_frame_or_monitor(peer)) {
-		/* Peer has an active monitor, audiohook, or framehook. */
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	bridge_channel = ast_channel_internal_bridge_channel(peer);
-	if (!bridge_channel || ast_bridge_channel_trylock(bridge_channel)) {
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	bridge = bridge_channel->bridge;
-	if (bridge_channel->activity != BRIDGE_CHANNEL_THREAD_IDLE
-		|| bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT
-		|| ast_bridge_trylock(bridge)) {
-		ast_bridge_channel_unlock(bridge_channel);
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	if (!bridge_allows_optimization(bridge) ||
-			!bridge_channel_internal_allows_optimization(bridge_channel)) {
-		ast_bridge_unlock(bridge);
-		ast_bridge_channel_unlock(bridge_channel);
-		ast_channel_unlock(peer);
-		return NULL;
-	}
-	return bridge;
-}
-
-/*!
- * \internal
  * \brief Indicates allowability of a swap optimization
  */
 enum bridge_allow_swap {
@@ -2485,84 +2382,6 @@
 
 /*!
  * \internal
- * \brief Check and attempt to swap optimize out the unreal channels.
- * \since 12.0.0
- *
- * \param chan_bridge
- * \param chan_bridge_channel
- * \param peer_bridge
- * \param peer_bridge_channel
- * \param pvt Unreal data containing callbacks to call if the optimization actually
- * happens
- *
- * \retval 1 if unreal channels failed to optimize out.
- * \retval 0 if unreal channels were not optimized out.
- * \retval -1 if unreal channels were optimized out.
- */
-static int try_swap_optimize_out(struct ast_bridge *chan_bridge,
-	struct ast_bridge_channel *chan_bridge_channel, struct ast_bridge *peer_bridge,
-	struct ast_bridge_channel *peer_bridge_channel,
-	struct ast_unreal_pvt *pvt)
-{
-	struct ast_bridge *dst_bridge;
-	struct ast_bridge_channel *dst_bridge_channel;
-	struct ast_bridge_channel *src_bridge_channel;
-	struct ast_bridge_channel *other;
-	int res = 1;
-
-	switch (bridges_allow_swap_optimization(chan_bridge, peer_bridge)) {
-	case SWAP_TO_CHAN_BRIDGE:
-		dst_bridge = chan_bridge;
-		dst_bridge_channel = chan_bridge_channel;
-		src_bridge_channel = peer_bridge_channel;
-		break;
-	case SWAP_TO_PEER_BRIDGE:
-		dst_bridge = peer_bridge;
-		dst_bridge_channel = peer_bridge_channel;
-		src_bridge_channel = chan_bridge_channel;
-		break;
-	case SWAP_PROHIBITED:
-	default:
-		return 0;
-	}
-
-	other = ast_bridge_channel_peer(src_bridge_channel);
-	if (other && other->state == BRIDGE_CHANNEL_STATE_WAIT) {
-		unsigned int id;
-
-		if (ast_channel_trylock(other->chan)) {
-			return 1;
-		}
-
-		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, 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, AST_CAUSE_NORMAL_CLEARING);
-			res = -1;
-		}
-		if (pvt && pvt->callbacks && pvt->callbacks->optimization_finished) {
-			pvt->callbacks->optimization_finished(pvt, res == 1, id);
-		}
-		ast_channel_unlock(other->chan);
-	}
-	return res;
-}
-
-/*!
- * \internal
  * \brief Indicates allowability of a merge optimization
  */
 enum bridge_allow_merge {
@@ -2606,112 +2425,6 @@
 	}
 
 	return MERGE_ALLOWED;
-}
-
-/*!
- * \internal
- * \brief Check and attempt to merge optimize out the unreal channels.
- * \since 12.0.0
- *
- * \param chan_bridge
- * \param chan_bridge_channel
- * \param peer_bridge
- * \param peer_bridge_channel
- * \param pvt Unreal data containing callbacks to call if the optimization actually
- * happens
- *
- * \retval 0 if unreal channels were not optimized out.
- * \retval -1 if unreal channels were optimized out.
- */
-static int try_merge_optimize_out(struct ast_bridge *chan_bridge,
-	struct ast_bridge_channel *chan_bridge_channel, struct ast_bridge *peer_bridge,
-	struct ast_bridge_channel *peer_bridge_channel,
-	struct ast_unreal_pvt *pvt)
-{
-	struct merge_direction merge;
-	struct ast_bridge_channel *kick_me[] = {
-		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:
-		break;
-	case MERGE_PROHIBITED:
-		return 0;
-	case MERGE_NOT_ENOUGH_CHANNELS:
-		ast_debug(4, "Can't optimize %s -- %s out, not enough channels in bridge %s.\n",
-			ast_channel_name(chan_bridge_channel->chan),
-			ast_channel_name(peer_bridge_channel->chan),
-			merge.src->uniqueid);
-		return 0;
-	case MERGE_NO_MULTIMIX:
-		ast_debug(4, "Can't optimize %s -- %s out, multimix is needed and it cannot be acquired.\n",
-			ast_channel_name(chan_bridge_channel->chan),
-			ast_channel_name(peer_bridge_channel->chan));
-		return 0;
-	}
-
-	ast_verb(3, "Merge optimizing %s -- %s out.\n",
-		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, 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, 1, id);
-	}
-
-	return -1;
-}
-
-int ast_bridge_unreal_optimize_out(struct ast_channel *chan, struct ast_channel *peer, struct ast_unreal_pvt *pvt)
-{
-	struct ast_bridge *chan_bridge;
-	struct ast_bridge *peer_bridge;
-	struct ast_bridge_channel *chan_bridge_channel;
-	struct ast_bridge_channel *peer_bridge_channel;
-	int res = 0;
-
-	chan_bridge = optimize_lock_chan_stack(chan);
-	if (!chan_bridge) {
-		return res;
-	}
-	chan_bridge_channel = ast_channel_internal_bridge_channel(chan);
-
-	peer_bridge = optimize_lock_peer_stack(peer);
-	if (peer_bridge) {
-		peer_bridge_channel = ast_channel_internal_bridge_channel(peer);
-
-		res = try_swap_optimize_out(chan_bridge, chan_bridge_channel,
-			peer_bridge, peer_bridge_channel, pvt);
-		if (!res) {
-			res = try_merge_optimize_out(chan_bridge, chan_bridge_channel,
-				peer_bridge, peer_bridge_channel, pvt);
-		} else if (0 < res) {
-			res = 0;
-		}
-
-		/* Release peer locks. */
-		ast_bridge_unlock(peer_bridge);
-		ast_bridge_channel_unlock(peer_bridge_channel);
-		ast_channel_unlock(peer);
-	}
-
-	/* Release chan locks. */
-	ast_bridge_unlock(chan_bridge);
-	ast_bridge_channel_unlock(chan_bridge_channel);
-
-	return res;
 }
 
 enum ast_bridge_optimization ast_bridges_allow_optimization(struct ast_bridge *chan_bridge,

Modified: team/file/bridge_unreal/main/core_unreal.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_unreal/main/core_unreal.c?view=diff&rev=410303&r1=410302&r2=410303
==============================================================================
--- team/file/bridge_unreal/main/core_unreal.c (original)
+++ team/file/bridge_unreal/main/core_unreal.c Sat Mar  8 12:55:35 2014
@@ -279,38 +279,6 @@
 	return res;
 }
 
-/*!
- * \internal
- * \brief Check and optimize out the unreal channels between bridges.
- * \since 12.0.0
- *
- * \param ast Channel writing a frame into the unreal channels.
- * \param p Unreal channel private.
- *
- * \note It is assumed that ast is locked.
- * \note It is assumed that p is locked.
- *
- * \retval 0 if unreal channels were not optimized out.
- * \retval non-zero if unreal channels were optimized out.
- */
-static int got_optimized_out(struct ast_channel *ast, struct ast_unreal_pvt *p)
-{
-	int res = 0;
-
-	/* Do a few conditional checks early on just to see if this optimization is possible */
-	if (ast_test_flag(p, AST_UNREAL_NO_OPTIMIZATION) || !p->chan || !p->owner) {
-		return res;
-	}
-
-	if (ast == p->owner) {
-		res = ast_bridge_unreal_optimize_out(p->owner, p->chan, p);
-	} else if (ast == p->chan) {
-		res = ast_bridge_unreal_optimize_out(p->chan, p->owner, p);
-	}
-
-	return res;
-}
-
 struct ast_frame  *ast_unreal_read(struct ast_channel *ast)
 {
 	return &ast_null_frame;
@@ -328,17 +296,7 @@
 	/* Just queue for delivery to the other side */
 	ao2_ref(p, 1);
 	ao2_lock(p);
-	switch (f->frametype) {
-	case AST_FRAME_VOICE:
-	case AST_FRAME_VIDEO:
-		if (got_optimized_out(ast, p)) {
-			break;
-		}
-		/* fall through */
-	default:
-		res = unreal_queue_frame(p, AST_UNREAL_IS_OUTBOUND(ast, p), f, ast, 1);
-		break;
-	}
+	res = unreal_queue_frame(p, AST_UNREAL_IS_OUTBOUND(ast, p), f, ast, 1);
 	ao2_unlock(p);
 	ao2_ref(p, -1);
 




More information about the asterisk-commits mailing list