[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r395300 - in /team/rmudgett/bridge_pha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 24 14:37:16 CDT 2013


Author: rmudgett
Date: Wed Jul 24 14:37:14 2013
New Revision: 395300

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395300
Log:
Update bridge_channel refactorings; export bridge_ symbol
........

Merged revisions 395295 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/rmudgett/bridge_phase/   (props changed)
    team/rmudgett/bridge_phase/apps/app_agent_pool.c
    team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c
    team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c
    team/rmudgett/bridge_phase/include/asterisk/bridging_channel.h
    team/rmudgett/bridge_phase/include/asterisk/bridging_channel_internal.h
    team/rmudgett/bridge_phase/include/asterisk/bridging_features.h
    team/rmudgett/bridge_phase/main/bridging.c
    team/rmudgett/bridge_phase/main/bridging_basic.c
    team/rmudgett/bridge_phase/main/bridging_channel.c
    team/rmudgett/bridge_phase/res/parking/parking_bridge_features.c

Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
--- bridge_phase-integrated (original)
+++ bridge_phase-integrated Wed Jul 24 14:37:14 2013
@@ -1,1 +1,1 @@
-/trunk:1-395292
+/trunk:1-395297

Modified: team/rmudgett/bridge_phase/apps/app_agent_pool.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/apps/app_agent_pool.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/apps/app_agent_pool.c (original)
+++ team/rmudgett/bridge_phase/apps/app_agent_pool.c Wed Jul 24 14:37:14 2013
@@ -1055,7 +1055,7 @@
 
 	if (!caller_bridge) {
 		/* Reset agent. */
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 		return;
 	}
 	res = ast_bridge_move(caller_bridge, bridge_channel->bridge, bridge_channel->chan,
@@ -1063,7 +1063,7 @@
 	if (res) {
 		/* Reset agent. */
 		ast_bridge_destroy(caller_bridge);
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 		return;
 	}
 	ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_ANSWER, NULL, 0);
@@ -1159,13 +1159,13 @@
 
 	if (deferred_logoff) {
 		ast_debug(1, "Agent %s: Deferred logoff.\n", agent->username);
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 	} else if (probation_timedout) {
 		ast_debug(1, "Agent %s: Login complete.\n", agent->username);
 		agent_devstate_changed(agent->username);
 	} else if (ack_timedout) {
 		ast_debug(1, "Agent %s: Ack call timeout.\n", agent->username);
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 	} else if (wrapup_timedout) {
 		ast_debug(1, "Agent %s: Wrapup timeout. Ready for new call.\n", agent->username);
 		agent_devstate_changed(agent->username);
@@ -1270,7 +1270,7 @@
 		 * agent will have some slightly different behavior in corner
 		 * cases.
 		 */
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 		return 0;
 	}
 
@@ -1704,7 +1704,7 @@
 	}
 
 	/* Kick the agent out of the holding bridge to reset it. */
-	ast_bridge_channel_leave_bridge_nolock(logged);
+	ast_bridge_channel_leave_bridge_nolock(logged, AST_BRIDGE_CHANNEL_STATE_END);
 	ast_bridge_channel_unlock(logged);
 }
 
@@ -1714,7 +1714,7 @@
 
 	if (agent->state == AGENT_STATE_CALL_PRESENT) {
 		ast_verb(3, "Agent '%s' did not respond.  Safety timeout.\n", agent->username);
-		ast_bridge_channel_leave_bridge(bridge_channel);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 		caller_abort_agent(agent);
 	}
 

Modified: team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c (original)
+++ team/rmudgett/bridge_phase/bridges/bridge_builtin_features.c Wed Jul 24 14:37:14 2013
@@ -483,7 +483,7 @@
 	 * bridge_channel to force the channel out of the bridge and the
 	 * core takes care of the rest.
 	 */
-	ast_bridge_channel_leave_bridge(bridge_channel);
+	ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 	return 0;
 }
 

Modified: team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c (original)
+++ team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c Wed Jul 24 14:37:14 2013
@@ -58,7 +58,7 @@
 		ast_stream_and_wait(bridge_channel->chan, limits->duration_sound, AST_DIGIT_NONE);
 	}
 
-	ast_bridge_channel_leave_bridge(bridge_channel);
+	ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 
 	ast_test_suite_event_notify("BRIDGE_TIMELIMIT", "Channel1: %s", ast_channel_name(bridge_channel->chan));
 	return -1;

Modified: team/rmudgett/bridge_phase/include/asterisk/bridging_channel.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridging_channel.h?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridging_channel.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridging_channel.h Wed Jul 24 14:37:14 2013
@@ -22,7 +22,20 @@
  * \file
  * \brief Bridging Channel API
  *
- * An API that act on a channel in a bridge
+ * An API that act on a channel in a bridge. Note that while the
+ * \ref ast_bridge_channel is owned by a channel, it should only be used
+ * by members of the bridging system. The only places where this API should
+ * be used is:
+ *  - The \ref AstBridging API itself
+ *  - Bridge mixing technologies
+ *  - Bridge sub-classes
+ *
+ * In general, anywhere else it is unsafe to use this API. Care should be
+ * taken when using this API to ensure that the locking order remains
+ * correct. The locking order must be:
+ *  - The \ref ast_bridge
+ *  - The \ref ast_bridge_channel
+ *  - The \ref ast_channel
  *
  * \author Joshua Colp <jcolp at digium.com>
  * \author Richard Mudgett <rmudgett at digium.com>
@@ -48,8 +61,8 @@
 	AST_BRIDGE_CHANNEL_STATE_WAIT = 0,
 	/*! Bridged channel was forced out and should be hung up (Bridge may dissolve.) */
 	AST_BRIDGE_CHANNEL_STATE_END,
-	/*! Bridged channel was forced out and should be hung up */
-	AST_BRIDGE_CHANNEL_STATE_HANGUP,
+	/*! Bridged channel was forced out. Don't dissolve the bridge regardless */
+	AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE,
 };
 
 enum ast_bridge_channel_thread_state {
@@ -59,43 +72,6 @@
 	AST_BRIDGE_CHANNEL_THREAD_SIMPLE,
 	/*! Bridge channel thread is processing a frame. */
 	AST_BRIDGE_CHANNEL_THREAD_FRAME,
-};
-
-/*! \brief Actions that can be taken on a channel in a bridge */
-enum ast_bridge_action_type {
-	/*! Bridged channel is to detect a feature hook */
-	AST_BRIDGE_ACTION_FEATURE,
-	/*! Bridged channel is to act on an interval hook */
-	AST_BRIDGE_ACTION_INTERVAL,
-	/*! Bridged channel is to send a DTMF stream out */
-	AST_BRIDGE_ACTION_DTMF_STREAM,
-	/*! Bridged channel is to indicate talking start */
-	AST_BRIDGE_ACTION_TALKING_START,
-	/*! Bridged channel is to indicate talking stop */
-	AST_BRIDGE_ACTION_TALKING_STOP,
-	/*! Bridge channel is to play the indicated sound file. */
-	AST_BRIDGE_ACTION_PLAY_FILE,
-	/*! Bridge channel is to run the indicated application. */
-	AST_BRIDGE_ACTION_RUN_APP,
-	/*! Bridge channel is to run the custom callback routine. */
-	AST_BRIDGE_ACTION_CALLBACK,
-	/*! Bridge channel is to get parked. */
-	AST_BRIDGE_ACTION_PARK,
-	/*! Bridge channel is to execute a blind transfer. */
-	AST_BRIDGE_ACTION_BLIND_TRANSFER,
-	/*! Bridge channel is to execute an attended transfer */
-	AST_BRIDGE_ACTION_ATTENDED_TRANSFER,
-
-	/*
-	 * Bridge actions put after this comment must never be put onto
-	 * the bridge_channel wr_queue because they have other resources
-	 * that must be freed.
-	 */
-
-	/*! Bridge reconfiguration deferred technology destruction. */
-	AST_BRIDGE_ACTION_DEFERRED_TECH_DESTROY = 1000,
-	/*! Bridge deferred dissolving. */
-	AST_BRIDGE_ACTION_DEFERRED_DISSOLVING,
 };
 
 struct ast_bridge;
@@ -241,20 +217,40 @@
 void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel);
 
 /*!
- * \brief Ask the bridged channel to leave the bridge it is currently in
- *
- * \param bridge_channel Channel to leave the bridge
- */
-void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel);
-
-/*!
- * \brief Ask the bridged channel to leave the bridge it is currently in
- *
- * \param bridge_channel Channel to leave the bridge
- *
- * \note This function assumes the bridge_channel is locked.
- */
-void ast_bridge_channel_leave_bridge_nolock(struct ast_bridge_channel *bridge_channel);
+ * \brief Set bridge channel state to leave bridge (if not leaving already).
+ *
+ * \param bridge_channel Channel to change the state on
+ * \param new_state The new state to place the channel into
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ * \endcode
+ *
+ * This places the channel pointed to by bridge_channel into the
+ * state AST_BRIDGE_CHANNEL_STATE_END if it was
+ * AST_BRIDGE_CHANNEL_STATE_WAIT before.
+ */
+void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
+
+/*!
+ * \brief Set bridge channel state to leave bridge (if not leaving already).
+ *
+ * \param bridge_channel Channel to change the state on
+ * \param new_state The new state to place the channel into
+ *
+ * Example usage:
+ *
+ * \code
+ * ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+ * \endcode
+ *
+ * This places the channel pointed to by bridge_channel into the
+ * state AST_BRIDGE_CHANNEL_STATE_END if it was
+ * AST_BRIDGE_CHANNEL_STATE_WAIT before.
+ */
+void ast_bridge_channel_leave_bridge_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
 
 /*!
  * \brief Write a frame to the specified bridge_channel.
@@ -265,53 +261,8 @@
  *
  * \retval 0 on success.
  * \retval -1 on error.
- *
- * \note This API call is meant for internal bridging operations.
- * \note BUGBUG This may get moved.
  */
 int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr);
-
-/*!
- * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
- * \since 12.0.0
- *
- * \param bridge_channel Which channel work with.
- * \param action Type of bridge action frame.
- * \param data Frame payload data to pass.
- * \param datalen Frame payload data length to pass.
- *
- * \retval 0 on success.
- * \retval -1 on error.
- */
-typedef int (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
-
-/*!
- * \brief Queue an action frame onto the bridge channel with data.
- * \since 12.0.0
- *
- * \param bridge_channel Which channel to queue the frame onto.
- * \param action Type of bridge action frame.
- * \param data Frame payload data to pass.
- * \param datalen Frame payload data length to pass.
- *
- * \retval 0 on success.
- * \retval -1 on error.
- */
-int ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
-
-/*!
- * \brief Write an action frame into the bridge with data.
- * \since 12.0.0
- *
- * \param bridge_channel Which channel is putting the frame into the bridge.
- * \param action Type of bridge action frame.
- * \param data Frame payload data to pass.
- * \param datalen Frame payload data length to pass.
- *
- * \retval 0 on success.
- * \retval -1 on error.
- */
-int ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen);
 
 /*!
  * \brief Queue a control frame onto the bridge channel with data.
@@ -569,6 +520,56 @@
  */
 struct ast_bridge_channel *ast_bridge_channel_peer(struct ast_bridge_channel *bridge_channel);
 
+struct blind_transfer_data {
+	char exten[AST_MAX_EXTENSION];
+	char context[AST_MAX_CONTEXT];
+};
+
+/*!
+ * \brief Adjust the bridge_channel's bridge merge inhibit request count.
+ * \since 12.0.0
+ *
+ * \param bridge_channel What to operate on.
+ * \param request Inhibit request increment.
+ *     (Positive to add requests.  Negative to remove requests.)
+ *
+ * \note This API call is meant for internal bridging operations.
+ *
+ * \retval bridge adjusted merge inhibit with reference count.
+ */
+struct ast_bridge *ast_bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request);
+
+/*!
+ * \internal
+ * \brief Update the linkedids for all channels in a bridge
+ * \since 12.0.0
+ *
+ * \param bridge_channel The channel joining the bridge
+ * \param swap The channel being swapped out of the bridge. May be NULL.
+ *
+ * \note The bridge must be locked prior to calling this function. This should be called
+ * during a \ref bridge_channel_push operation, typically by a sub-class of a bridge
+ */
+void ast_bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
+
+/*!
+ * \internal
+ * \brief Update the accountcodes for a channel entering a bridge
+ * \since 12.0.0
+ *
+ * This function updates the accountcode and peeraccount on channels in two-party
+ * bridges. In multi-party bridges, peeraccount is not set - it doesn't make much sense -
+ * however accountcode propagation will still occur if the channel joining has an
+ * accountcode.
+ *
+ * \param bridge_channel The channel joining the bridge
+ * \param swap The channel being swapped out of the bridge. May be NULL.
+ *
+ * \note The bridge must be locked prior to calling this function. This should be called
+ * during a \ref bridge_channel_push operation, typically by a sub-class of a bridge
+ */
+void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/rmudgett/bridge_phase/include/asterisk/bridging_channel_internal.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridging_channel_internal.h?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridging_channel_internal.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridging_channel_internal.h Wed Jul 24 14:37:14 2013
@@ -33,24 +33,59 @@
 #ifndef _ASTERISK_PRIVATE_BRIDGING_CHANNEL_H
 #define _ASTERISK_PRIVATE_BRIDGING_CHANNEL_H
 
-struct blind_transfer_data {
-	char exten[AST_MAX_EXTENSION];
-	char context[AST_MAX_CONTEXT];
+/*!
+ * \internal
+ * \brief Actions that can be taken on a channel in a bridge
+ */
+enum bridge_channel_action_type {
+	/*! Bridged channel is to detect a feature hook */
+	BRIDGE_CHANNEL_ACTION_FEATURE,
+	/*! Bridged channel is to act on an interval hook */
+	BRIDGE_CHANNEL_ACTION_INTERVAL,
+	/*! Bridged channel is to send a DTMF stream out */
+	BRIDGE_CHANNEL_ACTION_DTMF_STREAM,
+	/*! Bridged channel is to indicate talking start */
+	BRIDGE_CHANNEL_ACTION_TALKING_START,
+	/*! Bridged channel is to indicate talking stop */
+	BRIDGE_CHANNEL_ACTION_TALKING_STOP,
+	/*! Bridge channel is to play the indicated sound file. */
+	BRIDGE_CHANNEL_ACTION_PLAY_FILE,
+	/*! Bridge channel is to run the indicated application. */
+	BRIDGE_CHANNEL_ACTION_RUN_APP,
+	/*! Bridge channel is to run the custom callback routine. */
+	BRIDGE_CHANNEL_ACTION_CALLBACK,
+	/*! Bridge channel is to get parked. */
+	BRIDGE_CHANNEL_ACTION_PARK,
+	/*! Bridge channel is to execute a blind transfer. */
+	BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER,
+	/*! Bridge channel is to execute an attended transfer */
+	BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER,
+
+	/*
+	 * Bridge actions put after this comment must never be put onto
+	 * the bridge_channel wr_queue because they have other resources
+	 * that must be freed.
+	 */
+
+	/*! Bridge reconfiguration deferred technology destruction. */
+	BRIDGE_CHANNEL_ACTION_DEFERRED_TECH_DESTROY = 1000,
+	/*! Bridge deferred dissolving. */
+	BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING,
 };
 
 /*!
- * \brief Adjust the bridge_channel's bridge merge inhibit request count.
+ * \internal
+ * \brief Push the bridge channel into its specified bridge.
  * \since 12.0.0
  *
- * \param bridge_channel What to operate on.
- * \param request Inhibit request increment.
- *     (Positive to add requests.  Negative to remove requests.)
+ * \param bridge_channel Channel to push.
  *
- * \note This API call is meant for internal bridging operations.
+ * \note On entry, bridge_channel->bridge is already locked.
  *
- * \retval bridge adjusted merge inhibit with reference count.
+ * \retval 0 on success.
+ * \retval -1 on failure.  The channel did not get pushed.
  */
-struct ast_bridge *bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request);
+int bridge_channel_push(struct ast_bridge_channel *bridge_channel);
 
 /*!
  * \internal
@@ -67,90 +102,57 @@
 
 /*!
  * \internal
- * \brief Push the bridge channel into its specified bridge.
- * \since 12.0.0
+ * \brief Join the bridge_channel to the bridge
  *
- * \param bridge_channel Channel to push.
+ * \param bridge_channel The Channel in the bridge
  *
- * \note On entry, bridge_channel->bridge is already locked.
- *
- * \retval 0 on success.
- * \retval -1 on failure.  The channel did not get pushed.
+ * \note This API call starts the bridge_channel's processing of events while
+ * it is in the bridge. It will return when the channel has been instructed to
+ * leave the bridge.
  */
-int bridge_channel_push(struct ast_bridge_channel *bridge_channel);
-
 void bridge_channel_join(struct ast_bridge_channel *bridge_channel);
 
+/*!
+ * \internal
+ * \brief Temporarily suspend a channel from a bridge, handing control over to some
+ * other system
+ *
+ * \param bridge_channel The channel in the bridge
+ * \note This function assumes that \ref bridge_channel is already locked
+ */
 void bridge_channel_suspend_nolock(struct ast_bridge_channel *bridge_channel);
 
+/*!
+ * \internal
+ * \brief Unsuspend a channel that was previously suspended
+ *
+ * \param bridge_channel The channel in the bridge
+ * \note This function assumes that \ref bridge_channel is already locked
+ */
 void bridge_channel_unsuspend_nolock(struct ast_bridge_channel *bridge_channel);
 
 /*!
  * \internal
- * \brief Update the linkedids for all channels in a bridge
- * \since 12.0.0
+ * \brief Queue a blind transfer action on a transferee bridge channel
  *
- * \param bridge_channel The channel joining the bridge
- * \param swap The channel being swapped out of the bridge. May be NULL.
+ * This is only relevant for when a blind transfer is performed on a two-party
+ * bridge. The transferee's bridge channel will have a blind transfer bridge
+ * action queued onto it, resulting in the party being redirected to a new
+ * destination
  *
- * \note The bridge must be locked prior to calling this function. This should be called
- * during a \ref bridge_channel_push operation, typically by a sub-class of a bridge
+ * \param transferee The channel to have the action queued on
+ * \param exten The destination extension for the transferee
+ * \param context The destination context for the transferee
+ * \param hook Frame hook to attach to transferee
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
  */
-void bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
+int bridge_channel_queue_blind_transfer(struct ast_channel *transferee,
+		const char *exten, const char *context,
+		transfer_channel_cb new_channel_cb, void *user_data);
 
-/*!
- * \internal
- * \brief Update the accountcodes for a channel entering a bridge
- * \since 12.0.0
- *
- * This function updates the accountcode and peeraccount on channels in two-party
- * bridges. In multi-party bridges, peeraccount is not set - it doesn't make much sense -
- * however accountcode propagation will still occur if the channel joining has an
- * accountcode.
- *
- * \param bridge_channel The channel joining the bridge
- * \param swap The channel being swapped out of the bridge. May be NULL.
- *
- * \note The bridge must be locked prior to calling this function. This should be called
- * during a \ref bridge_channel_push operation, typically by a sub-class of a bridge
- */
-void bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap);
-
-
-/*!
- * \brief Set bridge channel state to leave bridge (if not leaving already) with no lock.
- *
- * \param bridge_channel Channel to change the state on
- * \param new_state The new state to place the channel into
- *
- * \note This API call is only meant to be used within the
- * bridging module and hook callbacks to request the channel
- * exit the bridge.
- *
- * \note This function assumes the bridge_channel is locked.
- */
-void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
-
-/*!
- * \brief Set bridge channel state to leave bridge (if not leaving already).
- *
- * \param bridge_channel Channel to change the state on
- * \param new_state The new state to place the channel into
- *
- * Example usage:
- *
- * \code
- * ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
- * \endcode
- *
- * This places the channel pointed to by bridge_channel into the
- * state AST_BRIDGE_CHANNEL_STATE_HANGUP if it was
- * AST_BRIDGE_CHANNEL_STATE_WAIT before.
- *
- * \note This API call is only meant to be used within the
- * bridging module and hook callbacks to request the channel
- * exit the bridge.
- */
-void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state);
+int bridge_channel_queue_attended_transfer(struct ast_channel *transferee,
+		struct ast_channel *unbridged_chan);
 
 #endif /* _ASTERISK_PRIVATE_BRIDGING_H */

Modified: team/rmudgett/bridge_phase/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/bridging_features.h?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/bridging_features.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/bridging_features.h Wed Jul 24 14:37:14 2013
@@ -75,7 +75,7 @@
 	 * how it was imparted.
 	 *
 	 * \note Joined channels exit the bridge with
-	 * AST_BRIDGE_CHANNEL_STATE_END.
+	 * AST_BRIDGE_CHANNEL_STATE_END_WITH_DISSOLVE.
 	 */
 	AST_BRIDGE_BUILTIN_HANGUP,
 	/*!

Modified: team/rmudgett/bridge_phase/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging.c (original)
+++ team/rmudgett/bridge_phase/main/bridging.c Wed Jul 24 14:37:14 2013
@@ -256,7 +256,7 @@
 	struct ast_bridge_channel *bridge_channel;
 	struct ast_frame action = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
-		.subclass.integer = AST_BRIDGE_ACTION_DEFERRED_DISSOLVING,
+		.subclass.integer = BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING,
 	};
 
 	if (bridge->dissolved) {
@@ -268,7 +268,7 @@
 
 /* BUGBUG need a cause code on the bridge for the later ejected channels. */
 	AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) {
-		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 	}
 
 	/* Must defer dissolving bridge because it is already locked. */
@@ -518,12 +518,12 @@
 #endif
 
 	switch (action->subclass.integer) {
-	case AST_BRIDGE_ACTION_DEFERRED_TECH_DESTROY:
+	case BRIDGE_CHANNEL_ACTION_DEFERRED_TECH_DESTROY:
 		ast_bridge_unlock(bridge);
 		bridge_tech_deferred_destroy(bridge, action);
 		ast_bridge_lock(bridge);
 		break;
-	case AST_BRIDGE_ACTION_DEFERRED_DISSOLVING:
+	case BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING:
 		ast_bridge_unlock(bridge);
 		bridge->v_table->dissolving(bridge);
 		ast_bridge_lock(bridge);
@@ -999,7 +999,7 @@
 		};
 		struct ast_frame action = {
 			.frametype = AST_FRAME_BRIDGE_ACTION,
-			.subclass.integer = AST_BRIDGE_ACTION_DEFERRED_TECH_DESTROY,
+			.subclass.integer = BRIDGE_CHANNEL_ACTION_DEFERRED_TECH_DESTROY,
 			.data.ptr = &deferred_tech_destroy,
 			.datalen = sizeof(deferred_tech_destroy),
 		};
@@ -2161,14 +2161,14 @@
 		ao2_ref(bridge, -1);
 	}
 	if (!bridge_channel) {
-		state = AST_BRIDGE_CHANNEL_STATE_HANGUP;
+		state = AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE;
 		goto join_exit;
 	}
 /* BUGBUG features cannot be NULL when passed in. When it is changed to allocated we can do like ast_bridge_impart() and allocate one. */
 	ast_assert(features != NULL);
 	if (!features) {
 		ao2_ref(bridge_channel, -1);
-		state = AST_BRIDGE_CHANNEL_STATE_HANGUP;
+		state = AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE;
 		goto join_exit;
 	}
 	if (tech_args) {
@@ -2350,7 +2350,7 @@
 	 * channel thread.
 	 */
 
-	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+	ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 
 	/* Wait for the depart thread to die */
 	ast_debug(1, "Waiting for %p(%s) bridge thread to die.\n",
@@ -2378,7 +2378,7 @@
 		return -1;
 	}
 
-	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+	ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 
 	ast_bridge_unlock(bridge);
 
@@ -2443,7 +2443,7 @@
 		if (kick_me) {
 			for (idx = 0; idx < num_kick; ++idx) {
 				if (bridge_channel == kick_me[idx]) {
-					ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+					ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 					break;
 				}
 			}
@@ -2461,7 +2461,7 @@
 		bridge_channel_change_bridge(bridge_channel, dst_bridge);
 
 		if (bridge_channel_push(bridge_channel)) {
-			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+			ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
@@ -2475,7 +2475,7 @@
 			bridge_channel = kick_me[idx];
 			ast_bridge_channel_lock(bridge_channel);
 			if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
-				ast_bridge_change_state_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+				ast_bridge_channel_leave_bridge_nolock(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 				bridge_channel_pull(bridge_channel);
 			}
 			ast_bridge_channel_unlock(bridge_channel);
@@ -2710,10 +2710,10 @@
 			bridge_channel_change_bridge(bridge_channel, orig_bridge);
 
 			if (bridge_channel_push(bridge_channel)) {
-				ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+				ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 			}
 		} else {
-			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+			ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 		}
 		res = -1;
 	}
@@ -3111,7 +3111,7 @@
 		}
 		other->swap = dst_bridge_channel->chan;
 		if (!bridge_do_move(dst_bridge, other, 1, 1)) {
-			ast_bridge_change_state(src_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+			ast_bridge_channel_leave_bridge(src_bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 			res = -1;
 			if (pvt && pvt->callbacks && pvt->callbacks->optimization_finished) {
 				pvt->callbacks->optimization_finished(pvt);
@@ -4524,71 +4524,6 @@
 	return transferee;
 }
 
-/*!
- * \internal
- * \brief Queue a blind transfer action on a transferee bridge channel
- *
- * This is only relevant for when a blind transfer is performed on a two-party
- * bridge. The transferee's bridge channel will have a blind transfer bridge
- * action queued onto it, resulting in the party being redirected to a new
- * destination
- *
- * \param transferee The channel to have the action queued on
- * \param exten The destination extension for the transferee
- * \param context The destination context for the transferee
- * \param hook Frame hook to attach to transferee
- *
- * \retval 0 on success.
- * \retval -1 on error.
- */
-static int bridge_channel_queue_blind_transfer(struct ast_channel *transferee,
-		const char *exten, const char *context,
-		transfer_channel_cb new_channel_cb, void *user_data)
-{
-	RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
-	struct blind_transfer_data blind_data;
-
-	ast_channel_lock(transferee);
-	transferee_bridge_channel = ast_channel_get_bridge_channel(transferee);
-	ast_channel_unlock(transferee);
-
-	if (!transferee_bridge_channel) {
-		return -1;
-	}
-
-	if (new_channel_cb) {
-		new_channel_cb(transferee, user_data, AST_BRIDGE_TRANSFER_SINGLE_PARTY);
-	}
-
-	ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
-	ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
-
-	return ast_bridge_channel_queue_action_data(transferee_bridge_channel,
-		AST_BRIDGE_ACTION_BLIND_TRANSFER, &blind_data, sizeof(blind_data));
-}
-
-static int bridge_channel_queue_attended_transfer(struct ast_channel *transferee,
-		struct ast_channel *unbridged_chan)
-{
-	RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
-	char unbridged_chan_name[AST_CHANNEL_NAME];
-
-	ast_channel_lock(transferee);
-	transferee_bridge_channel = ast_channel_get_bridge_channel(transferee);
-	ast_channel_unlock(transferee);
-
-	if (!transferee_bridge_channel) {
-		return -1;
-	}
-
-	ast_copy_string(unbridged_chan_name, ast_channel_name(unbridged_chan),
-		sizeof(unbridged_chan_name));
-
-	return ast_bridge_channel_queue_action_data(transferee_bridge_channel,
-		AST_BRIDGE_ACTION_ATTENDED_TRANSFER, unbridged_chan_name,
-		sizeof(unbridged_chan_name));
-}
-
 enum try_parking_result {
 	PARKING_SUCCESS,
 	PARKING_FAILURE,
@@ -4808,7 +4743,7 @@
 			return AST_BRIDGE_TRANSFER_FAIL;
 		}
 		/* Must kick the source channel out of its bridge. */
-		ast_bridge_change_state(source_bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		ast_bridge_channel_leave_bridge(source_bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 		return AST_BRIDGE_TRANSFER_SUCCESS;
 	} else {
 		return AST_BRIDGE_TRANSFER_INVALID;

Modified: team/rmudgett/bridge_phase/main/bridging_basic.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging_basic.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging_basic.c (original)
+++ team/rmudgett/bridge_phase/main/bridging_basic.c Wed Jul 24 14:37:14 2013
@@ -285,7 +285,7 @@
 	}
 	if (2 <= bridge_count) {
 		/* Just allow this channel to leave the multi-party bridge. */
-		ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP);
+		ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
 	}
 	ast_bridge_unlock(bridge_channel->bridge);
 	return 0;
@@ -342,8 +342,8 @@
 		return -1;
 	}
 
-	bridge_channel_update_accountcodes(bridge_channel, swap);
-	bridge_channel_update_linkedids(bridge_channel, swap);
+	ast_bridge_channel_update_accountcodes(bridge_channel, swap);
+	ast_bridge_channel_update_linkedids(bridge_channel, swap);
 	return 0;
 }
 
@@ -2659,7 +2659,7 @@
 	}
 
 	ast_bridge_channel_write_hold(bridge_channel, NULL);
-	props->transferee_bridge = bridge_channel_merge_inhibit(bridge_channel, +1);
+	props->transferee_bridge = ast_bridge_channel_merge_inhibit(bridge_channel, +1);
 
 	/* Grab the extension to transfer to */
 	if (grab_transfer(bridge_channel->chan, exten, sizeof(exten), props->context)) {

Modified: team/rmudgett/bridge_phase/main/bridging_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridging_channel.c?view=diff&rev=395300&r1=395299&r2=395300
==============================================================================
--- team/rmudgett/bridge_phase/main/bridging_channel.c (original)
+++ team/rmudgett/bridge_phase/main/bridging_channel.c Wed Jul 24 14:37:14 2013
@@ -53,8 +53,21 @@
 #include "asterisk/features_config.h"
 #include "asterisk/parking.h"
 
-
-struct ast_bridge *bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request)
+/*!
+ * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
+ * \since 12.0.0
+ *
+ * \param bridge_channel Which channel work with.
+ * \param action Type of bridge action frame.
+ * \param data Frame payload data to pass.
+ * \param datalen Frame payload data length to pass.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+typedef int (*ast_bridge_channel_post_action_data)(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen);
+
+struct ast_bridge *ast_bridge_channel_merge_inhibit(struct ast_bridge_channel *bridge_channel, int request)
 {
 	struct ast_bridge *bridge;
 
@@ -98,31 +111,7 @@
 	}
 }
 
-void ast_bridge_change_state_nolock(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
-{
-/* BUGBUG need cause code for the bridge_channel leaving the bridge. */
-	if (bridge_channel->state != AST_BRIDGE_CHANNEL_STATE_WAIT) {
-		return;
-	}
-
-	ast_debug(1, "Setting %p(%s) state from:%d to:%d\n",
-		bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->state,
-		new_state);
-
-	/* Change the state on the bridge channel */
-	bridge_channel->state = new_state;
-
-	bridge_channel_poke(bridge_channel);
-}
-
-void ast_bridge_change_state(struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state)
-{
-	ast_bridge_channel_lock(bridge_channel);
-	ast_bridge_change_state_nolock(bridge_channel, new_state);
-	ast_bridge_channel_unlock(bridge_channel);
-}
-
-void bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+void ast_bridge_channel_update_accountcodes(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 {
 	struct ast_bridge *bridge = bridge_channel->bridge;
 	struct ast_bridge_channel *other = NULL;
@@ -167,7 +156,7 @@
 	}
 }
 
-void bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
+void ast_bridge_channel_update_linkedids(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
 {
 	struct ast_bridge_channel *other = NULL;
 	struct ast_bridge *bridge = bridge_channel->bridge;
@@ -233,7 +222,19 @@
 	return 0;
 }
 
-int ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
+/*!
+ * \brief Queue an action frame onto the bridge channel with data.
+ * \since 12.0.0
+ *
+ * \param bridge_channel Which channel to queue the frame onto.
+ * \param action Type of bridge action frame.
+ * \param data Frame payload data to pass.
+ * \param datalen Frame payload data length to pass.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int ast_bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
@@ -322,7 +323,7 @@
 	return 0;
 }
 
-int ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum ast_bridge_action_type action, const void *data, size_t datalen)
+static int ast_bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 {
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
@@ -426,7 +427,7 @@
 	ao2_iterator_destroy(&iter);
 
 	/* Default hangup action. */
-	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
+	ast_bridge_channel_leave_bridge(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
 }
 
 void ast_bridge_channel_run_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
@@ -491,7 +492,7 @@
 		strcpy(&app_data->app_name[app_data->moh_offset], moh_class);/* Safe */
 	}
 
-	return post_it(bridge_channel, AST_BRIDGE_ACTION_RUN_APP, app_data, len_data);
+	return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_RUN_APP, app_data, len_data);
 }
 
 int ast_bridge_channel_write_app(struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
@@ -576,7 +577,7 @@
 		strcpy(&payload->playfile[payload->moh_offset], moh_class);/* Safe */
 	}
 
-	return post_it(bridge_channel, AST_BRIDGE_ACTION_PLAY_FILE, payload, len_payload);
+	return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_PLAY_FILE, payload, len_payload);
 }
 
 int ast_bridge_channel_write_playfile(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
@@ -638,7 +639,7 @@
 		memcpy(cb_data->payload, payload, payload_size);/* Safe */
 	}
 
-	return post_it(bridge_channel, AST_BRIDGE_ACTION_CALLBACK, cb_data, len_data);
+	return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_CALLBACK, cb_data, len_data);
 }
 
 int ast_bridge_channel_write_callback(struct ast_bridge_channel *bridge_channel, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
@@ -688,7 +689,7 @@
 		strcpy(&payload->parkee_uuid[payload->app_data_offset], app_data);
 	}
 
-	return post_it(bridge_channel, AST_BRIDGE_ACTION_PARK, payload, len_payload);
+	return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_PARK, payload, len_payload);
 }
 
 int ast_bridge_channel_write_park(struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
@@ -716,7 +717,7 @@
 	struct ast_frame action = {
 		.frametype = AST_FRAME_BRIDGE_ACTION,
 		.subclass.integer = started_talking
-			? AST_BRIDGE_ACTION_TALKING_START : AST_BRIDGE_ACTION_TALKING_STOP,
+			? BRIDGE_CHANNEL_ACTION_TALKING_START : BRIDGE_CHANNEL_ACTION_TALKING_STOP,
 	};
 
 	return ast_bridge_channel_queue_frame(bridge_channel, &action);
@@ -908,7 +909,7 @@
 static int bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
 {
 	return ast_bridge_channel_write_action_data(bridge_channel,
-		AST_BRIDGE_ACTION_DTMF_STREAM, dtmf, strlen(dtmf) + 1);
+		BRIDGE_CHANNEL_ACTION_DTMF_STREAM, dtmf, strlen(dtmf) + 1);
 }
 
 /*!

[... 248 lines stripped ...]



More information about the asterisk-commits mailing list