Asterisk - The Open Source Telephony Project GIT-master-8f1982c
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Data Structures | Macros | Typedefs | Enumerations | Functions
bridge_features.h File Reference

Channel Bridging API. More...

#include "asterisk/channel.h"
Include dependency graph for bridge_features.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_bridge_features
 Structure that contains features information. More...
 
struct  ast_bridge_features_attended_transfer
 Structure that contains configuration information for the attended transfer built in feature. More...
 
struct  ast_bridge_features_automixmonitor
 
struct  ast_bridge_features_blind_transfer
 Structure that contains configuration information for the blind transfer built in feature. More...
 
struct  ast_bridge_features_limits
 Structure that contains configuration information for the limits feature. More...
 
struct  ast_bridge_hook
 Structure that is the essence of a feature hook. More...
 
struct  ast_bridge_hook_dtmf
 
struct  ast_bridge_hook_dtmf_parms
 
struct  ast_bridge_hook_timer
 
struct  ast_bridge_hook_timer_parms
 

Macros

#define MAXIMUM_DTMF_FEATURE_STRING   (11 + 1)
 Maximum length of a DTMF feature string. More...
 

Typedefs

typedef int(* ast_bridge_builtin_set_limits_fn) (struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
 Attach interval hooks to a bridge features structure. More...
 
typedef int(* ast_bridge_hook_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 Hook callback type. More...
 
typedef void(* ast_bridge_hook_pvt_destructor) (void *hook_pvt)
 Hook pvt destructor callback. More...
 
typedef int(* ast_bridge_move_indicate_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt, struct ast_bridge *src, struct ast_bridge *dst)
 Move indicator callback. More...
 
typedef int(* ast_bridge_talking_indicate_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt, int talking)
 Talking indicator callback. More...
 

Enumerations

enum  ast_bridge_builtin_feature {
  AST_BRIDGE_BUILTIN_BLINDTRANSFER , AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER , AST_BRIDGE_BUILTIN_HANGUP , AST_BRIDGE_BUILTIN_PARKCALL ,
  AST_BRIDGE_BUILTIN_AUTOMIXMON , AST_BRIDGE_BUILTIN_END
}
 Built in DTMF features. More...
 
enum  ast_bridge_builtin_interval { AST_BRIDGE_BUILTIN_INTERVAL_LIMITS , AST_BRIDGE_BUILTIN_INTERVAL_END }
 
enum  ast_bridge_channel_feature_flags { AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP = (1 << 0) , AST_BRIDGE_CHANNEL_FLAG_LONELY = (1 << 1) , AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE = (1 << 2) }
 Flags used for per bridge channel features. More...
 
enum  ast_bridge_feature_flags {
  AST_BRIDGE_FLAG_DISSOLVE_HANGUP = (1 << 0) , AST_BRIDGE_FLAG_DISSOLVE_EMPTY = (1 << 1) , AST_BRIDGE_FLAG_SMART = (1 << 2) , AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM = (1 << 3) ,
  AST_BRIDGE_FLAG_MERGE_INHIBIT_TO = (1 << 4) , AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM = (1 << 5) , AST_BRIDGE_FLAG_SWAP_INHIBIT_TO = (1 << 6) , AST_BRIDGE_FLAG_MASQUERADE_ONLY = (1 << 7) ,
  AST_BRIDGE_FLAG_TRANSFER_PROHIBITED = (1 << 8) , AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY = (1 << 9) , AST_BRIDGE_FLAG_INVISIBLE = (1 << 10)
}
 Flags used for bridge features. More...
 
enum  ast_bridge_features_monitor { AUTO_MONITOR_TOGGLE , AUTO_MONITOR_START , AUTO_MONITOR_STOP }
 
enum  ast_bridge_hook_remove_flags { AST_BRIDGE_HOOK_REMOVE_ON_PULL = (1 << 0) , AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE = (1 << 1) }
 
enum  ast_bridge_hook_timer_option { AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA = (1 << 0) }
 
enum  ast_bridge_hook_type {
  AST_BRIDGE_HOOK_TYPE_NONE , AST_BRIDGE_HOOK_TYPE_DTMF , AST_BRIDGE_HOOK_TYPE_TIMER , AST_BRIDGE_HOOK_TYPE_HANGUP ,
  AST_BRIDGE_HOOK_TYPE_JOIN , AST_BRIDGE_HOOK_TYPE_LEAVE , AST_BRIDGE_HOOK_TYPE_TALK , AST_BRIDGE_HOOK_TYPE_MOVE
}
 

Functions

int ast_bridge_dtmf_hook (struct ast_bridge_features *features, const char *dtmf, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a DTMF hook to a bridge features structure. More...
 
void ast_bridge_features_cleanup (struct ast_bridge_features *features)
 Clean up the contents of a bridge features structure. More...
 
void ast_bridge_features_destroy (struct ast_bridge_features *features)
 Destroy an allocated bridge features struct. More...
 
int ast_bridge_features_do (enum ast_bridge_builtin_feature feature, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 Invoke a built in feature hook now. More...
 
int ast_bridge_features_enable (struct ast_bridge_features *features, enum ast_bridge_builtin_feature feature, const char *dtmf, void *config, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Enable a built in feature on a bridge features structure. More...
 
int ast_bridge_features_init (struct ast_bridge_features *features)
 Initialize bridge features structure. More...
 
int ast_bridge_features_limits_construct (struct ast_bridge_features_limits *limits)
 Constructor function for ast_bridge_features_limits. More...
 
void ast_bridge_features_limits_destroy (struct ast_bridge_features_limits *limits)
 Destructor function for ast_bridge_features_limits. More...
 
void ast_bridge_features_merge (struct ast_bridge_features *into, const struct ast_bridge_features *from)
 Merge one ast_bridge_features into another. More...
 
struct ast_bridge_featuresast_bridge_features_new (void)
 Allocate a new bridge features struct. More...
 
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. More...
 
void ast_bridge_features_set_flag (struct ast_bridge_features *features, unsigned int flag)
 Set a flag on a bridge channel features structure. More...
 
int ast_bridge_features_set_limits (struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
 Limit the amount of time a channel may stay in the bridge and optionally play warning messages as time runs out. More...
 
int ast_bridge_features_unregister (enum ast_bridge_builtin_feature feature)
 Unregister a handler for a built in feature. More...
 
int ast_bridge_hangup_hook (struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a hangup hook to a bridge features structure. More...
 
int ast_bridge_interval_hook (struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach an interval hook to a bridge features structure. More...
 
int ast_bridge_interval_register (enum ast_bridge_builtin_interval interval, ast_bridge_builtin_set_limits_fn callback)
 Register a handler for a built in interval feature. More...
 
int ast_bridge_interval_unregister (enum ast_bridge_builtin_interval interval)
 Unregisters a handler for a built in interval feature. More...
 
int ast_bridge_join_hook (struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a bridge channel join hook to a bridge features structure. More...
 
int ast_bridge_leave_hook (struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a bridge channel leave hook to a bridge features structure. More...
 
int ast_bridge_move_hook (struct ast_bridge_features *features, ast_bridge_move_indicate_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a bridge channel move detection hook to a bridge features structure. More...
 
int ast_bridge_talk_detector_hook (struct ast_bridge_features *features, ast_bridge_talking_indicate_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
 Attach a bridge channel talk detection hook to a bridge features structure. More...
 

Detailed Description

Channel Bridging API.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file bridge_features.h.

Macro Definition Documentation

◆ MAXIMUM_DTMF_FEATURE_STRING

#define MAXIMUM_DTMF_FEATURE_STRING   (11 + 1)

Maximum length of a DTMF feature string.

Definition at line 208 of file bridge_features.h.

Typedef Documentation

◆ ast_bridge_builtin_set_limits_fn

typedef int(* ast_bridge_builtin_set_limits_fn) (struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)

Attach interval hooks to a bridge features structure.

Parameters
featuresBridge features structure
limitsConfigured limits applicable to the channel
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure

Definition at line 408 of file bridge_features.h.

◆ ast_bridge_hook_callback

typedef int(* ast_bridge_hook_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt)

Hook callback type.

Parameters
bridge_channelChannel executing the feature
hook_pvtPrivate data passed in when the hook was created
Return values
0for interval hooks: setup to fire again at the last interval. for other hooks: keep the callback hook.
positivefor interval hooks: Setup to fire again at the new interval returned. for other hooks: n/a
-1for all hooks: remove the callback hook.

Definition at line 127 of file bridge_features.h.

◆ ast_bridge_hook_pvt_destructor

typedef void(* ast_bridge_hook_pvt_destructor) (void *hook_pvt)

Hook pvt destructor callback.

Parameters
hook_pvtPrivate data passed in when the hook was created to destroy

Definition at line 134 of file bridge_features.h.

◆ ast_bridge_move_indicate_callback

typedef int(* ast_bridge_move_indicate_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt, struct ast_bridge *src, struct ast_bridge *dst)

Move indicator callback.

This callback can be registered with the bridge channel in order to be notified when the bridge channel is being moved from one bridge to another.

Parameters
bridge_channelThe channel executing the feature
hook_pvtPrivate data passed in when the hook was created
srcThe bridge from which the bridge channel is moving
dstThe bridge into which the bridge channel is moving
Return values
0Keep the callback hook.
-1Remove the callback hook.

Definition at line 169 of file bridge_features.h.

◆ ast_bridge_talking_indicate_callback

typedef int(* ast_bridge_talking_indicate_callback) (struct ast_bridge_channel *bridge_channel, void *hook_pvt, int talking)

Talking indicator callback.

This callback can be registered with the bridge channel in order to receive updates when the bridge_channel has started and stopped talking.

Parameters
bridge_channelChannel executing the feature
hook_pvtPrivate data passed in when the hook was created
talkingTRUE if the channel is now talking
Return values
0Keep the callback hook.
-1Remove the callback hook.

Definition at line 151 of file bridge_features.h.

Enumeration Type Documentation

◆ ast_bridge_builtin_feature

Built in DTMF features.

Enumerator
AST_BRIDGE_BUILTIN_BLINDTRANSFER 

DTMF based Blind Transfer

AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER 

DTMF based Attended Transfer

AST_BRIDGE_BUILTIN_HANGUP 

DTMF based depart bridge feature

Note
Imparted channels are optionally hangup depending upon how it was imparted.
Joined channels exit the bridge with BRIDGE_CHANNEL_STATE_END_WITH_DISSOLVE.
AST_BRIDGE_BUILTIN_PARKCALL 

DTMF based Park

The bridge is parked and the channel hears the parking slot to which it was parked.

AST_BRIDGE_BUILTIN_AUTOMIXMON 

DTMF one-touch-record toggle using MixMonitor app.

Note
Only valid on two party bridges.
AST_BRIDGE_BUILTIN_END 

End terminator for list of built in features. Must remain last.

Definition at line 71 of file bridge_features.h.

71 {
72 /*! DTMF based Blind Transfer */
74 /*! DTMF based Attended Transfer */
76 /*!
77 * DTMF based depart bridge feature
78 *
79 * \note Imparted channels are optionally hangup depending upon
80 * how it was imparted.
81 *
82 * \note Joined channels exit the bridge with
83 * BRIDGE_CHANNEL_STATE_END_WITH_DISSOLVE.
84 */
86 /*!
87 * DTMF based Park
88 *
89 * \details The bridge is parked and the channel hears the
90 * parking slot to which it was parked.
91 */
93 /*!
94 * DTMF one-touch-record toggle using MixMonitor app.
95 *
96 * \note Only valid on two party bridges.
97 */
99
100 /*! End terminator for list of built in features. Must remain last. */
102};
@ AST_BRIDGE_BUILTIN_BLINDTRANSFER
@ AST_BRIDGE_BUILTIN_END
@ AST_BRIDGE_BUILTIN_AUTOMIXMON
@ AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER
@ AST_BRIDGE_BUILTIN_HANGUP
@ AST_BRIDGE_BUILTIN_PARKCALL

◆ ast_bridge_builtin_interval

Enumerator
AST_BRIDGE_BUILTIN_INTERVAL_LIMITS 

Apply Call Duration Limits

AST_BRIDGE_BUILTIN_INTERVAL_END 

End terminator for list of built in interval features. Must remain last.

Definition at line 104 of file bridge_features.h.

104 {
105 /*! Apply Call Duration Limits */
107
108 /*! End terminator for list of built in interval features. Must remain last. */
110};
@ AST_BRIDGE_BUILTIN_INTERVAL_LIMITS
@ AST_BRIDGE_BUILTIN_INTERVAL_END

◆ ast_bridge_channel_feature_flags

Flags used for per bridge channel features.

Enumerator
AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP 

Upon channel hangup all bridge participants should be kicked out.

AST_BRIDGE_CHANNEL_FLAG_LONELY 

This channel leaves the bridge if all participants have this flag set.

AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE 

This channel cannot be moved to another bridge.

Definition at line 61 of file bridge_features.h.

61 {
62 /*! Upon channel hangup all bridge participants should be kicked out. */
64 /*! This channel leaves the bridge if all participants have this flag set. */
66 /*! This channel cannot be moved to another bridge. */
68};
@ AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE
@ AST_BRIDGE_CHANNEL_FLAG_LONELY
@ AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP

◆ ast_bridge_feature_flags

Flags used for bridge features.

Enumerator
AST_BRIDGE_FLAG_DISSOLVE_HANGUP 

Upon channel hangup all bridge participants should be kicked out.

AST_BRIDGE_FLAG_DISSOLVE_EMPTY 

The last channel to leave the bridge dissolves it.

AST_BRIDGE_FLAG_SMART 

Move between bridging technologies as needed.

AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM 

Bridge channels cannot be merged from this bridge.

AST_BRIDGE_FLAG_MERGE_INHIBIT_TO 

Bridge channels cannot be merged to this bridge.

AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM 

Bridge channels cannot be local channel swap optimized from this bridge.

AST_BRIDGE_FLAG_SWAP_INHIBIT_TO 

Bridge channels cannot be local channel swap optimized to this bridge.

AST_BRIDGE_FLAG_MASQUERADE_ONLY 

Bridge channels can be moved to another bridge only by masquerade (ConfBridge)

AST_BRIDGE_FLAG_TRANSFER_PROHIBITED 

Bridge does not allow transfers of channels out

AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY 

Bridge transfers require transfer of entire bridge rather than individual channels

AST_BRIDGE_FLAG_INVISIBLE 

Bridge is invisible to AMI/CLI/ARI/etc.

Definition at line 35 of file bridge_features.h.

35 {
36 /*! Upon channel hangup all bridge participants should be kicked out. */
38 /*! The last channel to leave the bridge dissolves it. */
40 /*! Move between bridging technologies as needed. */
41 AST_BRIDGE_FLAG_SMART = (1 << 2),
42 /*! Bridge channels cannot be merged from this bridge. */
44 /*! Bridge channels cannot be merged to this bridge. */
46 /*! Bridge channels cannot be local channel swap optimized from this bridge. */
48 /*! Bridge channels cannot be local channel swap optimized to this bridge. */
50 /*! Bridge channels can be moved to another bridge only by masquerade (ConfBridge) */
52 /*! Bridge does not allow transfers of channels out */
54 /*! Bridge transfers require transfer of entire bridge rather than individual channels */
56 /*! Bridge is invisible to AMI/CLI/ARI/etc. */
57 AST_BRIDGE_FLAG_INVISIBLE = (1 << 10),
58};
@ AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_TO
@ AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM
@ AST_BRIDGE_FLAG_TRANSFER_PROHIBITED
@ AST_BRIDGE_FLAG_DISSOLVE_EMPTY
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_TO
@ AST_BRIDGE_FLAG_SMART
@ AST_BRIDGE_FLAG_MASQUERADE_ONLY
@ AST_BRIDGE_FLAG_DISSOLVE_HANGUP
@ AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM
@ AST_BRIDGE_FLAG_INVISIBLE

◆ ast_bridge_features_monitor

Enumerator
AUTO_MONITOR_TOGGLE 

Toggle start/stop of MixMonitor.

AUTO_MONITOR_START 

Start MixMonitor if not already started.

AUTO_MONITOR_STOP 

Stop MixMonitor if not already stopped.

Definition at line 301 of file bridge_features.h.

301 {
302 /*! Toggle start/stop of MixMonitor. */
304 /*! Start MixMonitor if not already started. */
306 /*! Stop MixMonitor if not already stopped. */
308};
@ AUTO_MONITOR_START
@ AUTO_MONITOR_STOP
@ AUTO_MONITOR_TOGGLE

◆ ast_bridge_hook_remove_flags

Enumerator
AST_BRIDGE_HOOK_REMOVE_ON_PULL 

The hook is removed when the channel is pulled from the bridge.

AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE 

The hook is removed when the bridge's personality changes.

Definition at line 172 of file bridge_features.h.

172 {
173 /*! The hook is removed when the channel is pulled from the bridge. */
175 /*! The hook is removed when the bridge's personality changes. */
177};
@ AST_BRIDGE_HOOK_REMOVE_ON_PULL
@ AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE

◆ ast_bridge_hook_timer_option

Enumerator
AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA 

The timer temporarily affects media. (Like a custom playfile.)

Definition at line 224 of file bridge_features.h.

224 {
225 /*! The timer temporarily affects media. (Like a custom playfile.) */
227};
@ AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA

◆ ast_bridge_hook_type

Enumerator
AST_BRIDGE_HOOK_TYPE_NONE 

The hook type has not been specified.

AST_BRIDGE_HOOK_TYPE_DTMF 
AST_BRIDGE_HOOK_TYPE_TIMER 
AST_BRIDGE_HOOK_TYPE_HANGUP 
AST_BRIDGE_HOOK_TYPE_JOIN 
AST_BRIDGE_HOOK_TYPE_LEAVE 
AST_BRIDGE_HOOK_TYPE_TALK 
AST_BRIDGE_HOOK_TYPE_MOVE 

Definition at line 179 of file bridge_features.h.

179 {
180 /*! The hook type has not been specified. */
189};
@ AST_BRIDGE_HOOK_TYPE_JOIN
@ AST_BRIDGE_HOOK_TYPE_HANGUP
@ AST_BRIDGE_HOOK_TYPE_MOVE
@ AST_BRIDGE_HOOK_TYPE_DTMF
@ AST_BRIDGE_HOOK_TYPE_LEAVE
@ AST_BRIDGE_HOOK_TYPE_TALK
@ AST_BRIDGE_HOOK_TYPE_NONE
@ AST_BRIDGE_HOOK_TYPE_TIMER

Function Documentation

◆ ast_bridge_dtmf_hook()

int ast_bridge_dtmf_hook ( struct ast_bridge_features features,
const char *  dtmf,
ast_bridge_hook_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a DTMF hook to a bridge features structure.

Parameters
featuresBridge features structure
dtmfDTMF string to be activated upon
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
ast_bridge_dtmf_hook(&features, "#", pound_callback, NULL, NULL, 0);
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition: bridge.c:3689
int ast_bridge_dtmf_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a DTMF hook to a bridge features structure.
Definition: bridge.c:3251
#define NULL
Definition: resample.c:96
Structure that contains features information.

This makes the bridging core call pound_callback if a channel that has this feature structure inputs the DTMF string '#'. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3251 of file bridge.c.

3257{
3258 struct ast_bridge_hook_dtmf *hook;
3259 int res;
3260
3261 /* Allocate new hook and setup it's various variables */
3262 hook = (struct ast_bridge_hook_dtmf *) bridge_hook_generic(sizeof(*hook), callback,
3263 hook_pvt, destructor, remove_flags);
3264 if (!hook) {
3265 return -1;
3266 }
3268 ast_copy_string(hook->dtmf.code, dtmf, sizeof(hook->dtmf.code));
3269
3270 /* Once done we put it in the container. */
3271 res = ao2_link(features->dtmf_hooks, hook) ? 0 : -1;
3272 if (res) {
3273 /*
3274 * Could not link the hook into the container.
3275 *
3276 * Remove the hook_pvt destructor call from the hook since we
3277 * are returning failure to install the hook.
3278 */
3279 hook->generic.destructor = NULL;
3280 }
3281 ao2_ref(hook, -1);
3282
3283 return res;
3284}
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static struct ast_bridge_hook * bridge_hook_generic(size_t size, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Definition: bridge.c:3231
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
struct ao2_container * dtmf_hooks
char code[MAXIMUM_DTMF_FEATURE_STRING]
struct ast_bridge_hook generic
struct ast_bridge_hook_dtmf_parms dtmf
ast_bridge_hook_pvt_destructor destructor
enum ast_bridge_hook_type type

References ao2_link, ao2_ref, AST_BRIDGE_HOOK_TYPE_DTMF, ast_copy_string(), bridge_hook_generic(), callback(), ast_bridge_hook_dtmf_parms::code, ast_bridge_hook::destructor, ast_bridge_hook_dtmf::dtmf, ast_bridge_features::dtmf_hooks, ast_bridge_hook_dtmf::generic, NULL, and ast_bridge_hook::type.

Referenced by apply_menu_to_user(), ast_bridge_features_enable(), AST_TEST_DEFINE(), bridge_agent_hold_push(), bridge_personality_atxfer_push(), and dynamic_dtmf_hook_add().

◆ ast_bridge_features_cleanup()

void ast_bridge_features_cleanup ( struct ast_bridge_features features)

Clean up the contents of a bridge features structure.

Parameters
featuresBridge features structure

Example usage:

struct ast_bridge_features features;
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition: bridge.c:3722

This cleans up the feature structure 'features'.

Note
This MUST be called after the features structure is done being used or a memory leak may occur.

Definition at line 3722 of file bridge.c.

3723{
3724 struct ast_bridge_hook_timer *hook;
3725
3726 /* Destroy the interval hooks heap. */
3727 if (features->interval_hooks) {
3728 while ((hook = ast_heap_pop(features->interval_hooks))) {
3729 ao2_ref(hook, -1);
3730 }
3731 features->interval_hooks = ast_heap_destroy(features->interval_hooks);
3732 }
3733
3734 /* Destroy the miscellaneous other hooks container. */
3735 ao2_cleanup(features->other_hooks);
3736 features->other_hooks = NULL;
3737
3738 /* Destroy the DTMF hooks container. */
3739 ao2_cleanup(features->dtmf_hooks);
3740 features->dtmf_hooks = NULL;
3741}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
struct ast_heap * ast_heap_destroy(struct ast_heap *h)
Destroy a max heap.
Definition: heap.c:146
void * ast_heap_pop(struct ast_heap *h)
Pop the max element off of the heap.
Definition: heap.c:262
struct ao2_container * other_hooks
struct ast_heap * interval_hooks

References ao2_cleanup, ao2_ref, ast_heap_destroy(), ast_heap_pop(), ast_bridge_features::dtmf_hooks, ast_bridge_features::interval_hooks, NULL, and ast_bridge_features::other_hooks.

Referenced by agent_request_exec(), agent_run(), ast_bridge_call_with_flags(), ast_bridge_features_destroy(), AST_TEST_DEFINE(), bridge_exec(), bridgeadd_exec(), bridgewait_exec(), channel_feature_hooks_set_full(), confbridge_exec(), park_and_announce_app_exec(), park_app_exec(), and parked_call_app_exec().

◆ ast_bridge_features_destroy()

void ast_bridge_features_destroy ( struct ast_bridge_features features)

Destroy an allocated bridge features struct.

Since
12.0.0
Parameters
featuresBridge features structure

Example usage:

struct ast_bridge_features *features;
struct ast_bridge_features * ast_bridge_features_new(void)
Allocate a new bridge features struct.
Definition: bridge.c:3752
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
Definition: bridge.c:3743

Definition at line 3743 of file bridge.c.

3744{
3745 if (!features) {
3746 return;
3747 }
3749 ast_free(features);
3750}
#define ast_free(a)
Definition: astmm.h:180
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition: bridge.c:3722

References ast_bridge_features_cleanup(), and ast_free.

Referenced by ast_bridge_add_channel(), ast_bridge_call_with_flags(), ast_bridge_features_new(), ast_local_setup_bridge(), bridge_channel_depart_thread(), bridge_channel_ind_thread(), bridge_exec(), bridge_impart_internal(), conf_start_record(), control_dtor(), features_destroy(), and local_pvt_destructor().

◆ ast_bridge_features_do()

int ast_bridge_features_do ( enum ast_bridge_builtin_feature  feature,
struct ast_bridge_channel bridge_channel,
void *  hook_pvt 
)

Invoke a built in feature hook now.

Parameters
featureThe feature to invoke
bridge_channelChannel executing the feature
hook_pvtPrivate data passed in when the hook was created
Note
This API call is only meant to be used by bridge subclasses and hook callbacks to request a builtin feature hook to be executed.
Return values
0on success
-1on failure

Example usage:

ast_bridge_features_do(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER, bridge_channel, hook_pvt);
int ast_bridge_features_do(enum ast_bridge_builtin_feature feature, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Invoke a built in feature hook now.
Definition: bridge.c:3159

Definition at line 3159 of file bridge.c.

3160{
3162
3163 if (ARRAY_LEN(builtin_features_handlers) <= feature) {
3164 return -1;
3165 }
3166
3168 if (!callback) {
3169 return -1;
3170 }
3171 callback(bridge_channel, hook_pvt);
3172
3173 return 0;
3174}
static ast_bridge_hook_callback builtin_features_handlers[AST_BRIDGE_BUILTIN_END]
Definition: bridge.c:158
int(* ast_bridge_hook_callback)(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
Hook callback type.
#define ARRAY_LEN(a)
Definition: utils.h:666

References ARRAY_LEN, builtin_features_handlers, and callback().

Referenced by agent_connect_caller().

◆ ast_bridge_features_enable()

int ast_bridge_features_enable ( struct ast_bridge_features features,
enum ast_bridge_builtin_feature  feature,
const char *  dtmf,
void *  config,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Enable a built in feature on a bridge features structure.

Parameters
featuresBridge features structure
featureFeature to enable
dtmfOptionally the DTMF stream to trigger the feature, if not specified it will be the default
configConfiguration structure unique to the built in type
destructorOptional destructor callback for config data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure

Example usage:

struct ast_bridge_features features;
int ast_bridge_features_enable(struct ast_bridge_features *features, enum ast_bridge_builtin_feature feature, const char *dtmf, void *config, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Enable a built in feature on a bridge features structure.
Definition: bridge.c:3434

This enables the attended transfer DTMF option using the default DTMF string. An alternate string may be provided using the dtmf parameter. Internally this is simply setting up a hook to a built in feature callback function.

Definition at line 3434 of file bridge.c.

3440{
3441 if (ARRAY_LEN(builtin_features_handlers) <= feature
3442 || !builtin_features_handlers[feature]) {
3443 return -1;
3444 }
3445
3446 /* If no alternate DTMF stream was provided use the default one */
3447 if (ast_strlen_zero(dtmf)) {
3448 dtmf = builtin_features_dtmf[feature];
3449 /* If no DTMF is still available (ie: it has been disabled) then error out now */
3450 if (ast_strlen_zero(dtmf)) {
3451 ast_debug(1, "Failed to enable built in feature %u on %p, no DTMF string is available for it.\n",
3452 feature, features);
3453 return -1;
3454 }
3455 }
3456
3457 /*
3458 * The rest is basically pretty easy. We create another hook
3459 * using the built in feature's DTMF callback. Easy as pie.
3460 */
3461 return ast_bridge_dtmf_hook(features, dtmf, builtin_features_handlers[feature],
3462 config, destructor, remove_flags);
3463}
static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][MAXIMUM_DTMF_FEATURE_STRING]
Definition: bridge.c:155
int ast_bridge_dtmf_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a DTMF hook to a bridge features structure.
Definition: bridge.c:3251
static const char config[]
Definition: chan_ooh323.c:111
#define ast_debug(level,...)
Log a DEBUG message.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65

References ARRAY_LEN, ast_bridge_dtmf_hook(), ast_debug, ast_strlen_zero(), builtin_features_dtmf, builtin_features_handlers, and config.

Referenced by builtin_features_helper().

◆ ast_bridge_features_init()

int ast_bridge_features_init ( struct ast_bridge_features features)

Initialize bridge features structure.

Parameters
featuresBridge featues structure
Return values
0on success
-1on failure

Example usage:

struct ast_bridge_features features;

This initializes the feature structure 'features' to have nothing enabled.

Note
This MUST be called before enabling features or flags. Failure to do so may result in a crash.

Definition at line 3689 of file bridge.c.

3690{
3691 /* Zero out the structure */
3692 memset(features, 0, sizeof(*features));
3693
3694 /* Initialize the DTMF hooks container */
3697 if (!features->dtmf_hooks) {
3698 return -1;
3699 }
3700
3701 /* Initialize the miscellaneous other hooks container */
3703 NULL);
3704 if (!features->other_hooks) {
3705 return -1;
3706 }
3707
3708 /* Initialize the interval hooks heap */
3710 offsetof(struct ast_bridge_hook_timer, timer.heap_index));
3711 if (!features->interval_hooks) {
3712 return -1;
3713 }
3714
3715 features->dtmf_passthrough = 1;
3716 features->text_messaging = 1;
3717
3718 return 0;
3719}
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE
Replace objects with duplicate keys in container.
Definition: astobj2.h:1211
static int interval_hook_time_cmp(void *a, void *b)
Definition: bridge.c:3577
static int bridge_dtmf_hook_sort(const void *obj_left, const void *obj_right, int flags)
Definition: bridge.c:3608
static struct ast_timer * timer
Definition: chan_iax2.c:388
#define ast_heap_create(init_height, cmp_fn, index_offset)
Create a max heap.
Definition: heap.h:100
unsigned int dtmf_passthrough
unsigned int text_messaging

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ast_heap_create, bridge_dtmf_hook_sort(), ast_bridge_features::dtmf_hooks, ast_bridge_features::dtmf_passthrough, interval_hook_time_cmp(), ast_bridge_features::interval_hooks, NULL, ast_bridge_features::other_hooks, ast_bridge_features::text_messaging, and timer.

Referenced by agent_request_exec(), agent_run(), ast_bridge_call_with_flags(), ast_bridge_features_new(), AST_TEST_DEFINE(), bridge_exec(), bridgeadd_exec(), bridgewait_exec(), channel_feature_hooks_set_full(), confbridge_exec(), park_and_announce_app_exec(), park_app_exec(), and parked_call_app_exec().

◆ ast_bridge_features_limits_construct()

int ast_bridge_features_limits_construct ( struct ast_bridge_features_limits limits)

Constructor function for ast_bridge_features_limits.

Parameters
limitspointer to a ast_bridge_features_limits struct that has been allocated, but not initialized
Return values
0on success
-1on failure

Definition at line 3465 of file bridge.c.

3466{
3467 memset(limits, 0, sizeof(*limits));
3468
3469 if (ast_string_field_init(limits, 256)) {
3470 return -1;
3471 }
3472
3473 return 0;
3474}
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359

References ast_string_field_init.

Referenced by bridge_builtin_set_limits(), and pre_bridge_setup().

◆ ast_bridge_features_limits_destroy()

void ast_bridge_features_limits_destroy ( struct ast_bridge_features_limits limits)

Destructor function for ast_bridge_features_limits.

Parameters
limitspointer to an ast_bridge_features_limits struct that needs to be destroyed

This function does not free memory allocated to the ast_bridge_features_limits struct, it only frees elements within the struct. You must still call ast_free on the struct if you allocated it with malloc.

Definition at line 3476 of file bridge.c.

3477{
3479}
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374

References ast_string_field_free_memory.

Referenced by bridge_features_limits_dtor(), and pre_bridge_setup().

◆ ast_bridge_features_merge()

void ast_bridge_features_merge ( struct ast_bridge_features into,
const struct ast_bridge_features from 
)

Merge one ast_bridge_features into another.

Parameters
intoThe ast_bridge_features that will be merged into
fromThe ast_bridge_features that will be merged from

Definition at line 3664 of file bridge.c.

3665{
3666 struct ast_bridge_hook_timer *hook;
3667 int idx;
3668
3669 /* Merge hook containers */
3672
3673 /* Merge hook heaps */
3675 for (idx = 1; (hook = ast_heap_peek(from->interval_hooks, idx)); idx++) {
3676 wrap_hook(into, hook);
3677 }
3679
3680 /* Merge feature flags */
3681 into->feature_flags.flags |= from->feature_flags.flags;
3682 into->usable |= from->usable;
3683
3684 into->mute |= from->mute;
3685 into->dtmf_passthrough |= from->dtmf_passthrough;
3686}
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
static int merge_container_cb(void *obj, void *data, int flags)
Callback for merging hook ao2_containers.
Definition: bridge.c:3631
static void wrap_hook(struct ast_bridge_features *features, struct ast_bridge_hook_timer *hook)
Wrap the provided interval hook and add it to features.
Definition: bridge.c:3652
#define ast_heap_unlock(h)
Definition: heap.h:249
#define ast_heap_wrlock(h)
Definition: heap.h:247
void * ast_heap_peek(struct ast_heap *h, unsigned int index)
Peek at an element on a heap.
Definition: heap.c:267
struct ast_flags feature_flags
unsigned int flags
Definition: utils.h:200

References ao2_callback, ast_heap_peek(), ast_heap_unlock, ast_heap_wrlock, ast_bridge_features::dtmf_hooks, ast_bridge_features::dtmf_passthrough, ast_bridge_features::feature_flags, ast_flags::flags, ast_bridge_features::interval_hooks, merge_container_cb(), ast_bridge_features::mute, ast_bridge_features::other_hooks, ast_bridge_features::usable, and wrap_hook().

Referenced by bridge_channel_internal_join(), and channel_feature_hooks_set_full().

◆ ast_bridge_features_new()

struct ast_bridge_features * ast_bridge_features_new ( void  )

Allocate a new bridge features struct.

Since
12.0.0

Example usage:

struct ast_bridge_features *features;
Returns
features New allocated features struct.
Return values
NULLon error.

Definition at line 3752 of file bridge.c.

3753{
3754 struct ast_bridge_features *features;
3755
3756 features = ast_malloc(sizeof(*features));
3757 if (features) {
3758 if (ast_bridge_features_init(features)) {
3760 features = NULL;
3761 }
3762 }
3763
3764 return features;
3765}
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition: bridge.c:3689
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
Definition: bridge.c:3743

References ast_bridge_features_destroy(), ast_bridge_features_init(), ast_malloc, and NULL.

Referenced by ast_bridge_call_with_flags(), ast_unreal_channel_push_to_bridge(), bridge_exec(), bridge_impart_internal(), channel_feature_hooks_set_full(), conf_announce_channel_push(), conf_start_record(), and stasis_app_control_bridge_features_init().

◆ ast_bridge_features_register()

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.

Parameters
featureThe feature that the handler will be responsible for
callbackThe callback function that will handle it
dtmfDefault DTMF string used to activate the feature
Return values
0on success
-1on failure

Example usage:

ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER, bridge_builtin_attended_transfer, "*1");
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:3131

This registers the function bridge_builtin_attended_transfer as the function responsible for the built in attended transfer feature.

Definition at line 3131 of file bridge.c.

3132{
3133 if (ARRAY_LEN(builtin_features_handlers) <= feature
3134 || builtin_features_handlers[feature]) {
3135 return -1;
3136 }
3137
3138 if (!ast_strlen_zero(dtmf)) {
3139 ast_copy_string(builtin_features_dtmf[feature], dtmf, sizeof(builtin_features_dtmf[feature]));
3140 }
3141
3143
3144 return 0;
3145}

References ARRAY_LEN, ast_copy_string(), ast_strlen_zero(), builtin_features_dtmf, builtin_features_handlers, and callback().

Referenced by ast_bridging_init_basic(), load_module(), and load_parking_bridge_features().

◆ ast_bridge_features_set_flag()

void ast_bridge_features_set_flag ( struct ast_bridge_features features,
unsigned int  flag 
)

Set a flag on a bridge channel features structure.

Parameters
featuresBridge channel features structure
flagFlag to enable

Example usage:

struct ast_bridge_features features;
void ast_bridge_features_set_flag(struct ast_bridge_features *features, unsigned int flag)
Set a flag on a bridge channel features structure.
Definition: bridge.c:3496

This sets the AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP feature to be enabled on the features structure 'features'.

Definition at line 3496 of file bridge.c.

3497{
3498 ast_set_flag(&features->feature_flags, flag);
3499 features->usable = 1;
3500}
long int flag
Definition: f2c.h:83
#define ast_set_flag(p, flag)
Definition: utils.h:70

References ast_set_flag, ast_bridge_features::feature_flags, and ast_bridge_features::usable.

◆ ast_bridge_features_set_limits()

int ast_bridge_features_set_limits ( struct ast_bridge_features features,
struct ast_bridge_features_limits limits,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Limit the amount of time a channel may stay in the bridge and optionally play warning messages as time runs out.

Parameters
featuresBridge features structure
limitsConfigured limits applicable to the channel
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure

Example usage:

struct ast_bridge_features features;
int ast_bridge_features_set_limits(struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
Limit the amount of time a channel may stay in the bridge and optionally play warning messages as tim...
Definition: bridge.c:3481
int ast_bridge_features_limits_construct(struct ast_bridge_features_limits *limits)
Constructor function for ast_bridge_features_limits.
Definition: bridge.c:3465
void ast_bridge_features_limits_destroy(struct ast_bridge_features_limits *limits)
Destructor function for ast_bridge_features_limits.
Definition: bridge.c:3476
Structure that contains configuration information for the limits feature.

This sets the maximum time the channel can be in the bridge to 10 seconds and does not play any warnings.

Note
This API call can only be used on a features structure that will be used in association with a bridge channel.
The ast_bridge_features_limits structure must remain accessible for the lifetime of the features structure.

Definition at line 3481 of file bridge.c.

3484{
3487
3489 return callback(features, limits, remove_flags);
3490 }
3491
3492 ast_log(LOG_ERROR, "Attempted to set limits without an AST_BRIDGE_BUILTIN_INTERVAL_LIMITS callback registered.\n");
3493 return -1;
3494}
#define ast_log
Definition: astobj2.c:42
static ast_bridge_builtin_set_limits_fn builtin_interval_handlers[AST_BRIDGE_BUILTIN_INTERVAL_END]
Definition: bridge.c:161
int(* ast_bridge_builtin_set_limits_fn)(struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
Attach interval hooks to a bridge features structure.
#define LOG_ERROR

References AST_BRIDGE_BUILTIN_INTERVAL_LIMITS, ast_log, builtin_interval_handlers, callback(), and LOG_ERROR.

Referenced by pre_bridge_setup().

◆ ast_bridge_features_unregister()

int ast_bridge_features_unregister ( enum ast_bridge_builtin_feature  feature)

Unregister a handler for a built in feature.

Parameters
featureThe feature to unregister
Return values
0on success
-1on failure

Example usage:

ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER);
int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature)
Unregister a handler for a built in feature.
Definition: bridge.c:3147

This unregisters the function that is handling the built in attended transfer feature.

Definition at line 3147 of file bridge.c.

3148{
3149 if (ARRAY_LEN(builtin_features_handlers) <= feature
3150 || !builtin_features_handlers[feature]) {
3151 return -1;
3152 }
3153
3155
3156 return 0;
3157}

References ARRAY_LEN, builtin_features_handlers, and NULL.

Referenced by unload_module(), and unload_parking_bridge_features().

◆ ast_bridge_hangup_hook()

int ast_bridge_hangup_hook ( struct ast_bridge_features features,
ast_bridge_hook_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a hangup hook to a bridge features structure.

Parameters
featuresBridge features structure
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
ast_bridge_hangup_hook(&features, hangup_callback, NULL, NULL, 0);
int ast_bridge_hangup_hook(struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a hangup hook to a bridge features structure.
Definition: bridge.c:3334

This makes the bridging core call hangup_callback if a channel that has this hook hangs up. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3334 of file bridge.c.

3339{
3340 return bridge_other_hook(features, callback, hook_pvt, destructor, remove_flags,
3342}
static int bridge_other_hook(struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags, enum ast_bridge_hook_type type)
Definition: bridge.c:3300

References AST_BRIDGE_HOOK_TYPE_HANGUP, bridge_other_hook(), callback(), ast_bridge_hook::destructor, ast_bridge_hook::hook_pvt, and ast_bridge_hook::remove_flags.

Referenced by add_normal_hooks(), and bridge_personality_atxfer_push().

◆ ast_bridge_interval_hook()

int ast_bridge_interval_hook ( struct ast_bridge_features features,
enum ast_bridge_hook_timer_option  flags,
unsigned int  interval,
ast_bridge_hook_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach an interval hook to a bridge features structure.

Parameters
featuresBridge features structure
flagsInterval timer callback option flags.
intervalThe interval that the hook should execute at in milliseconds
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)
struct ast_bridge_features features;
ast_bridge_interval_hook(&features, 1000, playback_callback, NULL, NULL, 0);
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
Definition: bridge.c:3388

This makes the bridging core call playback_callback every second. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3388 of file bridge.c.

3395{
3396 struct ast_bridge_hook_timer *hook;
3397 int res;
3398
3399 if (!features ||!interval || !callback) {
3400 return -1;
3401 }
3402
3403 /* Allocate new hook and setup it's various variables */
3404 hook = (struct ast_bridge_hook_timer *) bridge_hook_generic(sizeof(*hook), callback,
3405 hook_pvt, destructor, remove_flags);
3406 if (!hook) {
3407 return -1;
3408 }
3410 hook->timer.interval = interval;
3411 hook->timer.trip_time = ast_tvadd(ast_tvnow(), ast_samp2tv(interval, 1000));
3412 hook->timer.seqno = ast_atomic_fetchadd_int((int *) &features->interval_sequence, +1);
3413 hook->timer.flags = flags;
3414
3415 ast_debug(1, "Putting interval hook %p with interval %u in the heap on features %p\n",
3416 hook, hook->timer.interval, features);
3418 res = ast_heap_push(features->interval_hooks, hook);
3420 if (res) {
3421 /*
3422 * Could not push the hook into the heap
3423 *
3424 * Remove the hook_pvt destructor call from the hook since we
3425 * are returning failure to install the hook.
3426 */
3427 hook->generic.destructor = NULL;
3428 ao2_ref(hook, -1);
3429 }
3430
3431 return res ? -1 : 0;
3432}
#define ast_heap_push(h, elm)
Push an element on to a heap.
Definition: heap.h:125
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:764
unsigned int interval_sequence
struct ast_bridge_hook generic
struct ast_bridge_hook_timer_parms timer
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:282
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159

References ao2_ref, ast_atomic_fetchadd_int(), AST_BRIDGE_HOOK_TYPE_TIMER, ast_debug, ast_heap_push, ast_heap_unlock, ast_heap_wrlock, ast_samp2tv(), ast_tvadd(), ast_tvnow(), bridge_hook_generic(), callback(), ast_bridge_hook::destructor, ast_bridge_hook_timer_parms::flags, ast_bridge_hook_timer::generic, ast_bridge_hook_timer_parms::interval, ast_bridge_features::interval_hooks, ast_bridge_features::interval_sequence, NULL, ast_bridge_hook_timer_parms::seqno, ast_bridge_hook_timer::timer, ast_bridge_hook_timer_parms::trip_time, and ast_bridge_hook::type.

Referenced by agent_request_exec(), apply_option_timeout(), AST_TEST_DEFINE(), bridge_agent_hold_push(), bridge_builtin_set_limits(), confbridge_exec(), parking_set_duration(), set_interval_hook(), and wrap_hook().

◆ ast_bridge_interval_register()

int ast_bridge_interval_register ( enum ast_bridge_builtin_interval  interval,
ast_bridge_builtin_set_limits_fn  callback 
)

Register a handler for a built in interval feature.

Parameters
intervalThe interval feature that the handler will be responsible for
callbackthe Callback function that will handle it
Return values
0on success
-1on failure

Example usage:

static int bridge_builtin_set_limits(struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags)
int ast_bridge_interval_register(enum ast_bridge_builtin_interval interval, ast_bridge_builtin_set_limits_fn callback)
Register a handler for a built in interval feature.
Definition: bridge.c:3176

This registers the function bridge_builtin_set_limits as the function responsible for the built in duration limit feature.

Definition at line 3176 of file bridge.c.

3177{
3178 if (ARRAY_LEN(builtin_interval_handlers) <= interval
3179 || builtin_interval_handlers[interval]) {
3180 return -1;
3181 }
3182
3184
3185 return 0;
3186}

References ARRAY_LEN, builtin_interval_handlers, and callback().

Referenced by load_module().

◆ ast_bridge_interval_unregister()

int ast_bridge_interval_unregister ( enum ast_bridge_builtin_interval  interval)

Unregisters a handler for a built in interval feature.

Parameters
intervalthe interval feature to unregister
Return values
0on success
-1on failure

Example usage:

ast_bridge_interval_unregister(AST_BRIDGE_BULTIN_INTERVAL_LIMITS)
int ast_bridge_interval_unregister(enum ast_bridge_builtin_interval interval)
Unregisters a handler for a built in interval feature.
Definition: bridge.c:3188

This unregisters the function that is handling the built in duration limit feature.

Definition at line 3188 of file bridge.c.

3189{
3190 if (ARRAY_LEN(builtin_interval_handlers) <= interval
3191 || !builtin_interval_handlers[interval]) {
3192 return -1;
3193 }
3194
3195 builtin_interval_handlers[interval] = NULL;
3196
3197 return 0;
3198
3199}

References ARRAY_LEN, builtin_interval_handlers, and NULL.

Referenced by unload_module().

◆ ast_bridge_join_hook()

int ast_bridge_join_hook ( struct ast_bridge_features features,
ast_bridge_hook_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a bridge channel join hook to a bridge features structure.

Parameters
featuresBridge features structure
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
static int join_callback(struct ast_bridge_channel *bridge_channel, void *ignore)
int ast_bridge_join_hook(struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a bridge channel join hook to a bridge features structure.
Definition: bridge.c:3344

This makes the bridging core call join_callback when a channel successfully joins the bridging system. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3344 of file bridge.c.

3349{
3350 return bridge_other_hook(features, callback, hook_pvt, destructor, remove_flags,
3352}

References AST_BRIDGE_HOOK_TYPE_JOIN, bridge_other_hook(), callback(), ast_bridge_hook::destructor, ast_bridge_hook::hook_pvt, and ast_bridge_hook::remove_flags.

Referenced by agent_request_exec(), and confbridge_exec().

◆ ast_bridge_leave_hook()

int ast_bridge_leave_hook ( struct ast_bridge_features features,
ast_bridge_hook_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a bridge channel leave hook to a bridge features structure.

Parameters
featuresBridge features structure
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
ast_bridge_leave_hook(&features, leave_callback, NULL, NULL, 0);
int ast_bridge_leave_hook(struct ast_bridge_features *features, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a bridge channel leave hook to a bridge features structure.
Definition: bridge.c:3354

This makes the bridging core call leave_callback when a channel successfully leaves the bridging system. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3354 of file bridge.c.

3359{
3360 return bridge_other_hook(features, callback, hook_pvt, destructor, remove_flags,
3362}

References AST_BRIDGE_HOOK_TYPE_LEAVE, bridge_other_hook(), callback(), ast_bridge_hook::destructor, ast_bridge_hook::hook_pvt, and ast_bridge_hook::remove_flags.

Referenced by confbridge_exec().

◆ ast_bridge_move_hook()

int ast_bridge_move_hook ( struct ast_bridge_features features,
ast_bridge_move_indicate_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a bridge channel move detection hook to a bridge features structure.

Parameters
featuresBridge features structure
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
ast_bridge_move_hook(&features, move_callback, NULL, NULL, 0);
int ast_bridge_move_hook(struct ast_bridge_features *features, ast_bridge_move_indicate_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a bridge channel move detection hook to a bridge features structure.
Definition: bridge.c:3376

This makes the bridging core call callback when a channel is moved from one bridge to another. A pointer to useful data may be provided to the hook_pvt parameter.

Definition at line 3376 of file bridge.c.

3381{
3383
3384 return bridge_other_hook(features, hook_cb, hook_pvt, destructor, remove_flags,
3386}
static int hook_cb(struct ast_config *cfg)
Definition: test_config.c:875

References AST_BRIDGE_HOOK_TYPE_MOVE, bridge_other_hook(), callback(), ast_bridge_hook::destructor, hook_cb(), ast_bridge_hook::hook_pvt, and ast_bridge_hook::remove_flags.

Referenced by bridge_stasis_pull().

◆ ast_bridge_talk_detector_hook()

int ast_bridge_talk_detector_hook ( struct ast_bridge_features features,
ast_bridge_talking_indicate_callback  callback,
void *  hook_pvt,
ast_bridge_hook_pvt_destructor  destructor,
enum ast_bridge_hook_remove_flags  remove_flags 
)

Attach a bridge channel talk detection hook to a bridge features structure.

Parameters
featuresBridge features structure
callbackFunction to execute upon activation
hook_pvtUnique data
destructorOptional destructor callback for hook_pvt data
remove_flagsDictates what situations the hook should be removed.
Return values
0on success
-1on failure (The caller must cleanup any hook_pvt resources.)

Example usage:

struct ast_bridge_features features;
ast_bridge_talk_hook(&features, talk_callback, NULL, NULL, 0);

This makes the bridging technology call talk_callback when a channel is recognized as starting and stopping talking. A pointer to useful data may be provided to the hook_pvt parameter.

Note
This hook is currently only supported by softmix.

Definition at line 3364 of file bridge.c.

3369{
3371
3372 return bridge_other_hook(features, hook_cb, hook_pvt, destructor, remove_flags,
3374}

References AST_BRIDGE_HOOK_TYPE_TALK, bridge_other_hook(), callback(), ast_bridge_hook::destructor, hook_cb(), ast_bridge_hook::hook_pvt, and ast_bridge_hook::remove_flags.

Referenced by confbridge_exec().