Asterisk - The Open Source Telephony Project  21.4.1
Macros | Functions | Variables
bridge_basic.h File Reference

Basic bridge subclass API. More...

Go to the source code of this file.

Macros

#define AST_TRANSFERER_ROLE_NAME   "transferer"
 

Functions

struct ast_bridgeast_bridge_basic_new (void)
 Create a new basic class bridge. More...
 
void ast_bridge_basic_set_flags (struct ast_bridge *bridge, unsigned int flags)
 Set feature flags on a basic bridge. More...
 
int ast_bridge_features_ds_append (struct ast_channel *chan, struct ast_flags *flags)
 Append basic bridge DTMF feature flags on the channel. More...
 
struct ast_flagsast_bridge_features_ds_get (struct ast_channel *chan)
 Get DTMF feature flags from the channel. More...
 
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 More...
 
int ast_bridge_features_ds_set (struct ast_channel *chan, struct ast_flags *flags)
 Set basic bridge DTMF feature flags datastore on the channel. More...
 
int ast_bridge_features_ds_set_string (struct ast_channel *chan, const char *features)
 Sets the features a channel will use upon being bridged. More...
 
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 rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

See Also:

Definition in file bridge_basic.h.

Function Documentation

struct ast_bridge* ast_bridge_basic_new ( void  )

Create a new basic class bridge.

Returns
a pointer to a new bridge on success
Return values
NULLon failure

Example usage:

1 struct ast_bridge *bridge;
2 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 3661 of file bridge_basic.c.

References ast_bridge_basic_v_table, AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_CAPABILITY_MULTIMIX, AST_BRIDGE_CAPABILITY_NATIVE, bridge_base_init(), and bridge_register().

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

3662 {
3663  struct ast_bridge *bridge;
3664 
3665  bridge = bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_basic_v_table);
3666  bridge = bridge_base_init(bridge,
3668  | AST_BRIDGE_CAPABILITY_MULTIMIX, NORMAL_FLAGS, NULL, NULL, NULL);
3669  bridge = bridge_basic_personality_alloc(bridge);
3670  bridge = bridge_register(bridge);
3671  return bridge;
3672 }
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
Definition: bridge.c:691
struct ast_bridge * bridge_base_init(struct ast_bridge *self, uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
Initialize the base class of the bridge.
Definition: bridge.c:742
Structure that contains information about a bridge.
Definition: bridge.h:349
struct ast_bridge_methods ast_bridge_basic_v_table
Bridge basic class virtual method table.
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.

Parameters
bridge
flagsThese are added to the flags already set.

Definition at line 3674 of file bridge_basic.c.

References ast_bridge_lock, ast_bridge_unlock, 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().

3675 {
3677  struct bridge_basic_personality *personality = bridge->personality;
3678 
3679  personality->details[personality->current].bridge_flags |= flags;
3680  ast_set_flag(&bridge->feature_flags, flags);
3681 }
struct ast_flags feature_flags
Definition: bridge.h:369
unsigned int bridge_flags
Definition: bridge_basic.c:317
enum bridge_basic_personality_type current
Definition: bridge_basic.c:329
void * personality
Definition: bridge.h:353
ast_mutex_t lock
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
structure that organizes different personalities for basic bridges.
Definition: bridge_basic.c:327
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
struct personality_details details[BRIDGE_BASIC_PERSONALITY_END]
Definition: bridge_basic.c:331
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
chanChannel to append DTMF features datastore.
flagsBuiltin 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
0on success.
-1on error.

Definition at line 263 of file bridge_basic.c.

264 {
265  return bridge_features_ds_set_full(chan, flags, 0);
266 }
struct ast_flags* ast_bridge_features_ds_get ( struct ast_channel chan)

Get DTMF feature flags from the channel.

Since
12.0.0
Parameters
chanChannel 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.
Returns
flags on success.
Return values
NULLif the datastore does not exist.

Definition at line 268 of file bridge_basic.c.

References ast_channel_datastore_find(), and ast_datastore::data.

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

269 {
270  struct ast_datastore *datastore;
271 
272  datastore = ast_channel_datastore_find(chan, &dtmf_features_info, NULL);
273  if (!datastore) {
274  return NULL;
275  }
276  return datastore->data;
277 }
Structure for a data store object.
Definition: datastore.h:64
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition: channel.c:2399
void * data
Definition: datastore.h:66
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
chanchannel whose feature flags should be checked
bufferpointer string buffer where the output should be stored
buf_sizesize of the provided buffer (ideally enough for all features, 6+)
Return values
0on successful write
-1on failure

Definition at line 208 of file bridge_basic.c.

References ast_bridge_features_ds_get().

209 {
210  struct ast_flags *channel_flags;
211  struct ast_flags held_copy;
212 
213  ast_channel_lock(chan);
214  if (!(channel_flags = ast_bridge_features_ds_get(chan))) {
215  ast_channel_unlock(chan);
216  return -1;
217  }
218  held_copy = *channel_flags;
219  ast_channel_unlock(chan);
220 
221  return dtmf_features_flags_to_string(&held_copy, buffer, buf_size);
222 }
struct ast_flags * ast_bridge_features_ds_get(struct ast_channel *chan)
Get DTMF feature flags from the channel.
Definition: bridge_basic.c:268
Structure used to handle boolean flags.
Definition: utils.h:199
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
chanChannel to set DTMF features datastore.
flagsBuiltin DTMF feature flags. (ast_bridge_config flags)
Note
The channel must be locked before calling this function.
Return values
0on success.
-1on error.

Definition at line 258 of file bridge_basic.c.

Referenced by ast_bridge_features_ds_set_string(), and parked_call_retrieve_enable_features().

259 {
260  return bridge_features_ds_set_full(chan, flags, 1);
261 }
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
chanWhich channel to set features for
featuresWhich feature codes to set for the channel
Return values
0on success
-1on failure

Definition at line 189 of file bridge_basic.c.

References ast_bridge_features_ds_set().

190 {
191  struct ast_flags flags = {0};
192 
193  if (build_dtmf_features(&flags, features)) {
194  return -1;
195  }
196 
197  ast_channel_lock(chan);
198  if (ast_bridge_features_ds_set(chan, &flags)) {
199  ast_channel_unlock(chan);
200  ast_log(LOG_ERROR, "Failed to apply features datastore for '%s' to channel '%s'\n", features, ast_channel_name(chan));
201  return -1;
202  }
203  ast_channel_unlock(chan);
204 
205  return 0;
206 }
int ast_bridge_features_ds_set(struct ast_channel *chan, struct ast_flags *flags)
Set basic bridge DTMF feature flags datastore on the channel.
Definition: bridge_basic.c:258
Structure used to handle boolean flags.
Definition: utils.h:199
void ast_bridging_init_basic ( void  )

Initialize the basic bridge class for use by the system.

Definition at line 3683 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(), ast_bridge_methods::destroy, feature_attended_transfer(), feature_blind_transfer(), ast_bridge_methods::name, ast_bridge_methods::pull, and ast_bridge_methods::push.

Referenced by ast_bridging_init().

3684 {
3685  /* Setup bridge basic subclass v_table. */
3687  ast_bridge_basic_v_table.name = "basic";
3688  ast_bridge_basic_v_table.push = bridge_basic_push;
3689  ast_bridge_basic_v_table.pull = bridge_basic_pull;
3690  ast_bridge_basic_v_table.destroy = bridge_basic_destroy;
3691 
3692  /*
3693  * Personality vtables don't have the same rules as
3694  * normal bridge vtables. These vtable functions are
3695  * used as alterations to the ast_bridge_basic_v_table
3696  * method functionality and are checked for NULL before
3697  * calling.
3698  */
3699  personality_normal_v_table.name = "normal";
3700  personality_normal_v_table.push = bridge_personality_normal_push;
3701 
3702  personality_atxfer_v_table.name = "attended transfer";
3703  personality_atxfer_v_table.push = bridge_personality_atxfer_push;
3704  personality_atxfer_v_table.pull = bridge_personality_atxfer_pull;
3705 
3708 }
const char * name
Definition: bridge.h:259
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
Definition: bridge.c:923
int ast_bridge_features_register(enum ast_bridge_builtin_feature feature, ast_bridge_hook_callback callback, const char *dtmf)
Register a handler for a built in feature.
Definition: bridge.c:3062
struct ast_bridge_methods ast_bridge_basic_v_table
Bridge basic class virtual method table.
static int feature_blind_transfer(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Internal built in feature for blind transfers.
ast_bridge_pull_channel_fn pull
Definition: bridge.h:267
ast_bridge_destructor_fn destroy
Definition: bridge.h:261
ast_bridge_push_channel_fn push
Definition: bridge.h:265
static int feature_attended_transfer(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Internal built in feature for attended transfers.