Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Macros | Functions | Variables
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.

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. More...
 

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.

Macro Definition Documentation

◆ AST_TRANSFERER_ROLE_NAME

#define AST_TRANSFERER_ROLE_NAME   "transferer"

Definition at line 36 of file bridge_basic.h.

Function Documentation

◆ ast_bridge_basic_new()

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:

struct ast_bridge *bridge;
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
Structure that contains information about a bridge.
Definition: bridge.h:349

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 3655 of file bridge_basic.c.

3656{
3657 struct ast_bridge *bridge;
3658
3659 bridge = bridge_alloc(sizeof(struct ast_bridge), &ast_bridge_basic_v_table);
3660 bridge = bridge_base_init(bridge,
3663 bridge = bridge_basic_personality_alloc(bridge);
3664 bridge = bridge_register(bridge);
3665 return bridge;
3666}
@ AST_BRIDGE_CAPABILITY_MULTIMIX
Definition: bridge.h:94
@ AST_BRIDGE_CAPABILITY_NATIVE
Definition: bridge.h:90
@ AST_BRIDGE_CAPABILITY_1TO1MIX
Definition: bridge.h:92
struct ast_bridge_methods ast_bridge_basic_v_table
Bridge basic class virtual method table.
static struct ast_bridge * bridge_basic_personality_alloc(struct ast_bridge *bridge)
#define NORMAL_FLAGS
Definition: bridge_basic.c:51
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
struct ast_bridge * bridge_alloc(size_t size, const struct ast_bridge_methods *v_table)
Definition: bridge.c:706
#define NULL
Definition: resample.c:96

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(), ast_bridge_call_with_flags(), AST_TEST_DEFINE(), bridge_exec(), feature_attended_transfer(), and parked_call_app_exec().

◆ ast_bridge_basic_set_flags()

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 3668 of file bridge_basic.c.

3669{
3671 struct bridge_basic_personality *personality = bridge->personality;
3672
3673 personality->details[personality->current].bridge_flags |= flags;
3674 ast_set_flag(&bridge->feature_flags, flags);
3675}
ast_mutex_t lock
Definition: app_sla.c:331
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
void * personality
Definition: bridge.h:353
struct ast_flags feature_flags
Definition: bridge.h:369
structure that organizes different personalities for basic bridges.
Definition: bridge_basic.c:327
enum bridge_basic_personality_type current
Definition: bridge_basic.c:329
struct personality_details details[BRIDGE_BASIC_PERSONALITY_END]
Definition: bridge_basic.c:331
unsigned int bridge_flags
Definition: bridge_basic.c:317
#define ast_set_flag(p, flag)
Definition: utils.h:70

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().

◆ ast_bridge_features_ds_append()

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}
static int bridge_features_ds_set_full(struct ast_channel *chan, struct ast_flags *flags, int replace)
Definition: bridge_basic.c:224

References bridge_features_ds_set_full(), and ast_flags::flags.

Referenced by pre_bridge_setup().

◆ ast_bridge_features_ds_get()

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.

269{
270 struct ast_datastore *datastore;
271
273 if (!datastore) {
274 return NULL;
275 }
276 return datastore->data;
277}
static const struct ast_datastore_info dtmf_features_info
Definition: bridge_basic.c:82
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
Structure for a data store object.
Definition: datastore.h:64
void * data
Definition: datastore.h:66

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

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

◆ ast_bridge_features_ds_get_string()

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.

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}
static int dtmf_features_flags_to_string(struct ast_flags *feature_flags, char *buffer, size_t buffer_size)
Definition: bridge_basic.c:133
struct ast_flags * ast_bridge_features_ds_get(struct ast_channel *chan)
Get DTMF feature flags from the channel.
Definition: bridge_basic.c:268
#define ast_channel_lock(chan)
Definition: channel.h:2922
#define ast_channel_unlock(chan)
Definition: channel.h:2923
Structure used to handle boolean flags.
Definition: utils.h:199

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

Referenced by func_channel_read().

◆ ast_bridge_features_ds_set()

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.

259{
260 return bridge_features_ds_set_full(chan, flags, 1);
261}

References bridge_features_ds_set_full(), and ast_flags::flags.

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

◆ ast_bridge_features_ds_set_string()

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.

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}
#define ast_log
Definition: astobj2.c:42
static int build_dtmf_features(struct ast_flags *flags, const char *features)
Definition: bridge_basic.c:162
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
const char * ast_channel_name(const struct ast_channel *chan)
#define LOG_ERROR
unsigned int flags
Definition: utils.h:200

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

Referenced by func_channel_write_real().

◆ ast_bridging_init_basic()

void ast_bridging_init_basic ( void  )

Initialize the basic bridge class for use by the system.

Definition at line 3677 of file bridge_basic.c.

3678{
3679 /* Setup bridge basic subclass v_table. */
3685
3686 /*
3687 * Personality vtables don't have the same rules as
3688 * normal bridge vtables. These vtable functions are
3689 * used as alterations to the ast_bridge_basic_v_table
3690 * method functionality and are checked for NULL before
3691 * calling.
3692 */
3695
3696 personality_atxfer_v_table.name = "attended transfer";
3699
3702}
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
Definition: bridge.c:923
static int feature_blind_transfer(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Internal built in feature for blind transfers.
static void bridge_basic_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
Definition: bridge_basic.c:687
static void bridge_personality_atxfer_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
static void bridge_basic_destroy(struct ast_bridge *self)
Definition: bridge_basic.c:702
struct ast_bridge_methods personality_normal_v_table
static int bridge_personality_normal_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
Definition: bridge_basic.c:661
static int bridge_basic_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
Definition: bridge_basic.c:670
struct ast_bridge_methods personality_atxfer_v_table
static int bridge_personality_atxfer_push(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
static int feature_attended_transfer(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Internal built in feature for attended transfers.
@ AST_BRIDGE_BUILTIN_BLINDTRANSFER
@ AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER
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
ast_bridge_push_channel_fn push
Definition: bridge.h:265
const char * name
Definition: bridge.h:259
ast_bridge_destructor_fn destroy
Definition: bridge.h:261
ast_bridge_pull_channel_fn pull
Definition: bridge.h:267

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().

Variable Documentation

◆ ast_bridge_basic_v_table

struct ast_bridge_methods ast_bridge_basic_v_table
extern

Bridge basic class virtual method table.

Definition at line 3564 of file bridge_basic.c.

Referenced by ast_bridge_basic_new(), and ast_bridging_init_basic().