Restore Dial, Queue, and FollowMe 'I' option support.

The Dial, Queue, and FollowMe applications need to inhibit the bridging
initial connected line exchange in order to support the 'I' option.

* Replaced the pass_reference flag on ast_bridge_join() with a flags
parameter to pass other flags defined by enum ast_bridge_join_flags.

* Replaced the independent flag on ast_bridge_impart() with a flags
parameter to pass other flags defined by enum ast_bridge_impart_flags.

* Since the Dial, Queue, and FollowMe applications are now the only
callers of ast_bridge_call() and ast_bridge_call_with_flags(), changed the
calling contract to require the initial COLP exchange to already have been
done by the caller.

* Made all callers of ast_bridge_impart() check the return value.  It is
important.  As a precaution, I also made the compiler complain now if it
is not checked.

* Did some cleanup in parking_tests.c as a result of checking the
ast_bridge_impart() return value.

An independent, but associated change is:
* Reduce stack usage in ast_indicate_data() and add a dropping redundant
connected line verbose message.

(closes issue ASTERISK-22072)
Reported by: Joshua Colp

Review: https://reviewboard.asterisk.org/r/2845/
........

Merged revisions 399136 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2013-09-13 22:19:23 +00:00
parent 03c7857375
commit 2a371cd80b
20 changed files with 235 additions and 130 deletions

View File

@@ -422,6 +422,13 @@ int ast_bridge_destroy(struct ast_bridge *bridge, int cause);
*/
void ast_bridge_notify_masquerade(struct ast_channel *chan);
enum ast_bridge_join_flags {
/*! The bridge reference is being passed by the caller. */
AST_BRIDGE_JOIN_PASS_REFERENCE = (1 << 0),
/*! The initial bridge join does not cause a COLP exchange. */
AST_BRIDGE_JOIN_INHIBIT_JOIN_COLP = (1 << 1),
};
/*!
* \brief Join (blocking) a channel to a bridge
*
@@ -430,7 +437,7 @@ void ast_bridge_notify_masquerade(struct ast_channel *chan);
* \param swap Channel to swap out if swapping
* \param features Bridge features structure
* \param tech_args Optional Bridging tech optimization parameters for this channel.
* \param pass_reference TRUE if the bridge reference is being passed by the caller.
* \param flags defined by enum ast_bridge_join_flags.
*
* \note Absolutely _NO_ locks should be held before calling
* this function since it blocks.
@@ -441,7 +448,7 @@ void ast_bridge_notify_masquerade(struct ast_channel *chan);
* Example usage:
*
* \code
* ast_bridge_join(bridge, chan, NULL, NULL, NULL, 0);
* ast_bridge_join(bridge, chan, NULL, NULL, NULL, AST_BRIDGE_JOIN_PASS_REFERENCE);
* \endcode
*
* This adds a channel pointed to by the chan pointer to the bridge pointed to by
@@ -460,7 +467,18 @@ int ast_bridge_join(struct ast_bridge *bridge,
struct ast_channel *swap,
struct ast_bridge_features *features,
struct ast_bridge_tech_optimizations *tech_args,
int pass_reference);
enum ast_bridge_join_flags flags);
enum ast_bridge_impart_flags {
/*! Field describing what the caller can do with the channel after it is imparted. */
AST_BRIDGE_IMPART_CHAN_MASK = (1 << 0),
/*! The caller wants to reclaim the channel using ast_bridge_depart(). */
AST_BRIDGE_IMPART_CHAN_DEPARTABLE = (0 << 0),
/*! The caller is passing channel control entirely to the bridging system. */
AST_BRIDGE_IMPART_CHAN_INDEPENDENT = (1 << 0),
/*! The initial bridge join does not cause a COLP exchange. */
AST_BRIDGE_IMPART_INHIBIT_JOIN_COLP = (1 << 1),
};
/*!
* \brief Impart (non-blocking) a channel onto a bridge
@@ -469,7 +487,7 @@ int ast_bridge_join(struct ast_bridge *bridge,
* \param chan Channel to impart (The channel reference is stolen if impart successful.)
* \param swap Channel to swap out if swapping. NULL if not swapping.
* \param features Bridge features structure.
* \param independent TRUE if caller does not want to reclaim the channel using ast_bridge_depart().
* \param flags defined by enum ast_bridge_impart_flags.
*
* \note The features parameter must be NULL or obtained by
* ast_bridge_features_new(). You must not dereference features
@@ -478,12 +496,12 @@ int ast_bridge_join(struct ast_bridge *bridge,
* \note chan is locked by this function.
*
* \retval 0 on success
* \retval -1 on failure
* \retval -1 on failure (Caller still has ownership of chan)
*
* Example usage:
*
* \code
* ast_bridge_impart(bridge, chan, NULL, NULL, 0);
* ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_CHAN_INDEPENDENT);
* \endcode
*
* \details
@@ -501,20 +519,26 @@ int ast_bridge_join(struct ast_bridge *bridge,
* features structure can be specified in the features
* parameter.
*
* \note If you impart a channel as not independent you MUST
* \note If you impart a channel with
* AST_BRIDGE_IMPART_CHAN_DEPARTABLE you MUST
* ast_bridge_depart() the channel if this call succeeds. The
* bridge channel thread is created join-able. The implication
* is that the channel is special and will not behave like a
* normal channel.
*
* \note If you impart a channel as independent you must not
* \note If you impart a channel with
* AST_BRIDGE_IMPART_CHAN_INDEPENDENT you must not
* ast_bridge_depart() the channel. The bridge channel thread
* is created non-join-able. The channel must be treated as if
* it were placed into the bridge by ast_bridge_join().
* Channels placed into a bridge by ast_bridge_join() are
* removed by a third party using ast_bridge_remove().
*/
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int independent);
int ast_bridge_impart(struct ast_bridge *bridge,
struct ast_channel *chan,
struct ast_channel *swap,
struct ast_bridge_features *features,
enum ast_bridge_impart_flags flags) attribute_warn_unused_result;
/*!
* \brief Depart a channel from a bridge

View File

@@ -122,6 +122,8 @@ struct ast_bridge_channel {
unsigned int just_joined:1;
/*! TRUE if the channel is suspended from the bridge. */
unsigned int suspended:1;
/*! TRUE if the COLP update on initial join is inhibited. */
unsigned int inhibit_colp:1;
/*! TRUE if the channel must wait for an ast_bridge_depart to reclaim the channel. */
unsigned int depart_wait:1;
/* ^-- These flags change while the bridge is locked or before the channel is in the bridge. */

View File

@@ -39,8 +39,14 @@ enum {
AST_FEATURE_FLAG_BYBOTH = (3 << 3),
};
/*! \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, optionally allowing redirection
*
* \note The function caller is assumed to have already done the
* COLP exchange for the initial bridging of the two channels if
* it was desired.
*/
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
@@ -53,6 +59,10 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer,struct as
* \param peer The called channel
* \param config Bridge configuration for the channels
* \param flags Additional flags to set on the created bridge
*
* \note The function caller is assumed to have already done the
* COLP exchange for the initial bridging of the two channels if
* it was desired.
*/
int ast_bridge_call_with_flags(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, unsigned int flags);