bridge_basic.h File Reference

Basic bridge subclass API. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define AST_TRANSFERER_ROLE_NAME   "transferer"

Functions

struct ast_bridgeast_bridge_basic_new (void)
 Create a new basic class bridge.
void ast_bridge_basic_set_flags (struct ast_bridge *bridge, unsigned int flags)
 Set feature flags on a basic bridge.
int ast_bridge_features_ds_append (struct ast_channel *chan, struct ast_flags *flags)
 Append basic bridge DTMF feature flags on the channel.
struct ast_flagsast_bridge_features_ds_get (struct ast_channel *chan)
 Get DTMF feature flags from the channel.
int ast_bridge_features_ds_get_string (struct ast_channel *chan, char *buffer, size_t buf_size)
 writes a channel's DTMF features to a buffer string
int ast_bridge_features_ds_set (struct ast_channel *chan, struct ast_flags *flags)
 Set basic bridge DTMF feature flags datastore on the channel.
int ast_bridge_features_ds_set_string (struct ast_channel *chan, const char *features)
 Sets the features a channel will use upon being bridged.
void ast_bridging_init_basic (void)

Variables

struct ast_bridge_methods ast_bridge_basic_v_table
 Bridge basic class virtual method table.


Detailed Description

Basic bridge subclass API.

Author:
Richard Mudgett <rmudgett@digium.com>
See Also:

Definition in file bridge_basic.h.


Define Documentation

#define AST_TRANSFERER_ROLE_NAME   "transferer"


Function Documentation

struct ast_bridge* ast_bridge_basic_new ( void   )  [read]

Create a new basic class bridge.

Return values:
a pointer to a new bridge on success
NULL on failure
Example usage:

 struct ast_bridge *bridge;
 bridge = ast_bridge_basic_new();

This creates a basic two party bridge with any configured DTMF features enabled that will be destroyed once one of the channels hangs up.

Definition at line 3503 of file bridge_basic.c.

References ast_bridge_basic_v_table, AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_CAPABILITY_MULTIMIX, AST_BRIDGE_CAPABILITY_NATIVE, bridge_alloc(), bridge_base_init(), bridge_basic_personality_alloc(), bridge_register(), NORMAL_FLAGS, and NULL.

Referenced by action_bridge(), agent_request_exec(), app_control_dial(), ast_bridge_call_with_flags(), AST_TEST_DEFINE(), bridge_exec(), feature_attended_transfer(), and parked_call_app_exec().

03504 {
03505    struct ast_bridge *bridge;
03506 
03507    bridge = bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_basic_v_table);
03508    bridge = bridge_base_init(bridge,
03509       AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_1TO1MIX
03510          | AST_BRIDGE_CAPABILITY_MULTIMIX, NORMAL_FLAGS, NULL, NULL, NULL);
03511    bridge = bridge_basic_personality_alloc(bridge);
03512    bridge = bridge_register(bridge);
03513    return bridge;
03514 }

void ast_bridge_basic_set_flags ( struct ast_bridge bridge,
unsigned int  flags 
)

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.

Flags to set on the bridge. These are added to the flags already set.

Definition at line 3516 of file bridge_basic.c.

References ast_bridge_lock, ast_bridge_unlock, ast_set_flag, personality_details::bridge_flags, bridge_basic_personality::current, bridge_basic_personality::details, ast_bridge::feature_flags, lock, ast_bridge::personality, and SCOPED_LOCK.

Referenced by ast_bridge_call_with_flags().

03517 {
03518    SCOPED_LOCK(lock, bridge, ast_bridge_lock, ast_bridge_unlock);
03519    struct bridge_basic_personality *personality = bridge->personality;
03520 
03521    personality->details[personality->current].bridge_flags |= flags;
03522    ast_set_flag(&bridge->feature_flags, flags);
03523 }

int ast_bridge_features_ds_append ( struct ast_channel chan,
struct ast_flags flags 
)

Append basic bridge DTMF feature flags on the channel.

Since:
12.0.0
Parameters:
chan Channel to append DTMF features datastore.
flags Builtin DTMF feature flags. (ast_bridge_config flags)
Note:
The channel must be locked before calling this function.

This function differs from ast_bridge_features_ds_set only in that it won't remove features already set on the channel.

Return values:
0 on success.
-1 on error.

Definition at line 265 of file bridge_basic.c.

References bridge_features_ds_set_full().

Referenced by pre_bridge_setup().

00266 {
00267    return bridge_features_ds_set_full(chan, flags, 0);
00268 }

struct ast_flags* ast_bridge_features_ds_get ( struct ast_channel chan  )  [read]

Get DTMF feature flags from the channel.

Since:
12.0.0
Parameters:
chan Channel to get DTMF features datastore.
Note:
The channel should be locked before calling this function.

The channel must remain locked until the flags returned have been consumed.

Return values:
flags on success.
NULL if the datastore does not exist.

Definition at line 270 of file bridge_basic.c.

References ast_channel_datastore_find(), ast_datastore::data, and NULL.

Referenced by ast_bridge_features_ds_get_string(), attended_transfer_properties_alloc(), parked_call_retrieve_enable_features(), and setup_bridge_features_builtin().

00271 {
00272    struct ast_datastore *datastore;
00273 
00274    datastore = ast_channel_datastore_find(chan, &dtmf_features_info, NULL);
00275    if (!datastore) {
00276       return NULL;
00277    }
00278    return datastore->data;
00279 }

int ast_bridge_features_ds_get_string ( struct ast_channel chan,
char *  buffer,
size_t  buf_size 
)

writes a channel's DTMF features to a buffer string

Since:
12.0.0
Parameters:
chan channel whose feature flags should be checked
buffer pointer string buffer where the output should be stored
buf_size size of the provided buffer (ideally enough for all features, 6+)
Return values:
0 on successful write
-1 on failure

Definition at line 210 of file bridge_basic.c.

References ast_bridge_features_ds_get(), ast_channel_lock, ast_channel_unlock, and dtmf_features_flags_to_string().

Referenced by func_channel_read().

00211 {
00212    struct ast_flags *channel_flags;
00213    struct ast_flags held_copy;
00214 
00215    ast_channel_lock(chan);
00216    if (!(channel_flags = ast_bridge_features_ds_get(chan))) {
00217       ast_channel_unlock(chan);
00218       return -1;
00219    }
00220    held_copy = *channel_flags;
00221    ast_channel_unlock(chan);
00222 
00223    return dtmf_features_flags_to_string(&held_copy, buffer, buf_size);
00224 }

int ast_bridge_features_ds_set ( struct ast_channel chan,
struct ast_flags flags 
)

Set basic bridge DTMF feature flags datastore on the channel.

Since:
12.0.0
Parameters:
chan Channel to set DTMF features datastore.
flags Builtin DTMF feature flags. (ast_bridge_config flags)
Note:
The channel must be locked before calling this function.
Return values:
0 on success.
-1 on error.

Definition at line 260 of file bridge_basic.c.

References bridge_features_ds_set_full().

Referenced by ast_bridge_features_ds_set_string(), parked_call_retrieve_enable_features(), and recalling_exit().

00261 {
00262    return bridge_features_ds_set_full(chan, flags, 1);
00263 }

int ast_bridge_features_ds_set_string ( struct ast_channel chan,
const char *  features 
)

Sets the features a channel will use upon being bridged.

Since:
12.0.0
Parameters:
chan Which channel to set features for
features Which feature codes to set for the channel
Return values:
0 on success
-1 on failure

Definition at line 191 of file bridge_basic.c.

References ast_bridge_features_ds_set(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_log, build_dtmf_features(), and LOG_ERROR.

Referenced by func_channel_write_real().

00192 {
00193    struct ast_flags flags = {0};
00194 
00195    if (build_dtmf_features(&flags, features)) {
00196       return -1;
00197    }
00198 
00199    ast_channel_lock(chan);
00200    if (ast_bridge_features_ds_set(chan, &flags)) {
00201       ast_channel_unlock(chan);
00202       ast_log(LOG_ERROR, "Failed to apply features datastore for '%s' to channel '%s'\n", features, ast_channel_name(chan));
00203       return -1;
00204    }
00205    ast_channel_unlock(chan);
00206 
00207    return 0;
00208 }

void ast_bridging_init_basic ( void   ) 

Initialize the basic bridge class for use by the system.

Definition at line 3525 of file bridge_basic.c.

References ast_bridge_base_v_table, ast_bridge_basic_v_table, AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, AST_BRIDGE_BUILTIN_BLINDTRANSFER, ast_bridge_features_register(), bridge_basic_destroy(), bridge_basic_pull(), bridge_basic_push(), bridge_personality_atxfer_pull(), bridge_personality_atxfer_push(), bridge_personality_normal_push(), ast_bridge_methods::destroy, feature_attended_transfer(), feature_blind_transfer(), ast_bridge_methods::name, NULL, personality_atxfer_v_table, personality_normal_v_table, ast_bridge_methods::pull, and ast_bridge_methods::push.

Referenced by ast_bridging_init().

03526 {
03527    /* Setup bridge basic subclass v_table. */
03528    ast_bridge_basic_v_table = ast_bridge_base_v_table;
03529    ast_bridge_basic_v_table.name = "basic";
03530    ast_bridge_basic_v_table.push = bridge_basic_push;
03531    ast_bridge_basic_v_table.pull = bridge_basic_pull;
03532    ast_bridge_basic_v_table.destroy = bridge_basic_destroy;
03533 
03534    /*
03535     * Personality vtables don't have the same rules as
03536     * normal bridge vtables.  These vtable functions are
03537     * used as alterations to the ast_bridge_basic_v_table
03538     * method functionality and are checked for NULL before
03539     * calling.
03540     */
03541    personality_normal_v_table.name = "normal";
03542    personality_normal_v_table.push = bridge_personality_normal_push;
03543 
03544    personality_atxfer_v_table.name = "attended transfer";
03545    personality_atxfer_v_table.push = bridge_personality_atxfer_push;
03546    personality_atxfer_v_table.pull = bridge_personality_atxfer_pull;
03547 
03548    ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, feature_attended_transfer, NULL);
03549    ast_bridge_features_register(AST_BRIDGE_BUILTIN_BLINDTRANSFER, feature_blind_transfer, NULL);
03550 }


Variable Documentation

Bridge basic class virtual method table.

Definition at line 3412 of file bridge_basic.c.

Referenced by ast_bridge_basic_new(), and ast_bridging_init_basic().


Generated on Thu Apr 16 06:29:08 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6